@@ -9,186 +9,186 @@ discard block  | 
                                                    ||
| 9 | 9 | */  | 
                                                        
| 10 | 10 |  class Settings_Theme { | 
                                                        
| 11 | 11 | |
| 12 | - /**  | 
                                                        |
| 13 | - * Holds class instance  | 
                                                        |
| 14 | - *  | 
                                                        |
| 15 | - * @since 1.0.0  | 
                                                        |
| 16 | - *  | 
                                                        |
| 17 | - * @var object \lsx_team\classes\admin\Settings_Theme()  | 
                                                        |
| 18 | - */  | 
                                                        |
| 19 | - protected static $instance = null;  | 
                                                        |
| 12 | + /**  | 
                                                        |
| 13 | + * Holds class instance  | 
                                                        |
| 14 | + *  | 
                                                        |
| 15 | + * @since 1.0.0  | 
                                                        |
| 16 | + *  | 
                                                        |
| 17 | + * @var object \lsx_team\classes\admin\Settings_Theme()  | 
                                                        |
| 18 | + */  | 
                                                        |
| 19 | + protected static $instance = null;  | 
                                                        |
| 20 | 20 | |
| 21 | - /**  | 
                                                        |
| 22 | - * Will return true if this is the LSX Search settings page.  | 
                                                        |
| 23 | - *  | 
                                                        |
| 24 | - * @var array  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - public $is_options_page = false;  | 
                                                        |
| 21 | + /**  | 
                                                        |
| 22 | + * Will return true if this is the LSX Search settings page.  | 
                                                        |
| 23 | + *  | 
                                                        |
| 24 | + * @var array  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + public $is_options_page = false;  | 
                                                        |
| 27 | 27 | |
| 28 | - /**  | 
                                                        |
| 29 | - * Holds the id and labels for the navigation.  | 
                                                        |
| 30 | - *  | 
                                                        |
| 31 | - * @var array  | 
                                                        |
| 32 | - */  | 
                                                        |
| 33 | - public $navigation = array();  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * Holds the id and labels for the navigation.  | 
                                                        |
| 30 | + *  | 
                                                        |
| 31 | + * @var array  | 
                                                        |
| 32 | + */  | 
                                                        |
| 33 | + public $navigation = array();  | 
                                                        |
| 34 | 34 | |
| 35 | - /**  | 
                                                        |
| 36 | - * Contructor  | 
                                                        |
| 37 | - */  | 
                                                        |
| 38 | -	public function __construct() { | 
                                                        |
| 39 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );  | 
                                                        |
| 40 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );  | 
                                                        |
| 41 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );  | 
                                                        |
| 42 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );  | 
                                                        |
| 43 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );  | 
                                                        |
| 44 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );  | 
                                                        |
| 45 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );  | 
                                                        |
| 46 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );  | 
                                                        |
| 47 | - }  | 
                                                        |
| 35 | + /**  | 
                                                        |
| 36 | + * Contructor  | 
                                                        |
| 37 | + */  | 
                                                        |
| 38 | +     public function __construct() { | 
                                                        |
| 39 | + add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );  | 
                                                        |
| 40 | + add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );  | 
                                                        |
| 41 | + add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );  | 
                                                        |
| 42 | + add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );  | 
                                                        |
| 43 | + add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );  | 
                                                        |
| 44 | + add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );  | 
                                                        |
| 45 | + add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );  | 
                                                        |
| 46 | + add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );  | 
                                                        |
| 47 | + }  | 
                                                        |
| 48 | 48 | |
| 49 | - /**  | 
                                                        |
| 50 | - * Return an instance of this class.  | 
                                                        |
| 51 | - *  | 
                                                        |
| 52 | - * @since 1.0.0  | 
                                                        |
| 53 | - *  | 
                                                        |
| 54 | - * @return object \lsx_team\classes\admin\Settings_Theme() A single instance of this class.  | 
                                                        |
| 55 | - */  | 
                                                        |
| 56 | -	public static function get_instance() { | 
                                                        |
| 57 | - // If the single instance hasn't been set, set it now.  | 
                                                        |
| 58 | -		if ( null == self::$instance ) { | 
                                                        |
| 59 | - self::$instance = new self();  | 
                                                        |
| 60 | - }  | 
                                                        |
| 61 | - return self::$instance;  | 
                                                        |
| 62 | - }  | 
                                                        |
| 49 | + /**  | 
                                                        |
| 50 | + * Return an instance of this class.  | 
                                                        |
| 51 | + *  | 
                                                        |
| 52 | + * @since 1.0.0  | 
                                                        |
| 53 | + *  | 
                                                        |
| 54 | + * @return object \lsx_team\classes\admin\Settings_Theme() A single instance of this class.  | 
                                                        |
| 55 | + */  | 
                                                        |
| 56 | +     public static function get_instance() { | 
                                                        |
| 57 | + // If the single instance hasn't been set, set it now.  | 
                                                        |
| 58 | +          if ( null == self::$instance ) { | 
                                                        |
| 59 | + self::$instance = new self();  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | + return self::$instance;  | 
                                                        |
| 62 | + }  | 
                                                        |
| 63 | 63 | |
| 64 | - /**  | 
                                                        |
| 65 | - * Disable CMB2 styles on front end forms.  | 
                                                        |
| 66 | - *  | 
                                                        |
| 67 | - * @return bool $enabled Whether to enable (enqueue) styles.  | 
                                                        |
| 68 | - */  | 
                                                        |
| 69 | -	public function disable_cmb2_styles( $enabled ) { | 
                                                        |
| 70 | -		if ( is_admin() ) { | 
                                                        |
| 71 | - $current_screen = get_current_screen();  | 
                                                        |
| 72 | -			if ( is_object( $current_screen ) && 'team_page_lsx_team_options' === $current_screen->id ) { | 
                                                        |
| 73 | - $enabled = false;  | 
                                                        |
| 74 | - }  | 
                                                        |
| 75 | - }  | 
                                                        |
| 76 | - return $enabled;  | 
                                                        |
| 77 | - }  | 
                                                        |
| 64 | + /**  | 
                                                        |
| 65 | + * Disable CMB2 styles on front end forms.  | 
                                                        |
| 66 | + *  | 
                                                        |
| 67 | + * @return bool $enabled Whether to enable (enqueue) styles.  | 
                                                        |
| 68 | + */  | 
                                                        |
| 69 | +     public function disable_cmb2_styles( $enabled ) { | 
                                                        |
| 70 | +          if ( is_admin() ) { | 
                                                        |
| 71 | + $current_screen = get_current_screen();  | 
                                                        |
| 72 | +               if ( is_object( $current_screen ) && 'team_page_lsx_team_options' === $current_screen->id ) { | 
                                                        |
| 73 | + $enabled = false;  | 
                                                        |
| 74 | + }  | 
                                                        |
| 75 | + }  | 
                                                        |
| 76 | + return $enabled;  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | 78 | |
| 79 | - /**  | 
                                                        |
| 80 | - * Generates the tabbed navigation for the settings page.  | 
                                                        |
| 81 | - *  | 
                                                        |
| 82 | - * @param string $cmb_id  | 
                                                        |
| 83 | - * @param string $object_id  | 
                                                        |
| 84 | - * @param string $object_type  | 
                                                        |
| 85 | - * @param object $cmb2_obj  | 
                                                        |
| 86 | - * @return void  | 
                                                        |
| 87 | - */  | 
                                                        |
| 88 | -	public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { | 
                                                        |
| 89 | -		if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) { | 
                                                        |
| 90 | - $this->navigation = array();  | 
                                                        |
| 91 | - $this->is_options_page = true;  | 
                                                        |
| 92 | -			if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { | 
                                                        |
| 93 | -				foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { | 
                                                        |
| 94 | -					if ( 'title' === $field['type'] ) { | 
                                                        |
| 95 | - $this->navigation[ $field_index ] = $field['name'];  | 
                                                        |
| 96 | - }  | 
                                                        |
| 97 | - }  | 
                                                        |
| 98 | - }  | 
                                                        |
| 99 | - $this->output_navigation();  | 
                                                        |
| 100 | - }  | 
                                                        |
| 101 | - }  | 
                                                        |
| 79 | + /**  | 
                                                        |
| 80 | + * Generates the tabbed navigation for the settings page.  | 
                                                        |
| 81 | + *  | 
                                                        |
| 82 | + * @param string $cmb_id  | 
                                                        |
| 83 | + * @param string $object_id  | 
                                                        |
| 84 | + * @param string $object_type  | 
                                                        |
| 85 | + * @param object $cmb2_obj  | 
                                                        |
| 86 | + * @return void  | 
                                                        |
| 87 | + */  | 
                                                        |
| 88 | +     public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { | 
                                                        |
| 89 | +          if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) { | 
                                                        |
| 90 | + $this->navigation = array();  | 
                                                        |
| 91 | + $this->is_options_page = true;  | 
                                                        |
| 92 | +               if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { | 
                                                        |
| 93 | +                    foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { | 
                                                        |
| 94 | +                         if ( 'title' === $field['type'] ) { | 
                                                        |
| 95 | + $this->navigation[ $field_index ] = $field['name'];  | 
                                                        |
| 96 | + }  | 
                                                        |
| 97 | + }  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | + $this->output_navigation();  | 
                                                        |
| 100 | + }  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | - /**  | 
                                                        |
| 104 | - * Outputs the WP style navigation for the Settings page.  | 
                                                        |
| 105 | - *  | 
                                                        |
| 106 | - * @return void  | 
                                                        |
| 107 | - */  | 
                                                        |
| 108 | -	public function output_navigation() { | 
                                                        |
| 109 | -		if ( ! empty( $this->navigation ) ) { | 
                                                        |
| 110 | - ?>  | 
                                                        |
| 103 | + /**  | 
                                                        |
| 104 | + * Outputs the WP style navigation for the Settings page.  | 
                                                        |
| 105 | + *  | 
                                                        |
| 106 | + * @return void  | 
                                                        |
| 107 | + */  | 
                                                        |
| 108 | +     public function output_navigation() { | 
                                                        |
| 109 | +          if ( ! empty( $this->navigation ) ) { | 
                                                        |
| 110 | + ?>  | 
                                                        |
| 111 | 111 | <div class="wp-filter hide-if-no-js">  | 
                                                        
| 112 | 112 | <ul class="filter-links">  | 
                                                        
| 113 | 113 | <?php  | 
                                                        
| 114 | - $first_tab = true;  | 
                                                        |
| 115 | - $total = count( $this->navigation );  | 
                                                        |
| 116 | - $count = 0;  | 
                                                        |
| 117 | - $separator = ' |';  | 
                                                        |
| 118 | - $selected_tab = '';  | 
                                                        |
| 119 | -					if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { | 
                                                        |
| 120 | - $selected_tab = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) );  | 
                                                        |
| 121 | - $selected_tab = 'settings_' . $selected_tab;  | 
                                                        |
| 122 | - }  | 
                                                        |
| 123 | -					foreach ( $this->navigation as $key => $label ) { | 
                                                        |
| 124 | - $count++;  | 
                                                        |
| 125 | - $current_css = '';  | 
                                                        |
| 126 | -						if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { | 
                                                        |
| 127 | - $first_tab = false;  | 
                                                        |
| 128 | - $current_css = 'current';  | 
                                                        |
| 129 | - }  | 
                                                        |
| 130 | -						if ( $count === $total ) { | 
                                                        |
| 131 | - $separator = '';  | 
                                                        |
| 132 | - }  | 
                                                        |
| 133 | - ?>  | 
                                                        |
| 114 | + $first_tab = true;  | 
                                                        |
| 115 | + $total = count( $this->navigation );  | 
                                                        |
| 116 | + $count = 0;  | 
                                                        |
| 117 | + $separator = ' |';  | 
                                                        |
| 118 | + $selected_tab = '';  | 
                                                        |
| 119 | +                         if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { | 
                                                        |
| 120 | + $selected_tab = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) );  | 
                                                        |
| 121 | + $selected_tab = 'settings_' . $selected_tab;  | 
                                                        |
| 122 | + }  | 
                                                        |
| 123 | +                         foreach ( $this->navigation as $key => $label ) { | 
                                                        |
| 124 | + $count++;  | 
                                                        |
| 125 | + $current_css = '';  | 
                                                        |
| 126 | +                              if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { | 
                                                        |
| 127 | + $first_tab = false;  | 
                                                        |
| 128 | + $current_css = 'current';  | 
                                                        |
| 129 | + }  | 
                                                        |
| 130 | +                              if ( $count === $total ) { | 
                                                        |
| 131 | + $separator = '';  | 
                                                        |
| 132 | + }  | 
                                                        |
| 133 | + ?>  | 
                                                        |
| 134 | 134 | <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li>  | 
                                                        
| 135 | 135 | <?php  | 
                                                        
| 136 | - }  | 
                                                        |
| 137 | - ?>  | 
                                                        |
| 136 | + }  | 
                                                        |
| 137 | + ?>  | 
                                                        |
| 138 | 138 | </ul>  | 
                                                        
| 139 | 139 | </div>  | 
                                                        
| 140 | 140 | <?php  | 
                                                        
| 141 | - }  | 
                                                        |
| 142 | - }  | 
                                                        |
| 141 | + }  | 
                                                        |
| 142 | + }  | 
                                                        |
| 143 | 143 | |
| 144 | - /**  | 
                                                        |
| 145 | - * Outputs the opening tab div.  | 
                                                        |
| 146 | - *  | 
                                                        |
| 147 | - * @param object $field CMB2_Field();  | 
                                                        |
| 148 | - * @return void  | 
                                                        |
| 149 | - */  | 
                                                        |
| 150 | -	public function output_tab_open_div( $field ) { | 
                                                        |
| 151 | -		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { | 
                                                        |
| 152 | - ?>  | 
                                                        |
| 144 | + /**  | 
                                                        |
| 145 | + * Outputs the opening tab div.  | 
                                                        |
| 146 | + *  | 
                                                        |
| 147 | + * @param object $field CMB2_Field();  | 
                                                        |
| 148 | + * @return void  | 
                                                        |
| 149 | + */  | 
                                                        |
| 150 | +     public function output_tab_open_div( $field ) { | 
                                                        |
| 151 | +          if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { | 
                                                        |
| 152 | + ?>  | 
                                                        |
| 153 | 153 | <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden">  | 
                                                        
| 154 | 154 | <?php  | 
                                                        
| 155 | - }  | 
                                                        |
| 156 | - }  | 
                                                        |
| 155 | + }  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | 157 | |
| 158 | - /**  | 
                                                        |
| 159 | - * Outputs the opening closing div.  | 
                                                        |
| 160 | - *  | 
                                                        |
| 161 | - * @param object $field CMB2_Field();  | 
                                                        |
| 162 | - * @return void  | 
                                                        |
| 163 | - */  | 
                                                        |
| 164 | -	public function output_tab_closing_div( $field ) { | 
                                                        |
| 165 | -		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { | 
                                                        |
| 166 | - ?>  | 
                                                        |
| 158 | + /**  | 
                                                        |
| 159 | + * Outputs the opening closing div.  | 
                                                        |
| 160 | + *  | 
                                                        |
| 161 | + * @param object $field CMB2_Field();  | 
                                                        |
| 162 | + * @return void  | 
                                                        |
| 163 | + */  | 
                                                        |
| 164 | +     public function output_tab_closing_div( $field ) { | 
                                                        |
| 165 | +          if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { | 
                                                        |
| 166 | + ?>  | 
                                                        |
| 167 | 167 | </div>  | 
                                                        
| 168 | 168 | <?php  | 
                                                        
| 169 | - }  | 
                                                        |
| 170 | - }  | 
                                                        |
| 169 | + }  | 
                                                        |
| 170 | + }  | 
                                                        |
| 171 | 171 | |
| 172 | -	public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { | 
                                                        |
| 173 | - return;  | 
                                                        |
| 174 | - }  | 
                                                        |
| 172 | +     public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { | 
                                                        |
| 173 | + return;  | 
                                                        |
| 174 | + }  | 
                                                        |
| 175 | 175 | |
| 176 | -	public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { | 
                                                        |
| 177 | - return '';  | 
                                                        |
| 178 | - }  | 
                                                        |
| 176 | +     public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { | 
                                                        |
| 177 | + return '';  | 
                                                        |
| 178 | + }  | 
                                                        |
| 179 | 179 | |
| 180 | - /**  | 
                                                        |
| 181 | - * Outputs the Script for the tabbed navigation.  | 
                                                        |
| 182 | - *  | 
                                                        |
| 183 | - * @param string $cmb_id  | 
                                                        |
| 184 | - * @param string $object_id  | 
                                                        |
| 185 | - * @param string $object_type  | 
                                                        |
| 186 | - * @param object $cmb2_obj  | 
                                                        |
| 187 | - * @return void  | 
                                                        |
| 188 | - */  | 
                                                        |
| 189 | -	public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { | 
                                                        |
| 190 | -		if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) { | 
                                                        |
| 191 | - ?>  | 
                                                        |
| 180 | + /**  | 
                                                        |
| 181 | + * Outputs the Script for the tabbed navigation.  | 
                                                        |
| 182 | + *  | 
                                                        |
| 183 | + * @param string $cmb_id  | 
                                                        |
| 184 | + * @param string $object_id  | 
                                                        |
| 185 | + * @param string $object_type  | 
                                                        |
| 186 | + * @param object $cmb2_obj  | 
                                                        |
| 187 | + * @return void  | 
                                                        |
| 188 | + */  | 
                                                        |
| 189 | +     public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { | 
                                                        |
| 190 | +          if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) { | 
                                                        |
| 191 | + ?>  | 
                                                        |
| 192 | 192 | <script>  | 
                                                        
| 193 | 193 | var LSX_TEAM_CMB2 = Object.create( null );  | 
                                                        
| 194 | 194 | |
@@ -261,25 +261,25 @@ discard block  | 
                                                    ||
| 261 | 261 | } )( jQuery, window, document );  | 
                                                        
| 262 | 262 | </script>  | 
                                                        
| 263 | 263 | <?php  | 
                                                        
| 264 | - }  | 
                                                        |
| 265 | - }  | 
                                                        |
| 264 | + }  | 
                                                        |
| 265 | + }  | 
                                                        |
| 266 | 266 | |
| 267 | - /**  | 
                                                        |
| 268 | - * This will add the tab selection to the url.  | 
                                                        |
| 269 | - *  | 
                                                        |
| 270 | - * @param string $url  | 
                                                        |
| 271 | - * @return void  | 
                                                        |
| 272 | - */  | 
                                                        |
| 273 | -	public function add_tab_argument( $url ) { | 
                                                        |
| 274 | -		if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine | 
                                                        |
| 275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine  | 
                                                        |
| 276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine  | 
                                                        |
| 277 | -			if ( 'single' !== $tab_selection ) { | 
                                                        |
| 278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url );  | 
                                                        |
| 279 | -			} else { | 
                                                        |
| 280 | - $url = remove_query_arg( 'cmb_tab', $url );  | 
                                                        |
| 281 | - }  | 
                                                        |
| 282 | - }  | 
                                                        |
| 283 | - return $url;  | 
                                                        |
| 284 | - }  | 
                                                        |
| 267 | + /**  | 
                                                        |
| 268 | + * This will add the tab selection to the url.  | 
                                                        |
| 269 | + *  | 
                                                        |
| 270 | + * @param string $url  | 
                                                        |
| 271 | + * @return void  | 
                                                        |
| 272 | + */  | 
                                                        |
| 273 | +     public function add_tab_argument( $url ) { | 
                                                        |
| 274 | +          if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine | 
                                                        |
| 275 | + $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine  | 
                                                        |
| 276 | + $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine  | 
                                                        |
| 277 | +               if ( 'single' !== $tab_selection ) { | 
                                                        |
| 278 | + $url = add_query_arg( 'cmb_tab', $tab_selection, $url );  | 
                                                        |
| 279 | +               } else { | 
                                                        |
| 280 | + $url = remove_query_arg( 'cmb_tab', $url );  | 
                                                        |
| 281 | + }  | 
                                                        |
| 282 | + }  | 
                                                        |
| 283 | + return $url;  | 
                                                        |
| 284 | + }  | 
                                                        |
| 285 | 285 | }  | 
                                                        
@@ -36,14 +36,14 @@ discard block  | 
                                                    ||
| 36 | 36 | * Contructor  | 
                                                        
| 37 | 37 | */  | 
                                                        
| 38 | 38 |  	public function __construct() { | 
                                                        
| 39 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );  | 
                                                        |
| 40 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );  | 
                                                        |
| 41 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );  | 
                                                        |
| 42 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );  | 
                                                        |
| 43 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );  | 
                                                        |
| 44 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );  | 
                                                        |
| 45 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );  | 
                                                        |
| 46 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );  | 
                                                        |
| 39 | +		add_filter('cmb2_enqueue_css', array($this, 'disable_cmb2_styles'), 1, 1); | 
                                                        |
| 40 | +		add_action('cmb2_before_form', array($this, 'generate_navigation'), 10, 4); | 
                                                        |
| 41 | +		add_action('cmb2_before_title_field_row', array($this, 'output_tab_open_div'), 10, 1); | 
                                                        |
| 42 | +		add_action('cmb2_after_tab_closing_field_row', array($this, 'output_tab_closing_div'), 10, 1); | 
                                                        |
| 43 | +		add_action('cmb2_render_tab_closing', array($this, 'cmb2_render_callback_for_tab_closing'), 10, 5); | 
                                                        |
| 44 | +		add_filter('cmb2_sanitize_tab_closing', array($this, 'cmb2_sanitize_tab_closing_callback'), 10, 2); | 
                                                        |
| 45 | +		add_action('cmb2_after_form', array($this, 'navigation_js'), 10, 4); | 
                                                        |
| 46 | +		add_filter('cmb2_options_page_redirect_url', array($this, 'add_tab_argument'), 10, 1); | 
                                                        |
| 47 | 47 | }  | 
                                                        
| 48 | 48 | |
| 49 | 49 | /**  | 
                                                        
@@ -55,7 +55,7 @@ discard block  | 
                                                    ||
| 55 | 55 | */  | 
                                                        
| 56 | 56 |  	public static function get_instance() { | 
                                                        
| 57 | 57 | // If the single instance hasn't been set, set it now.  | 
                                                        
| 58 | -		if ( null == self::$instance ) { | 
                                                        |
| 58 | +		if (null == self::$instance) { | 
                                                        |
| 59 | 59 | self::$instance = new self();  | 
                                                        
| 60 | 60 | }  | 
                                                        
| 61 | 61 | return self::$instance;  | 
                                                        
@@ -66,10 +66,10 @@ discard block  | 
                                                    ||
| 66 | 66 | *  | 
                                                        
| 67 | 67 | * @return bool $enabled Whether to enable (enqueue) styles.  | 
                                                        
| 68 | 68 | */  | 
                                                        
| 69 | -	public function disable_cmb2_styles( $enabled ) { | 
                                                        |
| 70 | -		if ( is_admin() ) { | 
                                                        |
| 69 | +	public function disable_cmb2_styles($enabled) { | 
                                                        |
| 70 | +		if (is_admin()) { | 
                                                        |
| 71 | 71 | $current_screen = get_current_screen();  | 
                                                        
| 72 | -			if ( is_object( $current_screen ) && 'team_page_lsx_team_options' === $current_screen->id ) { | 
                                                        |
| 72 | +			if (is_object($current_screen) && 'team_page_lsx_team_options' === $current_screen->id) { | 
                                                        |
| 73 | 73 | $enabled = false;  | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | }  | 
                                                        
@@ -85,14 +85,14 @@ discard block  | 
                                                    ||
| 85 | 85 | * @param object $cmb2_obj  | 
                                                        
| 86 | 86 | * @return void  | 
                                                        
| 87 | 87 | */  | 
                                                        
| 88 | -	public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { | 
                                                        |
| 89 | -		if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) { | 
                                                        |
| 88 | +	public function generate_navigation($cmb_id, $object_id, $object_type, $cmb2_obj) { | 
                                                        |
| 89 | +		if ('lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type) { | 
                                                        |
| 90 | 90 | $this->navigation = array();  | 
                                                        
| 91 | 91 | $this->is_options_page = true;  | 
                                                        
| 92 | -			if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { | 
                                                        |
| 93 | -				foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { | 
                                                        |
| 94 | -					if ( 'title' === $field['type'] ) { | 
                                                        |
| 95 | - $this->navigation[ $field_index ] = $field['name'];  | 
                                                        |
| 92 | +			if (isset($cmb2_obj->meta_box['fields']) && !empty($cmb2_obj->meta_box['fields'])) { | 
                                                        |
| 93 | +				foreach ($cmb2_obj->meta_box['fields'] as $field_index => $field) { | 
                                                        |
| 94 | +					if ('title' === $field['type']) { | 
                                                        |
| 95 | + $this->navigation[$field_index] = $field['name'];  | 
                                                        |
| 96 | 96 | }  | 
                                                        
| 97 | 97 | }  | 
                                                        
| 98 | 98 | }  | 
                                                        
@@ -106,32 +106,32 @@ discard block  | 
                                                    ||
| 106 | 106 | * @return void  | 
                                                        
| 107 | 107 | */  | 
                                                        
| 108 | 108 |  	public function output_navigation() { | 
                                                        
| 109 | -		if ( ! empty( $this->navigation ) ) { | 
                                                        |
| 109 | +		if (!empty($this->navigation)) { | 
                                                        |
| 110 | 110 | ?>  | 
                                                        
| 111 | 111 | <div class="wp-filter hide-if-no-js">  | 
                                                        
| 112 | 112 | <ul class="filter-links">  | 
                                                        
| 113 | 113 | <?php  | 
                                                        
| 114 | 114 | $first_tab = true;  | 
                                                        
| 115 | - $total = count( $this->navigation );  | 
                                                        |
| 115 | + $total = count($this->navigation);  | 
                                                        |
| 116 | 116 | $count = 0;  | 
                                                        
| 117 | 117 | $separator = ' |';  | 
                                                        
| 118 | 118 | $selected_tab = '';  | 
                                                        
| 119 | -					if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { | 
                                                        |
| 120 | - $selected_tab = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) );  | 
                                                        |
| 121 | - $selected_tab = 'settings_' . $selected_tab;  | 
                                                        |
| 119 | +					if (isset($_GET['cmb_tab']) && '' !== $_GET['cmb_tab']) { | 
                                                        |
| 120 | + $selected_tab = sanitize_text_field(wp_unslash($_GET['cmb_tab']));  | 
                                                        |
| 121 | + $selected_tab = 'settings_'.$selected_tab;  | 
                                                        |
| 122 | 122 | }  | 
                                                        
| 123 | -					foreach ( $this->navigation as $key => $label ) { | 
                                                        |
| 123 | +					foreach ($this->navigation as $key => $label) { | 
                                                        |
| 124 | 124 | $count++;  | 
                                                        
| 125 | 125 | $current_css = '';  | 
                                                        
| 126 | -						if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { | 
                                                        |
| 126 | +						if ((true === $first_tab && '' === $selected_tab) || $key === $selected_tab) { | 
                                                        |
| 127 | 127 | $first_tab = false;  | 
                                                        
| 128 | 128 | $current_css = 'current';  | 
                                                        
| 129 | 129 | }  | 
                                                        
| 130 | -						if ( $count === $total ) { | 
                                                        |
| 130 | +						if ($count === $total) { | 
                                                        |
| 131 | 131 | $separator = '';  | 
                                                        
| 132 | 132 | }  | 
                                                        
| 133 | 133 | ?>  | 
                                                        
| 134 | - <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li>  | 
                                                        |
| 134 | + <li><a href="#" class="<?php echo esc_attr($current_css); ?>" data-sort="<?php echo esc_attr($key); ?>_tab"><?php echo esc_attr($label); ?></a><?php echo esc_attr($separator); ?></li>  | 
                                                        |
| 135 | 135 | <?php  | 
                                                        
| 136 | 136 | }  | 
                                                        
| 137 | 137 | ?>  | 
                                                        
@@ -147,10 +147,10 @@ discard block  | 
                                                    ||
| 147 | 147 | * @param object $field CMB2_Field();  | 
                                                        
| 148 | 148 | * @return void  | 
                                                        
| 149 | 149 | */  | 
                                                        
| 150 | -	public function output_tab_open_div( $field ) { | 
                                                        |
| 151 | -		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { | 
                                                        |
| 150 | +	public function output_tab_open_div($field) { | 
                                                        |
| 151 | +		if (true === $this->is_options_page && isset($field->args['type']) && 'title' === $field->args['type']) { | 
                                                        |
| 152 | 152 | ?>  | 
                                                        
| 153 | - <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden">  | 
                                                        |
| 153 | + <div id="<?php echo esc_attr($field->args['id']); ?>_tab" class="tab tab-nav hidden">  | 
                                                        |
| 154 | 154 | <?php  | 
                                                        
| 155 | 155 | }  | 
                                                        
| 156 | 156 | }  | 
                                                        
@@ -161,19 +161,19 @@ discard block  | 
                                                    ||
| 161 | 161 | * @param object $field CMB2_Field();  | 
                                                        
| 162 | 162 | * @return void  | 
                                                        
| 163 | 163 | */  | 
                                                        
| 164 | -	public function output_tab_closing_div( $field ) { | 
                                                        |
| 165 | -		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { | 
                                                        |
| 164 | +	public function output_tab_closing_div($field) { | 
                                                        |
| 165 | +		if (true === $this->is_options_page && isset($field->args['type']) && 'tab_closing' === $field->args['type']) { | 
                                                        |
| 166 | 166 | ?>  | 
                                                        
| 167 | 167 | </div>  | 
                                                        
| 168 | 168 | <?php  | 
                                                        
| 169 | 169 | }  | 
                                                        
| 170 | 170 | }  | 
                                                        
| 171 | 171 | |
| 172 | -	public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { | 
                                                        |
| 172 | +	public function cmb2_render_callback_for_tab_closing($field, $escaped_value, $object_id, $object_type, $field_type_object) { | 
                                                        |
| 173 | 173 | return;  | 
                                                        
| 174 | 174 | }  | 
                                                        
| 175 | 175 | |
| 176 | -	public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { | 
                                                        |
| 176 | +	public function cmb2_sanitize_tab_closing_callback($override_value, $value) { | 
                                                        |
| 177 | 177 | return '';  | 
                                                        
| 178 | 178 | }  | 
                                                        
| 179 | 179 | |
@@ -186,8 +186,8 @@ discard block  | 
                                                    ||
| 186 | 186 | * @param object $cmb2_obj  | 
                                                        
| 187 | 187 | * @return void  | 
                                                        
| 188 | 188 | */  | 
                                                        
| 189 | -	public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { | 
                                                        |
| 190 | -		if ( 'lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type ) { | 
                                                        |
| 189 | +	public function navigation_js($cmb_id, $object_id, $object_type, $cmb2_obj) { | 
                                                        |
| 190 | +		if ('lsx_team_settings' === $cmb_id && 'lsx_team_options' === $object_id && 'options-page' === $object_type) { | 
                                                        |
| 191 | 191 | ?>  | 
                                                        
| 192 | 192 | <script>  | 
                                                        
| 193 | 193 | var LSX_TEAM_CMB2 = Object.create( null );  | 
                                                        
@@ -270,14 +270,14 @@ discard block  | 
                                                    ||
| 270 | 270 | * @param string $url  | 
                                                        
| 271 | 271 | * @return void  | 
                                                        
| 272 | 272 | */  | 
                                                        
| 273 | -	public function add_tab_argument( $url ) { | 
                                                        |
| 274 | -		if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine | 
                                                        |
| 275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine  | 
                                                        |
| 276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine  | 
                                                        |
| 277 | -			if ( 'single' !== $tab_selection ) { | 
                                                        |
| 278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url );  | 
                                                        |
| 273 | +	public function add_tab_argument($url) { | 
                                                        |
| 274 | +		if (isset($_POST['cmb_tab']) && '' !== $_POST['cmb_tab']) { // @codingStandardsIgnoreLine | 
                                                        |
| 275 | + $tab_selection = sanitize_text_field($_POST['cmb_tab']); // @codingStandardsIgnoreLine  | 
                                                        |
| 276 | +			$tab_selection = str_replace(array('settings_', '_tab'), '', $tab_selection); // @codingStandardsIgnoreLine | 
                                                        |
| 277 | +			if ('single' !== $tab_selection) { | 
                                                        |
| 278 | +				$url = add_query_arg('cmb_tab', $tab_selection, $url); | 
                                                        |
| 279 | 279 |  			} else { | 
                                                        
| 280 | - $url = remove_query_arg( 'cmb_tab', $url );  | 
                                                        |
| 280 | +				$url = remove_query_arg('cmb_tab', $url); | 
                                                        |
| 281 | 281 | }  | 
                                                        
| 282 | 282 | }  | 
                                                        
| 283 | 283 | return $url;  |