Plugin Directory

Changeset 3323793


Ignore:
Timestamp:
07/07/2025 04:42:59 PM (9 months ago)
Author:
wpmethods
Message:

Release version 3.0.0 with fixes

Location:
order-list-table-elementor-widget
Files:
11 added
4 edited

Legend:

Unmodified
Added
Removed
  • order-list-table-elementor-widget/trunk/date-ago-function.php

    r3205036 r3323793  
    11<?php
    2 
     2if ( ! defined( 'ABSPATH' ) ) {
     3    exit; // Exit if accessed directly
     4}
    35//Convert PHP Date to Ago time format like facebook
    46if (get_option( 'timezone_string' )) {
  • order-list-table-elementor-widget/trunk/order-list-table-elementor-widget.php

    r3323680 r3323793  
    44 * Description: Order List Table use for to show Woocommerce recent order list on a table, just use this Elementor Widget/Addon.
    55 * Plugin URI:  https://wpmethods.com/order-list-table-elementor-widget
    6  * Version:     2.0.2
     6 * Version:     3.0.0
    77 * Author:      WP Methods
    88 * Author URI:  https://wpmethods.com/
     
    1010 * License:     GPL v2 or later
    1111 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    12  * Elementor tested up to: 3.29.2
    13  * Elementor Pro tested up to: 3.29.2
     12 * Requires PHP: 7.4
     13 * Requires at least: 5.9
     14 * Tested up to: 6.9
     15 * Requires Plugins: elementor, woocommerce
     16 * Elementor tested up to: 3.30.1
     17 * Elementor Pro tested up to: 3.30.0
    1418 */
    1519
  • order-list-table-elementor-widget/trunk/readme.txt

    r3323680 r3323793  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 2.0.2
     7Stable tag: 3.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • order-list-table-elementor-widget/trunk/widgets-loader.php

    r3323680 r3323793  
    1 <?php 
     1<?php
    22namespace OltewOrderListTableEle;
    33
     
    66}
    77
    8 /**
    9  * Plugin class.
    10  *
    11  * The main class that initiates and runs the addon.
    12  *
    13  * @since 2.0.0
    14  */
    158final class Plugin {
    169
    17     /**
    18      * Addon Version
    19      *
    20      * @since 2.0.0
    21      * @var string The addon version.
    22      */
    23     const VERSION = '2.0.1';
    24 
    25     /**
    26      * Minimum Elementor Version
    27      *
    28      * @since 2.0.0
    29      * @var string Minimum Elementor version required to run the addon.
    30      */
     10    const VERSION = '3.0.0';
    3111    const MINIMUM_ELEMENTOR_VERSION = '3.7.0';
    32 
    33     /**
    34      * Minimum PHP Version
    35      *
    36      * @since 2.0.0
    37      * @var string Minimum PHP version required to run the addon.
    38      */
    3912    const MINIMUM_PHP_VERSION = '7.4';
    4013
    41     /**
    42      * Instance
    43      *
    44      * @since 2.0.0
    45      * @access private
    46      * @static
    47      * @var \OltewOrderListTableEle\Plugin The single instance of the class.
    48      */
    4914    private static $_instance = null;
    5015
    51     /**
    52      * Instance
    53      *
    54      * Ensures only one instance of the class is loaded or can be loaded.
    55      *
    56      * @since 2.0.0
    57      * @access public
    58      * @static
    59      * @return \OltewOrderListTableEle\Plugin An instance of the class.
    60      */
    6116    public static function instance() {
    62 
    6317        if ( is_null( self::$_instance ) ) {
    6418            self::$_instance = new self();
    6519        }
    6620        return self::$_instance;
    67 
    6821    }
    6922
    70     /**
    71      * Constructor
    72      *
    73      * Perform some compatibility checks to make sure basic requirements are meet.
    74      * If all compatibility checks pass, initialize the functionality.
    75      *
    76      * @since 2.0.0
    77      * @access public
    78      */
    7923    public function __construct() {
     24        // Fallback only for older WordPress versions without plugin dependencies
     25        if ( ! function_exists( 'wp_get_active_and_valid_plugins' ) ) {
     26            add_action( 'admin_init', [ $this, 'maybe_deactivate' ] );
     27            return;
     28        }
    8029
     30        // If compatible, hook into Elementor init
    8131        if ( $this->is_compatible() ) {
    8232            add_action( 'elementor/init', [ $this, 'init' ] );
    8333        }
    84 
    8534    }
    8635
    87     /**
    88      * Compatibility Checks
    89      *
    90      * Checks whether the site meets the addon requirement.
    91      *
    92      * @since 2.0.0
    93      * @access public
    94      */
    95     public function is_compatible() {
     36    private function is_compatible() {
    9637
    97         // Check if Elementor installed and activated
    9838        if ( ! did_action( 'elementor/loaded' ) ) {
    99             add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
     39            add_action( 'admin_notices', [ $this, 'notice_missing_elementor' ] );
    10040            return false;
    10141        }
    10242
    103         // Check if WooCommerce installed and activated
    104         if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    105             add_action( 'admin_notices',[$this, 'admin_notice_missing_woo_plugin'] );
    106             return false;
    107         }
    108        
    109         // Check for required Elementor version
    110         if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
    111             add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
     43        if ( ! class_exists( 'WooCommerce' ) ) {
     44            add_action( 'admin_notices', [ $this, 'notice_missing_woocommerce' ] );
    11245            return false;
    11346        }
    11447
    115         // Check for required PHP version
     48        if ( version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '<' ) ) {
     49            add_action( 'admin_notices', [ $this, 'notice_minimum_elementor' ] );
     50            return false;
     51        }
     52
    11653        if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
    117             add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
     54            add_action( 'admin_notices', [ $this, 'notice_minimum_php' ] );
    11855            return false;
    11956        }
    12057
    12158        return true;
    122 
    12359    }
    12460
    125    
     61    // ❌ Fallback: Deactivate if dependencies not met (for old WP versions)
     62    public function maybe_deactivate() {
     63        if ( ! is_admin() || ! current_user_can( 'activate_plugins' ) ) {
     64            return;
     65        }
    12666
    127     /**
    128      * Admin notice
    129      *
    130      * Warning when the site doesn't have Elementor installed or activated.
    131      *
    132      * @since 2.0.0
    133      * @access public
    134      */
    135     public function admin_notice_missing_main_plugin() {
     67        $deactivate = false;
     68
     69        if ( ! class_exists( 'WooCommerce' ) || ! did_action( 'elementor/loaded' ) ) {
     70            $deactivate = true;
     71        }
     72
     73        if ( $deactivate ) {
     74            deactivate_plugins( plugin_basename( __FILE__ ) );
     75            add_action( 'admin_notices', [ $this, 'notice_dependency_missing_deactivated' ] );
     76        }
     77    }
     78
     79    public function init() {
     80        add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] );
     81    }
     82
     83    public function register_widgets( $widgets_manager ) {
     84        require_once __DIR__ . '/order-list-table-register.php';
     85        $widgets_manager->register( new \Oltew_Order_List_table_Ele_Widget() );
     86    }
     87
     88    // Admin Notices
     89
     90    public function notice_missing_elementor() {
     91        $this->print_notice(
     92            sprintf(
     93                esc_html__( '"%1$s" requires %2$s to be installed and activated.', 'order-list-table-elementor-widget' ),
     94                '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
     95                '<strong>' . esc_html__( 'Elementor', 'order-list-table-elementor-widget' ) . '</strong>'
     96            )
     97        );
     98    }
     99
     100    public function notice_missing_woocommerce() {
     101        $this->print_notice(
     102            sprintf(
     103                esc_html__( '"%1$s" requires %2$s to be installed and activated.', 'order-list-table-elementor-widget' ),
     104                '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
     105                '<strong>' . esc_html__( 'WooCommerce', 'order-list-table-elementor-widget' ) . '</strong>'
     106            )
     107        );
     108    }
     109
     110    public function notice_minimum_elementor() {
     111        $this->print_notice(
     112            sprintf(
     113                esc_html__( '"%1$s" requires %2$s version %3$s or greater.', 'order-list-table-elementor-widget' ),
     114                '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
     115                '<strong>' . esc_html__( 'Elementor', 'order-list-table-elementor-widget' ) . '</strong>',
     116                self::MINIMUM_ELEMENTOR_VERSION
     117            )
     118        );
     119    }
     120
     121    public function notice_minimum_php() {
     122        $this->print_notice(
     123            sprintf(
     124                esc_html__( '"%1$s" requires %2$s version %3$s or greater.', 'order-list-table-elementor-widget' ),
     125                '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
     126                '<strong>' . esc_html__( 'PHP', 'order-list-table-elementor-widget' ) . '</strong>',
     127                self::MINIMUM_PHP_VERSION
     128            )
     129        );
     130    }
     131
     132    public function notice_dependency_missing_deactivated() {
     133        $this->print_notice(
     134            esc_html__( 'Plugin deactivated because required dependencies are missing.', 'order-list-table-elementor-widget' )
     135        );
     136    }
     137
     138    private function print_notice( $message ) {
    136139        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    137140        if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
    138         $message = sprintf(
    139             /* translators: 2: Plugin name 2: Elementor */
    140             esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'order-list-table-elementor-widget' ),
    141             '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
    142             '<strong>' . esc_html__( 'Elementor', 'order-list-table-elementor-widget' ) . '</strong>'
    143         );
    144141
    145142        printf(
    146143            '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>',
    147             esc_html( $message )
     144            wp_kses_post( $message )
    148145        );
    149 
    150 
    151146    }
    152 
    153     /**
    154      * Admin notice
    155      *
    156      * Warning when the site doesn't have WooCommerce installed or activated.
    157      *
    158      * @since 1.0.0
    159      * @access public
    160      */
    161 
    162     public function admin_notice_missing_woo_plugin() {
    163         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    164         if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
    165 
    166         $message = sprintf(
    167             /* translators: 1: Plugin name 2: WooCommerce */
    168             esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'order-list-table-elementor-widget' ),
    169             '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
    170             '<strong>' . esc_html__( 'WooCommerce', 'order-list-table-elementor-widget' ) . '</strong>'
    171         );
    172 
    173         printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', esc_html( $message ) );
    174 
    175     }
    176 
    177     /**
    178      * Admin notice
    179      *
    180      * Warning when the site doesn't have a minimum required Elementor version.
    181      *
    182      * @since 1.0.0
    183      * @access public
    184      */
    185     public function admin_notice_minimum_elementor_version() {
    186         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    187         if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
    188 
    189         $message = sprintf(
    190             /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
    191             esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'order-list-table-elementor-widget' ),
    192             '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
    193             '<strong>' . esc_html__( 'Elementor', 'order-list-table-elementor-widget' ) . '</strong>',
    194              self::MINIMUM_ELEMENTOR_VERSION
    195         );
    196 
    197         printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', esc_html( $message ) );
    198 
    199     }
    200 
    201     /**
    202      * Admin notice
    203      *
    204      * Warning when the site doesn't have a minimum required PHP version.
    205      *
    206      * @since 1.0.0
    207      * @access public
    208      */
    209     public function admin_notice_minimum_php_version() {
    210         // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    211         if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
    212 
    213         $message = sprintf(
    214             /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
    215             esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'order-list-table-elementor-widget' ),
    216             '<strong>' . esc_html__( 'Woocommerce Order List Table', 'order-list-table-elementor-widget' ) . '</strong>',
    217             '<strong>' . esc_html__( 'PHP', 'order-list-table-elementor-widget' ) . '</strong>',
    218              self::MINIMUM_PHP_VERSION
    219         );
    220 
    221         printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', esc_html( $message ) );
    222 
    223     }
    224 
    225 
    226 
    227     /**
    228      * Initialize
    229      *
    230      * Load the addons functionality only after Elementor is initialized.
    231      *
    232      * Fired by `elementor/init` action hook.
    233      *
    234      * @since 1.0.0
    235      * @access public
    236      */
    237     public function init() {
    238 
    239         add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] );
    240 
    241     }
    242 
    243     /**
    244      * Register Widgets
    245      *
    246      * Load widgets files and register new Elementor widgets.
    247      *
    248      * Fired by `elementor/widgets/register` action hook.
    249      *
    250      * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
    251      */
    252     public function register_widgets( $widgets_manager ) {
    253 
    254         require_once( __DIR__ . '/order-list-table-register.php' );
    255 
    256         $widgets_manager->register( new \Oltew_Order_List_table_Ele_Widget() );
    257 
    258     }
    259 
    260147}
Note: See TracChangeset for help on using the changeset viewer.