Plugin Directory

Changeset 2585949


Ignore:
Timestamp:
08/20/2021 10:52:44 AM (4 years ago)
Author:
platformlycom
Message:

fixed notice: update field ply_page_html, fixed status for platform page.

Location:
platformly/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • platformly/trunk/css/ply_styles.css

    r1998157 r2585949  
    182182    margin-bottom: 0px;
    183183}
     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  
    147147                    <input type="hidden" id="edit_ply_page_id" value="<?= $editPage->ply_page_id ?>" />
    148148                    <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 ?>" />
    149150                    <button onclick="updatePage(true)" class="btn btn-primary">Update</button>
    150151                    <button onclick="location.reload();" class="button button-secondary">Cancel</button>
     
    240241    <input type="text" name="formPageType" id="formPageType" value=""/>
    241242    <input type="text" name="formPageSlug" id="formPageSlug" value=""/>
     243    <input type="text" name="formPagePingUpdateServices" id="formPagePingUpdateServices" value=""/>
    242244    <input type="hidden" name="savePage" value="1" />
    243245</form>
  • platformly/trunk/inc/ply.functions.php

    r2293315 r2585949  
    211211            "pageSlug" => $pageSlug
    212212        );
     213        $pingUpdateServices = 0;
     214        if($pageType === 'normal'){
     215            $plyPageInfo['ping_update_services'] = !empty($_POST['formPagePingUpdateServices']) ? 1 : 0;
     216            $pingUpdateServices = $plyPageInfo['ping_update_services'];
     217        }
    213218        $plyPageInfo = json_encode($plyPageInfo);
    214219
     
    224229                if($resultUnsub){
    225230                    $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);
    226232                }
    227233            }
     
    235241            //if it's an update don't register the page for updates, it's already been done
    236242            $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            }
    237254            return 1;
    238255        } else{
     
    244261                $pageHTML = $get_pages->html;
    245262                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                    }
    246269                    return 1;
    247270                } else{
     
    263286    if(isset($_POST['removePage']) && !empty($_POST['removePage'])){
    264287        $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;
    270293
    271294            $result = ply_unsubscribe_page_html($pageId);
     
    273296            if($result){
    274297                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);
    275299                    return 1;
    276300                } else{
     
    481505    return true;
    482506}
     507
     508function 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
     521function 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  
    7474        $("#formPageType").val(pageType);
    7575        $("#formPageSlug").val(pageSlug);
     76        $("#formPagePingUpdateServices").val($('#plyCheckboxPingUpdateServices').prop('checked') ? '1' : '0');
    7677
    7778        $("#pageSaveForm").submit();
     
    9495            $(elem).addClass('selected');
    9596        }
    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       
    97102        if ($(elem).attr('id') == 'normal' || $(elem).attr('id') == 'welcome' || text != false) {
    98103            $("#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> ");
     
    101106            } else {
    102107                $("#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>');
    103112            }
    104113        } else {
  • platformly/trunk/platformly.php

    r2501538 r2585949  
    44Plugin Name: Platform.ly Official
    55Description: 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.9
     6Version: 1.10
    77Author: Platform.ly
    88Author URI: https://www.platform.ly/
     
    1616define("PLATFORMLY_URL", "https://pageserver.platform.ly");
    1717
    18 define('PLATFORMLY_PLUGIN_VERSION', '1.9');
    19 
    20 //update
    21 $plyVersion = get_option('ply_plugin_version');
    22 
    23 updatePlugin($plyVersion);
     18define('PLATFORMLY_PLUGIN_VERSION', '1.10');
    2419
    2520include plugin_dir_path(__FILE__) . '/inc/ply.functions.php';
     21
     22add_action('init', 'ply_update_plugin', 5);
     23add_action('init', 'ply_register_post_types', 10);
     24
     25function 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}
    2646
    2747function ply_create_menus(){
     
    100120    $sql = "DROP TABLE ".$table_name;
    101121    $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    }
    102127}
    103128
     
    327352
    328353function 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
    329360    $welcomePage = ply_get_page_by_options('welcome');
    330361    if(!empty($welcomePage) && !isset($_COOKIE[$welcomePage['ply_page_slug']])){
     
    480511}
    481512
    482 function updatePlugin($version){
     513function ply_update_plugin(){
    483514    global $wpdb;
     515    $version = get_option('ply_plugin_version');
    484516    if(empty($version)){
    485517        $sql = 'ALTER TABLE `wp_ply_pages` CHANGE `ply_page_html` `ply_page_html` LONGTEXT';
     
    487519        update_option('ply_plugin_version', PLATFORMLY_PLUGIN_VERSION);
    488520    }
    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  
    33Tags: CRM, ecommerce, custom pages, landing pages, optin forms, events, tracking links, platform.ly, platform, platformly
    44Requires at least: 4.6
    5 Tested up to: 5.7
     5Tested up to: 5.8
    66Requires PHP: 5.5.9
    77Stable tag: trunk
     
    7878== Upgrade Notice ==
    7979
     80= 1.10 =
     81- Pages are displayed in the sitemap
     82- Added possibility to Submit page to Update Services
     83
    8084= 1.9 =
    8185- Minor fixes
Note: See TracChangeset for help on using the changeset viewer.