_presets = Presets::get_all(); } /** * Load all field objects and add them to the sections set. * * @since 1.0.0 */ public function load_fields() { $this->_sections = Options::get_sections(); $this->_fields = Options::get_fields(); foreach ( $this->_fields as $key => $field ) { $this->_sections[ $field->args['section'] ]['fields'][] = $field; } $this->_options = Options::get_options(); } /** * Render the options page content. * * @since 1.0.0 */ public function page_content() { wp_enqueue_script( 'woodmart-admin-options', WOODMART_ASSETS . '/js/options.js', array(), WOODMART_VERSION, true ); wp_enqueue_script( 'xts-helpers', WOODMART_SCRIPTS . '/scripts/global/helpers.min.js', array(), WOODMART_VERSION, true ); wp_enqueue_script( 'xts-tabs', WOODMART_SCRIPTS . '/scripts/elements/tabs.js', array(), WOODMART_VERSION, true ); $wrapper_classes = ''; if ( isset( $_GET['preset'] ) ) { // phpcs:ignore $wrapper_classes .= ' xts-preset-active'; } $current_preset_id = Presets::get_current_preset(); $all_presets = Presets::get_all(); if ( $current_preset_id ) { $title = $all_presets[ $current_preset_id ]['name']; } else { $title = esc_html__( 'Theme settings', 'woodmart' ); } $wrapper_classes .= ' xts-builder-' . woodmart_get_current_page_builder(); do_action( 'xts_before_theme_settings' ); if ( isset( $_GET['settings-updated'] ) ) { // phpcs:ignore do_action( 'xts_theme_settings_save' ); } ?>
_sections ); $first_tab = key( $this->_sections ); $current_tab = $first_tab; if ( isset( $this->_options['last_tab'] ) && isset( $_GET['settings-updated'] ) ) { $current_tab = $this->_options['last_tab']; } elseif ( isset( $_GET['tab'] ) ) { $current_tab = $_GET['tab']; } if ( ! isset( $this->_sections[ $current_tab ]['fields'] ) ) { $parent_id = $this->_sections[ $current_tab ]['id']; foreach ( $this->_sections as $section ) { if ( ! empty( $section['parent'] ) && $section['parent'] === $parent_id ) { $current_tab = $section['id']; break; } } } return $current_tab; } /** * Display saved/imported message. * * @since 1.0.0 */ private function display_message() { $message = $this->get_last_message(); $text = false; if ( 'save' === $message ) { $text = esc_html__( 'Settings are successfully saved.', 'woodmart' ); } elseif ( 'import' === $message ) { $text = esc_html__( 'New options are successfully imported.', 'woodmart' ); } elseif ( 'reset' === $message ) { $text = esc_html__( 'All options are set to default values.', 'woodmart' ); } if ( $text ) { echo '