Changeset 2585949
- Timestamp:
- 08/20/2021 10:52:44 AM (4 years ago)
- Location:
- platformly/trunk
- Files:
-
- 6 edited
-
css/ply_styles.css (modified) (1 diff)
-
inc/pages/ply.pages.php (modified) (2 diffs)
-
inc/ply.functions.php (modified) (7 diffs)
-
js/pages.js (modified) (3 diffs)
-
platformly.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
platformly/trunk/css/ply_styles.css
r1998157 r2585949 182 182 margin-bottom: 0px; 183 183 } 184 #plyCheckboxPingUpdateServices{ 185 width: 16px; 186 height: 16px; 187 margin-left: 0 !important; 188 } 189 #plyCheckboxPingUpdateServices::before{ 190 width: 21px; 191 height: 21px; 192 margin-top: -3px; 193 margin-left: -4px; 194 } 195 #plyLabelPingUpdateServices{ 196 font-size: 14px; 197 font-weight: normal; 198 margin-bottom: 0; 199 } -
platformly/trunk/inc/pages/ply.pages.php
r1998157 r2585949 147 147 <input type="hidden" id="edit_ply_page_id" value="<?= $editPage->ply_page_id ?>" /> 148 148 <input type="hidden" id="edit_ply_page_pid" value="<?= $editPage->ply_page_pid ?>" /> 149 <input type="hidden" id="edit_ply_ping_update_services" value="<?= !empty($options['ping_update_services']) ? 1 : 0 ?>" /> 149 150 <button onclick="updatePage(true)" class="btn btn-primary">Update</button> 150 151 <button onclick="location.reload();" class="button button-secondary">Cancel</button> … … 240 241 <input type="text" name="formPageType" id="formPageType" value=""/> 241 242 <input type="text" name="formPageSlug" id="formPageSlug" value=""/> 243 <input type="text" name="formPagePingUpdateServices" id="formPagePingUpdateServices" value=""/> 242 244 <input type="hidden" name="savePage" value="1" /> 243 245 </form> -
platformly/trunk/inc/ply.functions.php
r2293315 r2585949 211 211 "pageSlug" => $pageSlug 212 212 ); 213 $pingUpdateServices = 0; 214 if($pageType === 'normal'){ 215 $plyPageInfo['ping_update_services'] = !empty($_POST['formPagePingUpdateServices']) ? 1 : 0; 216 $pingUpdateServices = $plyPageInfo['ping_update_services']; 217 } 213 218 $plyPageInfo = json_encode($plyPageInfo); 214 219 … … 224 229 if($resultUnsub){ 225 230 $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->prefix . "ply_pages WHERE id=%d LIMIT 1", array($result->id))); 231 platformly_delete_wp_page($result->ply_page_slug); 226 232 } 227 233 } … … 235 241 //if it's an update don't register the page for updates, it's already been done 236 242 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}ply_pages SET `ply_page_options` = %s, `ply_page_type` = %s, `ply_page_slug` = %s WHERE ply_page_id = %d AND ply_cid = %d", array($plyPageInfo, $pageType, $pageSlug, $pageId, $ply_plugin_cid))); 243 // update page in wp_post table 244 if($results[0]->ply_page_type == $pageType){ 245 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET `post_name` = %s, `guid` = %s WHERE post_type = %d AND post_name = %s", array($pageSlug, get_site_url().'/'.$pageSlug, 'ply_page', $results[0]->ply_page_slug))); 246 }elseif($results[0]->ply_page_type === 'normal'){ 247 platformly_delete_wp_page($results[0]->ply_page_slug); 248 }elseif($pageType === 'normal'){ 249 platformly_create_wp_page($pageSlug, $results[0]->ply_page_name); 250 } 251 if($pingUpdateServices){ 252 generic_ping(); 253 } 237 254 return 1; 238 255 } else{ … … 244 261 $pageHTML = $get_pages->html; 245 262 if($wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "ply_pages(`ply_page_name`, `ply_page_pid`, `ply_page_id`, `ply_page_options`, `ply_page_html`, `ply_cid`, ply_page_type, ply_page_slug, ply_page_status) VALUES (%s, %d, %d, %s, %s, %d, %s, %s, %s)", array($pageName, $projectId, $pageId, $plyPageInfo, $pageHTML, $ply_plugin_cid, $pageType, $pageSlug, 'active')))){ 263 if($pingUpdateServices){ 264 generic_ping(); 265 } 266 if($pageType === 'normal'){ 267 platformly_create_wp_page($pageSlug, $pageName); 268 } 246 269 return 1; 247 270 } else{ … … 263 286 if(isset($_POST['removePage']) && !empty($_POST['removePage'])){ 264 287 $sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "ply_pages WHERE ply_page_id=%d AND ply_cid=%d LIMIT 1", array((int)$_POST['removePage'], $ply_plugin_cid)); 265 $ results = $wpdb->get_results($sql);266 267 if(count($ results)){268 $ result = $results[0];269 $pageId = $ result->ply_page_id;288 $ply_pages = $wpdb->get_results($sql); 289 290 if(count($ply_pages)){ 291 $ply_page = $ply_pages[0]; 292 $pageId = $ply_page->ply_page_id; 270 293 271 294 $result = ply_unsubscribe_page_html($pageId); … … 273 296 if($result){ 274 297 if($wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->prefix . "ply_pages WHERE ply_page_id=%d AND ply_cid=%d LIMIT 1", array((int)$_POST['removePage'], $ply_plugin_cid)))){ 298 platformly_delete_wp_page($ply_page->ply_page_slug); 275 299 return 1; 276 300 } else{ … … 481 505 return true; 482 506 } 507 508 function platformly_create_wp_page($pageSlug, $pageName){ 509 wp_insert_post(array( 510 'post_status' => 'publish', 511 'post_type' => 'ply_page', 512 'post_author' => 1, 513 'post_name' => $pageSlug, 514 'post_title' => $pageName, 515 'post_content' => '', 516 'comment_status' => 'closed', 517 'guid' => get_site_url().'/'.$pageSlug 518 )); 519 } 520 521 function platformly_delete_wp_page($pageSlug){ 522 global $wpdb; 523 $plyPage = $wpdb->get_row($wpdb->prepare("SELECT id FROM {$wpdb->posts} WHERE post_type = %s AND post_name = %s", array('ply_page', $pageSlug))); 524 wp_delete_post($plyPage->id, true); 525 } -
platformly/trunk/js/pages.js
r1998157 r2585949 74 74 $("#formPageType").val(pageType); 75 75 $("#formPageSlug").val(pageSlug); 76 $("#formPagePingUpdateServices").val($('#plyCheckboxPingUpdateServices').prop('checked') ? '1' : '0'); 76 77 77 78 $("#pageSaveForm").submit(); … … 94 95 $(elem).addClass('selected'); 95 96 } 96 97 var PingUpdateServices = ''; 98 if(typeof $('#edit_ply_ping_update_services') !== 'undefined'){ 99 PingUpdateServices = $('#edit_ply_ping_update_services').val() == 1 ? 'checked' : ''; 100 } 101 97 102 if ($(elem).attr('id') == 'normal' || $(elem).attr('id') == 'welcome' || text != false) { 98 103 $("#pageSlugContainer").html("<h4>Choose a slug name: <input type='text' name='pageSlug' id='pageSlug' value='" + plyPageSlug + "' /><br><small>* Only allowed: A-Z, a-z, 0-9, - and _</small> <br> <small>** Blank spaces will be automatically converted to hyphens (-)</small> </h4> "); … … 101 106 } else { 102 107 $("#pageSlugContainer").append("* If you already have a page of this slug name it will be overwritten as only one at a time can exist."); 108 $("#pageSlugContainer").append('<div style="margin-top: 8px;font-size: 13px;">\n' + 109 ' <input id="plyCheckboxPingUpdateServices" value="1" type="checkbox" ' + PingUpdateServices + ' />\n' + 110 ' <label id="plyLabelPingUpdateServices" for="plyCheckboxPingUpdateServices">Submit page to Update Services</label>\n' + 111 ' </div>'); 103 112 } 104 113 } else { -
platformly/trunk/platformly.php
r2501538 r2585949 4 4 Plugin Name: Platform.ly Official 5 5 Description: Platform.ly plugin is the easiest way to setup your optins and pages that your created with Platform.ly. After building your optin or page with our interactive WYSIWYG builders, you can set them up to show on your site with just a couple of clicks. 6 Version: 1. 96 Version: 1.10 7 7 Author: Platform.ly 8 8 Author URI: https://www.platform.ly/ … … 16 16 define("PLATFORMLY_URL", "https://pageserver.platform.ly"); 17 17 18 define('PLATFORMLY_PLUGIN_VERSION', '1.9'); 19 20 //update 21 $plyVersion = get_option('ply_plugin_version'); 22 23 updatePlugin($plyVersion); 18 define('PLATFORMLY_PLUGIN_VERSION', '1.10'); 24 19 25 20 include plugin_dir_path(__FILE__) . '/inc/ply.functions.php'; 21 22 add_action('init', 'ply_update_plugin', 5); 23 add_action('init', 'ply_register_post_types', 10); 24 25 function ply_register_post_types(){ 26 //global $wp_taxonomies; 27 28 register_post_type('ply_page', array( 29 'labels' => array( 30 'name' => 'PLY pages' 31 ), 32 'public' => true, 33 'publicly_queryable' => true, 34 'show_ui' => false, 35 'show_in_menu' => false, 36 'query_var' => false, 37 'rewrite' => array('slug'=>'/', 'with_front' => false), 38 'capability_type' => 'page', 39 'has_archive' => false, 40 'hierarchical' => false, 41 'menu_position' => null, 42 'supports' => false, 43 'taxonomies' => array('category') 44 )); 45 } 26 46 27 47 function ply_create_menus(){ … … 100 120 $sql = "DROP TABLE ".$table_name; 101 121 $wpdb->query($sql); 122 //remove ply page from wp_posts table 123 $plyPages = $wpdb->get_results($wpdb->prepare("SELECT id FROM {$wpdb->posts} WHERE post_type = %s", array('ply_page'))); 124 foreach($plyPages as $plyPage){ 125 wp_delete_post($plyPage->id, true); 126 } 102 127 } 103 128 … … 327 352 328 353 function ply_manage_pages(){ 354 $path = \sanitize_text_field( \wp_unslash( $_SERVER['REQUEST_URI'] ) ); 355 // If it's not a wp-sitemap request, nothing to do. 356 if ( \substr( $path, 0, 11 ) === '/wp-sitemap' ) { 357 return; 358 } 359 329 360 $welcomePage = ply_get_page_by_options('welcome'); 330 361 if(!empty($welcomePage) && !isset($_COOKIE[$welcomePage['ply_page_slug']])){ … … 480 511 } 481 512 482 function updatePlugin($version){513 function ply_update_plugin(){ 483 514 global $wpdb; 515 $version = get_option('ply_plugin_version'); 484 516 if(empty($version)){ 485 517 $sql = 'ALTER TABLE `wp_ply_pages` CHANGE `ply_page_html` `ply_page_html` LONGTEXT'; … … 487 519 update_option('ply_plugin_version', PLATFORMLY_PLUGIN_VERSION); 488 520 } 489 } 521 $versionData = explode('.',$version); 522 $major = empty($versionData[0]) ? 0 : $versionData[0]; 523 $minor = empty($versionData[1]) ? 0 : $versionData[1]; 524 // update for 1.10 version 525 if($major < 1 || ($major == 1 && $minor < 10)){ 526 $pages = $wpdb->get_results($wpdb->prepare('SELECT ply_page_slug, ply_page_name FROM '.$wpdb->prefix.'ply_pages WHERE ply_page_type = %s', array('normal'))); 527 foreach($pages as $page){ 528 $plyPage = $wpdb->get_row($wpdb->prepare("SELECT id FROM {$wpdb->posts} WHERE post_type = %s AND post_name = %s", array('ply_page', $page->ply_page_slug))); 529 if(!$plyPage){ 530 platformly_create_wp_page($page->ply_page_slug, $page->ply_page_name); 531 } 532 } 533 update_option('ply_plugin_version', PLATFORMLY_PLUGIN_VERSION); 534 } 535 } -
platformly/trunk/readme.txt
r2501538 r2585949 3 3 Tags: CRM, ecommerce, custom pages, landing pages, optin forms, events, tracking links, platform.ly, platform, platformly 4 4 Requires at least: 4.6 5 Tested up to: 5. 75 Tested up to: 5.8 6 6 Requires PHP: 5.5.9 7 7 Stable tag: trunk … … 78 78 == Upgrade Notice == 79 79 80 = 1.10 = 81 - Pages are displayed in the sitemap 82 - Added possibility to Submit page to Update Services 83 80 84 = 1.9 = 81 85 - Minor fixes
Note: See TracChangeset
for help on using the changeset viewer.