Plugin Directory

Changeset 2576583


Ignore:
Timestamp:
08/02/2021 03:33:10 PM (5 years ago)
Author:
custom4web
Message:

Fix uninstall plugin

Location:
growanizer/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • growanizer/trunk/growanizer.php

    r2574491 r2576583  
    44 * Plugin Name: Growanizer
    55 * Description: The new generation of smart sales for WooCommerce.
    6  * Version: 1.0.0
     6 * Version: 1.0.1
    77 * Author: Custom4Web
    88 * Author URI: https://www.custom4web.com/
     
    3838        const ADMIN_PATH   = 'admin';
    3939        const MODULES_PATH   = 'modules';
    40         const VERSION      = '1.0.0';
     40        const VERSION      = '1.0.1';
    4141        const PREFIX       = 'growanizer_';
    4242
     
    271271            $ba_ajax = false;
    272272            $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' ) {
    274274                $ba_ajax = true;
    275275            }
    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' ) {
    277277                $pf_ajax = true;
    278278            }
  • growanizer/trunk/readme.txt

    r2574534 r2576583  
    66Tested up to: 5.8.0
    77Requires PHP: 7.0
    8 Stable tag: 1.0.0
     8Stable tag: 1.0.1
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    6060
    61611.0.0 Initial release
     62
     631.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  
    11<?php
    22
    3 defined( 'ABSPATH' ) || exit;
     3defined('ABSPATH') || exit;
    44
    5 class Growanizer_Autoloader {
     5class Growanizer_Autoloader
     6{
    67
    78    private $dirs = array();
    89    protected $plugin_path;
    910
    10     public function __construct( $plugin_path ) {
     11    public function __construct($plugin_path)
     12    {
    1113        $this->plugin_path = $plugin_path;
    1214    }
    1315
    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);
    3837                                    }
    3938                                }
     
    4241                    }
    4342                }
    44 
    4543            } 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);
    4846            }
    4947        }
    5048    }
    5149
    52     protected function get_class_filename( $class ) {
    53         $class = strtolower( $class );
     50    protected function get_class_filename($class)
     51    {
     52        $class = strtolower($class);
    5453
    55         return 'class-' . str_replace( '_', '-', $class ) . '.php';
     54        return 'class-' . str_replace('_', '-', $class) . '.php';
    5655    }
    5756
    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)) {
    6060            include $path;
    6161        }
    6262    }
    6363
    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'));
    6768    }
    6869
    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);
    7274        }
    7375    }
    74 
    7576}
  • growanizer/trunk/uninstall.php

    r2574491 r2576583  
    55 */
    66
    7 if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     7if (!defined('WP_UNINSTALL_PLUGIN')) {
    88    exit;
    99}
    1010
    11 if ( !current_user_can( 'activate_plugins' ) ) {
     11if (!current_user_can('activate_plugins')) {
    1212    exit;
    1313}
    1414
    15 include_once dirname( __FILE__ ) . '/growanizer.php';
     15if (!file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'growanizer-pro' . DIRECTORY_SEPARATOR . 'growanizer-pro.php')) {
    1616
    17 $modules = scandir( WC_Growanizer()->get_path() . '/' . WC_Growanizer::MODULES_PATH );
     17    include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'growanizer.php';
    1818
    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                }
    3035            }
    3136        }
    3237    }
     38
     39    delete_option(Growanizer_Menu_Page::OPTIONS_NAME);
     40    delete_option('growanizer_hooks');
    3341}
    34 
    35 delete_option( Growanizer_Menu_Page::OPTIONS_NAME );
    36 delete_option( 'growanizer_hooks' );
Note: See TracChangeset for help on using the changeset viewer.