Changeset 2002204
- Timestamp:
- 12/27/2018 10:24:15 AM (7 years ago)
- Location:
- convertful
- Files:
-
- 4 edited
- 3 copied
-
tags/1.5 (copied) (copied from convertful/trunk)
-
tags/1.5/convertful.php (copied) (copied from convertful/trunk/convertful.php) (5 diffs)
-
tags/1.5/functions/admin_pages.php (modified) (2 diffs)
-
tags/1.5/readme.txt (copied) (copied from convertful/trunk/readme.txt) (3 diffs)
-
trunk/convertful.php (modified) (5 diffs)
-
trunk/functions/admin_pages.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
convertful/tags/1.5/convertful.php
r1978662 r2002204 3 3 /** 4 4 * Plugin Name: Convertful - Your Ultimate On-Site Conversion Tool 5 * Version: 1. 45 * Version: 1.5 6 6 * Plugin URI: https://convertful.com/ 7 7 * Description: All the modern on-site conversion solutions, natively integrates with all modern Email Marketing Platforms. … … 47 47 global $conv_domain, $conv_version; 48 48 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 ) ); 49 74 } 50 75 … … 127 152 } 128 153 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 161 154 if ( wp_doing_ajax() OR defined( 'DOING_AJAX' ) ) { 162 155 … … 165 158 function conv_get_info() { 166 159 160 if ( $_POST['access_token'] !== get_option( 'convertful_token' )) { 161 wp_send_json_error( array( 162 'access_token' => 'Wrong access token', 163 ) ); 164 } 165 167 166 $tags = array(); 168 167 foreach ( get_tags() as $tag ) { … … 175 174 } 176 175 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, 182 198 ); 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 31 31 $site_id = get_option( 'convertful_site_id' ); 32 32 if ( $site_id === FALSE ) { 33 $connect_url = $conv_domain . '/ oauth2/connect_site';33 $connect_url = $conv_domain . '/sites/authorize/WordPressPlugin/'; 34 34 if ( $ref_username = get_option( 'convertful_ref' ) ) { 35 35 $connect_url .= '?ref=' . $ref_username; 36 36 } 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 ); 37 40 ?> 38 41 <div class="conv-connect"> … … 49 52 </div> 50 53 <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' ) ) ?>">53 54 <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 57 60 <button class="conv-btn action_connect"> 58 61 Connect to Convertful -
convertful/tags/1.5/readme.txt
r1978662 r2002204 3 3 Tags: optin, opt-in, mailchimp, popup, bar, slidein, subscribe, signup, form, email, marketing, lead, campaign 4 4 Requires at least: 4.0 5 Tested up to: 5.0. 06 Stable tag: 1. 45 Tested up to: 5.0.2 6 Stable tag: 1.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 * **Scroll Boxes** which are shown when a visitor scrolls some part of your blog post 35 35 * **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 convers on36 * **Yes/No Forms** which break the standard form pattern, and increase conversion 37 37 * **Content Upgrades** which offer additional content for a blog post 38 38 * **Deadline Funnels** that display countdown timers (including evergreen countdown timers) … … 93 93 == Changelog == 94 94 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 95 100 = 1.4 = 96 101 * Tested compatibility with WordPress 5.0 -
convertful/trunk/convertful.php
r1978662 r2002204 3 3 /** 4 4 * Plugin Name: Convertful - Your Ultimate On-Site Conversion Tool 5 * Version: 1. 45 * Version: 1.5 6 6 * Plugin URI: https://convertful.com/ 7 7 * Description: All the modern on-site conversion solutions, natively integrates with all modern Email Marketing Platforms. … … 47 47 global $conv_domain, $conv_version; 48 48 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 ) ); 49 74 } 50 75 … … 127 152 } 128 153 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 161 154 if ( wp_doing_ajax() OR defined( 'DOING_AJAX' ) ) { 162 155 … … 165 158 function conv_get_info() { 166 159 160 if ( $_POST['access_token'] !== get_option( 'convertful_token' )) { 161 wp_send_json_error( array( 162 'access_token' => 'Wrong access token', 163 ) ); 164 } 165 167 166 $tags = array(); 168 167 foreach ( get_tags() as $tag ) { … … 175 174 } 176 175 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, 182 198 ); 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 31 31 $site_id = get_option( 'convertful_site_id' ); 32 32 if ( $site_id === FALSE ) { 33 $connect_url = $conv_domain . '/ oauth2/connect_site';33 $connect_url = $conv_domain . '/sites/authorize/WordPressPlugin/'; 34 34 if ( $ref_username = get_option( 'convertful_ref' ) ) { 35 35 $connect_url .= '?ref=' . $ref_username; 36 36 } 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 ); 37 40 ?> 38 41 <div class="conv-connect"> … … 49 52 </div> 50 53 <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' ) ) ?>">53 54 <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 57 60 <button class="conv-btn action_connect"> 58 61 Connect to Convertful -
convertful/trunk/readme.txt
r1978662 r2002204 3 3 Tags: optin, opt-in, mailchimp, popup, bar, slidein, subscribe, signup, form, email, marketing, lead, campaign 4 4 Requires at least: 4.0 5 Tested up to: 5.0. 06 Stable tag: 1. 45 Tested up to: 5.0.2 6 Stable tag: 1.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 * **Scroll Boxes** which are shown when a visitor scrolls some part of your blog post 35 35 * **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 convers on36 * **Yes/No Forms** which break the standard form pattern, and increase conversion 37 37 * **Content Upgrades** which offer additional content for a blog post 38 38 * **Deadline Funnels** that display countdown timers (including evergreen countdown timers) … … 93 93 == Changelog == 94 94 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 95 100 = 1.4 = 96 101 * Tested compatibility with WordPress 5.0
Note: See TracChangeset
for help on using the changeset viewer.