advanced-custom-order-status-for-woocommerce
Last commit date
assets
9 months ago
includes
5 months ago
languages
2 years ago
vendor
1 year ago
LICENSE.txt
2 years ago
README.txt
1 week ago
advanced-custom-order-status-for-woocommerce.php
1 week ago
index.php
2 years ago
uninstall.php
1 year ago
advanced-custom-order-status-for-woocommerce.php
121 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Plugin Name: Advanced Custom Order Status for WooCommerce |
| 5 | * Requires Plugins: woocommerce |
| 6 | * Plugin URI: https://storeplugin.net/plugins/advanced-custom-order-status-for-woocommerce |
| 7 | * Description: The Advanced Custom Order Status for WooCommerce plugin empowers users to effortlessly manage and customize Order Status in WooCommerce. |
| 8 | * Version: 3.0.7 |
| 9 | * Author: StorePlugin |
| 10 | * Author URI: https://storeplugin.net/ |
| 11 | * License: GPL-2.0+ |
| 12 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 13 | * Text Domain: advanced-custom-order-status-for-woocommerce |
| 14 | * Domain Path: /languages |
| 15 | */ |
| 16 | if ( ! defined( 'WPINC' ) ) { |
| 17 | die; |
| 18 | } |
| 19 | |
| 20 | /** PSR-4 compatible autoload */ |
| 21 | $_autoload = require __DIR__ . '/vendor/autoload.php'; |
| 22 | |
| 23 | /** Import necessary classes */ |
| 24 | use StorePlugin\CustomOrderStatus\Container; |
| 25 | use StorePlugin\CustomOrderStatus\PluginFactory; |
| 26 | use StorePlugin\CustomOrderStatus\Container\Dice; |
| 27 | use StorePlugin\CustomOrderStatus\Utils; |
| 28 | |
| 29 | /** Plugin version constant */ |
| 30 | if( ! defined( 'SPCOS_ORDER_STATUS_VERSION' ) ) { |
| 31 | define( 'SPCOS_ORDER_STATUS_VERSION', '3.0.7' ); |
| 32 | } |
| 33 | |
| 34 | /** Plugin PATH constant */ |
| 35 | if( ! defined( 'SPCOS_ORDER_STATUS_FILE' ) ) { |
| 36 | define( 'SPCOS_ORDER_STATUS_FILE', __FILE__ ); |
| 37 | } |
| 38 | |
| 39 | /** Plugin DIR constant */ |
| 40 | if( ! defined( 'SPCOS_ORDER_STATUS_DIR' ) ) { |
| 41 | define( 'SPCOS_ORDER_STATUS_DIR', __DIR__ ); |
| 42 | } |
| 43 | |
| 44 | /** Plugin Base constant */ |
| 45 | if( ! defined( 'SPCOS_ORDER_STATUS_BASE' ) ) { |
| 46 | define( 'SPCOS_ORDER_STATUS_BASE', plugin_basename( SPCOS_ORDER_STATUS_FILE ) ); |
| 47 | } |
| 48 | |
| 49 | /** Plugin URI constant */ |
| 50 | if( ! defined( 'SPCOS_ORDER_STATUS_URI' ) ) { |
| 51 | define( 'SPCOS_ORDER_STATUS_URI', plugins_url( '/assets', SPCOS_ORDER_STATUS_FILE ) ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Deactivate the unsupported Pro version |
| 56 | * During the initial lookup of the stpwcos_order_attribute() function. |
| 57 | * |
| 58 | * Will be removed in the future version |
| 59 | * |
| 60 | * @since 2.0.0 |
| 61 | * @return void |
| 62 | */ |
| 63 | if( ! function_exists( 'stpwcos_order_attribute' ) ) { |
| 64 | function stpwcos_order_attribute( $arg ) { |
| 65 | try { |
| 66 | Utils::deactivate_order_status_pro(); |
| 67 | } catch (\Exception $e) { |
| 68 | echo $e->getMessage(); |
| 69 | } |
| 70 | |
| 71 | return; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Deactivate the unsupported Pro version |
| 77 | * During the initial lookup of the stpwcos_order_attributes() function. |
| 78 | * |
| 79 | * Will be removed in the future version |
| 80 | * |
| 81 | * @since 2.0.0 |
| 82 | * @return array[] |
| 83 | */ |
| 84 | if ( ! function_exists('stpwcos_order_attributes') ) { |
| 85 | function stpwcos_order_attributes() { |
| 86 | try { |
| 87 | Utils::deactivate_order_status_pro(); |
| 88 | } catch (\Exception $e) { |
| 89 | echo $e->getMessage(); |
| 90 | } |
| 91 | |
| 92 | return []; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /** Load container with autowiring process. */ |
| 97 | add_action( 'plugins_loaded', function() use( $_autoload ) { |
| 98 | if( class_exists( Container::class ) ) { |
| 99 | if( Utils::is_active() ) { |
| 100 | // Boot Starter plugin |
| 101 | ( new Container( $_autoload->getPrefixesPsr4(), 'StorePlugin\CustomOrderStatus' ) ) |
| 102 | ->container( new Dice() ) |
| 103 | ->register(); |
| 104 | |
| 105 | // Check WooCommerce HPOS |
| 106 | add_action( 'before_woocommerce_init', array( Utils::class, 'declare_hpos_compatibility' ) ); |
| 107 | } |
| 108 | } |
| 109 | }); |
| 110 | |
| 111 | /** Do things in plugin activation and deactivation */ |
| 112 | add_action( 'init', fn() => Utils::deactivate_order_status_pro() ); |
| 113 | add_action( 'admin_footer', fn() => Utils::disable_order_status_active_link() ); |
| 114 | register_activation_hook( SPCOS_ORDER_STATUS_FILE, fn() => PluginFactory::activate() ); |
| 115 | register_deactivation_hook( SPCOS_ORDER_STATUS_FILE, fn() => PluginFactory::deactivate() ); |
| 116 | add_filter( 'plugin_action_links_' . SPCOS_ORDER_STATUS_BASE, [ Utils::class, 'setting_link_next_plugin_activation'] ); |
| 117 | |
| 118 | /* 2.0.0 PRO Notice - Will be removed in the future version */ |
| 119 | add_action( 'admin_notices', array( Utils::class, 'update_notice_for_pro_plugin')); |
| 120 | add_action( 'after_plugin_row_advanced-custom-order-status-pro-for-woocommerce/advanced-custom-order-status-pro-for-woocommerce.php', array( Utils::class, 'manual_update_notice_for_pro_plugin'), 10, 2 ); |
| 121 |