Changeset 2033536
- Timestamp:
- 02/18/2019 06:31:47 PM (7 years ago)
- Location:
- convertkit
- Files:
-
- 47 added
- 11 edited
-
tags/1.7.0 (added)
-
tags/1.7.0/LICENSE (added)
-
tags/1.7.0/admin (added)
-
tags/1.7.0/admin/class-convertkit-settings.php (added)
-
tags/1.7.0/admin/class-convertkit-tinymce.php (added)
-
tags/1.7.0/admin/class-multi-value-field-table.php (added)
-
tags/1.7.0/admin/section (added)
-
tags/1.7.0/admin/section/class-convertkit-settings-base.php (added)
-
tags/1.7.0/admin/section/class-convertkit-settings-contactform7.php (added)
-
tags/1.7.0/admin/section/class-convertkit-settings-general.php (added)
-
tags/1.7.0/admin/section/class-convertkit-settings-tools.php (added)
-
tags/1.7.0/admin/section/class-convertkit-settings-wishlist.php (added)
-
tags/1.7.0/codeception.dist.yml (added)
-
tags/1.7.0/includes (added)
-
tags/1.7.0/includes/class-ck-widget-form.php (added)
-
tags/1.7.0/includes/class-convertkit-api.php (added)
-
tags/1.7.0/includes/class-convertkit-custom-content.php (added)
-
tags/1.7.0/includes/class-convertkit.php (added)
-
tags/1.7.0/includes/integration (added)
-
tags/1.7.0/includes/integration/class-convertkit-contactform7-integration.php (added)
-
tags/1.7.0/includes/integration/class-convertkit-wishlist-integration.php (added)
-
tags/1.7.0/languages (added)
-
tags/1.7.0/languages/README.md (added)
-
tags/1.7.0/languages/convertkit.pot (added)
-
tags/1.7.0/lib (added)
-
tags/1.7.0/lib/README.md (added)
-
tags/1.7.0/lib/browser.php (added)
-
tags/1.7.0/lib/url-to-absolute (added)
-
tags/1.7.0/lib/url-to-absolute/url-to-absolute.php (added)
-
tags/1.7.0/readme.txt (added)
-
tags/1.7.0/resources (added)
-
tags/1.7.0/resources/backend (added)
-
tags/1.7.0/resources/backend/ck-2x.png (added)
-
tags/1.7.0/resources/backend/ck.png (added)
-
tags/1.7.0/resources/backend/tinymce-buttons.js (added)
-
tags/1.7.0/resources/backend/wp-convertkit.css (added)
-
tags/1.7.0/resources/backend/wp-convertkit.js (added)
-
tags/1.7.0/resources/frontend (added)
-
tags/1.7.0/resources/frontend/jquery.cookie.js (added)
-
tags/1.7.0/resources/frontend/jquery.cookie.min.js (added)
-
tags/1.7.0/resources/frontend/wp-convertkit.css (added)
-
tags/1.7.0/resources/frontend/wp-convertkit.js (added)
-
tags/1.7.0/views (added)
-
tags/1.7.0/views/backend (added)
-
tags/1.7.0/views/backend/meta-boxes (added)
-
tags/1.7.0/views/backend/meta-boxes/meta-box.php (added)
-
tags/1.7.0/wp-convertkit.php (added)
-
trunk/admin/class-convertkit-settings.php (modified) (2 diffs)
-
trunk/admin/section/class-convertkit-settings-base.php (modified) (1 diff)
-
trunk/admin/section/class-convertkit-settings-general.php (modified) (5 diffs)
-
trunk/includes/class-convertkit-api.php (modified) (3 diffs)
-
trunk/includes/class-convertkit-custom-content.php (modified) (2 diffs)
-
trunk/includes/class-convertkit.php (modified) (5 diffs)
-
trunk/includes/integration/class-convertkit-contactform7-integration.php (modified) (1 diff)
-
trunk/includes/integration/class-convertkit-wishlist-integration.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/resources/frontend/wp-convertkit.js (modified) (4 diffs)
-
trunk/wp-convertkit.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
convertkit/trunk/admin/class-convertkit-settings.php
r2014928 r2033536 286 286 $default_form = get_term_meta( $tag->term_id, 'ck_default_form', true ); 287 287 288 echo '<tr class="form-field term-description-wrap"><th scope="row"><label for="description">ConvertKit Form</label></th><td>';288 echo '<tr class="form-field"><th scope="row"><label for="description">ConvertKit Form</label></th><td>'; 289 289 290 290 // Check for error in response. … … 324 324 if ( $ck_default_form ) { 325 325 update_term_meta( $tag_id, 'ck_default_form', $ck_default_form ); 326 } 326 } else { 327 update_term_meta( $tag_id, 'ck_default_form', 'default' ); 328 } 327 329 328 330 } -
convertkit/trunk/admin/section/class-convertkit-settings-base.php
r2014928 r2033536 50 50 * API instance 51 51 * 52 * @var ConvertKit API52 * @var ConvertKit_API 53 53 */ 54 54 public $api; -
convertkit/trunk/admin/section/class-convertkit-settings-general.php
r2008063 r2033536 106 106 $this->name 107 107 ); 108 109 add_settings_field( 110 'no_scripts', 111 'Disable javascript', 112 array( $this, 'no_scripts_callback' ), 113 $this->settings_key, 114 $this->name 115 ); 108 116 } 109 117 … … 130 138 ); 131 139 132 $html .= '<p class="description"><a href="https://app.convertkit.com/account/edit" target="_blank">' . __( 'Get your ConvertKit API Key', 'convertkit' ) . '</a></p>'; 140 $html .= '<p class="description"><a href="https://app.convertkit.com/account/edit" target="_blank">' . __( 'Get your ConvertKit API Key.', 'convertkit' ) . '</a>'; 141 $html .= ' ' . __( 'Required for proper plugin function.', 'convertkit' ) . '</p>'; 133 142 134 143 $has_api = isset( $this->options['api_key'] ) ? esc_attr( $this->options['api_key'] ) : false; … … 152 161 $html .= '<p class="description"><a href="https://app.convertkit.com/account/edit" target="_blank">'; 153 162 $html .= __( 'Get your ConvertKit API Secret.', 'convertkit' ) . '</a>'; 154 $html .= ' ' . __( ' This setting is required to unsubscribe subscribers.', 'convertkit' ) . '</p>';163 $html .= ' ' . __( 'Required for proper plugin function.', 'convertkit' ) . '</p>'; 155 164 156 165 echo $html; // WPCS: XSS ok. … … 216 225 217 226 echo sprintf( // WPCS: XSS OK 218 '< input type="checkbox" class="" id="debug" name="%s[debug]" %s />%s',227 '<label><input type="checkbox" class="" id="debug" name="%s[debug]" %s />%s</label>', 219 228 $this->settings_key, 220 229 $debug, … … 224 233 } 225 234 235 /** 236 * Renders the input for no_scripts setting 237 */ 238 public function no_scripts_callback() { 239 240 $no_scripts = ''; 241 if ( isset( $this->options['no_scripts'] ) && 'on' === $this->options['no_scripts'] ) { 242 $no_scripts = 'checked'; 243 } 244 245 echo sprintf( // WPCS: XSS OK 246 '<label><input type="checkbox" class="" id="no_scripts" name="%s[no_scripts]" %s />%s</label>', 247 $this->settings_key, 248 $no_scripts, 249 __( 'Prevent plugin from loading javascript files. This will disable the custom content and tagging features of the plugin. Does not apply to landing pages. Use with caution!','convertkit' ) 250 ); 251 252 } 226 253 /** 227 254 * Sanitizes the settings 228 255 * 229 256 * @param array $settings The settings fields submitted. 230 * @return array Sanitized settings. 257 * 258 * @return array Sanitized settings. 231 259 */ 232 260 public function sanitize_settings( $settings ) { 233 234 if ( isset( $settings['api_key'] ) ) { 235 $forms = get_option( 'convertkit_forms' ); 236 if ( ! $forms ) { 237 // No Forms? Let's update the resources. 238 $this->api->update_resources( $settings['api_key'] ); 239 } 240 } 241 return shortcode_atts( array( 261 $defaults = array( 242 262 'api_key' => '', 243 263 'api_secret' => '', 244 264 'default_form' => 0, 245 'debug' => '', 246 ), $settings ); 265 'debug' => '', 266 'no_scripts' => '', 267 ); 268 269 if ( isset( $settings['api_key'] ) ) { 270 $this->api->update_resources( $settings['api_key'] ); 271 } 272 273 return wp_parse_args( $settings, $defaults ); 247 274 } 248 275 } -
convertkit/trunk/includes/class-convertkit-api.php
r2014928 r2033536 1 1 <?php 2 2 /** 3 * ConvertKit PI class3 * ConvertKit API class 4 4 * 5 5 * @package ConvertKit … … 397 397 if ( ! is_wp_error( $response ) ) { 398 398 399 if ( ! function_exists( 'str_get_html' ) ) {400 require_once( dirname( __FILE__ ) . '/../lib/simple-html-dom/simple-html-dom.php' );401 }402 403 399 if ( ! function_exists( 'url_to_absolute' ) ) { 404 require_once( dirname( __FILE__ ) . '/../lib/url-to-absolute/url-to-absolute.php' );400 require_once( CONVERTKIT_PLUGIN_PATH . '/lib/url-to-absolute/url-to-absolute.php' ); 405 401 } 406 402 … … 414 410 $body = wp_remote_retrieve_body( $response ); 415 411 416 $html = str_get_html( $body ); 412 /** @var \simple_html_dom\simple_html_dom $html */ 413 $html = \KubAT\PhpSimple\HtmlDomParser::str_get_html( $body ); 417 414 foreach ( $html->find( 'a, link' ) as $element ) { 418 415 if ( isset( $element->href ) ) { -
convertkit/trunk/includes/class-convertkit-custom-content.php
r2014928 r2033536 190 190 $tags = array(); 191 191 $tag = $attributes['tag']; 192 $user_id = get_current_user_id();193 192 $api = WP_ConvertKit::get_api(); 194 193 … … 197 196 // get cookie and check API for customer tags. 198 197 $subscriber_id = absint( $_COOKIE['ck_subscriber_id'] ); 199 if ( $subscriber_id ) {200 $tags = $api->get_subscriber_tags( $subscriber_id );201 }202 } elseif ( isset( $_COOKIE['ck_subscriber_id'] ) ) {203 WP_ConvertKit::log( 'shortcode: cookie param found, calling API' );204 // get cookie and check API for customer tags.205 $subscriber_id = absint( $_GET['ck_subscriber_id'] );206 198 if ( $subscriber_id ) { 207 199 $tags = $api->get_subscriber_tags( $subscriber_id ); -
convertkit/trunk/includes/class-convertkit.php
r2014928 r2033536 31 31 */ 32 32 private static $settings_defaults = array( 33 'api_key' => '', 33 'api_key' => '', 34 'api_secret' => '', 34 35 'default_form' => 0, 36 'debug' => false, 37 'no_scripts' => false, 35 38 ); 36 39 … … 301 304 */ 302 305 public static function enqueue_scripts() { 303 wp_enqueue_script( 'jquery-cookie', CONVERTKIT_PLUGIN_URL . 'resources/frontend/jquery.cookie.min.js', array( 'jquery' ), '1.4.0' ); 304 305 wp_register_script( 'convertkit-js', CONVERTKIT_PLUGIN_URL . 'resources/frontend/wp-convertkit.js', array( 'jquery-cookie' ), CONVERTKIT_PLUGIN_VERSION ); 306 wp_localize_script( 'convertkit-js', 'ck_data', array( 307 'ajaxurl' => admin_url( 'admin-ajax.php' ), 308 ) ); 309 wp_enqueue_script( 'convertkit-js' ); 306 307 // Only check for tags if we're on a singular post; otherwise, no tags 308 $has_tag = is_singular() ? self::post_has_tag( get_post() ) : false; 309 310 // Only load scripts if no scripts setting is not checked 311 $no_scripts = self::_get_settings( 'no_scripts' ); 312 if ( ! $no_scripts ) { 313 wp_register_script( 314 'jquery-cookie', 315 CONVERTKIT_PLUGIN_URL . 'resources/frontend/jquery.cookie.min.js', 316 array( 'jquery' ), 317 '1.4.0' 318 ); 319 320 wp_register_script( 321 'convertkit-js', 322 CONVERTKIT_PLUGIN_URL . 'resources/frontend/wp-convertkit.js', 323 array( 'jquery-cookie' ), 324 CONVERTKIT_PLUGIN_VERSION 325 ); 326 327 wp_localize_script( 328 'convertkit-js', 329 'ck_data', 330 array( 331 'ajaxurl' => admin_url( 'admin-ajax.php' ), 332 'post_has_tag' => $has_tag, 333 ) 334 ); 335 336 wp_enqueue_script( 'convertkit-js' ); 337 } 310 338 } 311 339 … … 322 350 * @param array $attributes Shortcode attributes. 323 351 * @param null $content 324 * @return mixed|void352 * @return string 325 353 */ 326 354 public static function shortcode( $attributes, $content = null ) { … … 430 458 * 431 459 * @param null $settings_key 432 * @return mixed|null |void460 * @return mixed|null 433 461 */ 434 462 public static function _get_settings( $settings_key = null ) { … … 619 647 }// End if(). 620 648 } 649 650 651 /** 652 * @param $post WP_Post 653 * 654 * @return boolean 655 */ 656 public static function post_has_tag( $post ) { 657 $meta = get_post_meta( $post->ID, '_wp_convertkit_post_meta', true ); 658 659 if ( isset( $meta['tag'] ) ) { 660 return ( $meta['tag'] == 0 ) ? false : true; 661 } 662 return false; 663 } 621 664 } -
convertkit/trunk/includes/integration/class-convertkit-contactform7-integration.php
r1747485 r2033536 7 7 */ 8 8 9 require_once plugin_dir_path( __FILE__ ) . '../class-convertkit-api.php';9 require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit-api.php'; 10 10 11 11 /** -
convertkit/trunk/includes/integration/class-convertkit-wishlist-integration.php
r1747485 r2033536 10 10 * API class require. 11 11 */ 12 require_once plugin_dir_path( __FILE__ ) . '../class-convertkit-api.php';12 require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit-api.php'; 13 13 14 14 /** -
convertkit/trunk/readme.txt
r2014928 r2033536 1 1 === ConvertKit === 2 Contributors: nathanbarry, growdev 2 Contributors: nathanbarry, growdev, travisnorthcutt 3 3 Donate link: https://convertkit.com 4 4 Tags: email, marketing, embed form, convertkit, capture 5 5 Requires at least: 3.6 6 6 Tested up to: 5.0.3 7 Stable tag: 1. 6.47 Stable tag: 1.7.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 == Changelog == 48 48 49 ### 1.7.0 2019-02-18 50 * New: Significantly improve performance of plugin by only attempting to tag visitors if needed (not on every page) 51 * New: Add option to disable javascript entirely (prevents tagging and custom content features from working) 52 * Fix conflict with Yoast SEO plugin 53 * Fix bug that prevented plugin from working with PHP 7.3 54 * Fix bug that prevented changing a category default form back to None 55 * Clarify that both API key and secret are required 56 * Fix bug that stripped out URL query parameters unrelated to ConvertKit 57 * Better handle refreshing list of forms in the connected ConvertKit account 58 49 59 ### 1.6.4 2019-01-18 50 60 * Added tools tab with debug log and system info boxes -
convertkit/trunk/resources/frontend/wp-convertkit.js
r2014928 r2033536 2 2 3 3 // Manage visit cookie 4 var subscriber_id = $.cookie( 'ck_subscriber_id' );4 var subscriber_id = parseInt($.cookie('ck_subscriber_id')) ? parseInt($.cookie('ck_subscriber_id')) : false; 5 5 6 6 if ( ! subscriber_id ) { … … 8 8 } 9 9 10 /* Check if subscriber_id is valid and maybe do add tags */ 11 $.ajax({ 12 type: "POST", 13 data: { 14 action: 'ck_add_user_visit', 15 subscriber_id: subscriber_id, 16 url: document.URL 17 }, 18 url: ck_data.ajaxurl, 19 success: function (response) { 20 var values = JSON.parse(response); 21 if ( 0 != values.subscriber_id) { 22 $.cookie('ck_subscriber_id', values.subscriber_id, {expires: 365, path: '/'}); 23 ckRemoveSubscriberId( window.location.href ); 10 // Only POST to admin-ajax.php if we have a subscriber_id to use... 11 // ...and the current post has a tag assigned to it 12 if ( subscriber_id && ck_data.post_has_tag ) { 13 /* Check if subscriber_id is valid and maybe do add tags */ 14 $.ajax({ 15 type: "POST", 16 data: { 17 action: 'ck_add_user_visit', 18 subscriber_id: subscriber_id, 19 url: document.URL 20 }, 21 url: ck_data.ajaxurl, 22 success: function (response) { 23 var values = JSON.parse(response); 24 if ( 0 != values.subscriber_id) { 25 $.cookie('ck_subscriber_id', values.subscriber_id, {expires: 365, path: '/'}); 26 ckRemoveSubscriberId( window.location.href ); 27 } 24 28 } 25 }26 29 27 }).fail(function (response) { 28 if ( window.console && window.console.log ) { 29 console.log( "AJAX ERROR" + response ); 30 } 31 }); 30 }).fail(function (response) { 31 if ( window.console && window.console.log ) { 32 console.log( "AJAX ERROR" + response ); 33 } 34 }); 35 } 32 36 33 37 /** … … 48 52 } 49 53 } 50 return (0);54 return false; 51 55 } 52 56 … … 59 63 * a URL with their subscriber ID in it. 60 64 * 61 * @param key62 65 * @param url 63 66 */ 64 function ckRemoveSubscriberId( key,url)67 function ckRemoveSubscriberId(url) 65 68 { 66 url = window.location.href; 67 var clean_url = url.substring(0, url.indexOf("?")); 69 var clean_url = url.substring(0, url.indexOf("?ck_subscriber_id")); 68 70 var title = document.getElementsByTagName("title")[0].innerHTML; 69 window.history.pushState( null, title, clean_url ); 71 if ( clean_url ) { 72 window.history.pushState( null, title, clean_url ); 73 } 70 74 } 71 75 -
convertkit/trunk/wp-convertkit.php
r2014928 r2033536 4 4 * Plugin URI: https://convertkit.com/ 5 5 * Description: Quickly and easily integrate ConvertKit forms into your site. 6 * Version: 1. 6.46 * Version: 1.7.0 7 7 * Author: ConvertKit 8 8 * Author URI: https://convertkit.com/ … … 16 16 define( 'CONVERTKIT_PLUGIN_FILE', plugin_basename( __FILE__ ) ); 17 17 define( 'CONVERTKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 18 define( 'CONVERTKIT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 19 define( 'CONVERTKIT_PLUGIN_VERSION', '1.6.4' ); 18 define( 'CONVERTKIT_PLUGIN_PATH', __DIR__ ); 19 define( 'CONVERTKIT_PLUGIN_VERSION', '1.7.0' ); 20 21 require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php'; 20 22 21 23 require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit.php';
Note: See TracChangeset
for help on using the changeset viewer.