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 4.6.1.1 6.5.1.4 4.6.10 6.5.1.5 4.6.10.2 6.5.1.6 4.6.11 6.5.2 4.6.11.2 6.6.0 4.6.12.1 6.6.0.1 4.6.13.1 6.6.0.2 4.6.14 6.6.1 4.6.14.2 6.6.2 4.6.15.1 6.6.3 4.6.16.1 6.6.4 4.6.17.1 6.6.4.1 4.6.18.1 6.6.4.2 4.6.19.1 6.7.0 4.6.2.1 6.7.1 4.6.20 6.8.0 4.6.20.2 6.8.1 4.6.21.1 6.8.2 4.6.22 6.8.2.1 4.6.22.2 6.8.3 4.6.23.1 6.9.0 4.6.24 6.9.1 4.6.24.2 4.6.25.1 4.6.26 4.6.26.2 4.6.3.1 4.6.4.1 4.6.5.1 4.6.6.1 4.6.7.1 4.6.8.1 4.6.9.1 4.7 4.7.0.2 4.7.1.1 4.7.2.1 4.7.3.1 4.7.4.1 4.8 4.8.0.2 4.8.1.1 4.8.2.1 4.9.0.1 4.9.0.2 4.9.0.4 4.9.1 4.9.1.2 4.9.10.1 4.9.11.1 4.9.12.1 4.9.13.1 4.9.14.1 4.9.2.1 4.9.3 4.9.3.1 4.9.3.3 4.9.4.1 4.9.5.1 4.9.6.1 4.9.7.1 4.9.8.1 4.9.9.1 5.0.0 5.0.0.1 5.0.0.3 5.0.1.1 5.0.1.2 5.0.2 5.0.2.2 5.0.2.3 5.0.3 5.0.3.2 5.0.3.3 5.1.0.1 5.1.0.2
the-events-calendar / common / src / Tribe / Settings_Tab.php
the-events-calendar / common / src / Tribe Last commit date
Admin 8 years ago Ajax 8 years ago Asset 8 years ago Customizer 8 years ago Documentation 8 years ago Duplicate 8 years ago Image 8 years ago JSON_LD 8 years ago Languages 8 years ago Log 8 years ago Meta 8 years ago PUE 8 years ago Process 8 years ago REST 8 years ago Service_Providers 8 years ago Support 8 years ago Tabbed_View 8 years ago Utils 8 years ago Validator 8 years ago Abstract_Deactivation.php 8 years ago App_Shop.php 8 years ago Assets.php 8 years ago Assets_Pipeline.php 8 years ago Autoloader.php 8 years ago Cache.php 8 years ago Cache_Listener.php 8 years ago Changelog_Reader.php 8 years ago Container.php 8 years ago Context.php 8 years ago Cost_Utils.php 8 years ago Credits.php 8 years ago Customizer.php 8 years ago Data.php 8 years ago Date_Utils.php 8 years ago Debug.php 8 years ago Dependency.php 8 years ago Deprecation.php 8 years ago Error.php 8 years ago Exception.php 8 years ago Extension.php 8 years ago Extension_Loader.php 8 years ago Field.php 8 years ago Field_Conditional.php 8 years ago Log.php 8 years ago Main.php 8 years ago Notices.php 8 years ago Plugin_Meta_Links.php 8 years ago Plugins.php 8 years ago Plugins_API.php 8 years ago Post_History.php 8 years ago Post_Transient.php 8 years ago Rewrite.php 8 years ago Settings.php 8 years ago Settings_Manager.php 8 years ago Settings_Tab.php 8 years ago Simple_Table.php 8 years ago Support.php 8 years ago Tabbed_View.php 8 years ago Template.php 8 years ago Template_Factory.php 8 years ago Template_Part_Cache.php 8 years ago Templates.php 8 years ago Terms.php 8 years ago Timezones.php 8 years ago Tracker.php 8 years ago Validate.php 8 years ago View_Helpers.php 8 years ago
Settings_Tab.php
228 lines
1 <?php
2
3 // Don't load directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 if ( ! class_exists( 'Tribe__Settings_Tab' ) ) {
9 /**
10 * helper class that creates a settings tab
11 * this is a public API, use it to create tabs
12 * simply by instantiating this class
13 *
14 */
15 class Tribe__Settings_Tab {
16
17 /**
18 * Tab ID, used in query string and elsewhere
19 * @var string
20 */
21 public $id;
22
23 /**
24 * Tab's name
25 * @var string
26 */
27 public $name;
28
29 /**
30 * Tab's arguments
31 * @var array
32 */
33 public $args;
34
35 /**
36 * Defaults for tabs
37 * @var array
38 */
39 public $defaults;
40
41 /**
42 * class constructor
43 *
44 * @param string $id the tab's id (no spaces or special characters)
45 * @param string $name the tab's visible name
46 * @param array $args additional arguments for the tab
47 */
48 public function __construct( $id, $name, $args = array() ) {
49
50 // setup the defaults
51 $this->defaults = array(
52 'fields' => array(),
53 'priority' => 50,
54 'show_save' => true,
55 'display_callback' => false,
56 'network_admin' => false,
57 );
58
59 // parse args with defaults
60 $this->args = wp_parse_args( $args, $this->defaults );
61
62 // set each instance variable and filter
63 $this->id = apply_filters( 'tribe_settings_tab_id', $id );
64 $this->name = apply_filters( 'tribe_settings_tab_name', $name );
65 foreach ( $this->defaults as $key => $value ) {
66 $this->{$key} = apply_filters( 'tribe_settings_tab_' . $key, $this->args[ $key ], $id );
67 }
68
69 // run actions & filters
70 if ( ! $this->network_admin ) {
71 add_filter( 'tribe_settings_all_tabs', array( $this, 'addAllTabs' ) );
72 }
73 add_filter( 'tribe_settings_tabs', array( $this, 'addTab' ), $this->priority );
74 }
75
76 /**
77 * filters the tabs array from Tribe__Settings
78 * and adds the current tab to it
79 * does not add a tab if it's empty
80 *
81 * @param array $tabs the $tabs from Tribe__Settings
82 *
83 * @return array $tabs the filtered tabs
84 */
85 public function addTab( $tabs ) {
86 $hideSettingsTabs = Tribe__Settings_Manager::get_network_option( 'hideSettingsTabs', array() );
87 if ( ( isset( $this->fields ) || has_action( 'tribe_settings_content_tab_' . $this->id ) ) && ( empty( $hideSettingsTabs ) || ! in_array( $this->id, $hideSettingsTabs ) ) ) {
88 if ( ( is_network_admin() && $this->args['network_admin'] ) || ( ! is_network_admin() && ! $this->args['network_admin'] ) ) {
89 $tabs[ $this->id ] = $this->name;
90 add_filter( 'tribe_settings_fields', array( $this, 'addFields' ) );
91 add_filter( 'tribe_settings_no_save_tabs', array( $this, 'showSaveTab' ) );
92 add_filter( 'tribe_settings_content_tab_' . $this->id, array( $this, 'doContent' ) );
93 }
94 }
95
96 return $tabs;
97 }
98
99 /**
100 * Adds this tab to the list of total tabs, even if it is not displayed.
101 *
102 * @param array $allTabs All the tabs from Tribe__Settings.
103 *
104 * @return array $allTabs All the tabs.
105 */
106 public function addAllTabs( $allTabs ) {
107 $allTabs[ $this->id ] = $this->name;
108
109 return $allTabs;
110 }
111
112
113 /**
114 * filters the fields array from Tribe__Settings
115 * and adds the current tab's fields to it
116 *
117 * @param array $field the $fields from Tribe__Settings
118 *
119 * @return array $fields the filtered fields
120 */
121 public function addFields( $fields ) {
122 if ( ! empty ( $this->fields ) ) {
123 $fields[ $this->id ] = $this->fields;
124 } elseif ( has_action( 'tribe_settings_content_tab_' . $this->id ) ) {
125 $fields[ $this->id ] = $this->fields = array( 0 => null ); // just to trick it
126 }
127
128 return $fields;
129 }
130
131 /**
132 * sets whether the current tab should show the save
133 * button or not
134 *
135 * @param array $noSaveTabs the $noSaveTabs from Tribe__Settings
136 *
137 * @return array $noSaveTabs the filtered non saving tabs
138 */
139 public function showSaveTab( $noSaveTabs ) {
140 if ( ! $this->show_save || empty( $this->fields ) ) {
141 $noSaveTabs[ $this->id ] = $this->id;
142 }
143
144 return $noSaveTabs;
145 }
146
147 /**
148 * displays the content for the tab
149 *
150 * @return void
151 */
152 public function doContent() {
153 if ( $this->display_callback && is_callable( $this->display_callback ) ) {
154 call_user_func( $this->display_callback );
155
156 return;
157 }
158
159 $sent_data = get_option( 'tribe_settings_sent_data', array() );
160
161 if ( is_array( $this->fields ) && ! empty( $this->fields ) ) {
162 foreach ( $this->fields as $key => $field ) {
163 if ( isset( $sent_data[ $key ] ) ) {
164 // if we just saved [or attempted to], get the value that was inputed
165 $value = $sent_data[ $key ];
166 } else {
167 // Some options should always be stored at network level
168 $network_option = isset( $field['network_option'] ) ? (bool) $field['network_option'] : false;
169
170 if ( is_network_admin() ) {
171 $parent_option = ( isset( $field['parent_option'] ) ) ? $field['parent_option'] : Tribe__Main::OPTIONNAMENETWORK;
172 }
173 if ( ! is_network_admin() ) {
174 $parent_option = ( isset( $field['parent_option'] ) ) ? $field['parent_option'] : Tribe__Main::OPTIONNAME;
175 }
176 // get the field's parent_option in order to later get the field's value
177 $parent_option = apply_filters( 'tribe_settings_do_content_parent_option', $parent_option, $key );
178 $default = ( isset( $field['default'] ) ) ? $field['default'] : null;
179 $default = apply_filters( 'tribe_settings_field_default', $default, $field );
180
181 if ( ! $parent_option ) {
182 // no parent option, get the straight up value
183 if ( $network_option || is_network_admin() ) {
184 $value = get_site_option( $key, $default );
185 } else {
186 $value = get_option( $key, $default );
187 }
188 } else {
189 // there's a parent option
190 if ( $parent_option == Tribe__Main::OPTIONNAME ) {
191 // get the options from Tribe__Settings_Manager if we're getting the main array
192 $value = Tribe__Settings_Manager::get_option( $key, $default );
193 } elseif ( $parent_option == Tribe__Main::OPTIONNAMENETWORK ) {
194 $value = Tribe__Settings_Manager::get_network_option( $key, $default );
195 } else {
196 // else, get the parent option normally
197 if ( is_network_admin() ) {
198 $options = (array) get_site_option( $parent_option );
199 } else {
200 $options = (array) get_option( $parent_option );
201 }
202 $value = ( isset( $options[ $key ] ) ) ? $options[ $key ] : $default;
203 }
204 }
205 }
206
207 // escape the value for display
208 if ( ! empty( $field['esc_display'] ) && function_exists( $field['esc_display'] ) ) {
209 $value = $field['esc_display']( $value );
210 } elseif ( is_string( $value ) ) {
211 $value = esc_attr( stripslashes( $value ) );
212 }
213
214 // filter the value
215 $value = apply_filters( 'tribe_settings_get_option_value_pre_display', $value, $key, $field );
216
217 // create the field
218 new Tribe__Field( $key, $field, $value );
219 }
220 } else {
221 // no fields setup for this tab yet
222 echo '<p>' . esc_html__( 'There are no fields setup for this tab yet.', 'tribe-common' ) . '</p>';
223 }
224 }
225
226 } // end class
227 } // endif class_exists
228