*/ namespace StorePlugin\CustomOrderStatus\Settings; use StorePlugin\CustomOrderStatus\Contracts\ServiceInterface; /** * AbstractWcSettings * * AbstractWcSettings holds WooCommerce settings functionalities to create tabs and sections. */ class WcSettings implements ServiceInterface { public function register(): void { \add_action( 'woocommerce_settings_tabs', [$this, 'orderStatusSettingsTab'], 1 ); \add_action( 'all_admin_notices', [$this, 'wcSettingsTabPostType'], 5 ); \add_action( 'all_admin_notices', [$this, 'wcSettingsSection'] ); \add_filter( 'parent_file', [$this, 'settingsMenuHighlight'] ); } /** * Check post type param * * @param string $post_type_name * @return bool */ protected function is_post_type( $post_type_name ) { global $typenow; return $typenow === $post_type_name; } /** * Check the current screen of order status post * * @return bool */ protected function is_order_status_screen() { if ( ! function_exists( 'get_current_screen') ) return false; $screen = get_current_screen(); return $screen && in_array( $screen->id, array( 'wc_order_status', 'edit-wc_order_status', 'wc_order_email', 'edit-wc_order_email', ), true ); } /** * Create tab in WooCommerce settings * * @return void */ public function orderStatusSettingsTab() { echo '', esc_html__( 'Order Statuses', 'advanced-custom-order-status-for-woocommerce' ) ,''; } /** * Display all WooCommerce settings tabs on top of custom order post type. * * @return void */ public function wcSettingsTabPostType() { if( ! $this->is_order_status_screen() ) return; // Get settings page \WC_Admin_Settings::get_settings_pages(); $wc_tabs = apply_filters('woocommerce_settings_tabs_array', array()); ?>
is_order_status_screen() ) return; ?>
is_order_status_screen() ) { $parent_file = 'woocommerce'; $submenu_file = 'wc-settings'; } return $parent_file; } }