Plugin Directory

Changeset 2002204


Ignore:
Timestamp:
12/27/2018 10:24:15 AM (7 years ago)
Author:
rsukhar
Message:

Tagging version 1.5

Location:
convertful
Files:
4 edited
3 copied

Legend:

Unmodified
Added
Removed
  • convertful/tags/1.5/convertful.php

    r1978662 r2002204  
    33/**
    44 * Plugin Name: Convertful - Your Ultimate On-Site Conversion Tool
    5  * Version: 1.4
     5 * Version: 1.5
    66 * Plugin URI: https://convertful.com/
    77 * Description: All the modern on-site conversion solutions, natively integrates with all modern Email Marketing Platforms.
     
    4747    global $conv_domain, $conv_version;
    4848    wp_enqueue_script( 'convertful-api', $conv_domain . '/Convertful.js', array(), $conv_version, TRUE );
     49
     50    $tags = array();
     51    $the_tags = get_the_tags();
     52    if ( is_array( $the_tags ) ) {
     53        foreach ( $the_tags as $tag ) {
     54            $tags[] = $tag->slug;
     55        }
     56    }
     57
     58    $categories = array();
     59    $the_categories = get_the_category();
     60    if ( is_array($the_categories)) {
     61        foreach ( $the_categories as $category ) {
     62            $categories[] = $category->slug;
     63        }
     64    }
     65
     66    $user_meta = wp_get_current_user();
     67
     68    wp_localize_script( 'convertful-api', 'convPlatformVars', array(
     69        'postType' => get_post_type(),
     70        'categories' => $categories,
     71        'tags' => $tags,
     72        'userRoles' => ( $user_meta instanceof WP_User ) ? $user_meta->roles : array( 'guest' ),
     73    ) );
    4974}
    5075
     
    127152}
    128153
    129 
    130 add_action( 'wp_head', 'conv_variables' );
    131 function conv_variables() {
    132 
    133     $tags = array();
    134     $the_tags = get_the_tags();
    135     if ( is_array( $the_tags ) ) {
    136         foreach ( $the_tags as $tag ) {
    137             $tags[ $tag->slug ] = $tag->name;
    138         }
    139     }
    140 
    141     $categories = array();
    142     $the_categories = get_the_category();
    143     if ( is_array($the_categories)) {
    144         foreach ( $the_categories as $category ) {
    145             $categories[ $category->slug ] = $category->name;
    146         }
    147     }
    148 
    149     $user_meta = wp_get_current_user();
    150     $variables = array(
    151         'url' => admin_url( 'admin-ajax.php' ),
    152         'tags' => $tags,
    153         'categories' => $categories,
    154         'user_roles' => ( $user_meta instanceof WP_User ) ? $user_meta->roles : array(),
    155         'type' => get_post_type(),
    156     );
    157 
    158     echo '<script type="text/javascript">window.conv_page_vars=' . json_encode( $variables ) . ';</script>';
    159 }
    160 
    161154if ( wp_doing_ajax() OR defined( 'DOING_AJAX' ) ) {
    162155
     
    165158    function conv_get_info() {
    166159
     160        if ( $_POST['access_token'] !== get_option( 'convertful_token' )) {
     161            wp_send_json_error( array(
     162                'access_token' => 'Wrong access token',
     163            ) );
     164        }
     165
    167166        $tags = array();
    168167        foreach ( get_tags() as $tag ) {
     
    175174        }
    176175
    177         wp_send_json_success(
    178             array(
    179                 'tags' => $tags,
    180                 'categories' => $categories,
    181             )
     176        $post_types = array();
     177        foreach ( get_post_types( array( 'public' => TRUE ), 'objects' ) as $post_type ) {
     178            $post_type_name = isset($post_type->name) ? $post_type->name : NULL;
     179            $post_type_title = (isset($post_type->labels) AND isset($post_type->labels->singular_name)) ? $post_type->labels->singular_name : $post_type['name'];
     180            if ($post_type_name AND $post_type_title)
     181            {
     182                $post_types[ $post_type_name ] = $post_type_title;
     183            }
     184        }
     185
     186        global $wp_roles;
     187        $user_roles = array();
     188        foreach ( apply_filters('editable_roles', $wp_roles->roles) as $user_role_name => $user_role ) {
     189            $user_roles[ $user_role_name ] = isset($user_role['name']) ? $user_role['name'] : $user_role_name;
     190        }
     191        $user_roles['guest'] = 'Guest (Unauthenticated)';
     192
     193        $result = array(
     194            'tags' => $tags,
     195            'categories' => $categories,
     196            'post_types' => $post_types,
     197            'user_roles' => $user_roles,
    182198        );
    183     }
    184 }
    185 
    186 
     199
     200        wp_send_json_success($result);
     201    }
     202
     203
     204    add_action( 'wp_ajax_conv_complete_authorization', 'conv_complete_authorization' );
     205    add_action( 'wp_ajax_nopriv_conv_complete_authorization', 'conv_complete_authorization' );
     206    function conv_complete_authorization() {
     207
     208        if ( $_POST['access_token'] !== get_option( 'convertful_token' )) {
     209            wp_send_json_error( array(
     210                'access_token' => 'Wrong access token',
     211            ) );
     212        }
     213
     214        foreach ( array( 'owner_id', 'site_id' ) as $key ) {
     215            if ( ! isset( $_POST[ $key ] ) OR empty( $_POST[ $key ] ) ) {
     216                wp_send_json_error( array(
     217                    $key => 'Wrong parameters for authorization (owner_id or site_id missing)',
     218                ) );
     219            }
     220        }
     221
     222        update_option( 'convertful_owner_id', (int) $_POST['owner_id'], TRUE );
     223        update_option( 'convertful_site_id', (int) $_POST['site_id'], FALSE );
     224
     225        wp_send_json_success();
     226    }
     227
     228
     229}
     230
     231
  • convertful/tags/1.5/functions/admin_pages.php

    r1834709 r2002204  
    3131    $site_id = get_option( 'convertful_site_id' );
    3232    if ( $site_id === FALSE ) {
    33         $connect_url = $conv_domain . '/oauth2/connect_site';
     33        $connect_url = $conv_domain . '/sites/authorize/WordPressPlugin/';
    3434        if ( $ref_username = get_option( 'convertful_ref' ) ) {
    3535            $connect_url .= '?ref=' . $ref_username;
    3636        }
     37        // Generating access token to use it to authenticate requests
     38        $access_token = wp_generate_password( 32, false );
     39        update_option( 'convertful_token', $access_token, FALSE );
    3740        ?>
    3841        <div class="conv-connect">
     
    4952                    </div>
    5053                    <div class="conv-connect-card-footer">
    51                         <input type="hidden" name="ajax_url" value="<?php echo esc_attr( admin_url('admin-ajax.php') ) ?>">
    52                         <input type="hidden" name="endpoint" value="<?php echo esc_attr( admin_url( 'tools.php?page=conv-settings' ) ) ?>">
    5354                        <input type="hidden" name="domain" value="<?php echo esc_attr( preg_replace( '~^https?:\/\/~', '', get_site_url() ) ) ?>">
    54                         <input type="hidden" name="site_name" value="<?php echo esc_attr( get_bloginfo( 'name' ) ) ?>">
    55                         <input type="hidden" name="platform" value="WordPress">
    56                         <input type="hidden" name="_nonce" value="<?php echo esc_attr( wp_create_nonce( 'conv_connect' ) ) ?>">
     55
     56                        <input type="hidden" name="credentials[index_page_url]" value="<?php echo esc_attr( get_home_url() ) ?>">
     57                        <input type="hidden" name="credentials[ajax_url]" value="<?php echo esc_attr( admin_url('admin-ajax.php') ) ?>">
     58                        <input type="hidden" name="credentials[access_token]" value="<?php echo esc_attr( $access_token ) ?>">
     59
    5760                        <button class="conv-btn action_connect">
    5861                            Connect to Convertful
  • convertful/tags/1.5/readme.txt

    r1978662 r2002204  
    33Tags: optin, opt-in, mailchimp, popup, bar, slidein, subscribe, signup, form, email, marketing, lead, campaign
    44Requires at least: 4.0
    5 Tested up to: 5.0.0
    6 Stable tag: 1.4
     5Tested up to: 5.0.2
     6Stable tag: 1.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3434* **Scroll Boxes** which are shown when a visitor scrolls some part of your blog post
    3535* **Welcome Mats** that are shown to new visitors and help to focus on the offer
    36 * **Yes/No Forms** which break the standard form pattern, and increase converson
     36* **Yes/No Forms** which break the standard form pattern, and increase conversion
    3737* **Content Upgrades** which offer additional content for a blog post
    3838* **Deadline Funnels** that display countdown timers (including evergreen countdown timers)
     
    9393== Changelog ==
    9494
     95= 1.5 =
     96* Added widgets' targeting by post types
     97* Added widgets' targeting by user roles
     98* Improved security for data exchange between the plugin and the service
     99
    95100= 1.4 =
    96101* Tested compatibility with WordPress 5.0
  • convertful/trunk/convertful.php

    r1978662 r2002204  
    33/**
    44 * Plugin Name: Convertful - Your Ultimate On-Site Conversion Tool
    5  * Version: 1.4
     5 * Version: 1.5
    66 * Plugin URI: https://convertful.com/
    77 * Description: All the modern on-site conversion solutions, natively integrates with all modern Email Marketing Platforms.
     
    4747    global $conv_domain, $conv_version;
    4848    wp_enqueue_script( 'convertful-api', $conv_domain . '/Convertful.js', array(), $conv_version, TRUE );
     49
     50    $tags = array();
     51    $the_tags = get_the_tags();
     52    if ( is_array( $the_tags ) ) {
     53        foreach ( $the_tags as $tag ) {
     54            $tags[] = $tag->slug;
     55        }
     56    }
     57
     58    $categories = array();
     59    $the_categories = get_the_category();
     60    if ( is_array($the_categories)) {
     61        foreach ( $the_categories as $category ) {
     62            $categories[] = $category->slug;
     63        }
     64    }
     65
     66    $user_meta = wp_get_current_user();
     67
     68    wp_localize_script( 'convertful-api', 'convPlatformVars', array(
     69        'postType' => get_post_type(),
     70        'categories' => $categories,
     71        'tags' => $tags,
     72        'userRoles' => ( $user_meta instanceof WP_User ) ? $user_meta->roles : array( 'guest' ),
     73    ) );
    4974}
    5075
     
    127152}
    128153
    129 
    130 add_action( 'wp_head', 'conv_variables' );
    131 function conv_variables() {
    132 
    133     $tags = array();
    134     $the_tags = get_the_tags();
    135     if ( is_array( $the_tags ) ) {
    136         foreach ( $the_tags as $tag ) {
    137             $tags[ $tag->slug ] = $tag->name;
    138         }
    139     }
    140 
    141     $categories = array();
    142     $the_categories = get_the_category();
    143     if ( is_array($the_categories)) {
    144         foreach ( $the_categories as $category ) {
    145             $categories[ $category->slug ] = $category->name;
    146         }
    147     }
    148 
    149     $user_meta = wp_get_current_user();
    150     $variables = array(
    151         'url' => admin_url( 'admin-ajax.php' ),
    152         'tags' => $tags,
    153         'categories' => $categories,
    154         'user_roles' => ( $user_meta instanceof WP_User ) ? $user_meta->roles : array(),
    155         'type' => get_post_type(),
    156     );
    157 
    158     echo '<script type="text/javascript">window.conv_page_vars=' . json_encode( $variables ) . ';</script>';
    159 }
    160 
    161154if ( wp_doing_ajax() OR defined( 'DOING_AJAX' ) ) {
    162155
     
    165158    function conv_get_info() {
    166159
     160        if ( $_POST['access_token'] !== get_option( 'convertful_token' )) {
     161            wp_send_json_error( array(
     162                'access_token' => 'Wrong access token',
     163            ) );
     164        }
     165
    167166        $tags = array();
    168167        foreach ( get_tags() as $tag ) {
     
    175174        }
    176175
    177         wp_send_json_success(
    178             array(
    179                 'tags' => $tags,
    180                 'categories' => $categories,
    181             )
     176        $post_types = array();
     177        foreach ( get_post_types( array( 'public' => TRUE ), 'objects' ) as $post_type ) {
     178            $post_type_name = isset($post_type->name) ? $post_type->name : NULL;
     179            $post_type_title = (isset($post_type->labels) AND isset($post_type->labels->singular_name)) ? $post_type->labels->singular_name : $post_type['name'];
     180            if ($post_type_name AND $post_type_title)
     181            {
     182                $post_types[ $post_type_name ] = $post_type_title;
     183            }
     184        }
     185
     186        global $wp_roles;
     187        $user_roles = array();
     188        foreach ( apply_filters('editable_roles', $wp_roles->roles) as $user_role_name => $user_role ) {
     189            $user_roles[ $user_role_name ] = isset($user_role['name']) ? $user_role['name'] : $user_role_name;
     190        }
     191        $user_roles['guest'] = 'Guest (Unauthenticated)';
     192
     193        $result = array(
     194            'tags' => $tags,
     195            'categories' => $categories,
     196            'post_types' => $post_types,
     197            'user_roles' => $user_roles,
    182198        );
    183     }
    184 }
    185 
    186 
     199
     200        wp_send_json_success($result);
     201    }
     202
     203
     204    add_action( 'wp_ajax_conv_complete_authorization', 'conv_complete_authorization' );
     205    add_action( 'wp_ajax_nopriv_conv_complete_authorization', 'conv_complete_authorization' );
     206    function conv_complete_authorization() {
     207
     208        if ( $_POST['access_token'] !== get_option( 'convertful_token' )) {
     209            wp_send_json_error( array(
     210                'access_token' => 'Wrong access token',
     211            ) );
     212        }
     213
     214        foreach ( array( 'owner_id', 'site_id' ) as $key ) {
     215            if ( ! isset( $_POST[ $key ] ) OR empty( $_POST[ $key ] ) ) {
     216                wp_send_json_error( array(
     217                    $key => 'Wrong parameters for authorization (owner_id or site_id missing)',
     218                ) );
     219            }
     220        }
     221
     222        update_option( 'convertful_owner_id', (int) $_POST['owner_id'], TRUE );
     223        update_option( 'convertful_site_id', (int) $_POST['site_id'], FALSE );
     224
     225        wp_send_json_success();
     226    }
     227
     228
     229}
     230
     231
  • convertful/trunk/functions/admin_pages.php

    r1834709 r2002204  
    3131    $site_id = get_option( 'convertful_site_id' );
    3232    if ( $site_id === FALSE ) {
    33         $connect_url = $conv_domain . '/oauth2/connect_site';
     33        $connect_url = $conv_domain . '/sites/authorize/WordPressPlugin/';
    3434        if ( $ref_username = get_option( 'convertful_ref' ) ) {
    3535            $connect_url .= '?ref=' . $ref_username;
    3636        }
     37        // Generating access token to use it to authenticate requests
     38        $access_token = wp_generate_password( 32, false );
     39        update_option( 'convertful_token', $access_token, FALSE );
    3740        ?>
    3841        <div class="conv-connect">
     
    4952                    </div>
    5053                    <div class="conv-connect-card-footer">
    51                         <input type="hidden" name="ajax_url" value="<?php echo esc_attr( admin_url('admin-ajax.php') ) ?>">
    52                         <input type="hidden" name="endpoint" value="<?php echo esc_attr( admin_url( 'tools.php?page=conv-settings' ) ) ?>">
    5354                        <input type="hidden" name="domain" value="<?php echo esc_attr( preg_replace( '~^https?:\/\/~', '', get_site_url() ) ) ?>">
    54                         <input type="hidden" name="site_name" value="<?php echo esc_attr( get_bloginfo( 'name' ) ) ?>">
    55                         <input type="hidden" name="platform" value="WordPress">
    56                         <input type="hidden" name="_nonce" value="<?php echo esc_attr( wp_create_nonce( 'conv_connect' ) ) ?>">
     55
     56                        <input type="hidden" name="credentials[index_page_url]" value="<?php echo esc_attr( get_home_url() ) ?>">
     57                        <input type="hidden" name="credentials[ajax_url]" value="<?php echo esc_attr( admin_url('admin-ajax.php') ) ?>">
     58                        <input type="hidden" name="credentials[access_token]" value="<?php echo esc_attr( $access_token ) ?>">
     59
    5760                        <button class="conv-btn action_connect">
    5861                            Connect to Convertful
  • convertful/trunk/readme.txt

    r1978662 r2002204  
    33Tags: optin, opt-in, mailchimp, popup, bar, slidein, subscribe, signup, form, email, marketing, lead, campaign
    44Requires at least: 4.0
    5 Tested up to: 5.0.0
    6 Stable tag: 1.4
     5Tested up to: 5.0.2
     6Stable tag: 1.5
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3434* **Scroll Boxes** which are shown when a visitor scrolls some part of your blog post
    3535* **Welcome Mats** that are shown to new visitors and help to focus on the offer
    36 * **Yes/No Forms** which break the standard form pattern, and increase converson
     36* **Yes/No Forms** which break the standard form pattern, and increase conversion
    3737* **Content Upgrades** which offer additional content for a blog post
    3838* **Deadline Funnels** that display countdown timers (including evergreen countdown timers)
     
    9393== Changelog ==
    9494
     95= 1.5 =
     96* Added widgets' targeting by post types
     97* Added widgets' targeting by user roles
     98* Improved security for data exchange between the plugin and the service
     99
    95100= 1.4 =
    96101* Tested compatibility with WordPress 5.0
Note: See TracChangeset for help on using the changeset viewer.