builders
2 years ago
privacy
2 years ago
class-yit-ajax.php
2 years ago
class-yit-assets.php
2 years ago
class-yit-cpt-unlimited.php
5 years ago
class-yit-gradients.php
2 years ago
class-yit-help-desk.php
2 years ago
class-yit-icons.php
2 years ago
class-yit-metabox.php
2 years ago
class-yit-plugin-common.php
5 years ago
class-yit-plugin-licence.php
2 years ago
class-yit-plugin-panel-woocommerce.php
1 year ago
class-yit-plugin-panel.php
1 year ago
class-yit-plugin-subpanel.php
2 years ago
class-yit-pointers.php
2 years ago
class-yit-theme-licence.php
2 years ago
class-yit-upgrade.php
5 years ago
class-yit-video.php
5 years ago
class-yith-bh-onboarding.php
3 years ago
class-yith-dashboard.php
4 years ago
class-yith-debug.php
2 years ago
class-yith-external-services.php
1 year ago
class-yith-post-type-admin.php
2 years ago
class-yith-system-status.php
1 year ago
class-yit-plugin-subpanel.php
148 lines
| 1 | <?php |
| 2 | /** |
| 3 | * YITH Plugin Sub-panel Class. |
| 4 | * |
| 5 | * @class YIT_Plugin_SubPanel |
| 6 | * @package YITH\PluginFramework\Classes |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 10 | |
| 11 | if ( ! class_exists( 'YIT_Plugin_SubPanel' ) ) { |
| 12 | /** |
| 13 | * YIT_Plugin_SubPanel class. |
| 14 | * |
| 15 | * @author YITH <plugins@yithemes.com> |
| 16 | */ |
| 17 | class YIT_Plugin_SubPanel extends YIT_Plugin_Panel { |
| 18 | |
| 19 | /** |
| 20 | * Version of the class. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | public $version = '1.0.0'; |
| 25 | |
| 26 | /** |
| 27 | * List of settings parameters. |
| 28 | * |
| 29 | * @var array |
| 30 | */ |
| 31 | public $settings = array(); |
| 32 | |
| 33 | /** |
| 34 | * YIT_Plugin_SubPanel constructor. |
| 35 | * |
| 36 | * @param array $args The panel arguments. |
| 37 | */ |
| 38 | public function __construct( $args = array() ) { |
| 39 | if ( ! empty( $args ) ) { |
| 40 | $this->settings = $args; |
| 41 | $this->settings['parent'] = $this->settings['page']; |
| 42 | $this->tabs_path_files = $this->get_tabs_path_files(); |
| 43 | |
| 44 | add_action( 'admin_init', array( $this, 'register_settings' ) ); |
| 45 | add_action( 'admin_menu', array( &$this, 'add_setting_page' ) ); |
| 46 | add_action( 'admin_bar_menu', array( &$this, 'add_admin_bar_menu' ), 100 ); |
| 47 | add_action( 'admin_init', array( &$this, 'add_fields' ) ); |
| 48 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Register Settings |
| 54 | * Generate wp-admin settings pages by registering your settings and using a few callbacks to control the output |
| 55 | */ |
| 56 | public function register_settings() { |
| 57 | register_setting( 'yit_' . $this->settings['page'] . '_options', 'yit_' . $this->settings['page'] . '_options', array( &$this, 'options_validate' ) ); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * Add Setting SubPage |
| 63 | * add Setting SubPage to WordPress administrator |
| 64 | */ |
| 65 | public function add_setting_page() { |
| 66 | global $admin_page_hooks; |
| 67 | $logo = yith_plugin_fw_get_default_logo(); |
| 68 | |
| 69 | $admin_logo = function_exists( 'yit_get_option' ) ? yit_get_option( 'admin-logo-menu' ) : ''; |
| 70 | |
| 71 | if ( ! empty( $admin_logo ) ) { |
| 72 | $logo = $admin_logo; |
| 73 | } |
| 74 | |
| 75 | if ( ! isset( $admin_page_hooks['yith_plugin_panel'] ) ) { |
| 76 | $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' ); |
| 77 | add_menu_page( 'yith_plugin_panel', 'YITH', 'nosuchcapability', 'yith_plugin_panel', null, $logo, $position ); |
| 78 | // Prevent issues for backward compatibility. |
| 79 | $admin_page_hooks['yith_plugin_panel'] = 'yith-plugins'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 80 | } |
| 81 | |
| 82 | add_submenu_page( 'yith_plugin_panel', $this->settings['label'], $this->settings['label'], 'manage_options', $this->settings['page'], array( $this, 'yit_panel' ) ); |
| 83 | remove_submenu_page( 'yith_plugin_panel', 'yith_plugin_panel' ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Show a tabbed panel to setting page |
| 88 | * a callback function called by add_setting_page => add_submenu_page |
| 89 | */ |
| 90 | public function yit_panel() { |
| 91 | $tabs = ''; |
| 92 | $current_tab = $this->get_current_tab(); |
| 93 | $yit_options = $this->get_main_array_options(); |
| 94 | |
| 95 | foreach ( $this->settings['admin-tabs'] as $tab => $tab_value ) { |
| 96 | $active_class = $current_tab === $tab ? ' nav-tab-active' : ''; |
| 97 | $url = '?page=' . $this->settings['page'] . '&tab=' . $tab; |
| 98 | |
| 99 | $tabs .= '<a class="nav-tab' . esc_attr( $active_class ) . '" href="' . esc_url( $url ) . '">' . wp_kses_post( $tab_value ) . '</a>'; |
| 100 | } |
| 101 | ?> |
| 102 | <div id="icon-themes" class="icon32"><br/></div> |
| 103 | <h2 class="nav-tab-wrapper"> |
| 104 | <?php echo $tabs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 105 | </h2> |
| 106 | <?php |
| 107 | $custom_tab_options = $this->get_custom_tab_options( $yit_options, $current_tab ); |
| 108 | if ( $custom_tab_options ) { |
| 109 | $this->print_custom_tab( $custom_tab_options ); |
| 110 | |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | $form_method = apply_filters( 'yit_admin_panel_form_method', 'POST', $current_tab ); |
| 115 | $panel_content_class = apply_filters( 'yit_admin_panel_content_class', 'yit-admin-panel-content-wrap', $current_tab ); |
| 116 | ?> |
| 117 | <div id="wrap" class="yith-plugin-fw plugin-option yit-admin-panel-container"> |
| 118 | <?php $this->message(); ?> |
| 119 | <div class="<?php echo esc_attr( $panel_content_class ); ?>"> |
| 120 | <h2><?php echo wp_kses_post( $this->get_tab_title() ); ?></h2> |
| 121 | <?php if ( $this->is_show_form() ) : ?> |
| 122 | <form id="yith-plugin-fw-panel" method="<?php echo esc_attr( $form_method ); ?>" action="options.php"> |
| 123 | <?php do_settings_sections( 'yit' ); ?> |
| 124 | <p> </p> |
| 125 | <?php settings_fields( 'yit_' . $this->settings['parent'] . '_options' ); ?> |
| 126 | <input type="hidden" name="<?php echo esc_attr( $this->get_name_field( 'current_tab' ) ); ?>" value="<?php echo esc_attr( $current_tab ); ?>"/> |
| 127 | <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'yith-plugin-fw' ); ?>" style="float:left;margin-right:10px;"/> |
| 128 | <input type="hidden" name="page" value="<?php echo esc_attr( $this->settings['page'] ); ?>"/> |
| 129 | <input type="hidden" name="tab" value="<?php echo esc_attr( $this->get_current_tab() ); ?>"/> |
| 130 | <input type="hidden" name="sub_tab" value="<?php echo esc_attr( $this->get_current_sub_tab() ); ?>"/> |
| 131 | </form> |
| 132 | <form method="post"> |
| 133 | <?php |
| 134 | $reset_warning = __( 'If you continue with this action, you will reset all options in this page.', 'yith-plugin-fw' ) . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ); |
| 135 | ?> |
| 136 | <input type="hidden" name="yit-action" value="reset"/> |
| 137 | <input type="submit" name="yit-reset" class="button-secondary" value="<?php esc_attr_e( 'Reset to default', 'yith-plugin-fw' ); ?>" |
| 138 | onclick="return confirm('<?php echo esc_attr( $reset_warning ); ?>');"/> |
| 139 | </form> |
| 140 | <p> </p> |
| 141 | <?php endif ?> |
| 142 | </div> |
| 143 | </div> |
| 144 | <?php |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 |