Changeset 2293315
- Timestamp:
- 04/28/2020 09:24:36 AM (6 years ago)
- Location:
- platformly/trunk
- Files:
-
- 7 edited
-
inc/pages/ply.settings.php (modified) (5 diffs)
-
inc/ply.btn.php (modified) (2 diffs)
-
inc/ply.functions.php (modified) (3 diffs)
-
js/ply_add_link_functions.js (modified) (1 diff)
-
js/settings.js (modified) (3 diffs)
-
platformly.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
platformly/trunk/inc/pages/ply.settings.php
r1998157 r2293315 12 12 $pkey = ply_get_plugin_key(); 13 13 $access = 1; 14 $projectCodeBlockClass = ''; 14 15 include plugin_dir_path(__FILE__) . 'input.php'; 15 16 $projectCode = array(); 16 17 $projectCodeInclude = 0; 18 $projectCodeSetInPlyWoocommerce = platfrom_ly_get_ply_wc_project_code_active(); 19 $plyWcPluginIsActive = platform_ly_check_ply_wc_plugin_is_activated(); 20 $disabled = ''; 17 21 if(!empty($user) && $user['status'] == 'active'){ 18 22 $get_projects = wp_remote_get( PLATFORMLY_URL . "/plugin/plugin.actions.php?plugin_key=".ply_get_plugin_key()."&action=listProjects" ); … … 21 25 $projectCodeInclude = get_option('ply_project_code_active'); 22 26 $projectCode = ply_get_project_code(); 27 if($plyWcPluginIsActive){ 28 $projectCodeBlockClass = 'ply-wc-project-code'; 29 $disabled = 'disabled'; 30 } 23 31 } 24 32 ?> … … 52 60 echo "<div class='ply_errorMsg' style='margin-top:1%'>The plugin key you added is not correct.</div>"; 53 61 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)){ 55 66 wp_die(); 56 67 } … … 88 99 </table> 89 100 <br/> 90 <div id="plyProjectCodeBlock" >101 <div id="plyProjectCodeBlock" class="<?php echo $projectCodeBlockClass ?>"> 91 102 <h2 style="margin-bottom: 5px;">Add a Project Code</h2> 92 103 <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' : '' ?>/> 94 105 <label for="plyCheckboxSetProjectCode">Click here to include a Platform.ly project code within your blog</label> 95 106 </div> … … 104 115 <div id="msgPlyGetProgectCodeError"></div> 105 116 <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> 107 120 </div> 108 121 </div> -
platformly/trunk/inc/ply.btn.php
r2248759 r2293315 17 17 var plyProjectId = 0; 18 18 <?php endif; ?> 19 var editInElementor = <?php echo isEditInElementor() ? 'true' : 'false'; ?>;19 var editInElementor = <?php echo platformLyisEditInElementor() ? 'true' : 'false'; ?>; 20 20 var siteUrl = '<?php echo home_url(); ?>'; 21 21 … … 269 269 }); 270 270 271 <?php if ( isEditInElementor()): ?>271 <?php if (platformLyisEditInElementor()): ?> 272 272 elementor.hooks.addAction( 'panel/open_editor/widget/text-editor', function( panel, model, view ) { 273 273 setTimeout(function() { -
platformly/trunk/inc/ply.functions.php
r2208564 r2293315 14 14 $block = true; 15 15 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{ 17 21 $ply_plugin_cid = get_option('ply_plugin_cid'); 18 22 if($ply_plugin_cid != $check['id']){ … … 394 398 global $wpdb; 395 399 $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; 410 417 } 411 418 … … 436 443 } 437 444 } 445 446 function platform_ly_check_ply_wc_plugin_is_activated(){ 447 return is_plugin_active('platformly-for-woocommerce/platformly-for-woocommerce.php'); 448 } 449 450 function 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 456 function 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 462 function 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 470 function 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 476 function 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 214 214 215 215 // 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()) { 217 217 var selectedText = tinymce.activeEditor.selection.getContent(); 218 218 if (selectedText.length === 0) { -
platformly/trunk/js/settings.js
r1998157 r2293315 5 5 alert('Please select project'); 6 6 }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)){ 8 12 $('#msgPlyGetProgectCodeError').hide(); 9 13 $('#msgPlyGetProgectCodeActivated').hide(); … … 35 39 }); 36 40 }); */ 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 });*/ 37 53 $('#plyCheckboxSetProjectCode').change(function(){ 38 54 if($(this).prop('checked')){ … … 43 59 var includeProjectCode = 0; 44 60 } 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 } 46 64 }); 47 65 $('#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 } 53 73 } 54 74 }); -
platformly/trunk/platformly.php
r2248759 r2293315 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. 6.16 Version: 1.7 7 7 Author: Platform.ly 8 8 Author URI: https://www.platform.ly/ … … 21 21 22 22 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); 27 27 } 28 28 … … 30 30 31 31 add_action('rest_api_init', 'ply_init_rest_route'); 32 33 add_action('admin_init', 'platform_ly_admin_init'); 34 35 // Platform.ly for WooCommerce hooks 36 add_action('platformly_wc_project_changed', 'platformly_wc_project_changed', 10, 2); 32 37 33 38 function ply_init_rest_route(){ … … 154 159 ) {$charset_collate};"; 155 160 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 } 157 165 } 158 166 … … 221 229 $setProject = ply_set_project_code($projectId, $data['projectCode']); 222 230 if($setProject === true){ 231 do_action('platform_ly_project_changed', $projectId); 223 232 echo json_encode(array('status' => 'success', 'projectName' => wp_strip_all_tags($data['projectName']))); 224 233 }else{ … … 401 410 * @return boolean 402 411 */ 403 function isEditInElementor() {412 function platformLyIsEditInElementor() { 404 413 $path = parse_url($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], PHP_URL_PATH); 405 414 if (strpos($path, 'post.php') !== false && isset($_GET['action']) && $_GET['action'] === 'elementor') { … … 410 419 } 411 420 412 if ( isEditInElementor()) {421 if (platformLyisEditInElementor()) { 413 422 add_action('elementor/editor/before_enqueue_scripts', 'add_mce_platform_ly_link_to_elementor_editor'); 414 423 } else { … … 422 431 $projectCode = ply_get_project_code(); 423 432 if(isset($projectCode['ply_project_code'])){ 424 echo $projectCode['ply_project_code'];433 echo wp_specialchars_decode($projectCode['ply_project_code'], ENT_QUOTES); 425 434 } 426 435 } … … 431 440 add_action('wp_head', 'platform_ly_set_project_code'); 432 441 433 function pl y_test_new_editor(){442 function platform_ly_test_new_editor(){ 434 443 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')); 435 444 } 436 445 437 add_action('enqueue_block_editor_assets', 'ply_test_new_editor'); 446 add_action('enqueue_block_editor_assets', 'platform_ly_test_new_editor'); 447 448 function 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 465 function 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 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. 35 Tested up to: 5.4 6 6 Requires PHP: 5.5.9 7 7 Stable tag: trunk … … 78 78 == Upgrade Notice == 79 79 80 = 1.7 = 81 - Integration with 'Platform.ly for WooCommerce' plugin 82 83 80 84 = 1.6.1 = 81 85 - Integration with Elementor plugin
Note: See TracChangeset
for help on using the changeset viewer.