per_page = $user_option ?: Helpers::get_option( 'posts_per_page', Settings::DEFAULT_POSTS_PER_PAGE ); // Initialize on admin page load. add_action( 'load-' . Globals::ATUM_UI_HOOK . '_page_' . self::UI_SLUG, array( $this, 'screen_options' ) ); parent::init_hooks(); } } /** * Add the Inbound Stock menu * * @since 1.3.6 * * @param array $menus * * @return array */ public function add_menu( $menus ) { $menus['inbound-stock'] = array( 'title' => __( 'Inbound Stock', ATUM_TEXT_DOMAIN ), 'callback' => array( $this, 'display' ), 'slug' => self::UI_SLUG, 'menu_order' => self::MENU_ORDER, 'capability' => ATUM_PREFIX . 'read_inbound_stock', ); return $menus; } /** * Display the Inbound Stock admin page * * @since 1.3.0 */ public function display() { parent::display(); Helpers::load_view( 'inbound-stock', array( 'list' => $this->list, 'ajax' => Helpers::get_option( 'enable_ajax_filter', 'yes' ), ) ); } /** * Enable Screen options creating the list table before the Screen option panel is rendered and enable "per page" option * * @since 1.3.0 */ public function screen_options() { // Add "Products per page" screen option. $args = array( 'label' => __( 'Products per page', ATUM_TEXT_DOMAIN ), 'default' => $this->per_page, 'option' => ATUM_PREFIX . 'inbound_stock_products_per_page', ); add_screen_option( 'per_page', $args ); // Add the help tab. $help_tabs = array( array( 'name' => 'columns', 'title' => __( 'Columns', ATUM_TEXT_DOMAIN ), ), ); Helpers::add_help_tab( $help_tabs, $this ); $this->list = new ListTable( [ 'per_page' => $this->per_page ] ); } /* @noinspection PhpUnusedParameterInspection */ /** * Display the help tabs' content * * @since 0.0.2 * * @param \WP_Screen $screen The current screen. * @param array $tab The current help tab. */ public function help_tabs_content( $screen, $tab ) { Helpers::load_view( 'help-tabs/inbound-stock/' . $tab['name'] ); } /******************** * Instance methods ********************/ /** * Cannot be cloned */ public function __clone() { _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', ATUM_TEXT_DOMAIN ), '1.0.0' ); } /** * Cannot be serialized */ public function __sleep() { _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin’ huh?', ATUM_TEXT_DOMAIN ), '1.0.0' ); } /** * Get Singleton instance * * @return InboundStock instance */ public static function get_instance() { if ( ! ( self::$instance && is_a( self::$instance, __CLASS__ ) ) ) { self::$instance = new self(); } return self::$instance; } }