Plugin Directory

Changeset 2293315


Ignore:
Timestamp:
04/28/2020 09:24:36 AM (6 years ago)
Author:
platformlycom
Message:

Integration with 'Platform.ly for WooCommerce' plugin

Location:
platformly/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • platformly/trunk/inc/pages/ply.settings.php

    r1998157 r2293315  
    1212$pkey = ply_get_plugin_key();
    1313$access = 1;
     14$projectCodeBlockClass = '';
    1415include plugin_dir_path(__FILE__) . 'input.php';
    1516$projectCode = array();
    1617$projectCodeInclude = 0;
     18$projectCodeSetInPlyWoocommerce = platfrom_ly_get_ply_wc_project_code_active();
     19$plyWcPluginIsActive = platform_ly_check_ply_wc_plugin_is_activated();
     20$disabled = '';
    1721if(!empty($user) && $user['status'] == 'active'){
    1822    $get_projects = wp_remote_get( PLATFORMLY_URL . "/plugin/plugin.actions.php?plugin_key=".ply_get_plugin_key()."&action=listProjects" );
     
    2125    $projectCodeInclude = get_option('ply_project_code_active');
    2226    $projectCode = ply_get_project_code();
     27    if($plyWcPluginIsActive){
     28        $projectCodeBlockClass = 'ply-wc-project-code';
     29        $disabled = 'disabled';
     30    }
    2331}
    2432?>
     
    5260            echo "<div class='ply_errorMsg' style='margin-top:1%'>The plugin key you added is not correct.</div>";
    5361            wp_die();
    54         } else if(empty($pkey)){
     62        }else if(!empty($pkey) && (empty($user) || $user['status'] == 'cid_does_not_match_wc_cid')){
     63            echo "<div class='ply_errorMsg' style='margin-top:1%'>Only one user can be used in  Platform.ly applications.</div>";
     64            wp_die();
     65        }else if(empty($pkey)){
    5566            wp_die();
    5667        }
     
    8899        </table>
    89100        <br/>
    90         <div id="plyProjectCodeBlock">
     101        <div id="plyProjectCodeBlock" class="<?php echo $projectCodeBlockClass ?>">
    91102            <h2 style="margin-bottom: 5px;">Add a Project Code</h2>
    92103            <div style="margin-bottom: 8px;">
    93                 <input id="plyCheckboxSetProjectCode" value='1' type="checkbox" <?php echo !empty($projectCodeInclude) && !empty($projectCode) ? 'checked' : '' ?>/>
     104                <input id="plyCheckboxSetProjectCode" value='1' <?php echo $disabled ?> type="checkbox" <?php echo !empty($projectCodeInclude) && !empty($projectCode) ? 'checked' : '' ?>/>
    94105                <label for="plyCheckboxSetProjectCode">Click here to include a Platform.ly project code within your blog</label>
    95106            </div>
     
    104115                <div id="msgPlyGetProgectCodeError"></div>
    105116                <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>
     117                <div id="msgPlyGetProgectCodeActivated" class='ply_successMsg' <?php echo !isset($projectCode['ply_project_id']) ? 'style="display:none"' : '' ?> >
     118                    <div>A code from Project '<span><?php echo isset($projectCode['ply_project_id']) ? $projects[$projectCode['ply_project_id']] : '' ?></span>' is being used on this site.  <?php echo $projectCodeSetInPlyWoocommerce ? "<span>This Code is installed from 'Platform.ly for WooCommerce' plugin</span>" : ($plyWcPluginIsActive ? '' : '<a id="plyRemoveProjectCode" href="javascript:;">Remove Project code.</a>') ?></div>
     119                </div>
    107120            </div>
    108121        </div>
  • platformly/trunk/inc/ply.btn.php

    r2248759 r2293315  
    1717    var plyProjectId = 0;
    1818<?php endif; ?>
    19     var editInElementor = <?php echo isEditInElementor() ? 'true' : 'false'; ?>;
     19    var editInElementor = <?php echo platformLyisEditInElementor() ? 'true' : 'false'; ?>;
    2020    var siteUrl = '<?php echo home_url(); ?>';
    2121
     
    269269    });
    270270
    271 <?php if (isEditInElementor()): ?>
     271<?php if (platformLyisEditInElementor()): ?>
    272272    elementor.hooks.addAction( 'panel/open_editor/widget/text-editor', function( panel, model, view ) {
    273273        setTimeout(function() {
  • platformly/trunk/inc/ply.functions.php

    r2208564 r2293315  
    1414            $block = true;
    1515            update_option('ply_plugin_cid', '');
    16         } else{
     16        }else if(!platformly_wc_check_user($check['id'])){
     17            $block = true;
     18            $check['status'] = 'cid_does_not_match_wc_cid';
     19            update_option('ply_plugin_cid', '');
     20        }else{
    1721            $ply_plugin_cid = get_option('ply_plugin_cid');
    1822            if($ply_plugin_cid != $check['id']){
     
    394398    global $wpdb;
    395399    $ply_plugin_cid = get_option('ply_plugin_cid');
    396     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}ply_project_code WHERE ply_cid = %d", array($ply_plugin_cid)));
    397     $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)));
    398     /*$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));
    399     $existsProjectCode = $wpdb->get_row($sql, ARRAY_A);
    400     if(!empty($existsProjectCode)){
    401         $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)));
    402     }else{
    403         $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)));
    404     }*/
    405     if($query){
    406         return true;
    407     }else{
    408         return false;
    409     }
     400    if($ply_plugin_cid){
     401        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}ply_project_code WHERE ply_cid = %d", array($ply_plugin_cid)));
     402        $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(absint($projectId), absint($ply_plugin_cid), esc_js($projectCode))));
     403        /*$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));
     404        $existsProjectCode = $wpdb->get_row($sql, ARRAY_A);
     405        if(!empty($existsProjectCode)){
     406            $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)));
     407        }else{
     408            $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)));
     409        }*/
     410        if($query){
     411            return true;
     412        }else{
     413            return false;
     414        }
     415    }
     416    return false;
    410417}
    411418
     
    436443    }
    437444}
     445
     446function platform_ly_check_ply_wc_plugin_is_activated(){
     447    return is_plugin_active('platformly-for-woocommerce/platformly-for-woocommerce.php');
     448}
     449
     450function platform_ly_get_ply_wc_project_id(){
     451    $platformly_wc_options = get_option('platformly-woocommerce');
     452    $platformly_wc_project_id = isset($platformly_wc_options['platformly-wc-project-id']) && !empty($platformly_wc_options['platformly-wc-project-id']) ? $platformly_wc_options['platformly-wc-project-id'] : null;
     453    return $platformly_wc_project_id;
     454}
     455
     456function platform_ly_get_ply_wc_project_code(){
     457    $platformly_wc_options = get_option('platformly-woocommerce');
     458    $platformly_wc_project_code = isset($platformly_wc_options['platformly-wc-project-code']) && !empty($platformly_wc_options['platformly-wc-project-code']) ? $platformly_wc_options['platformly-wc-project-code'] : null;
     459    return $platformly_wc_project_code;
     460}
     461
     462function platfrom_ly_project_code_include_from_ply_wc($v){
     463    if($v === true){
     464        update_option('ply_wc_project_code_active', 1);
     465    }else{
     466        update_option('ply_wc_project_code_active', 0);
     467    }
     468}
     469
     470function platfrom_ly_get_ply_wc_project_code_active(){
     471    $wc_project_code_is_active = get_option('ply_wc_project_code_active');
     472    return empty($wc_project_code_is_active) ? false : true;
     473   
     474}
     475
     476function platformly_wc_check_user($userId){
     477    $platformlyWcUserId = get_option('platformly_wc_cid');
     478    if($platformlyWcUserId && $platformlyWcUserId != $userId){
     479        return false;
     480    }
     481    return true;
     482}
  • platformly/trunk/js/ply_add_link_functions.js

    r2248759 r2293315  
    214214
    215215                // Check if no text selected
    216                 if (elementor !== 'undefined' && typeof window.tinymce !== 'undefined' && !tinymce.activeEditor.isHidden()) {
     216                if (typeof elementor !== 'undefined' && typeof window.tinymce !== 'undefined' && !tinymce.activeEditor.isHidden()) {
    217217                    var selectedText = tinymce.activeEditor.selection.getContent();
    218218                    if (selectedText.length === 0) {
  • platformly/trunk/js/settings.js

    r1998157 r2293315  
    55            alert('Please select project');
    66        }else{
    7             if(confirm('Changing the project code will remove the current code, continue?')){
     7            var confirmMsg = 'Changing the project code will remove the current code, continue?';
     8            if($('#plyProjectCodeBlock').hasClass('ply-wc-project-code')){
     9                confirmMsg = "If you change the project it will be also changed for your 'Platform.ly for WooCommerce' plugin, continue?";
     10            }
     11            if(confirm(confirmMsg)){
    812                $('#msgPlyGetProgectCodeError').hide();
    913                $('#msgPlyGetProgectCodeActivated').hide();
     
    3539        });
    3640    }); */
     41    /*var prevVal;
     42    $('#plyProjectSelect').focus(function(){
     43        prevVal = $(this).val();
     44    }).change(function(){
     45        if($('#plyProjectCodeBlock').hasClass('ply-wc-project-code')){
     46            $(this).blur();
     47            if(!confirm('Changing the project will change the current project in Platform.ly WooCommerce plugin')){
     48                $(this).val(prevVal);
     49                return false;
     50            }
     51        }
     52    });*/
    3753    $('#plyCheckboxSetProjectCode').change(function(){
    3854        if($(this).prop('checked')){
     
    4359            var includeProjectCode = 0;
    4460        }
    45         $.post(ajaxurl, {action: 'ply_project_code_include', includeCode: includeProjectCode}, function(response){});
     61        if(!$('#plyProjectCodeBlock').hasClass('ply-wc-project-code')){
     62            $.post(ajaxurl, {action: 'ply_project_code_include', includeCode: includeProjectCode}, function(response){});
     63        }
    4664    });
    4765    $('#plyRemoveProjectCode').click(function(){
    48         if(confirm('Are you sure you want to remove the project code?')){
    49             $.post(ajaxurl, {'action': 'ply_remove_project_code'}, function(response){
    50                 $('#msgPlyGetProgectCodeActivated').hide();
    51                 alert('Project code was removed.');
    52             });
     66        if(!$('#plyProjectCodeBlock').hasClass('ply-wc-project-code')) {
     67            if (confirm('Are you sure you want to remove the project code?')) {
     68                $.post(ajaxurl, {'action': 'ply_remove_project_code'}, function (response) {
     69                    $('#msgPlyGetProgectCodeActivated').hide();
     70                    alert('Project code was removed.');
     71                });
     72            }
    5373        }
    5474    });
  • platformly/trunk/platformly.php

    r2248759 r2293315  
    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.6.1
     6Version: 1.7
    77Author: Platform.ly
    88Author URI: https://www.platform.ly/
     
    2121
    2222    add_menu_page('Platform.ly', 'Platform.ly', 'manage_options', 'ply', 'ply_settings', plugins_url('img/logo.png', __FILE__));
    23     add_submenu_page('ply', 'Settings', 'Settings', 'manage_options', 'ply', 'ply_settings', '');
    24     add_submenu_page('ply', 'Events', 'Events', 'manage_options', 'ply_events', 'ply_events', '');
    25     add_submenu_page('ply', 'Pages', 'Pages', 'manage_options', 'ply_pages', 'ply_pages', '');
    26     add_submenu_page('ply', 'Optins', 'Optin Forms', 'manage_options', 'ply_optins', 'ply_optins_page', '');
     23    add_submenu_page('ply', 'Settings', 'Settings', 'manage_options', 'ply', 'ply_settings', null);
     24    add_submenu_page('ply', 'Events', 'Events', 'manage_options', 'ply_events', 'ply_events', null);
     25    add_submenu_page('ply', 'Pages', 'Pages', 'manage_options', 'ply_pages', 'ply_pages', null);
     26    add_submenu_page('ply', 'Optins', 'Optin Forms', 'manage_options', 'ply_optins', 'ply_optins_page', null);
    2727}
    2828
     
    3030
    3131add_action('rest_api_init', 'ply_init_rest_route');
     32
     33add_action('admin_init', 'platform_ly_admin_init');
     34
     35// Platform.ly for WooCommerce hooks
     36add_action('platformly_wc_project_changed', 'platformly_wc_project_changed', 10, 2);
    3237
    3338function ply_init_rest_route(){
     
    154159    ) {$charset_collate};";
    155160    dbDelta($sql);
    156    
     161
     162    if(platform_ly_check_ply_wc_plugin_is_activated() && get_option('ply_plugin_cid')){
     163        ply_remove_project_code();
     164    }
    157165}
    158166
     
    221229            $setProject = ply_set_project_code($projectId, $data['projectCode']);
    222230            if($setProject === true){
     231                do_action('platform_ly_project_changed', $projectId);
    223232                echo json_encode(array('status' => 'success', 'projectName' => wp_strip_all_tags($data['projectName'])));
    224233            }else{
     
    401410 * @return boolean
    402411 */
    403 function isEditInElementor() {
     412function platformLyIsEditInElementor() {
    404413    $path = parse_url($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], PHP_URL_PATH);
    405414    if (strpos($path, 'post.php') !== false && isset($_GET['action']) && $_GET['action'] === 'elementor') {
     
    410419}
    411420
    412 if (isEditInElementor()) {
     421if (platformLyisEditInElementor()) {
    413422    add_action('elementor/editor/before_enqueue_scripts', 'add_mce_platform_ly_link_to_elementor_editor');
    414423} else {
     
    422431        $projectCode = ply_get_project_code();
    423432        if(isset($projectCode['ply_project_code'])){
    424             echo $projectCode['ply_project_code'];
     433            echo wp_specialchars_decode($projectCode['ply_project_code'], ENT_QUOTES);
    425434        }
    426435    }
     
    431440add_action('wp_head', 'platform_ly_set_project_code');
    432441
    433 function ply_test_new_editor(){
     442function platform_ly_test_new_editor(){
    434443    wp_enqueue_script('ply-add-link-new', plugin_dir_url(__FILE__).'js/ply_editor_btn_functions.js', array('wp-blocks', 'wp-editor', 'wp-components', 'wp-i18n', 'wp-element', 'wp-rich-text', 'wp-format-library'));
    435444}
    436445
    437 add_action('enqueue_block_editor_assets', 'ply_test_new_editor');
     446add_action('enqueue_block_editor_assets', 'platform_ly_test_new_editor');
     447
     448function platform_ly_admin_init(){
     449    $plyProjectCode = ply_get_project_code();
     450    if(platform_ly_check_ply_wc_plugin_is_activated() && (empty($plyProjectCode) || empty(get_option('ply_project_code_active')))){
     451        $projectId = platform_ly_get_ply_wc_project_id();
     452        $projectCode = platform_ly_get_ply_wc_project_code();
     453        if($projectId && $projectCode){
     454            ply_set_project_code($projectId, $projectCode);
     455            ply_project_code_include(true);
     456            platfrom_ly_project_code_include_from_ply_wc(true);
     457        }else{
     458            platfrom_ly_project_code_include_from_ply_wc(false);
     459        }
     460    }else if(!platform_ly_check_ply_wc_plugin_is_activated() && platfrom_ly_get_ply_wc_project_code_active()){
     461        platfrom_ly_project_code_include_from_ply_wc(false);
     462    }
     463}
     464
     465function platformly_wc_project_changed($projectId, $projectCode){
     466    if(get_option('ply_plugin_cid')){
     467        ply_set_project_code($projectId, $projectCode);
     468    }
     469}
  • platformly/trunk/readme.txt

    r2248759 r2293315  
    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.3
     5Tested up to: 5.4
    66Requires PHP: 5.5.9
    77Stable tag: trunk
     
    7878== Upgrade Notice ==
    7979
     80= 1.7 =
     81- Integration with 'Platform.ly for WooCommerce' plugin
     82
     83
    8084= 1.6.1 =
    8185- Integration with Elementor plugin
Note: See TracChangeset for help on using the changeset viewer.