get_settings_pages() публичный статический Метод

Include the settings page classes.
public static get_settings_pages ( )
Пример #1
0
 /**
  * Default options.
  *
  * Sets up the default options used on the settings page.
  */
 private static function create_options()
 {
     // Include settings so that we can run through defaults
     include_once dirname(__FILE__) . '/admin/class-wc-admin-settings.php';
     $settings = WC_Admin_Settings::get_settings_pages();
     foreach ($settings as $section) {
         if (!method_exists($section, 'get_settings')) {
             continue;
         }
         $subsections = array_unique(array_merge(array(''), array_keys($section->get_sections())));
         foreach ($subsections as $subsection) {
             foreach ($section->get_settings($subsection) as $value) {
                 if (isset($value['default']) && isset($value['id'])) {
                     $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true;
                     add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no');
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Default options
  *
  * Sets up the default options used on the settings page
  *
  * @access public
  */
 function create_options()
 {
     // Include settings so that we can run through defaults
     include_once 'admin/class-wc-admin-settings.php';
     $settings = WC_Admin_Settings::get_settings_pages();
     foreach ($settings as $section) {
         if (!method_exists($section, 'get_settings')) {
             continue;
         }
         foreach ($section->get_settings() as $value) {
             if (isset($value['default']) && isset($value['id'])) {
                 $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true;
                 add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no');
             }
         }
         // Special case to install the inventory settings.
         if ($section instanceof WC_Settings_Products) {
             foreach ($section->get_settings('inventory') as $value) {
                 if (isset($value['default']) && isset($value['id'])) {
                     $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true;
                     add_option($value['id'], $value['default'], '', $autoload ? 'yes' : 'no');
                 }
             }
         }
     }
 }
Пример #3
0
 /**
  * Register WC settings from WP-API to the REST API.
  * @since  2.7.0
  */
 public function register_wp_admin_settings()
 {
     $pages = WC_Admin_Settings::get_settings_pages();
     foreach ($pages as $page) {
         new WC_Register_WP_Admin_Settings($page, 'page');
     }
     $emails = WC_Emails::instance();
     foreach ($emails->get_emails() as $email) {
         new WC_Register_WP_Admin_Settings($email, 'email');
     }
 }
 public function get_woocommerce_settings_fields()
 {
     if (!defined('WC_VERSION') || !class_exists('WC_Admin_Settings')) {
         return false;
     }
     if (!empty($this->settings)) {
         return $this->settings;
     }
     $settings_cache_key = 'stream_connector_woocommerce_settings_' . sanitize_key(WC_VERSION);
     if ($settings_transient = get_transient($settings_cache_key)) {
         $settings = $settings_transient['settings'];
         $settings_pages = $settings_transient['settings_pages'];
     } else {
         global $woocommerce;
         $settings = array();
         $settings_pages = array();
         foreach (\WC_Admin_Settings::get_settings_pages() as $page) {
             // Get ID / Label of the page, since they're protected, by hacking into
             // the callback filter for 'woocommerce_settings_tabs_array'
             $info = $page->add_settings_page(array());
             $page_id = key($info);
             $page_label = current($info);
             $sections = $page->get_sections();
             if (empty($sections)) {
                 $sections[''] = $page_label;
             }
             $settings_pages[$page_id] = $page_label;
             // Remove non-fields ( sections, titles and whatever )
             $fields = array();
             foreach ($sections as $section_key => $section_label) {
                 $_fields = array_filter($page->get_settings($section_key), function ($item) {
                     return isset($item['id']) && !in_array($item['type'], array('title', 'sectionend'));
                 });
                 foreach ($_fields as $field) {
                     $title = isset($field['title']) ? $field['title'] : (isset($field['desc']) ? $field['desc'] : 'N/A');
                     $fields[$field['id']] = array('title' => $title, 'page' => 'wc-settings', 'tab' => $page_id, 'section' => $section_key, 'type' => esc_html__('setting', 'stream'));
                 }
             }
             // Store fields in the global array to be searched later
             $settings = array_merge($settings, $fields);
         }
         // Provide additional context for each of the settings pages
         array_walk($settings_pages, function (&$value) {
             $value .= ' ' . esc_html__('Settings', 'stream');
         });
         // Load Payment Gateway Settings
         $payment_gateway_settings = array();
         $payment_gateways = $woocommerce->payment_gateways();
         foreach ($payment_gateways->payment_gateways as $section_key => $payment_gateway) {
             $title = $payment_gateway->title;
             $key = $payment_gateway->plugin_id . $payment_gateway->id . '_settings';
             $payment_gateway_settings[$key] = array('title' => $title, 'page' => 'wc-settings', 'tab' => 'checkout', 'section' => strtolower($section_key), 'type' => esc_html__('payment gateway', 'stream'));
         }
         $settings = array_merge($settings, $payment_gateway_settings);
         // Load Shipping Method Settings
         $shipping_method_settings = array();
         $shipping_methods = $woocommerce->shipping();
         foreach ($shipping_methods->shipping_methods as $section_key => $shipping_method) {
             $title = $shipping_method->title;
             $key = $shipping_method->plugin_id . $shipping_method->id . '_settings';
             $shipping_method_settings[$key] = array('title' => $title, 'page' => 'wc-settings', 'tab' => 'shipping', 'section' => strtolower($section_key), 'type' => esc_html__('shipping method', 'stream'));
         }
         $settings = array_merge($settings, $shipping_method_settings);
         // Load Email Settings
         $email_settings = array();
         $emails = $woocommerce->mailer();
         foreach ($emails->emails as $section_key => $email) {
             $title = $email->title;
             $key = $email->plugin_id . $email->id . '_settings';
             $email_settings[$key] = array('title' => $title, 'page' => 'wc-settings', 'tab' => 'email', 'section' => strtolower($section_key), 'type' => esc_html__('email', 'stream'));
         }
         $settings = array_merge($settings, $email_settings);
         // Tools page
         $tools_page = array('tools' => esc_html__('Tools', 'stream'));
         $settings_pages = array_merge($settings_pages, $tools_page);
         // Cache the results
         $settings_cache = array('settings' => $settings, 'settings_pages' => $settings_pages);
         set_transient($settings_cache_key, $settings_cache, MINUTE_IN_SECONDS * 60 * 6);
     }
     $custom_settings = $this->get_custom_settings();
     $this->settings = array_merge($settings, $custom_settings);
     $this->settings_pages = $settings_pages;
     return $this->settings;
 }
 /**
  * Print custom tab of settings for Stripe subpanel
  *
  * @return void
  * @since 1.0.0
  */
 public function print_panel()
 {
     $panel_template = YITH_WCSTRIPE_DIR . '/templates/admin/settings-tab.php';
     if (!file_exists($panel_template)) {
         return;
     }
     global $current_section;
     $current_section = 'yith_wcstripe_gateway';
     if (defined('YITH_WCSTRIPE_PREMIUM')) {
         $current_section .= YITH_WCStripe_Premium::addons_installed() ? '_addons' : '_advanced';
     }
     WC_Admin_Settings::get_settings_pages();
     if (!empty($_POST)) {
         $gateways = WC()->payment_gateways()->payment_gateways();
         $gateways[YITH_WCStripe::$gateway_id]->process_admin_options();
     }
     include_once $panel_template;
 }
 /**
  * Print custom tab of settings for Authorize.net subpanel
  *
  * @return void
  * @since 1.0.0
  */
 public function print_credit_card_panel()
 {
     if (file_exists(YITH_WCAUTHNET_DIR . '/templates/admin/settings-tab.php')) {
         global $current_section;
         $current_section = 'yith_wcauthnet_credit_card_gateway';
         WC_Admin_Settings::get_settings_pages();
         if (!empty($_POST)) {
             YITH_WCAUTHNET_Credit_Card_Gateway()->process_admin_options();
         }
         include_once YITH_WCAUTHNET_DIR . '/templates/admin/settings-tab.php';
     }
 }
Пример #7
0
 /**
  * Register WC settings from WP-API to the REST API.
  * @since  2.7.0
  */
 public function register_wp_admin_settings()
 {
     $pages = WC_Admin_Settings::get_settings_pages();
     foreach ($pages as $page) {
         new WC_Register_WP_Admin_Settings($page);
     }
 }
    /**
     * Print WooCommerce settings tabs on order status manager screens
     *
     * Simulates a simplified version of WC_Admin_Settings::output and
     * `html-admin-settings.php` from WC core
     *
     * @since 1.0.0
     */
    public function print_woocommerce_settings_tabs()
    {
        if (!$this->is_order_status_manager_screen()) {
            return;
        }
        WC_Admin_Settings::get_settings_pages();
        // Get tabs for the settings page
        $tabs = apply_filters('woocommerce_settings_tabs_array', array());
        ?>
			<div class="wrap woocommerce">
				<div class="icon32 icon32-woocommerce-settings" id="icon-woocommerce"><br /></div><h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
					<?php 
        foreach ($tabs as $name => $label) {
            echo '<a href="' . admin_url('admin.php?page=wc-settings&tab=' . $name) . '" class="nav-tab">' . $label . '</a>';
        }
        do_action('woocommerce_settings_tabs');
        ?>
				</h2>
			</div>
		<?php 
    }