Plugin Directory

Changeset 2033536


Ignore:
Timestamp:
02/18/2019 06:31:47 PM (7 years ago)
Author:
travisnorthcutt
Message:

Version 1.7.0

Location:
convertkit
Files:
47 added
11 edited

Legend:

Unmodified
Added
Removed
  • convertkit/trunk/admin/class-convertkit-settings.php

    r2014928 r2033536  
    286286        $default_form = get_term_meta( $tag->term_id, 'ck_default_form', true );
    287287
    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>';
    289289
    290290        // Check for error in response.
     
    324324        if ( $ck_default_form ) {
    325325            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        }
    327329
    328330    }
  • convertkit/trunk/admin/section/class-convertkit-settings-base.php

    r2014928 r2033536  
    5050     * API instance
    5151     *
    52      * @var ConvertKitAPI
     52     * @var ConvertKit_API
    5353     */
    5454    public $api;
  • convertkit/trunk/admin/section/class-convertkit-settings-general.php

    r2008063 r2033536  
    106106            $this->name
    107107        );
     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        );
    108116    }
    109117
     
    130138        );
    131139
    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>';
    133142
    134143        $has_api = isset( $this->options['api_key'] ) ? esc_attr( $this->options['api_key'] ) : false;
     
    152161        $html .= '<p class="description"><a href="https://app.convertkit.com/account/edit" target="_blank">';
    153162        $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>';
    155164
    156165        echo $html; // WPCS: XSS ok.
     
    216225
    217226        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>',
    219228            $this->settings_key,
    220229            $debug,
     
    224233    }
    225234
     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    }
    226253    /**
    227254     * Sanitizes the settings
    228255     *
    229256     * @param  array $settings The settings fields submitted.
    230      * @return array           Sanitized settings.
     257     *
     258     * @return array Sanitized settings.
    231259     */
    232260    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(
    242262            'api_key'      => '',
    243263            'api_secret'   => '',
    244264            '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 );
    247274    }
    248275}
  • convertkit/trunk/includes/class-convertkit-api.php

    r2014928 r2033536  
    11<?php
    22/**
    3  * ConvertKit PI class
     3 * ConvertKit API class
    44 *
    55 * @package ConvertKit
     
    397397            if ( ! is_wp_error( $response ) ) {
    398398
    399                 if ( ! function_exists( 'str_get_html' ) ) {
    400                     require_once( dirname( __FILE__ ) . '/../lib/simple-html-dom/simple-html-dom.php' );
    401                 }
    402 
    403399                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' );
    405401                }
    406402
     
    414410                $body = wp_remote_retrieve_body( $response );
    415411
    416                 $html = str_get_html( $body );
     412                /** @var \simple_html_dom\simple_html_dom $html */
     413                $html = \KubAT\PhpSimple\HtmlDomParser::str_get_html( $body );
    417414                foreach ( $html->find( 'a, link' ) as $element ) {
    418415                    if ( isset( $element->href ) ) {
  • convertkit/trunk/includes/class-convertkit-custom-content.php

    r2014928 r2033536  
    190190            $tags = array();
    191191            $tag = $attributes['tag'];
    192             $user_id = get_current_user_id();
    193192            $api = WP_ConvertKit::get_api();
    194193
     
    197196                // get cookie and check API for customer tags.
    198197                $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'] );
    206198                if ( $subscriber_id ) {
    207199                    $tags = $api->get_subscriber_tags( $subscriber_id );
  • convertkit/trunk/includes/class-convertkit.php

    r2014928 r2033536  
    3131     */
    3232    private static $settings_defaults = array(
    33         'api_key' => '',
     33        'api_key'      => '',
     34        'api_secret'   => '',
    3435        'default_form' => 0,
     36        'debug'        => false,
     37        'no_scripts'   => false,
    3538    );
    3639
     
    301304     */
    302305    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        }
    310338    }
    311339
     
    322350     * @param array $attributes Shortcode attributes.
    323351     * @param null $content
    324      * @return mixed|void
     352     * @return string
    325353     */
    326354    public static function shortcode( $attributes, $content = null ) {
     
    430458     *
    431459     * @param null $settings_key
    432      * @return mixed|null|void
     460     * @return mixed|null
    433461     */
    434462    public static function _get_settings( $settings_key = null ) {
     
    619647        }// End if().
    620648    }
     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    }
    621664}
  • convertkit/trunk/includes/integration/class-convertkit-contactform7-integration.php

    r1747485 r2033536  
    77 */
    88
    9 require_once plugin_dir_path( __FILE__ ) . '../class-convertkit-api.php';
     9require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit-api.php';
    1010
    1111/**
  • convertkit/trunk/includes/integration/class-convertkit-wishlist-integration.php

    r1747485 r2033536  
    1010 * API class require.
    1111 */
    12 require_once plugin_dir_path( __FILE__ ) . '../class-convertkit-api.php';
     12require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit-api.php';
    1313
    1414/**
  • convertkit/trunk/readme.txt

    r2014928 r2033536  
    11=== ConvertKit ===
    2 Contributors: nathanbarry, growdev
     2Contributors: nathanbarry, growdev, travisnorthcutt
    33Donate link: https://convertkit.com
    44Tags: email, marketing, embed form, convertkit, capture
    55Requires at least: 3.6
    66Tested up to: 5.0.3
    7 Stable tag: 1.6.4
     7Stable tag: 1.7.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4747== Changelog ==
    4848
     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
    4959### 1.6.4 2019-01-18
    5060* Added tools tab with debug log and system info boxes
  • convertkit/trunk/resources/frontend/wp-convertkit.js

    r2014928 r2033536  
    22
    33    // 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;
    55
    66    if ( ! subscriber_id ) {
     
    88    }
    99
    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                }
    2428            }
    25         }
    2629
    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    }
    3236
    3337    /**
     
    4852            }
    4953        }
    50         return(0);
     54        return false;
    5155    }
    5256
     
    5963     * a URL with their subscriber ID in it.
    6064     *
    61      * @param key
    6265     * @param url
    6366     */
    64     function ckRemoveSubscriberId(key,url)
     67    function ckRemoveSubscriberId(url)
    6568    {
    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"));
    6870        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        }
    7074    }
    7175
  • convertkit/trunk/wp-convertkit.php

    r2014928 r2033536  
    44 * Plugin URI: https://convertkit.com/
    55 * Description: Quickly and easily integrate ConvertKit forms into your site.
    6  * Version: 1.6.4
     6 * Version: 1.7.0
    77 * Author: ConvertKit
    88 * Author URI: https://convertkit.com/
     
    1616define( 'CONVERTKIT_PLUGIN_FILE', plugin_basename( __FILE__ ) );
    1717define( 'CONVERTKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    18 define( 'CONVERTKIT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    19 define( 'CONVERTKIT_PLUGIN_VERSION', '1.6.4' );
     18define( 'CONVERTKIT_PLUGIN_PATH', __DIR__ );
     19define( 'CONVERTKIT_PLUGIN_VERSION', '1.7.0' );
     20
     21require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php';
    2022
    2123require_once CONVERTKIT_PLUGIN_PATH . '/includes/class-convertkit.php';
Note: See TracChangeset for help on using the changeset viewer.