public function create( $page_id = '', array $menu_ops = [], array $page_ops = [], $settings_field = '', array $default_settings = [] ) { $this->page_id = $this->page_id ?: $page_id; if ( ! $this->page_id ) { return; } $this->menu_ops = $this->menu_ops ?: $menu_ops; $this->page_ops = $this->page_ops ?: $page_ops; $this->settings_field = $this->settings_field ?: $settings_field; $this->default_settings = $this->default_settings ?: $default_settings; $this->help_base = $this->help_base ?: GENESIS_VIEWS_DIR . '/help/' . $page_id . '-'; $this->views_base = $this->views_base ?: GENESIS_VIEWS_DIR; $this->page_ops = wp_parse_args( $this->page_ops, [ 'save_button_text' => __( 'Save Changes', 'genesis' ), 'reset_button_text' => __( 'Reset Settings', 'genesis' ), 'saved_notice_text' => __( 'Settings saved.', 'genesis' ), 'reset_notice_text' => __( 'Settings reset.', 'genesis' ), 'error_notice_text' => __( 'Error saving settings.', 'genesis' ), ] ); // Check to make sure there we are only creating one menu per subclass. if ( isset( $this->menu_ops['submenu'] ) && ( isset( $this->menu_ops['main_menu'] ) || isset( $this->menu_ops['first_submenu'] ) ) ) { /* translators: %s: Genesis_Admin class name. */ wp_die( sprintf( /* translators: %s: Genesis_Admin class name. */ esc_html__( 'You cannot use %s to create two menus in the same subclass. Please use separate subclasses for each menu.', 'genesis' ), 'Genesis_Admin' ) ); } // Create the menu(s). Conditional logic happens within the separate methods. add_action( 'admin_menu', [ $this, 'maybe_add_main_menu' ], 5 ); add_action( 'admin_menu', [ $this, 'maybe_add_first_submenu' ], 5 ); add_action( 'admin_menu', [ $this, 'maybe_add_submenu' ] ); // Redirect to location on access, if specified. add_action( 'admin_init', [ $this, 'maybe_redirect' ], 1000 ); // Set up settings and notices. add_action( 'admin_init', [ $this, 'register_settings' ] ); add_action( 'admin_notices', [ $this, 'notices' ] ); // Load the page content (meta boxes or custom form). add_action( 'admin_init', [ $this, 'settings_init' ] ); // Load help tab. add_action( 'admin_init', [ $this, 'load_help' ] ); // Load contextual assets (registered admin page). add_action( 'admin_init', [ $this, 'load_assets' ] ); // Add a sanitizer/validator. add_filter( 'pre_update_option_' . $this->settings_field, [ $this, 'save' ], 10, 2 ); }