Plugin Directory

Changeset 1998157


Ignore:
Timestamp:
12/19/2018 03:18:31 PM (7 years ago)
Author:
platformlycom
Message:

new feature for automatic adding the project code in the site header;extended settings to show optins

Location:
platformly/trunk
Files:
3 added
12 edited

Legend:

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

    r1955138 r1998157  
    140140    vertical-align: middle !important;
    141141}
     142#btnVisitAccount{
     143    display: inline-block;
     144    margin-top: 10px;
     145}
     146.table-name{
     147    display: inline-block;
     148    margin-right: 8px;
     149    margin-bottom: 18px;
     150}
     151#links_table_toggle .ply_serch_not_result{
     152    display: none;
     153}
     154#msgPlyGetProgectCodeError, #plyLoadingProjectCode{
     155    display: none;
     156}
     157#plyCheckboxSetProjectCode{
     158    margin-left: 0px !important;
     159}
     160#plyProjectCodeSettings{
     161    display: none;
     162}
     163#msgPlyGetProgectCodeError{
     164    color:#cb2727;
     165}
     166#msgPlyGetProgectCodeActivated span{
     167    font-weight: bold;
     168}
     169.ply_label_optin_form{
     170    margin-bottom: 0px;
     171    margin-left: 3px;
     172    font-weight: normal;
     173}
     174#msgPlyGetProgectCodeActivated{
     175    margin-top: 8px;
     176}
     177#optinWherePage{
     178    min-width: 160px;
     179    width: 20%;
     180}
     181#plyBlockListWpPages dd, li{
     182    margin-bottom: 0px;
     183}
  • platformly/trunk/inc/pages/ply.events.php

    r1955138 r1998157  
    55$get_projects = wp_remote_retrieve_body($get_projects);
    66$projects = json_decode($get_projects, true);
    7 
     7$projectCodeInclude = get_option('ply_project_code_active');
     8$projectCode = ply_get_project_code();
    89?>
    9 <?php if(isset($msg)) {
     10<?php if(isset($msg)){
    1011    echo $msg;
    1112    wp_add_inline_script('ply_events_script', "jQuery(document).ready(function() {setTimeout(function(){jQuery('#ply_closeNotification').fadeOut();}, 5000);});");
     
    2324            </div>
    2425            <div class="col-md-12">
    25                 <select onchange='loadEvents(this.value)'>
     26                <select id='plyProjectSelect'>
    2627                    <option value='-1'>Please choose...</option>
    2728                    <?php foreach($projects as $pid => $pname): ?>
     
    3334        <div class="row">
    3435            <div class="col-md-12">
    35                 <h4>Active Optins</h4><hr>
     36                <h4 class="table-name">Active Events</h4>
     37                <a target="_blank" href="<?php echo $user['main_url'] ?>/?page=setup.events" class="btn btn-default">View Events</a>
     38                <a href="javascript:;" id="btnPlyRefreshEvents" class="btn btn-default" title="Refresh">&#8635;</a>
     39                <hr>
    3640                <table id="plyEventsTable" class="table">
    3741                    <thead>
     
    6064                    <div class="modal-body">
    6165                        <div class="created-code" id="evCode">
    62                             <div style="margin-bottom: 15px;">
     66                            <?php /* <div style="margin-bottom: 15px;">
    6367                                <a href="#" id="eventTabJs" class="active event-tabs">Javascript Code</a>&nbsp;|&nbsp;<a  id="eventTabPixel" class="event-tabs" href="#">Pixel Code</a>
    64                             </div>
     68                            </div> */ ?>
    6569                            <div id="eventTabContentJs">
    66                                 <p>Place below code within your &lt;head&gt; section.</p>
     70                                <?php /* <p>Place below code within your &lt;head&gt; section.</p>
    6771                                <textarea name="evCode_top" id="evCode_top" class="form-control" onclick="jQuery(this).select()" style="background-color:#f4f4f4;  font-size:12px; height:100px;"></textarea>
     72                                 */ ?>
     73                                <?php if(!empty($projectCodeInclude) && !empty($projectCode)): ?>
     74                                    <p class='ply_successMsg'>A code from Project '<span><?php echo $projects[$projectCode['ply_project_id']] ?></span>' is being used on this site.</p>
     75                                <?php else: ?>
     76                                    <p class='ply_errorMsg'>
     77                                        You must include a Platform.ly project code within your site, please <a href="<?php echo get_admin_url(null, 'admin.php?page=ply') ?>">"click here"</a> to do it now.
     78                                    </p>
     79                                <?php endif; ?>
    6880                                <p style="margin-top: 15px;">Place below code where you want to fire the event. The events can be fired in any HTML code, onClick,onChange events, JS functions...</p>
    6981                                <div style="margin-bottom: 10px;">
     
    7890                                </div>
    7991                            </div>
     92                            <?php /*
    8093                            <div id="eventTabContentPixel" style="display:none;">
    8194                                <p>Place below code where you want to fire the event.</p>
    8295                                <textarea name="evCode_bottom_pixel" id="evCode_bottom_pixel" class="form-control" onclick="jQuery(this).select()" style="background-color:#f4f4f4;  font-size:12px;"></textarea>
     96                            </div> */ ?>
    8397                            </div>
    8498                        </div>
    85                     </div>
    8699                    <div class="modal-footer">
    87                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
     100                        <button type="button" class="btn btn-default" data-dismiss="modal">Done</button>
    88101                    </div>
    89102                </div>
  • platformly/trunk/inc/pages/ply.optins.page.php

    r1955138 r1998157  
    3838    $editOptin = ply_get_optin_by_id((int)$_POST['editOptin']);
    3939}
     40
     41$postList = get_posts(array('post_status' => 'publish,future,private'));
     42$pageList = get_pages(array('post_status' => 'publish,future,private'));
    4043?>
    4144
     
    9093            <div class="row">
    9194                <div class="col-md-12">
    92                     <h4>Please select optin</h4><hr>
     95                    <h4 style='display: inline-block; margin-right: 5px'>Please select optin</h4><a target="_blank" href="<?php echo $user['main_url'] ?>/?page=lead_capture.forms" class="btn btn-default">View Optins</a><hr style="margin-top: 5px !important">
    9396                </div>
    9497                <div class="col-md-12" id="tdOptins">
     
    104107                <?php
    105108                $loc = "all";
     109                $optinExceptPage = array();
     110                $optionSpecificPage = 0;
    106111                if($editOptin != false){
    107112                    $options = json_decode($editOptin->ply_optin_options, true);
    108113                    $loc = $options['optinLoc'];
    109                 }
    110                 ?>
    111                 <input type="radio" name="optinwhere" id="optinWhereAll" value="all" <?= ($loc == 'all') ? 'checked' : '' ?>> Every WordPress page
    112                 <input type="radio" name="optinwhere" id="optinWherePosts" value="posts" <?= ($loc == 'posts') ? 'checked' : '' ?>> Only on posts
     114                    if(empty($options['optinPages'])){
     115                        $optinExceptPage = array();
     116                    }else{
     117                        $optinExceptPage = $options['optinPages'];
     118                    }
     119                }
     120                ?>
     121                <input type="radio" name="optinwhere" id="optinWhereAll" value="all" <?php echo ($loc == 'all') ? 'checked' : '' ?>>
     122                <label for='optinWhereAll' class='ply_label_optin_form'> Everywhere</label>
     123                <input type="radio" name="optinwhere" id="optinWherePages" value="pages" <?php echo ($loc == 'pages') ? 'checked' : '' ?>>
     124                <label for='optinWherePages' class='ply_label_optin_form'> On Pages</label>
     125                <input type="radio" name="optinwhere" id="optinWherePosts" value="posts" <?php echo ($loc == 'posts') ? 'checked' : '' ?>>
     126                <label for='optinWherePosts' class='ply_label_optin_form'> On Posts</label>
     127                <input type="radio" name="optinwhere" id="optinWhereExcept" value="except" <?php echo ($loc == 'except') ? 'checked' : '' ?>>
     128                <label for='optinWhereExcept' class='ply_label_optin_form'> Everywhere except</label>
     129                <input type="radio" name="optinwhere" id="optinWhereSpecific" value="specific" <?php echo ($loc == 'specific') ? 'checked' : '' ?>>
     130                <label for='optinWhereSpecific' class='ply_label_optin_form'> Show only on a specific page/post</label>
     131            </div>
     132        </div>
     133        <div id='plyBlockListWpPages' class="row" <?php echo in_array($loc, array('except', 'specific')) ? '' : 'style="display:none;"' ?>>
     134            <div class="col-md-12">
     135                <h4>Please select pages/posts</h4><hr>
     136            </div>
     137            <div class="col-md-12">
     138                <select id='optinWherePage' multiple name='optinWherePage[]'>
     139                    <?php foreach($postList as $post): ?>
     140                        <option value="<?php echo $post->ID ?>" <?php echo in_array($post->ID, $optinExceptPage) ? 'selected' : '' ?>><?php echo $post->post_title ?></option>
     141                    <?php endforeach; ?>
     142                    <?php foreach($pageList as $page): ?>
     143                        <option value="<?php echo $page->ID ?>" <?php echo in_array($page->ID, $optinExceptPage) ? 'selected' : '' ?>><?php echo $page->post_title ?></option>
     144                    <?php endforeach; ?>
     145                </select>
    113146            </div>
    114147        </div>
     
    202235        <div class="row">
    203236            <div class="col-md-12">
    204                 <h4 style="display: inline-block;">Close optin if user clicks away?</h4>
     237                <label for='ply_clickAway'><h4>Close optin if user clicks away?</h4></label>
    205238                <?php
    206239                //by default true
     
    217250        <div class="row">
    218251            <div class="col-md-12">
    219                 <h4 style="display: inline-block;">Blur the page while the optin is visible?</h4>
     252                <label for='ply_blurBack'><h4>Blur the page while the optin is visible?</h4></label>
    220253                <?php
    221254                //by default true
     
    245278        <div class="row">
    246279            <div class="col-md-12">
    247                 <h4>Active Optins</h4><hr>
     280                <h4 class="table-name">Active Optins</h4>
     281                <?php /* <a target="_blank" href="<?php echo $user['main_url'] ?>/?page=lead_capture.forms" class="btn btn-default">View Optin</a>
     282                <a class="btn btn-default" title="Refresh">&#8635;</a> */ ?>
     283                <hr>
    248284                <table class="table">
    249285                    <thead>
     
    327363    <input type="text" name="formOptinClickAway" id="formOptinClickAway" value="" />
    328364    <input type="text" name="formOptinBlurBack" id="formOptinBlurBack" value="" />
    329 
     365    <input type="hidden" name='formOptinWherePages' id='formOptinWherePages' value=''/>
     366   
    330367    <input type="hidden" name="saveOptin" value="1" />
    331368</form>
  • platformly/trunk/inc/pages/ply.pages.php

    r1955138 r1998157  
    9999            <div class="row">
    100100                <div class="col-md-12">
    101                     <h4>Please select page</h4><hr>
     101                    <h4 style='display: inline-block; margin-right: 5px'>Please select page</h4><a target="_blank" href="<?php echo $user['main_url'] ?>/?page=lead_capture.pages" class="btn btn-default">View Pages</a><hr style="margin-top: 5px !important">
    102102                </div>
    103103                <div class="col-md-12" id="tdPages">
     
    127127                        <p>Homepage</p>
    128128                    </a>
    129                     <a id="welcome" href="javascript:" onclick="choosePageType(jQuery(this));" class="<?= ($pageType == 'welcome') ? 'selected' : '' ?>">
     129                    <?php /* <a id="welcome" href="javascript:" onclick="choosePageType(jQuery(this));" class="<?= ($pageType == 'welcome') ? 'selected' : '' ?>">
    130130                        <img src="<?= plugins_url('', dirname(__FILE__)) ?>/../img/welcome-page-type.png" width="100" height="100"/>
    131131                        <p>Welcome</p>
    132                     </a>
     132                    </a> */ ?>
    133133                    <a id="404" href="javascript:" onclick="choosePageType(jQuery(this));" class="<?= ($pageType == '404') ? 'selected' : '' ?>">
    134134                        <img src="<?= plugins_url('', dirname(__FILE__)) ?>/../img/error-page-type.png" width="100" height="100"/>
     
    156156        <div class="row">
    157157            <div class="col-md-12">
    158                 <h4>Active Pages</h4><hr>
     158                <h4 class="table-name">Active Pages</h4>
     159               
     160                <hr>
    159161                <table class="table">
    160162                    <thead>
  • platformly/trunk/inc/pages/ply.settings.php

    r1955138 r1998157  
    1313$access = 1;
    1414include plugin_dir_path(__FILE__) . 'input.php';
     15$projectCode = array();
     16$projectCodeInclude = 0;
     17if(!empty($user) && $user['status'] == 'active'){
     18    $get_projects = wp_remote_get( PLATFORMLY_URL . "/plugin/plugin.actions.php?plugin_key=".ply_get_plugin_key()."&action=listProjects" );
     19    $get_projects = wp_remote_retrieve_body($get_projects);
     20    $projects = json_decode($get_projects, true);
     21    $projectCodeInclude = get_option('ply_project_code_active');
     22    $projectCode = ply_get_project_code();
     23}
    1524?>
    1625<table width="100%" border="0" cellspacing="0" cellpadding="3">
     
    5463                <td width="90" valign="top">
    5564                    <?php
     65                    $default = plugins_url('', dirname(__FILE__)) . "/../img/profile_img.png";
    5666                    if(isset($user['profile_image']) && strlen($user['profile_image']) > 0){
    57                         $img_url = urldecode($user['main_url']) . '/images_v2/profile_images/' . $user['profile_image'];
     67                        if(!empty($user['use_gravatar'])){
     68                            $img_url = $user['profile_image']."?d=".urlencode( $default )."&s=90";
     69                        }else{
     70                            $img_url = $user['profile_image'];
     71                        }
    5872                    } else{
    59                         $default = plugins_url('', dirname(__FILE__)) . "/../img/profile_img.png";
    6073                        $size = 80;
    6174                        $img_url = $default;
    62                     }
    63                     ?><img src="<?= $img_url ?>" width="80" height="80" class="round" style="border:3px #f4f4f4 solid;" title="<?= $user['first_name'] ?>" />
     75                    }//var_dump($user);die;
     76                    ?>
     77                    <img src="<?= $img_url ?>" width="80" height="80" class="round" style="border:3px #f4f4f4 solid;" title="<?= $user['first_name'] ?>" />
    6478                </td>
    65                 <td valign="top"><h2 style="margin-bottom:5px; padding-bottom:5px;">Welcome <?= $user['first_name'] . ' ' . $user['last_name'] ?></h2>
    66                     <strong>Email: </strong><?= $user['email'] ?><br />
     79                <td valign="top">
     80                    <h2 style="margin-bottom:0; display: inline-block;margin-top: 5px;">Welcome <?= $user['first_name'] . ' ' . $user['last_name'] ?></h2>
     81                    <div><strong>Email: </strong><?= $user['email'] ?></div>
     82                    <form id="btnVisitAccount" method="get" target="_blank" action="<?php echo $user['main_url'] ?>">
     83                        <input type='hidden' name='page' value='settings.personal_information'/>
     84                        <input type="submit" class="button" value="Visit your Account" />
     85                    </form>
    6786                </td>
    6887            </tr>
    6988        </table>
     89        <br/>
     90        <div id="plyProjectCodeBlock">
     91            <h2 style="margin-bottom: 5px;">Add a Project Code</h2>
     92            <div style="margin-bottom: 8px;">
     93                <input id="plyCheckboxSetProjectCode" value='1' type="checkbox" <?php echo !empty($projectCodeInclude) && !empty($projectCode) ? 'checked' : '' ?>/>
     94                <label for="plyCheckboxSetProjectCode">Click here to include a Platform.ly project code within your blog</label>
     95            </div>
     96            <div id='plyProjectCodeSettings' <?php echo !empty($projectCodeInclude) && !empty($projectCode) ? 'style="display:block"' : '' ?>>
     97                <select id="plyProjectSelect">
     98                    <option value='-1'>Please choose...</option>
     99                    <?php foreach($projects as $pid => $pname): ?>
     100                        <option value="<?php echo $pid ?>" <?php echo isset($projectCode['ply_project_id']) && $projectCode['ply_project_id'] == $pid ? 'selected' : ''  ?>><?php echo $pname ?></option>
     101                    <?php endforeach; ?>
     102                </select>
     103                <input id="btnPlySaveProjectCode" class="button" type="button" value="Save"/>
     104                <div id="msgPlyGetProgectCodeError"></div>
     105                <div id='plyLoadingProjectCode'>Loading...</div>
     106                <div id="msgPlyGetProgectCodeActivated" class='ply_successMsg' <?php echo !isset($projectCode['ply_project_id']) ? 'style="display:none"' : '' ?> >A code from Project '<span><?php echo isset($projectCode['ply_project_id']) ? $projects[$projectCode['ply_project_id']] : '' ?></span>' is being used on this site. <a id="plyRemoveProjectCode" href="javascript:;">Remove Project code.</a></div>
     107            </div>
     108        </div>
    70109<?php } ?>
    71110</div>
  • platformly/trunk/inc/ply.functions.php

    r1955138 r1998157  
    6464            $optinType = "pop";
    6565        }
    66         if(isset($_POST['formOptinWhere']) && in_array($_POST['formOptinWhere'], array('all', 'posts'))){
     66        if(isset($_POST['formOptinWhere']) && in_array($_POST['formOptinWhere'], array('all', 'posts', 'pages', 'except', 'specific'))){
    6767            $optinWhere = $_POST['formOptinWhere'];
    6868        }else{
     
    8989            $optinBlurBack = "false";
    9090        }
     91        if(isset($_POST['formOptinWherePages']) && ($optinWhere == 'except' || $optinWhere == 'specific') && !empty($_POST['formOptinWherePages'])){
     92            $wpPages = explode(',', $_POST['formOptinWherePages']);
     93            $optinPages = array();
     94            foreach($wpPages as $wpPage){
     95                $optinPages[] = (int)$wpPage;
     96            }
     97        }else{
     98            $optinPages = 0;
     99        }
     100       
    91101        $plyOptinInfo = array(
    92102            "optinPosition" => $optinPosition,
     
    96106            "optinLoc" => $optinWhere,
    97107            "optinClickAway" => $optinClickAway,
    98             "optinBlurBack" => $optinBlurBack
     108            "optinBlurBack" => $optinBlurBack,
     109            "optinPages" => $optinPages
    99110        );
    100111        $plyOptinInfo = json_encode($plyOptinInfo);
     
    383394}
    384395
     396function ply_set_project_code($projectId, $projectCode){
     397    global $wpdb;
     398    $ply_plugin_cid = get_option('ply_plugin_cid');
     399    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}ply_project_code WHERE ply_cid = %d", array($ply_plugin_cid)));
     400    $query = $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}ply_project_code(ply_project_id, ply_cid, ply_project_code) VALUES (%d, %d, %s)", array($projectId, $ply_plugin_cid, $projectCode)));
     401    /*$sql = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}ply_project_code WHERE ply_project_id = %d AND ply_cid = %d", array($projectId, $ply_plugin_cid));
     402    $existsProjectCode = $wpdb->get_row($sql, ARRAY_A);
     403    if(!empty($existsProjectCode)){
     404        $query = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}ply_project_code SET ply_project_code = %s WHERE ply_project_id = %d AND ply_cid = %d", array($projectCode, $projectId, $ply_plugin_cid)));
     405    }else{
     406        $query = $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}ply_project_code(ply_project_id, ply_cid, ply_project_code) VALUES (%d, %d, %s)", array($projectId, $ply_plugin_cid, $projectCode)));
     407    }*/
     408    if($query){
     409        return true;
     410    }else{
     411        return false;
     412    }
     413}
     414
     415function ply_get_project_code($projectId = null){
     416    global $wpdb;
     417    $ply_plugin_cid = get_option('ply_plugin_cid');
     418    if($projectId){
     419        $sql = $wpdb->prepare("SELECT id, ply_project_code, ply_project_id FROM {$wpdb->prefix}ply_project_code WHERE ply_project_id = %d AND ply_cid = %d", array($projectId, $ply_plugin_cid));
     420        return $wpdb->get_row($sql, ARRAY_A);
     421    }else{
     422        $sql = $wpdb->prepare("SELECT id, ply_project_code, ply_project_id  FROM {$wpdb->prefix}ply_project_code WHERE ply_cid = %d", array($ply_plugin_cid));
     423        //return $wpdb->get_results($sql, ARRAY_A);
     424        return $wpdb->get_row($sql, ARRAY_A);
     425    }
     426}
     427
     428function ply_remove_project_code(){
     429    global $wpdb;
     430    $ply_plugin_cid = get_option('ply_plugin_cid');
     431    $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}ply_project_code WHERE ply_cid = %d", array($ply_plugin_cid)));
     432}
     433
     434function ply_project_code_include($v){
     435    if($v === true){
     436        update_option('ply_project_code_active', 1);
     437    }else{
     438        update_option('ply_project_code_active', 0);
     439    }
     440}
    385441?>
  • platformly/trunk/js/events.js

    r1955138 r1998157  
    99            jQuery('#plyEventsTable tbody').html('<tr><td colspan="6">'+data.status+'</td></tr>');
    1010        }else{
    11             jQuery('#evCode_top').text(data.eventCode);
     11            //jQuery('#evCode_top').text(data.eventCode);
    1212            if(data.events.length > 0){
    1313                var tbody = '';
     
    4747        var eventCode = "<script type='text/javascript'>plyt('"+action.replace(/[^a-zA-Z0-9_ ]/gi, "")+"', '"+description.replace(/[^a-zA-Z0-9_ ]/gi, "")+"','"+encodeURIComponent(id)+"');<\/script>";
    4848        var eventCodeClick = "onclick=\"plyt('"+action.replace(/[^a-zA-Z0-9_ ]/gi, "")+"', '"+description.replace(/[^a-zA-Z0-9_ ]/gi, "")+"','"+encodeURIComponent(id)+"');\"";
    49         var eventPixelCode = '<img height="1" width="1" style="display:none"    src="https://www.platform.ly/platformly.php?a='+encodeURIComponent(action.replace(/[^a-zA-Z0-9_ ]/gi, ""))+'&d='+encodeURIComponent(description.replace(/[^a-zA-Z0-9_ ]/gi, ""))+'&e='+encodeURIComponent(id)+'"/>';
     49        //var eventPixelCode = '<img height="1" width="1" style="display:none"  src="https://www.platform.ly/platformly.php?a='+encodeURIComponent(action.replace(/[^a-zA-Z0-9_ ]/gi, ""))+'&d='+encodeURIComponent(description.replace(/[^a-zA-Z0-9_ ]/gi, ""))+'&e='+encodeURIComponent(id)+'"/>';
    5050
    5151        $("#eventType").val(1).trigger('change');
    5252        $("#evCode_bottom_click").val(eventCodeClick);
    5353        $("#evCode_bottom").val(eventCode);
    54         $("#evCode_bottom_pixel").val(eventPixelCode);
     54        //$("#evCode_bottom_pixel").val(eventPixelCode);
    5555        $('#plyEventsModal').modal('show');
    5656    });
     
    7777        }
    7878    });
     79    $('#btnPlyRefreshEvents').click(function(e){
     80        e.preventDefault();
     81        var projectId = $('#plyProjectSelect').val();
     82        loadEvents(projectId);
     83    });
     84    $('#plyProjectSelect').click(function(){
     85        var projectId = $(this).val();
     86        /*$('#msgPlyGetProgectCodeActivated').hide();
     87        $('#plyProjectCodeMsgNotExist').hide();
     88        $.post(ajaxurl, {'action': 'ply_check_project_code','projectId': projectId}, function(response){
     89            if(response){
     90                $('#msgPlyGetProgectCodeActivated span').text($('#plyProjectSelect option:selected').text());
     91                $('#msgPlyGetProgectCodeActivated').show();
     92            }else{
     93                $('#plyProjectCodeMsgNotExist').show();
     94            }
     95        });*/
     96        loadEvents(projectId);
     97    });
    7998})(jQuery);
  • platformly/trunk/js/optins.js

    r1955138 r1998157  
    4545function updateOptin(edit) {
    4646    (function($) {
     47        var optinWhere = $('input[name="optinwhere"]:checked').val();
     48        var optinWherePage = $('#optinWherePage').val();
     49       
    4750        if ($("#ply_project").val() == -1) {
    4851            alert("Please select optin form first!");
     
    6164            return;
    6265        }
    63 
     66        if((optinWhere == 'except' || optinWhere == 'specific') && optinWherePage === null){
     67            alert("Please choose a page/post!");
     68            return;
     69        }
     70       
    6471        if (edit) {
    6572            var projectId = $("#edit_ply_optin_pid").val();
     
    7784            optinId = -1;
    7885
    79         var optinWhere = '';
    80         if ($("#optinWhereAll").is(":checked"))
     86        /*if ($("#optinWhereAll").is(":checked"))
    8187            optinWhere = 'all';
    8288        else if ($("#optinWherePosts").is(":checked"))
    8389            optinWhere = 'posts';
    84 
     90        */
    8591        var clickAway = false;
    8692        if ($("#ply_clickAway").is(":checked"))
     
    9096        if ($("#ply_blurBack").is(":checked"))
    9197            blurBack = true;
    92 
     98        if(optinWherePage !== null){
     99            optinWherePage = optinWherePage.join(",");
     100        }else{
     101            optinWherePage = 0;
     102        }
    93103        $("#formProjectId").val(projectId);
    94104        $("#formOptinId").val(optinId);
     
    101111        $("#formOptinClickAway").val(clickAway);
    102112        $("#formOptinBlurBack").val(blurBack);
    103 
     113        $("#formOptinWherePages").val(optinWherePage);
     114       
    104115        $("#optinSaveForm").submit();
    105116    })(jQuery);
     
    111122            $("#thTrigger").html("Please select the delay (in seconds) before this optins is shown:");
    112123
    113             $("#tdTrigger").html("<input type='text' name='triggerValue' id='triggerValue' value='" + value + "' /> seconds");
     124            $("#tdTrigger").html("<input type='text' name='triggerValue' id='triggerValue' style='width: 50px' value='" + value + "' /> seconds");
    114125        } else if (type == 'scroll') {
    115126            $("#thTrigger").html("Please select the scroll percentage before this optins is shown");
     
    151162    })(jQuery);
    152163}
     164
     165(function($){
     166    $(document).ready(function(){
     167        $('#optinWherePage').select2({
     168            placeholder: "Please choose...",
     169            width: '20%'
     170        });
     171    });
     172    $('input[name="optinwhere"]').change(function(){
     173        if($(this).val() == 'except' || $(this).val() == 'specific'){
     174            $('#plyBlockListWpPages').show();
     175        }else{
     176            $('#plyBlockListWpPages').hide();
     177        }
     178    });
     179})(jQuery);
  • platformly/trunk/js/pages.js

    r1955138 r1998157  
     1plyPageSlug = '';
    12function loadPages(projectId, pageId) {
    23    if (projectId == -1)
     
    8687    (function($){
    8788        text = typeof text !== 'undefined' ?  text : false;
    88         if (value == undefined)
    89             value = '';
     89        if (typeof value != 'undefined'){
     90            plyPageSlug = value;
     91        }
    9092        if (elem != '') {
    9193            $('#plugin-type a').removeClass('selected');
     
    9496
    9597        if ($(elem).attr('id') == 'normal' || $(elem).attr('id') == 'welcome' || text != false) {
    96             $("#pageSlugContainer").html("<h4>Choose a slug name: <input type='text' name='pageSlug' id='pageSlug' value='" + value + "' /><br><small>* Only allowed: A-Z, a-z, 0-9, - and _</small> <br> <small>** Blank spaces will be automatically converted to hyphens (-)</small> </h4> ");
     98            $("#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> ");
    9799            if ($(elem).attr("id") == "welcome") {
    98100                $("#pageSlugContainer").append("* If you already have a page of this type it will be overwritten as only one at a time can exist.");
     
    113115    })(jQuery);
    114116}
     117(function($){
     118    $(document).on('change', '#pageSlug', function(){
     119        plyPageSlug = $(this).val();
     120    });
     121})(jQuery);
  • platformly/trunk/js/ply_add_link_functions.js

    r1955138 r1998157  
    11plyAddLinkDialog = '<div id="ply-add-link-dialog" class="hidden" style="max-width:800px"></div>';
     2plySearchWord = '';
    23function get_ply_tracking_links(){
    34    jQuery.post(ajaxurl, {action: 'ply_get_tracking_links'}, function(response){
     
    1415                if(data.links[key]['disabled'] != 'disabled'){
    1516                    tbody += '<tr>\n\
    16                                 <td style="font-size:12px;">'+data.links[key]['cat_name']+'</td>\n\
    17                                 <td style="font-size:12px;"><a href="javascript:;" style="text-decoration: none; color: inherit;" onclick="load_trackingLinks_inDetails('+data.links[key]['id']+')"><strong>'+data.links[key]['name']+'</strong></a></td>\n\
     17                                <td class="ply_search_link" style="font-size:12px;">'+data.links[key]['project_name']+'</td>\n\
     18                                <td class="ply_search_link" style="font-size:12px;">'+data.links[key]['cat_name']+'</td>\n\
     19                                <td class="ply_search_link" style="font-size:12px;"><a href="javascript:;" style="text-decoration: none; color: inherit;" onclick="load_trackingLinks_inDetails('+data.links[key]['id']+')"><strong>'+data.links[key]['name']+'</strong></a></td>\n\
    1820                                <td style="font-size:12px; text-align:left"><a style="word-break: break-all" href="'+data.links[key]['target_link']+'" target="_blank">'+data.links[key]['target_link']+'</a></td>\n\
    1921                            </tr>';
    2022                }
    2123            }
    22             var table = '<table id="links_table_toggle">\n\
     24            var search = '<div><input id="ply_links_table_search" type="text" placeholder="Enter search word"/></div>';
     25            var table = search+'<table id="links_table_toggle">\n\
    2326                <thead>\n\
     27                    <th>Project</th>\n\
    2428                    <th>Category</th>\n\
    2529                    <th>Campaign</th>\n\
     
    2933                </table>';
    3034            $('#ply-add-link-dialog').html(table);
    31             $('#ply-add-link-dialog').dialog('widget').position({ my: "center", at: "center", of: window });
     35            if(plySearchWord){
     36                $('#ply_links_table_search').val(plySearchWord).keyup();
    3237        }
     38            $('#ply-add-link-dialog').on('keyup', '#ply_links_table_search', function(){
     39                $('#links_table_toggle tr').removeClass('ply_search_has_result');
     40                plySearchWord = $('#ply_links_table_search').val();
     41                //$('#links_table_toggle td.ply_search_link:not(:contains("'+plySearchWord+'"))').parents('tr').addClass('ply_serch_not_result');
     42                var lowerPlySearchWord = plySearchWord.toLowerCase();
     43                $('#links_table_toggle td.ply_search_link').each(function(){
     44                    if($(this).text().toLowerCase().indexOf(lowerPlySearchWord) < 0){
     45                        if(!$(this).parent('tr').hasClass('ply_search_has_result')){
     46                            $(this).parent('tr').addClass('ply_serch_not_result');
     47                        }
     48                    }else{
     49                        $(this).parent('tr').addClass('ply_search_has_result').removeClass('ply_serch_not_result');
     50                    }
     51    });
     52            });
     53            $('#ply-add-link-dialog').dialog({width: '600px'}).position({ my: "center", at: "center", of: window });
     54}
    3355    });
    3456}
     
    83105    $('#ply-add-link-dialog').html('<div>Loading . . .</div>');
    84106}
    85 
  • platformly/trunk/platformly.php

    r1955138 r1998157  
    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.2
     6Version: 1.3
    77Author: Platform.ly
    88Author URI: https://www.platform.ly/
     
    4444
    4545function ply_settings(){
     46    wp_enqueue_script('ply_optins_script', plugin_dir_url(__FILE__)."js/settings.js");
    4647    include plugin_dir_path(__FILE__) . 'inc/pages/ply.settings.php';
    4748}
     
    5051    wp_enqueue_style('bootstrap_styles', plugin_dir_url(__FILE__)."css/bootstrap.min.css");
    5152    wp_enqueue_style('bootstrap_theme_styles', plugin_dir_url(__FILE__)."css/bootstrap-theme.min.css");
     53    wp_enqueue_style('select2', plugin_dir_url(__FILE__)."css/select2.min.css");
     54    wp_enqueue_script('select2', plugin_dir_url(__FILE__)."js/select2.min.js");
    5255    wp_enqueue_script('ply_optins_script', plugin_dir_url(__FILE__)."js/optins.js");
    5356    include plugin_dir_path(__FILE__) . 'inc/pages/ply.optins.page.php';
     
    7275    delete_option('ply_plugin_key');
    7376    delete_option('ply_plugin_cid');
     77    delete_option('ply_project_code_active');
    7478    global $wpdb;
    7579    //remove optin_forms table
     
    7983    $table_name = $wpdb->prefix . "ply_pages";
    8084    $sql = "DROP TABLE " . $table_name;
     85    $wpdb->query($sql);
     86    $table_name = $wpdb->prefix."ply_project_code";
     87    $sql = "DROP TABLE ".$table_name;
    8188    $wpdb->query($sql);
    8289}
     
    95102    };
    96103    $table_name = $wpdb->prefix . "ply_optins";
    97     $val = $wpdb->get_results('select 1 from ' . $table_name);
    98     if(!empty($val)){
    99         //DO NOTHING! IT EXISTS!
    100     } else{
    101         //I can't find it... Create table
    102         $sql = "CREATE TABLE $table_name (
    103         id mediumint(9) NOT NULL AUTO_INCREMENT,       
    104                 ply_cid int NOT NULL,
    105         ply_optin_name VARCHAR(255) NULL,
    106         ply_optin_id int NOT NULL UNIQUE,
    107         ply_optin_pid int NULL,
    108         ply_optin_options text NULL,
    109         ply_optin_stats text NULL,
    110         PRIMARY KEY  (id)
    111             ) {$charset_collate};";
    112         dbDelta($sql);
    113     }
     104    $sql = "CREATE TABLE IF NOT EXISTS $table_name (
     105            id mediumint(9) NOT NULL AUTO_INCREMENT,       
     106            ply_cid int NOT NULL,
     107            ply_optin_name VARCHAR(255) NULL,
     108            ply_optin_id int NOT NULL UNIQUE,
     109            ply_optin_pid int NULL,
     110            ply_optin_options text NULL,
     111            ply_optin_stats text NULL,
     112            ply_optin_except_page int NULL,
     113            ply_optin_specific_page int NULL,
     114            PRIMARY KEY (id)
     115        ) {$charset_collate};";
     116    dbDelta($sql);
     117   
    114118    $table_name = $wpdb->prefix . "ply_pages";
    115     $val = $wpdb->get_results('select 1 from ' . $table_name);
     119    $val = $wpdb->get_results("SHOW TABLES LIKE '{$table_name}'");
    116120    if(!empty($val)){
    117121        //IT EXISTS! Fresh update every active page html
     
    123127    }else{
    124128        //I can't find it... Create table
    125         $sql = "CREATE TABLE $table_name (
     129        $sql = "CREATE TABLE IF NOT EXISTS $table_name (
    126130        id mediumint(9) NOT NULL AUTO_INCREMENT,               
    127131                ply_cid int NOT NULL,
     
    139143        dbDelta($sql);
    140144    }
     145    $table_name = $wpdb->prefix."ply_project_code";
     146    $sql = "CREATE TABLE IF NOT EXISTS {$table_name} (
     147        `id` int NOT NULL AUTO_INCREMENT,
     148        `ply_project_id` int NOT NULL,
     149        `ply_cid` int NOT NULL,
     150        `ply_project_code` text NULL,
     151        PRIMARY KEY  (`id`),
     152        UNIQUE KEY `ply_project_id` (`ply_project_id`,`ply_cid`),
     153        KEY `ply_cid` (`ply_cid`)
     154    ) {$charset_collate};";
     155    dbDelta($sql);
     156   
    141157}
    142158
     
    149165add_action('wp_ajax_ply_load_events', 'ply_load_events_callback');
    150166add_action('wp_ajax_ply_get_tracking_links_details', 'ply_get_tracking_links_details_callback');
     167add_action('wp_ajax_ply_save_project_code', 'ply_save_project_code_callback');
     168add_action('wp_ajax_ply_check_project_code', 'ply_check_project_code_callback');
     169add_action('wp_ajax_ply_remove_project_code', 'ply_remove_project_code_callback');
     170add_action('wp_ajax_ply_project_code_include', 'ply_project_code_include_callback');
    151171
    152172function ply_load_optins_callback(){
     
    186206    $result = wp_remote_retrieve_body($result);
    187207    echo $result;
     208    wp_die();
     209}
     210
     211function ply_save_project_code_callback(){
     212    $projectId = intval($_POST['projectId']);
     213    $result = wp_remote_get(PLATFORMLY_URL."/plugin/plugin.actions.php?plugin_key=".ply_get_plugin_key()."&action=getProjectCode&projectId=".$projectId);
     214    $result = wp_remote_retrieve_body($result);
     215    $data = json_decode($result, true);
     216    if($data['status'] != 'success'){
     217        echo $result;
     218    }else{
     219        if(isset($data['projectCode']) && !empty($data['projectCode'])){
     220            $setProject = ply_set_project_code($projectId, $data['projectCode']);
     221            if($setProject === true){
     222                echo json_encode(array('status' => 'success', 'projectName' => wp_strip_all_tags($data['projectName'])));
     223            }else{
     224                echo json_encode(array('status' => 'An error occured.'));
     225            }
     226        }else{
     227            echo json_encode(array('status' => 'An error occured.'));
     228        }
     229    }
     230    wp_die();
     231}
     232function ply_check_project_code_callback(){
     233    $projectId = intval($_POST['projectId']);
     234    $projectCode = ply_get_project_code($projectId);
     235    if(empty($projectCode)){
     236        $response = false;
     237    }else{
     238        $response = true;
     239    }
     240    echo $response;
     241    wp_die();
     242}
     243
     244function ply_remove_project_code_callback(){
     245    ply_remove_project_code();
     246    wp_die();
     247}
     248
     249function ply_project_code_include_callback(){
     250    $includeCode = isset($_POST['includeCode']) && !empty($_POST['includeCode']) ? true : false;
     251    ply_project_code_include($includeCode);
    188252    wp_die();
    189253}
     
    207271                "oca" => $options->optinClickAway,
    208272                "obb" => $options->optinBlurBack,
    209                 "oloc" => $options->optinLoc
     273                "oloc" => $options->optinLoc,
     274                "pageId" => $post->ID,
     275                "selectedPages" => $options->optinPages,
    210276            );
    211277            $optinsBodyEncoded = json_encode($optinsBody);
    212278            $optinsString .= "'{$optinsBodyEncoded}',";
    213279        }
    214         wp_enqueue_script('ply_optins_load_script', PLATFORMLY_URL."/plugin/plyoptin.js?v=1.2");
     280        wp_enqueue_script('ply_optins_load_script', PLATFORMLY_URL."/plugin/plyoptin.js?v=1.3");
    215281        wp_add_inline_script('ply_optins_load_script', "var plyoptins = [" . rtrim($optinsString, ',') . "];var PLY = {'plugin_key':'" . ply_get_plugin_key() . "'};", 'before');
    216282    }
     
    250316          die($res);
    251317          } */
    252         if(!empty($welcomePage) && $slug == $welcomePage['ply_page_slug']){
     318        /*if(!empty($welcomePage) && $slug == $welcomePage['ply_page_slug']){
    253319            $page['ply_page_html'] = $welcomePage['ply_page_html'];
    254         } elseif(is_front_page()){
     320        } else
     321        */if(is_front_page()){
    255322            $page = ply_get_page_by_options('homepage');
    256323        } else{
     
    312379
    313380add_action('admin_enqueue_scripts', 'platform_ly_editor_css');
     381
     382function platform_ly_set_project_code(){
     383    $projectCodeInclude = get_option('ply_project_code_active');
     384    if(!empty($projectCodeInclude)){
     385        $projectCode = ply_get_project_code();
     386        if(isset($projectCode['ply_project_code'])){
     387            echo $projectCode['ply_project_code'];
     388        }
     389    }
     390    /*foreach($projectCode as $code){
     391        echo $code['ply_project_code'];
     392    }*/
     393}
     394add_action('wp_head', 'platform_ly_set_project_code');
    314395?>
  • platformly/trunk/readme.txt

    r1955138 r1998157  
    6363== Upgrade Notice ==
    6464
     65= 1.3 =
     66- new feature for automatic adding the project code in the site header.
     67- extended settings to show optins.
     68
    6569= 1.2 =
    6670Added new features, such as events and ability to insert the tracking links straight in WP default editor.
Note: See TracChangeset for help on using the changeset viewer.