Skip to content

Commit

Permalink
Merge pull request #114 from ConvertKit/fix-landing-pages
Browse files Browse the repository at this point in the history
Version 1.6.1
  • Loading branch information
growdev authored Jul 3, 2018
2 parents 79addd8 + 8fb4d1c commit 217f595
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
46 changes: 33 additions & 13 deletions includes/class-convertkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,29 @@ public static function page_takeover() {
if ( isset( $queried_object->post_type )
&& 'page' === $queried_object->post_type ) {

$landing_page_url = self::_get_meta( $queried_object->ID, 'landing_page' );

$landing_page = self::$api->get_resource( $landing_page_url );

if ( ! empty( $landing_page ) ) {
$script = WP_ConvertKit::get_ck_script();
$script .= "\n</head>";
$landing_page = str_replace( '</head>', $script, $landing_page );
echo $landing_page; // WPCS: XSS ok.
exit;
$landing_page_id = self::_get_meta( $queried_object->ID, 'landing_page' );

if ( strstr( $landing_page_id, 'http') ) {
// Old landing page
$landing_page = self::$api->get_resource( $landing_page_id );
if ( ! empty( $landing_page ) ) {
$script = WP_ConvertKit::get_ck_script();
$script .= "</head>";
$landing_page = str_replace( '</head>', $script, $landing_page );
echo $landing_page; // WPCS: XSS ok.
exit;
}
} else {
// New landing page
$landing_pages = get_option( 'convertkit_landing_pages' );
$landing_page = self::$api->get_resource( $landing_pages[$landing_page_id]['embed_url'] );
if ( ! empty( $landing_page ) ) {
$script = WP_ConvertKit::get_ck_script( true );
$script .= "</head>";
$landing_page = str_replace( '</head>', $script, $landing_page );
echo $landing_page; // WPCS: XSS ok.
exit;
}
}
}
}
Expand All @@ -263,9 +276,16 @@ public static function page_takeover() {
* javascript if we want subscribers tagged correctly.
*
* @since 1.5.2
* @param bool $include_jquery
* @return string
*/
public static function get_ck_script() {
$script = "<script type='text/javascript' src='" . CONVERTKIT_PLUGIN_URL . "resources/frontend/jquery.cookie.min.js?ver=1.4.0'></script>";
public static function get_ck_script( $include_jquery = false) {
$script = '';
if ( $include_jquery ) {
$scripts = new WP_Scripts();
$script .= "<script type='text/javascript' src='" . trailingslashit( $scripts->base_url ) . "wp-includes/js/jquery/jquery.js?ver=1.4.0'></script>";
}
$script .= "<script type='text/javascript' src='" . CONVERTKIT_PLUGIN_URL . "resources/frontend/jquery.cookie.min.js?ver=1.4.0'></script>";
$script .= "<script type='text/javascript' src='" . CONVERTKIT_PLUGIN_URL . 'resources/frontend/wp-convertkit.js?ver=' . CONVERTKIT_PLUGIN_VERSION . "'></script>";
$script .= "<script type='text/javascript'>/* <![CDATA[ */var ck_data = {\"ajaxurl\":\"" . admin_url( 'admin-ajax.php' ) . '"};/* ]]> */</script>';
return $script;
Expand Down Expand Up @@ -576,7 +596,7 @@ public static function upgrade() {
ConvertKit_Custom_Content::create_table();
update_option( 'convertkit_version', CONVERTKIT_PLUGIN_VERSION );

} elseif ( version_compare( $current_version, '1.6.0', '<' ) ) {
} elseif ( version_compare( $current_version, '1.6.1', '<' ) ) {
// Refresh the forms meta to get new forms builder settings
$api_key = self::_get_settings( 'api_key' );
if ( ! empty( $api_key ) ) {
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://convertkit.com
Tags: email, marketing, embed form, convertkit, capture
Requires at least: 3.6
Tested up to: 4.9.6
Stable tag: 1.6.0
Stable tag: 1.6.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -46,6 +46,11 @@ Yes, for it to work you must first have an account on ConvertKit.com

== Changelog ==

### 1.6.1 2018-07-03
* Fix for landing pages not showing in the admin area drop down
* Fix for showing new landing pages on the front end of the site
* Added jquery to landing pages as new landing page builder does not include it

### 1.6.0 2018-06-30
* Add support for new form builder
* Remove unnecessary API calls
Expand Down
12 changes: 8 additions & 4 deletions views/backend/meta-boxes/meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@
<td>
<select name="wp-convertkit[landing_page]" id="wp-convertkit-landing_page">
<option <?php selected( '', $meta['landing_page'] ); ?> value="0"><?php _e( 'None', 'convertkit' ); // WPCS: XSS ok. ?></option>
<?php foreach ( $landing_pages as $landing_page ) {
$name = sanitize_text_field( $landing_page['name'] ); ?>
<option <?php selected( $landing_page['url'], $meta['landing_page'] ); ?> value="<?php echo esc_attr( $landing_page['url'], 'convertkit' ); ?>"><?php echo esc_attr( $name ); ?></option>
<?php } ?>
<?php foreach ( $landing_pages as $landing_page ) :
$name = sanitize_text_field( $landing_page['name'] );
if ( isset( $landing_page['url'] ) ) : ?>
<option <?php selected( $landing_page['url'], $meta['landing_page'] ); ?> value="<?php echo esc_attr( $landing_page['url'], 'convertkit' ); ?>"><?php echo esc_attr( $name ); ?></option>
<?php else: ?>
<option <?php selected( $landing_page['id'], $meta['landing_page'] ); ?> value="<?php echo esc_attr( $landing_page['id'], 'convertkit' ); ?>"><?php echo esc_attr( $name ); ?></option>
<?php endif;
endforeach; ?>
</select>
<p class="description"><?php esc_html_e( 'Select a landing page to make it appear in place of this page.', 'convertkit' ); ?></p>
</td>
Expand Down
4 changes: 2 additions & 2 deletions wp-convertkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: ConvertKit
* Plugin URI: https://convertkit.com/
* Description: Quickly and easily integrate ConvertKit forms into your site.
* Version: 1.6.0
* Version: 1.6.1
* Author: ConvertKit
* Author URI: https://convertkit.com/
* Text Domain: convertkit
Expand All @@ -16,7 +16,7 @@
define( 'CONVERTKIT_PLUGIN_FILE', plugin_basename( __FILE__ ) );
define( 'CONVERTKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'CONVERTKIT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'CONVERTKIT_PLUGIN_VERSION', '1.6.0' );
define( 'CONVERTKIT_PLUGIN_VERSION', '1.6.1' );

require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit.php';
require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit-api.php';
Expand Down

0 comments on commit 217f595

Please sign in to comment.