Changeset 2576583
- Timestamp:
- 08/02/2021 03:33:10 PM (5 years ago)
- Location:
- growanizer/trunk
- Files:
-
- 4 edited
-
growanizer.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
src/class-growanizer-autoloader.php (modified) (2 diffs)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
growanizer/trunk/growanizer.php
r2574491 r2576583 4 4 * Plugin Name: Growanizer 5 5 * Description: The new generation of smart sales for WooCommerce. 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Custom4Web 8 8 * Author URI: https://www.custom4web.com/ … … 38 38 const ADMIN_PATH = 'admin'; 39 39 const MODULES_PATH = 'modules'; 40 const VERSION = '1.0. 0';40 const VERSION = '1.0.1'; 41 41 const PREFIX = 'growanizer_'; 42 42 … … 271 271 $ba_ajax = false; 272 272 $pf_ajax = false; 273 if( $pagenow == 'edit.php' && sanitize_text_field($_GET['post_type']) == 'growba_rules' ) {273 if( $pagenow == 'edit.php' && ! empty( $_GET['post_type'] ) && sanitize_text_field($_GET['post_type']) == 'growba_rules' ) { 274 274 $ba_ajax = true; 275 275 } 276 if( $pagenow == 'edit.php' && sanitize_text_field($_GET['post_type']) == 'growpf_rules' ) {276 if( $pagenow == 'edit.php' && ! empty( $_GET['post_type'] ) && sanitize_text_field($_GET['post_type']) == 'growpf_rules' ) { 277 277 $pf_ajax = true; 278 278 } -
growanizer/trunk/readme.txt
r2574534 r2576583 6 6 Tested up to: 5.8.0 7 7 Requires PHP: 7.0 8 Stable tag: 1.0. 08 Stable tag: 1.0.1 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 60 60 61 61 1.0.0 Initial release 62 63 1.0.1 Added compatibility with the Pro version of the plugin when uninstalling one of the plugins. -
growanizer/trunk/src/class-growanizer-autoloader.php
r2574491 r2576583 1 1 <?php 2 2 3 defined( 'ABSPATH') || exit;3 defined('ABSPATH') || exit; 4 4 5 class Growanizer_Autoloader { 5 class Growanizer_Autoloader 6 { 6 7 7 8 private $dirs = array(); 8 9 protected $plugin_path; 9 10 10 public function __construct( $plugin_path ) { 11 public function __construct($plugin_path) 12 { 11 13 $this->plugin_path = $plugin_path; 12 14 } 13 15 14 public function load( $class ) { 15 foreach ( $this->dirs as $dir ) { 16 if( $dir === 'modules' ) { 17 18 $path = $this->plugin_path . '/'. $dir . '/' . $this->get_class_filename( $class ); 19 if ( file_exists( $path ) ) { 20 $this->get_class_path( $class, $path ); 21 } else { 22 $cdir = scandir( $this->plugin_path . '/'. $dir ); 23 foreach ($cdir as $key => $module) 24 { 25 if (!in_array($module,array(".",".."))) 26 { 27 $path = $this->plugin_path . '/'. $dir . '/' . $module . '/' . $this->get_class_filename( $class ); 28 if ( file_exists( $path ) ) { 29 $this->get_class_path( $class, $path ); 30 } else { 31 $cdir2 = scandir( $this->plugin_path . '/'. $dir . '/' . $module ); 32 foreach ($cdir2 as $key2 => $modulePart) 33 { 34 if ( !in_array($modulePart,array(".","..")) && ( $modulePart === 'includes' || $modulePart === 'admin' ) ) 35 { 36 $path = $this->plugin_path . '/'. $dir . '/' . $module . '/' . $modulePart . '/' . $this->get_class_filename( $class ); 37 $this->get_class_path( $class, $path ); 16 public function load($class) 17 { 18 foreach ($this->dirs as $dir) { 19 if ($dir === 'modules') { 20 21 $path = $this->plugin_path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $this->get_class_filename($class); 22 if (file_exists($path)) { 23 $this->get_class_path($class, $path); 24 } elseif (file_exists($this->plugin_path . DIRECTORY_SEPARATOR . $dir)) { 25 $cdir = scandir($this->plugin_path . DIRECTORY_SEPARATOR . $dir); 26 foreach ($cdir as $key => $module) { 27 if (!in_array($module, array(".", ".."))) { 28 $path = $this->plugin_path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . $this->get_class_filename($class); 29 if (file_exists($path)) { 30 $this->get_class_path($class, $path); 31 } elseif (file_exists($this->plugin_path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $module)) { 32 $cdir2 = scandir($this->plugin_path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $module); 33 foreach ($cdir2 as $key2 => $modulePart) { 34 if (!in_array($modulePart, array(".", "..")) && ($modulePart === 'includes' || $modulePart === 'admin')) { 35 $path = $this->plugin_path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . $modulePart . DIRECTORY_SEPARATOR . $this->get_class_filename($class); 36 $this->get_class_path($class, $path); 38 37 } 39 38 } … … 42 41 } 43 42 } 44 45 43 } else { 46 $path = $this->plugin_path . '/'. $dir . '/' . $this->get_class_filename( $class);47 $this->get_class_path( $class, $path);44 $path = $this->plugin_path . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $this->get_class_filename($class); 45 $this->get_class_path($class, $path); 48 46 } 49 47 } 50 48 } 51 49 52 protected function get_class_filename( $class ) { 53 $class = strtolower( $class ); 50 protected function get_class_filename($class) 51 { 52 $class = strtolower($class); 54 53 55 return 'class-' . str_replace( '_', '-', $class) . '.php';54 return 'class-' . str_replace('_', '-', $class) . '.php'; 56 55 } 57 56 58 protected function get_class_path( $class, $path ) { 59 if ( file_exists( $path ) ) { 57 protected function get_class_path($class, $path) 58 { 59 if (file_exists($path)) { 60 60 include $path; 61 61 } 62 62 } 63 63 64 public function autoload( $dir ) { 65 $this->add_dir( $dir ); 66 spl_autoload_register( array( $this, 'load' ) ); 64 public function autoload($dir) 65 { 66 $this->add_dir($dir); 67 spl_autoload_register(array($this, 'load')); 67 68 } 68 69 69 protected function add_dir( $dir ) { 70 if( ! in_array( $dir, $this->dirs ) ) { 71 array_push( $this->dirs, $dir ); 70 protected function add_dir($dir) 71 { 72 if (!in_array($dir, $this->dirs)) { 73 array_push($this->dirs, $dir); 72 74 } 73 75 } 74 75 76 } -
growanizer/trunk/uninstall.php
r2574491 r2576583 5 5 */ 6 6 7 if ( !defined( 'WP_UNINSTALL_PLUGIN' )) {7 if (!defined('WP_UNINSTALL_PLUGIN')) { 8 8 exit; 9 9 } 10 10 11 if ( !current_user_can( 'activate_plugins' )) {11 if (!current_user_can('activate_plugins')) { 12 12 exit; 13 13 } 14 14 15 i nclude_once dirname( __FILE__ ) . '/growanizer.php';15 if (!file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'growanizer-pro' . DIRECTORY_SEPARATOR . 'growanizer-pro.php')) { 16 16 17 $modules = scandir( WC_Growanizer()->get_path() . '/' . WC_Growanizer::MODULES_PATH );17 include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'growanizer.php'; 18 18 19 foreach( $modules as $module_name ) { 20 if( $module_name !== '.' && $module_name !== '..' ) { 21 $module_main_file_path = WC_Growanizer()->get_path() . '/' . WC_Growanizer::MODULES_PATH . '/' . $module_name . '/' . 'class-' . str_replace( '_', '-', $module_name ) . '.php'; 22 if( file_exists( $module_main_file_path ) ) { 23 $module_name_parts = explode( '-', $module_name ); 24 array_map( function ( $item ) { 25 return ucfirst( $item ); 26 }, $module_name_parts ); 27 $class_name = implode( '_', $module_name_parts ); 28 if( class_exists( $class_name ) && method_exists($class_name, "uninstall") ) { 29 $class_name::uninstall(); 19 if (file_exists(WC_Growanizer()->get_path() . DIRECTORY_SEPARATOR . WC_Growanizer::MODULES_PATH)) { 20 $modules = scandir(WC_Growanizer()->get_path() . DIRECTORY_SEPARATOR . WC_Growanizer::MODULES_PATH); 21 22 foreach ($modules as $module_name) { 23 if ($module_name !== '.' && $module_name !== '..') { 24 $module_main_file_path = WC_Growanizer()->get_path() . DIRECTORY_SEPARATOR . WC_Growanizer::MODULES_PATH . DIRECTORY_SEPARATOR . $module_name . DIRECTORY_SEPARATOR . 'class-' . str_replace('_', '-', $module_name) . '.php'; 25 if (file_exists($module_main_file_path)) { 26 $module_name_parts = explode('-', $module_name); 27 array_map(function ($item) { 28 return ucfirst($item); 29 }, $module_name_parts); 30 $class_name = implode('_', $module_name_parts); 31 if (class_exists($class_name) && method_exists($class_name, "uninstall")) { 32 $class_name::uninstall(); 33 } 34 } 30 35 } 31 36 } 32 37 } 38 39 delete_option(Growanizer_Menu_Page::OPTIONS_NAME); 40 delete_option('growanizer_hooks'); 33 41 } 34 35 delete_option( Growanizer_Menu_Page::OPTIONS_NAME );36 delete_option( 'growanizer_hooks' );
Note: See TracChangeset
for help on using the changeset viewer.