Changeset 1872868
- Timestamp:
- 05/11/2018 07:24:47 PM (8 years ago)
- Location:
- leadbi/trunk
- Files:
-
- 2 added
- 7 edited
-
admin/Admin.php (modified) (3 diffs)
-
admin/js/leadbi-options.js (modified) (4 diffs)
-
admin/partials/view.php (modified) (1 diff)
-
frontend/Frontend.php (modified) (2 diffs)
-
frontend/WooCommerce.php (added)
-
frontend/WooCommerceIntegration.php (added)
-
includes/Info.php (modified) (1 diff)
-
includes/Plugin.php (modified) (1 diff)
-
leadbi.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
leadbi/trunk/admin/Admin.php
r1736960 r1872868 23 23 * Implement the init hook 24 24 */ 25 public function init(){25 public function init(){ 26 26 // Empty for now 27 27 } … … 62 62 63 63 /** 64 * Check if wooCommerce is installed and active 65 */ 66 private function isWooCommerceActive(){ 67 return Info::isWooCommerceActive(); 68 } 69 70 /** 64 71 * Render the view using MVC pattern. 65 72 */ … … 94 101 } 95 102 96 if(!isset($_REQUEST['connected']) || !isset($_REQUEST['websiteId']) || !isset($_REQUEST['websiteDomain'])){ 97 echo "Unexpected input!"; 98 die(); 103 $newOptions = []; 104 105 if(isset($_REQUEST['connected'])){ 106 $newOptions['connected'] = $_REQUEST['connected']; 99 107 } 100 108 101 $connected = isset($_REQUEST['connected']) ? $_REQUEST['connected'] : null; 102 $websiteId = isset($_REQUEST['websiteId']) ? $_REQUEST['websiteId'] : null; 103 $websiteDomain = isset($_REQUEST['websiteDomain']) ? $_REQUEST['websiteDomain']: null; 109 if(isset($_REQUEST['websiteId'])){ 110 $newOptions['websiteId'] = $_REQUEST['websiteId']; 111 } 112 113 if(isset($_REQUEST['websiteDomain'])){ 114 $newOptions['websiteDomain'] = $_REQUEST['websiteDomain']; 115 } 116 117 if(isset($_REQUEST['wooCommerceEnabled'])){ 118 $newOptions['wooCommerceEnabled'] = $_REQUEST['wooCommerceEnabled']; 119 } 104 120 105 121 $option_name = Info::OPTION_NAME; 106 107 $newOptions = [108 'connected' => $connected,109 'websiteId' => $websiteId,110 'websiteDomain' => $websiteDomain,111 ];112 122 113 123 $options = get_option($option_name); -
leadbi/trunk/admin/js/leadbi-options.js
r1736960 r1872868 41 41 websiteId: data.websiteId, 42 42 websiteDomain: data.websiteDomain, 43 wooCommerceEnabled: null, 43 44 nonce: nonce 44 45 }, … … 56 57 // disconnect button 57 58 jQuery(document).on('click', '#leadbi-disconnect', function () { 58 console.log(1);59 59 return jQuery.ajax({ 60 60 type: "post", … … 66 66 websiteId: null, 67 67 websiteDomain: null, 68 wooCommerceEnabled: null, 68 69 nonce: nonce 69 70 }, … … 78 79 }); 79 80 81 /** 82 * Handle enable woocommerce integration 83 */ 84 jQuery(document).on('click', '#leadbi-disable-woocommerce', function () { 85 return jQuery.ajax({ 86 type: "post", 87 dataType: "json", 88 url: leadbiAjaxUpdate.ajaxurl, 89 data: { 90 action: "leadbi_update_options", 91 wooCommerceEnabled: 0, 92 nonce: nonce 93 }, 94 success: function (response) { 95 if (response.type == "success") { 96 window.location.reload(); 97 } else { 98 alert("Failed to disable woocommerce") 99 } 100 }, 101 error: function () { 102 alert("Failed to disable woocommerce") 103 } 104 }); 105 }); 106 107 /** 108 * Handle disable woocommerce integration 109 */ 110 jQuery(document).on('click', '#leadbi-enable-woocommerce', function () { 111 return jQuery.ajax({ 112 type: "post", 113 dataType: "json", 114 url: leadbiAjaxUpdate.ajaxurl, 115 data: { 116 action: "leadbi_update_options", 117 wooCommerceEnabled: 1, 118 nonce: nonce 119 }, 120 success: function (response) { 121 if (response.type == "success") { 122 window.location.reload(); 123 } else { 124 alert("Failed to enable woocommerce") 125 } 126 }, 127 error: function () { 128 alert("Failed to enable woocommerce") 129 } 130 }); 131 }); 132 80 133 }); -
leadbi/trunk/admin/partials/view.php
r1736960 r1872868 4 4 <div> 5 5 <h1 class="wp-heading-inline">LeadBI for WordPress (<?php echo $settings['websiteDomain'] ?>)</h1> 6 <button class="button button-primary" style="float: right;margin-top: 10px" id="leadbi-disconnect" type="button">Disconnect</button> 6 <button class="button button-primary" style="float: right;margin-top: 10px; margin-left: 10px;" id="leadbi-disconnect" type="button">Disconnect</button> 7 8 <?php if($this->isWooCommerceActive()) : ?> 9 <?php if(isset($settings['wooCommerceEnabled']) && $settings['wooCommerceEnabled']) : ?> 10 <button class="button button-primary" style="float: right;margin-top: 10px" id="leadbi-disable-woocommerce" type="button">Disable WooCommerce</button> 11 <?php else: ?> 12 <button class="button button-primary" style="float: right;margin-top: 10px" id="leadbi-enable-woocommerce" type="button">Enable WooCommerce</button> 13 <?php endif; ?> 14 <?php endif; ?> 7 15 </div> 8 16 -
leadbi/trunk/frontend/Frontend.php
r1736960 r1872868 15 15 $this->settings = get_option($this->option_name); 16 16 $this->settings_group = $this->option_name.'_group'; 17 $this->wooCommerce = null; 17 18 } 18 19 … … 21 22 } 22 23 24 /** 25 * Load frontend integrations 26 */ 27 public function pluginLoaded(){ 28 $settings = $this->settings; 29 if(Info::isWooCommerceActive() && $settings['wooCommerceEnabled']){ 30 include_once 'WooCommerceIntegration.php'; 31 $this->wooCommerce = WooCommerceIntegration::getInstance(); 32 $this->wooCommerce->init(); 33 } 34 } 23 35 /** 24 36 * Render the view using MVC pattern. -
leadbi/trunk/includes/Info.php
r1736960 r1872868 32 32 */ 33 33 const LEADBI_ENDPOINT = 'https://app.leadbi.com'; 34 35 36 /** 37 * Check if wooCommerce is installed and active 38 */ 39 public static function isWooCommerceActive(){ 40 if(class_exists('WC_Integration') && defined('WOOCOMMERCE_VERSION') && version_compare(WOOCOMMERCE_VERSION, '3.0.0', '>=') ) { 41 return true; 42 } 43 44 return false; 45 } 34 46 } -
leadbi/trunk/includes/Plugin.php
r1828900 r1872868 50 50 $this->loader->add_action('wp_enqueue_scripts', $frontend, 'assets'); 51 51 $this->loader->add_action('wp_footer', $frontend, 'render'); 52 $this->loader->add_action('plugins_loaded', $frontend, 'pluginLoaded'); 52 53 53 54 add_shortcode('leadbi_form', array($this, 'leadbiForm')); -
leadbi/trunk/leadbi.php
r1828900 r1872868 8 8 * Plugin URI: https://www.leadbi.com/features/ 9 9 * Description: LeadBI's WordPress plugin allows existing LeadBI customers and trial users to install the LeadBI tracking code on their existing WordPress blogs and websites and view the dashboard. 10 * Version: 1. 110 * Version: 1.2 11 11 * Author: LeadBI 12 12 * Author URI: https://www.leadbi.com/
Note: See TracChangeset
for help on using the changeset viewer.