Multiple Themes - Version 7.0.1

Version Description

  • Fix Query Matching when Value is an Integer in Query Settings
Download this release

Release Info

Developer dgewirtz
Plugin Icon 128x128 Multiple Themes
Version 7.0.1
Comparing to
See all releases

Version 7.0.1

includes/admin-functions.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Exit if .php file accessed directly
4
+ */
5
+ if ( !defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ function jr_mt_messages( $message, $action = 'count' ) {
10
+ global $jr_mt_messages;
11
+ switch ( $action ) {
12
+ case 'display':
13
+ if ( isset( $jr_mt_messages ) ) {
14
+ foreach ( $jr_mt_messages as $echo => $count ) {
15
+ echo '<li>' . $echo;
16
+ if ( $count > 1 ) {
17
+ echo ' ('. $count . ' times)';
18
+ }
19
+ echo '</li>';
20
+ }
21
+ unset( $jr_mt_messages );
22
+ }
23
+ if ( empty( $message ) ) {
24
+ break;
25
+ }
26
+ /* Purposely let it fall through to output message,
27
+ after stored messages are output.
28
+ */
29
+ case 'immediate':
30
+ echo '<li>' . $message . '</li>';
31
+ break;
32
+ case 'count':
33
+ if ( isset( $jr_mt_messages[ $message ] ) ) {
34
+ ++$jr_mt_messages[ $message ];
35
+ } else {
36
+ $jr_mt_messages[ $message ] = 1;
37
+ }
38
+ break;
39
+ }
40
+ }
41
+
42
+ function jr_mt_theme_entry( $type, $theme = '', $display1 = NULL, $display2 = NULL ) {
43
+ $three_dots = '&#133;';
44
+ $before = '<li>Delete <input type="checkbox" id="del_entry" name="jr_mt_settings[del_entry][]" value="';
45
+ $after = '" /> &nbsp; ';
46
+ /* Fortunately, wp_get_theme() creates an Object if $theme does not exist,
47
+ complete with a Name entry that matches the folder name.
48
+
49
+ TODO: flag the situation of a non-existent Theme (i.e. - was deleted after entry was created)
50
+ */
51
+ $theme_equals = 'Theme=' . wp_get_theme( $theme )->Name . '; ';
52
+ switch ( $type ) {
53
+ case 'Query':
54
+ echo $before
55
+ . 'query'
56
+ . '='
57
+ . $display1
58
+ . '='
59
+ . $display2
60
+ . $after
61
+ . $theme_equals;
62
+ if ( '*' !== $display2 ) {
63
+ $settings = get_option( 'jr_mt_settings' );
64
+ $sticky = isset( $settings['remember']['query'][ $display1 ][ $display2 ] );
65
+ $override = isset( $settings['override']['query'][ $display1 ][ $display2 ] );
66
+ if ( $sticky ) {
67
+ if ( $override ) {
68
+ echo 'Sticky/Override ';
69
+ } else {
70
+ echo 'Sticky ';
71
+ }
72
+ } else {
73
+ if ( $override ) {
74
+ echo 'Override ';
75
+ }
76
+ }
77
+ }
78
+ echo 'Query='
79
+ . '<code>'
80
+ . JR_MT_HOME_URL
81
+ . "/</code>$three_dots<code>/?"
82
+ . '<b><input type="text" readonly="readonly" disable="disabled" name="jr_mt_delkw" value="'
83
+ . $display1
84
+ . '" size="'
85
+ . jr_mt_strlen( $display1 )
86
+ . '" /></b>'
87
+ . '=';
88
+ if ( '*' === $display2 ) {
89
+ echo '</code>' . $three_dots;
90
+ } else {
91
+ echo '<b><input type="text" readonly="readonly" disable="disabled" name="jr_mt_delkwval" value="'
92
+ . $display2
93
+ . '" size="'
94
+ . jr_mt_strlen( $display2 )
95
+ . '" /></b></code>';
96
+ }
97
+ break;
98
+ case 'url':
99
+ case 'url_prefix':
100
+ case 'url_asterisk':
101
+ echo $before
102
+ . $type
103
+ . '='
104
+ . 'url'
105
+ . '='
106
+ . $display1
107
+ . $after
108
+ . $theme_equals
109
+ . $display2
110
+ . '=<code>' . $display1 . '</code>';
111
+ break;
112
+ case 'wordpress':
113
+ echo '<li><a href="'
114
+ . get_admin_url()
115
+ . 'themes.php" class="button-primary">Change</a> &nbsp; '
116
+ . 'Theme='
117
+ . wp_get_theme()->Name
118
+ . ', the Theme chosen as Active from Appearance-Themes in the WordPress Admin panels';
119
+ break;
120
+ default:
121
+ echo $before
122
+ . $type
123
+ . $after
124
+ . $theme_equals
125
+ . $display1;
126
+ if ( 'site_home' === $type ) {
127
+ echo ' (<code>' . JR_MT_HOME_URL . '</code>) setting';
128
+ } else {
129
+ echo ' setting (see Advanced Settings tab)';
130
+ }
131
+ break;
132
+ }
133
+ echo '</li>';
134
+ }
135
+
136
+ // $theme_name is the name of the Theme's folder within the Theme directory
137
+ function jr_mt_themes_field( $field_name, $theme_name, $setting, $excl_current_theme ) {
138
+ echo "<select id='$field_name' name='$setting" . "[$field_name]' size='1'>";
139
+ if ( empty( $theme_name ) ) {
140
+ $selected = 'selected="selected"';
141
+ } else {
142
+ $selected = '';
143
+ }
144
+ echo "<option value='' $selected></option>";
145
+ foreach ( jr_mt_all_themes() as $folder => $theme_obj ) {
146
+ if ( $excl_current_theme ) {
147
+ if ( ( jr_mt_current_theme( 'stylesheet' ) == $theme_obj['stylesheet'] ) && ( jr_mt_current_theme( 'template' ) == $theme_obj['template'] ) ) {
148
+ // Skip the Current Theme
149
+ continue;
150
+ }
151
+ }
152
+ if ( $theme_name === $folder ) {
153
+ $selected = 'selected="selected"';
154
+ } else {
155
+ $selected = '';
156
+ }
157
+ $name = $theme_obj->Name;
158
+ echo "<option value='$folder' $selected>$name</option>";
159
+ }
160
+ echo '</select>' . PHP_EOL;
161
+ }
162
+
163
+ /**
164
+ * Update available for Plugin?
165
+ *
166
+ * @return bool - TRUE if an update is available in the WordPress Repository,
167
+ * FALSE if no update is available or if the update_plugins transient is not available
168
+ * (which also results in an error message).
169
+ **/
170
+ function jr_mt_plugin_update_available() {
171
+ global $jr_mt_update_plugins;
172
+ if ( !isset( $jr_mt_update_plugins ) ) {
173
+ $transient = get_site_transient( 'update_plugins' );
174
+ if ( FALSE === $transient ) {
175
+ // Error
176
+ return FALSE;
177
+ } else {
178
+ $jr_mt_update_plugins = $transient;
179
+ }
180
+ }
181
+ if ( empty( $jr_mt_update_plugins->response ) ) {
182
+ return FALSE;
183
+ }
184
+ return array_key_exists( jr_mt_plugin_basename(), $jr_mt_update_plugins->response );
185
+ }
186
+
187
+ /**
188
+ * Prepare URL Query Value
189
+ *
190
+ * Sanitize and standardize a URL Query Value for storage in a database.
191
+ * Does not support ?keyword[]=value, i.e. - $value cannot be an Array.
192
+ *
193
+ * @param string $value URL Query Value to be sanitized and standardized; will fail if array
194
+ * @return string URL Query Value after being sanitized and standardized
195
+ */
196
+ function jr_mt_prep_query_value( $value ) {
197
+ return str_ireplace( '%e2%80%8e', '', jr_mt_strtolower( trim( $value ) ) );
198
+ }
199
+ function jr_mt_prep_query_keyword( $keyword ) {
200
+ return jr_mt_prep_query_value( $keyword );
201
+ }
202
+
203
+ /**
204
+ * Sanitize a URL from a Text Form field intended for database storage
205
+ */
206
+ function jr_mt_sanitize_url( $url ) {
207
+ /* Handle troublesome %E2%80%8E UTF Left-to-right Mark (LRM) suffix first.
208
+ */
209
+ if ( FALSE === stripos( $url, '%E2%80%8E' ) ) {
210
+ if ( FALSE === stripos( rawurlencode( $url ), '%E2%80%8E' ) ) {
211
+ $clean_url = $url;
212
+ } else {
213
+ $clean_url = rawurldecode( str_ireplace( '%E2%80%8E', '', rawurlencode( $url ) ) );
214
+ }
215
+ } else {
216
+ $clean_url = str_ireplace( '%E2%80%8E', '', $url );
217
+ }
218
+ $clean_url = rawurldecode( trim( $clean_url ) );
219
+
220
+ return $clean_url;
221
+ }
222
+
223
+ /**
224
+ * Make URL Relative to Site URL
225
+ *
226
+ */
227
+ function jr_mt_relative_url( $url, $site_url ) {
228
+ $url_path_array = parse_url( $url );
229
+ $url_path = $url_path_array['path'];
230
+ if ( !empty( $url_path_array['query'] ) ) {
231
+ $url_path .= '?' . $url_path_array['query'];
232
+ }
233
+ $site_url_path = parse_url( $site_url, PHP_URL_PATH );
234
+ return trim( jr_mt_substr( $url_path, jr_mt_strlen( $site_url_path ) ), '/\\' );
235
+ }
236
+
237
+ function jr_mt_missing_rel_url( $settings, $relative_to_url ) {
238
+ global $jr_mt_url_types;
239
+ foreach ( $jr_mt_url_types as $url_type ) {
240
+ if ( isset( $settings[ $url_type ] ) && is_array( $settings[ $url_type ] ) ) {
241
+ foreach ( $settings[ $url_type ] as $index => $url_array ) {
242
+ if ( !isset( $url_array['rel_url'] ) ) {
243
+ $settings[ $url_type ][ $index ]['rel_url'] = jr_mt_relative_url( $url_array['url'], $relative_to_url );
244
+ jr_mt_messages( 'Missing Relative URL added to URL setting' );
245
+ }
246
+ }
247
+ }
248
+ }
249
+ return $settings;
250
+ }
251
+
252
+ function jr_mt_rebuild_display_url( $settings, $old_site_url ) {
253
+ global $jr_mt_url_types;
254
+ foreach ( $jr_mt_url_types as $url_type ) {
255
+ if ( isset( $settings[ $url_type ] ) && is_array( $settings[ $url_type ] ) ) {
256
+ foreach ( $settings[ $url_type ] as $index => $url_array ) {
257
+ if ( !isset( $url_array['rel_url'] ) ) {
258
+ $settings[ $url_type ][ $index ]['rel_url'] = jr_mt_relative_url( $url_array['url'], $old_site_url );
259
+ }
260
+ $settings[ $url_type ][ $index ]['url'] = JR_MT_HOME_URL . '/' . $settings[ $url_type ][ $index ]['rel_url'];
261
+ }
262
+ } else {
263
+ $settings[ $url_type ] = array();
264
+ }
265
+ }
266
+ return $settings;
267
+ }
268
+
269
+ function jr_mt_rebuild_alias_home( $settings ) {
270
+ /* See if there is an Alias entry for the new Site URL.
271
+ If not, add one, and perhaps another with/without www.
272
+ */
273
+ $no_home = TRUE;
274
+ foreach ( $settings['aliases'] as $index => $alias ) {
275
+ if ( $settings['aliases'][ $index ]['home'] = jr_mt_same_url( $alias['prep'], JR_MT_HOME_URL ) ) {
276
+ $no_home = FALSE;
277
+ }
278
+ }
279
+ if ( $no_home ) {
280
+ $settings['aliases'] = array_merge( $settings['aliases'], jr_mt_init_aliases() );
281
+ }
282
+ return $settings;
283
+ }
284
+
285
+ function jr_mt_rebuild_prep( $settings ) {
286
+ /* Assumes that ['url'*] and ['aliases'] Settings have been checked,
287
+ so doesn't check if they exist and are array.
288
+ Be sure to do that if wrappering this function with get_ and update_option().
289
+ */
290
+ global $jr_mt_url_types;
291
+ foreach ( $jr_mt_url_types as $url_type ) {
292
+ foreach ( $settings[ $url_type ] as $url_key => $url_array ) {
293
+ $settings[ $url_type ][ $url_key ]['prep'] = array();
294
+ $rel_url = $url_array['rel_url'];
295
+ foreach ( $settings['aliases'] as $index => $alias ) {
296
+ $settings[ $url_type ][ $url_key ]['prep'][ $index ] = jr_mt_prep_url( $alias['url'] . '/' . $rel_url );
297
+ }
298
+ }
299
+ }
300
+ return $settings;
301
+ }
302
+
303
+ ?>
includes/admin-sections.php ADDED
@@ -0,0 +1,835 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Exit if .php file accessed directly
4
+ */
5
+ if ( !defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ /**
10
+ * Define the settings
11
+ *
12
+ * Everything to be stored and/or can be set by the user
13
+ *
14
+ */
15
+ function jr_mt_admin_init() {
16
+ $settings = get_option( 'jr_mt_settings' );
17
+ foreach ( array( 'query', 'url', 'url_prefix', 'url_asterisk' ) as $key ) {
18
+ if ( !empty( $settings[ $key ] ) ) {
19
+ DEFINE( 'JR_MT_LIST_SETTINGS', TRUE );
20
+ break;
21
+ }
22
+ }
23
+ if ( defined( 'JR_MT_LIST_SETTINGS' ) ) {
24
+ add_settings_section(
25
+ 'jr_mt_delete_settings_section',
26
+ 'Current Theme Selection Entries',
27
+ 'jr_mt_delete_settings_expl',
28
+ 'jr_mt_settings_page'
29
+ );
30
+ add_settings_field(
31
+ 'del_entry',
32
+ 'Theme Selection Entries:',
33
+ 'jr_mt_echo_delete_entry',
34
+ 'jr_mt_settings_page',
35
+ 'jr_mt_delete_settings_section'
36
+ );
37
+ }
38
+ add_settings_section(
39
+ 'jr_mt_site_home_section',
40
+ '<input name="jr_mt_settings[tab1]" type="submit" value="Save All Changes" class="button-primary" /></h3><h3>Site Home',
41
+ 'jr_mt_site_home_expl',
42
+ 'jr_mt_settings_page'
43
+ );
44
+ add_settings_field(
45
+ 'site_home',
46
+ 'Select Theme for Site Home<br /><code>' . JR_MT_HOME_URL . '</code>',
47
+ 'jr_mt_echo_site_home',
48
+ 'jr_mt_settings_page',
49
+ 'jr_mt_site_home_section'
50
+ );
51
+ add_settings_section(
52
+ 'jr_mt_single_settings_section',
53
+ 'For An Individual Page, Post or other non-Admin page;<br />or a group of pages, specified by URL Prefix, optionally with Asterisk(s)',
54
+ 'jr_mt_single_settings_expl',
55
+ 'jr_mt_settings_page'
56
+ );
57
+ add_settings_field( 'add_is_prefix', 'Select here if URL is a Prefix', 'jr_mt_echo_add_is_prefix', 'jr_mt_settings_page', 'jr_mt_single_settings_section' );
58
+ add_settings_field( 'add_theme', 'Theme', 'jr_mt_echo_add_theme', 'jr_mt_settings_page', 'jr_mt_single_settings_section' );
59
+ add_settings_field( 'add_path_id', 'URL of Page, Post, Prefix or other', 'jr_mt_echo_add_path_id', 'jr_mt_settings_page', 'jr_mt_single_settings_section' );
60
+ add_settings_section( 'jr_mt_querykw_section',
61
+ 'For A Query Keyword on any Page, Post or other non-Admin page',
62
+ 'jr_mt_querykw_expl',
63
+ 'jr_mt_settings_page'
64
+ );
65
+ add_settings_field( 'add_querykw_theme', 'Theme', 'jr_mt_echo_add_querykw_theme', 'jr_mt_settings_page', 'jr_mt_querykw_section' );
66
+ add_settings_field( 'add_querykw_keyword', 'Query Keyword', 'jr_mt_echo_add_querykw_keyword', 'jr_mt_settings_page', 'jr_mt_querykw_section' );
67
+ add_settings_section( 'jr_mt_query_section',
68
+ 'For A Query Keyword=Value on any Page, Post or other non-Admin page',
69
+ 'jr_mt_query_expl',
70
+ 'jr_mt_settings_page'
71
+ );
72
+ add_settings_field( 'add_query_theme', 'Theme', 'jr_mt_echo_add_query_theme', 'jr_mt_settings_page', 'jr_mt_query_section' );
73
+ add_settings_field( 'add_query_keyword', 'Query Keyword', 'jr_mt_echo_add_query_keyword', 'jr_mt_settings_page', 'jr_mt_query_section' );
74
+ add_settings_field( 'add_query_value', 'Query Value', 'jr_mt_echo_add_query_value', 'jr_mt_settings_page', 'jr_mt_query_section' );
75
+ add_settings_section( 'jr_mt_aliases_section',
76
+ '<input name="jr_mt_settings[tab1]" type="submit" value="Save All Changes" class="button-primary" /></h3></div><div id="jr-mt-settings2" style="display: none;"><h3>Site Aliases used in URLs to Access This WordPress Site',
77
+ 'jr_mt_aliases_expl',
78
+ 'jr_mt_settings_page'
79
+ );
80
+ /* There is always an entry for the Site URL ("Home").
81
+ */
82
+ if ( count( $settings['aliases'] ) > 1 ) {
83
+ add_settings_section(
84
+ 'jr_mt_delete_aliases_section',
85
+ 'Current Site Alias Entries',
86
+ 'jr_mt_delete_aliases_expl',
87
+ 'jr_mt_settings_page'
88
+ );
89
+ add_settings_field(
90
+ 'del_alias_entry',
91
+ 'Site Alias Entries:',
92
+ 'jr_mt_echo_delete_alias_entry',
93
+ 'jr_mt_settings_page',
94
+ 'jr_mt_delete_aliases_section'
95
+ );
96
+ }
97
+ add_settings_section(
98
+ 'jr_mt_create_alias_section',
99
+ 'Create New Site Alias Entry',
100
+ 'jr_mt_create_alias_expl',
101
+ 'jr_mt_settings_page'
102
+ );
103
+ add_settings_field(
104
+ 'add_alias',
105
+ 'Site Alias',
106
+ 'jr_mt_echo_add_alias',
107
+ 'jr_mt_settings_page',
108
+ 'jr_mt_create_alias_section'
109
+ );
110
+ add_settings_section( 'jr_mt_sticky_section',
111
+ '<input name="jr_mt_settings[tab2]" type="submit" value="Save All Changes" class="button-primary" /></h3></div><div id="jr-mt-settings3" style="display: none;"><h3>Advanced Settings</h3><p><b>Warning:</b> As the name of this section implies, Advanced Settings should be fully understood or they may surprise you with unintended consequences, so please be careful.</p><h3>Sticky and Override',
112
+ 'jr_mt_sticky_expl',
113
+ 'jr_mt_settings_page'
114
+ );
115
+ add_settings_field( 'query_present', 'When to add Sticky Query to a URL', 'jr_mt_echo_query_present', 'jr_mt_settings_page', 'jr_mt_sticky_section' );
116
+ add_settings_field( 'sticky_query', 'Keyword=Value Entries:', 'jr_mt_echo_sticky_query_entry', 'jr_mt_settings_page', 'jr_mt_sticky_section' );
117
+ add_settings_section( 'jr_mt_everything_section',
118
+ 'Theme for Everything',
119
+ 'jr_mt_everything_expl',
120
+ 'jr_mt_settings_page'
121
+ );
122
+ add_settings_field( 'current',
123
+ 'Select Theme for Everything, to Override WordPress Current Theme (<b>' . wp_get_theme()->Name . '</b>)',
124
+ 'jr_mt_echo_current',
125
+ 'jr_mt_settings_page',
126
+ 'jr_mt_everything_section'
127
+ );
128
+ add_settings_section( 'jr_mt_all_settings_section',
129
+ 'For All Pages and/or All Posts',
130
+ 'jr_mt_all_settings_expl',
131
+ 'jr_mt_settings_page'
132
+ );
133
+ $suffix = array(
134
+ 'Pages' => '<br />(Pages created with Add Page)',
135
+ 'Posts' => ''
136
+ );
137
+ foreach ( array( 'Pages', 'Posts' ) as $thing ) {
138
+ add_settings_field( 'all_' . jr_mt_strtolower( $thing ), "Select Theme for All $thing" . $suffix[$thing], 'jr_mt_echo_all_things', 'jr_mt_settings_page', 'jr_mt_all_settings_section',
139
+ array( 'thing' => $thing ) );
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Section text for Section1
145
+ *
146
+ * Display an explanation of this Section
147
+ *
148
+ */
149
+ function jr_mt_delete_settings_expl() {
150
+ if ( defined( 'JR_MT_LIST_SETTINGS' ) ) {
151
+ ?>
152
+ <p>
153
+ All Theme Selection entries are displayed below,
154
+ in the exact order in which they will be processed.
155
+ For example,
156
+ if a match is made with the first Entry,
157
+ the first Entry's Theme will be used,
158
+ no matter what Theme the Second and subsequent Entries specify.
159
+ </p>
160
+ <p>
161
+ You can delete any of these entries by filling in the check box beside the entry
162
+ and clicking any of the <b>Save All Changes</b> buttons.
163
+ To change the Theme for an entry,
164
+ you will need to delete the entry
165
+ and add the same entry with a different Theme in the relevant section
166
+ on this or the Advanced Settings tab.
167
+ </p>
168
+ <p>
169
+ To add or remove (or to learn about) the Sticky or Override setting for a Query,
170
+ see the Advanced Settings tab.
171
+ </p>
172
+ <?php
173
+ }
174
+ }
175
+
176
+ function jr_mt_echo_delete_entry() {
177
+ echo 'In order of Selection:<ol>';
178
+ $settings = get_option( 'jr_mt_settings' );
179
+ /* Display any Override entries first,
180
+ because they have the highest priority.
181
+ */
182
+ foreach ( $settings['override']['query'] as $override_keyword => $override_value_array ) {
183
+ foreach ( $override_value_array as $override_value => $bool ) {
184
+ jr_mt_theme_entry(
185
+ 'Query',
186
+ wp_get_theme( $settings['query'][ $override_keyword ][ $override_value ] )->Name,
187
+ $override_keyword,
188
+ $override_value
189
+ );
190
+ }
191
+ }
192
+ /* Display Non-Overrides:
193
+ first, keyword=value query in URL with matching setting entry.
194
+ */
195
+ foreach ( $settings['query'] as $keyword => $value_array ) {
196
+ foreach ( $value_array as $value => $theme ) {
197
+ /* Wildcard Keyword=* entries come later
198
+ */
199
+ if ( '*' !== $value ) {
200
+ if ( !isset( $settings['override']['query'][ $keyword ][ $value ] ) ) {
201
+ jr_mt_theme_entry(
202
+ 'Query',
203
+ wp_get_theme( $theme )->Name,
204
+ $keyword,
205
+ $value
206
+ );
207
+ }
208
+ }
209
+ }
210
+ }
211
+ /* Display Non-Overrides:
212
+ second, wildcard keyword=* query in URL with matching setting entry.
213
+ */
214
+ foreach ( $settings['query'] as $keyword => $value_array ) {
215
+ foreach ( $value_array as $value => $theme ) {
216
+ /* Wildcard Keyword=* entries
217
+ Overrides are not allowed, so no need to check.
218
+ */
219
+ if ( '*' === $value ) {
220
+ jr_mt_theme_entry(
221
+ 'Query',
222
+ wp_get_theme( $theme )->Name,
223
+ $keyword,
224
+ '*'
225
+ );
226
+ }
227
+ }
228
+ }
229
+ /* Display URL entries:
230
+ first, exact match URL entries;
231
+ second, prefix URL entries;
232
+ then, prefix URL entries with asterisk wildcards.
233
+ */
234
+ foreach ( array(
235
+ 'url' => 'URL',
236
+ 'url_prefix' => 'URL Prefix',
237
+ 'url_asterisk' => 'URL Prefix*'
238
+ ) as $key => $description ) {
239
+ foreach ( $settings[ $key ] as $settings_array ) {
240
+ jr_mt_theme_entry(
241
+ $key,
242
+ wp_get_theme( $settings_array['theme'] )->Name,
243
+ $settings_array['url'],
244
+ $description
245
+ );
246
+ }
247
+ }
248
+ /* Home Entry, then All Posts and Pages, and Everything Else
249
+ */
250
+ foreach ( array(
251
+ 'site_home' => 'Home',
252
+ 'all_posts' => 'All Posts',
253
+ 'all_pages' => 'All Pages',
254
+ 'current' => 'Everything Else'
255
+ ) as $key => $description ) {
256
+ if ( '' !== $settings[ $key ] ) {
257
+ jr_mt_theme_entry(
258
+ $key,
259
+ wp_get_theme( $settings[ $key ] )->Name,
260
+ $description
261
+ );
262
+ }
263
+ }
264
+ if ( '' === $settings['current'] ) {
265
+ jr_mt_theme_entry(
266
+ 'wordpress'
267
+ );
268
+ }
269
+ echo '</ol>';
270
+ }
271
+
272
+ /**
273
+ * Section text for Section2
274
+ *
275
+ * Display an explanation of this Section
276
+ *
277
+ */
278
+ function jr_mt_site_home_expl() {
279
+ ?>
280
+ <p>
281
+ In this section, you can select a different Theme for Site Home.
282
+ To remove a previously selected Theme, select the blank entry from the drop-down list.
283
+ </p>
284
+ <p>
285
+ In the <i>next</i> section, you will be able to select a Theme, including the Current Theme, for individual Pages, Posts or
286
+ any other non-Admin pages that have their own Permalink; for example, specific Archive or Category pages.
287
+ Or groups of Pages, Posts or any other non-Admin pages that share the same URL Prefix.
288
+ </p>
289
+ <p>
290
+ There is also a Query Keyword section
291
+ farther down this Settings page
292
+ that allows
293
+ you to select a Theme to use whenever a specified
294
+ Query Keyword (<code>?keyword=value</code> or <code>&keyword=value</code>)
295
+ appears in the URL of any Page, Post or other non-Admin page.
296
+ Query entries will even override the Site Home entry,
297
+ if the Query Keyword follows the Site Home URL.
298
+ </p>
299
+ <?php
300
+ }
301
+
302
+ function jr_mt_echo_site_home() {
303
+ $settings = get_option( 'jr_mt_settings' );
304
+ jr_mt_themes_field( 'site_home', $settings['site_home'], 'jr_mt_settings', FALSE );
305
+ }
306
+
307
+ /**
308
+ * Section text for Section3
309
+ *
310
+ * Display an explanation of this Section
311
+ *
312
+ */
313
+ function jr_mt_single_settings_expl() {
314
+ ?>
315
+ <p>
316
+ Select a Theme for an individual Page, Post or
317
+ any other non-Admin page that has its own Permalink; for example, a specific Archive or Category page.
318
+ Or for a group of pages which have URLs that all begin with the same characters ("Prefix"),
319
+ optionally specifying an Asterisk ("*") to match all subdirectories at specific levels.
320
+ </p>
321
+ <p>
322
+ Then cut and paste the URL of the desired Page, Post, Prefix or other non-Admin page.
323
+ And click any of the <b>Save All Changes</b> buttons to add the entry.
324
+ </p>
325
+ There are three types of Entries that you can specify here:
326
+ <ol>
327
+ <li>
328
+ <b>URL</b> - if Visitor URL matches this URL, use this Theme
329
+ </li>
330
+ <li>
331
+ <b>URL Prefix</b> - any Visitor URL that begins with this URL Prefix will use this Theme
332
+ </li>
333
+ <li>
334
+ <b>URL Prefix with Asterisk(s)</b> - URL Prefix that matches any subdirectory where Asterisk ("*") is specified
335
+ </li>
336
+ </ol>
337
+ For the third type, an Asterisk can only be specified to match the entire subdirectory name, not parts of the name:
338
+ <blockquote>
339
+ For example, using a Permalink structure that uses dates,
340
+ where a typical Post might be at URL
341
+ <code>http://example.com/wp/2014/04/13/daily-thoughts/</code>,
342
+ a URL Prefix with Asterisk entry of
343
+ <code>http://example.com/wp/*/04/*/d</code>
344
+ would match all April Posts with Titles that begin with the letter "d", no matter what year they were posted.
345
+ </blockquote>
346
+ </p>
347
+ </p>
348
+ Beginning with Version 5.0, <code>keyword=value</code> Queries are now supported in all URLs
349
+ (on this Settings tab;
350
+ Site Aliases may not include Queries).
351
+ </p>
352
+ <?php
353
+ }
354
+
355
+ function jr_mt_echo_add_is_prefix() {
356
+ echo '<input type="radio" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="false" checked="checked" /> URL';
357
+ ?>
358
+ <br/>
359
+ <input type="radio" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="prefix" /> URL Prefix<br/>
360
+ <input type="radio" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="*" /> URL Prefix with Asterisk ("*")
361
+ <?php
362
+ }
363
+
364
+ function jr_mt_echo_add_theme() {
365
+ jr_mt_themes_field( 'add_theme', '', 'jr_mt_settings', FALSE );
366
+ }
367
+
368
+ function jr_mt_echo_add_path_id() {
369
+ ?>
370
+ <input id="add_path_id" name="jr_mt_settings[add_path_id]" type="text" size="75" maxlength="256" value="" />
371
+ <br />
372
+ &nbsp;
373
+ (cut and paste URL here of Page, Post, Prefix or other)
374
+ <br />
375
+ &nbsp;
376
+ URL must begin with
377
+ the current
378
+ <a href="options-general.php">Site Address (URL)</a>:
379
+ <?php
380
+ echo '<code>' . JR_MT_HOME_URL . '/</code>.';
381
+ }
382
+
383
+ /**
384
+ * Section text for Section4
385
+ *
386
+ * Display an explanation of this Section
387
+ *
388
+ */
389
+ function jr_mt_querykw_expl() {
390
+ ?>
391
+ <p>
392
+ Select a Theme to use
393
+ whenever the specified Query Keyword (<code>?keyword=</code> or <code>&keyword=</code>)
394
+ is found in the URL of
395
+ any Page, Post or
396
+ any other non-Admin page.
397
+ And click any of the <b>Save All Changes</b> buttons to add the entry.
398
+ </p>
399
+ <p>
400
+ <b>
401
+ Note
402
+ </b>
403
+ that Query Keyword takes precedence over all other types of Theme selection entries.
404
+ For example,
405
+ <?php
406
+ echo '<code>' . JR_MT_HOME_URL . '?firstname=dorothy</code>'
407
+ . ' would use the Theme specified for the <code>firstname</code> keyword, not the Theme specified for Site Home.'
408
+ . ' Query matching is case-insensitive, so all Keywords entered are stored in lower-case.</p>';
409
+ }
410
+ function jr_mt_echo_add_querykw_theme() {
411
+ jr_mt_themes_field( 'add_querykw_theme', '', 'jr_mt_settings', FALSE );
412
+ }
413
+ function jr_mt_echo_add_querykw_keyword() {
414
+ $three_dots = '&#133;';
415
+ echo '<code>'
416
+ . JR_MT_HOME_URL
417
+ . "/</code>$three_dots<code>/?"
418
+ . '<input id="add_querykw_keyword" name="jr_mt_settings[add_querykw_keyword]" type="text" size="20" maxlength="64" value="" />=</code>'
419
+ . $three_dots;
420
+ }
421
+
422
+ /**
423
+ * Section text for Section5
424
+ *
425
+ * Display an explanation of this Section
426
+ *
427
+ */
428
+ function jr_mt_query_expl() {
429
+ ?>
430
+ <p>
431
+ Select a Theme to use
432
+ whenever the specified Query Keyword <b>and</b> Value (<code>?keyword=value</code> or <code>&keyword=value</code>)
433
+ are found in the URL of
434
+ any Page, Post or
435
+ any other non-Admin page.
436
+ And click any of the <b>Save All Changes</b> buttons to add the entry.
437
+ </p>
438
+ <p>
439
+ <b>
440
+ Note
441
+ </b>
442
+ that Query Keyword=Value takes precedence over all other Theme selection entries,
443
+ including a Query Keyword entry for the same Keyword.
444
+ For example,
445
+ <?php
446
+ echo '<code>' . JR_MT_HOME_URL . '?firstname=dorothy</code>'
447
+ . ' would use the Theme specified for the <code>firstname=dorothy</code> keyword=value pair,'
448
+ . ' not the Theme specified for Site Home nor even the Theme specified for the Keyword <code>firstname</code>.'
449
+ . ' Query matching is case-insensitive, so all Keywords and Values entered are stored in lower-case.</p>';
450
+ }
451
+ function jr_mt_echo_add_query_theme() {
452
+ jr_mt_themes_field( 'add_query_theme', '', 'jr_mt_settings', FALSE );
453
+ }
454
+ function jr_mt_echo_add_query_keyword() {
455
+ $three_dots = '&#133;';
456
+ echo '<code>'
457
+ . JR_MT_HOME_URL
458
+ . "/</code>$three_dots<code>/?"
459
+ . '<input id="add_query_keyword" name="jr_mt_settings[add_query_keyword]" type="text" size="20" maxlength="64" value="" /></code>';
460
+ }
461
+ function jr_mt_echo_add_query_value() {
462
+ echo '<code>'
463
+ . '='
464
+ . '<input id="add_query_value" name="jr_mt_settings[add_query_value]" type="text" size="20" maxlength="64" value="" /></code>';
465
+ }
466
+
467
+ function jr_mt_aliases_expl() {
468
+ ?>
469
+ <p>
470
+ Define any
471
+ <b>
472
+ Site Aliases
473
+ </b>
474
+ that may be used to access your WordPress website.
475
+ </p>
476
+ <p>
477
+ This plugin uses the value of
478
+ <b>
479
+ Site Address (URL)
480
+ </b>
481
+ defined on the
482
+ <a href="options-general.php">
483
+ General Settings</a>
484
+ Admin panel
485
+ to match URLs against the Theme Selection settings.
486
+ By default, when the plugin is first installed,
487
+ or the value of Site Address changed,
488
+ a
489
+ <i>
490
+ www Alias Entry
491
+ </i>
492
+ is automatically defined
493
+ to handle the most common Alias used on WordPress sites:
494
+ by adding or removing the "www." prefix of the Domain Name.
495
+ </p>
496
+ <p>
497
+ If your WordPress website is accessed by
498
+ anything other than the Site Address or Site Aliases defined below,
499
+ this Plugin will always use the WordPress Active Theme defined on the
500
+ <a href="themes.php">
501
+ Appearance-Themes</a>
502
+ Admin panel.
503
+ </p>
504
+ <p>
505
+ Although by no means exhaustive,
506
+ this list can help you remember where you might have defined Aliases that need to be defined below.
507
+ </p>
508
+ <ul class="jrmtpoints">
509
+ <?php
510
+ if ( is_multisite() ) {
511
+ echo '<li><b>Mapped Domain</b>. Plugins such as <a href="https://wordpress.org/plugins/wordpress-mu-domain-mapping/">WordPress MU Domain Mapping</a> allow each Site in a WordPress Network to have its own Domain Name.</li>';
512
+ }
513
+ ?>
514
+ <li>
515
+ <b>IP Address</b>.
516
+ Most sites can be accessed by an IP address,
517
+ either the IPv4 format of four numbers separated by dots (168.1.0.1)
518
+ or the newer IPv6 format of several hexadecimal numbers separated by colons (2001:0DB8:AC10:FE01::).
519
+ </li>
520
+ <li>
521
+ <b>Parked Domain</b>.
522
+ example.com might have example.club as a Alias defined as a Parked Domain to your web host.
523
+ </li>
524
+ <li>
525
+ <b>ServerAlias</b> or equivalent.
526
+ Apache allows one or more Domain or Subdomain aliases to be defined with the SeverAlias directive;
527
+ non-Apache equivalents offer similar capabilities.
528
+ </li>
529
+ <li>
530
+ <b>Redirection</b>.
531
+ Most domain name registration and web hosting providers also offer a Redirection service.
532
+ Optionally, Redirection can be Masked (or not) to keep the redirected URL in the browser's address bar.
533
+ </li>
534
+ <li>
535
+ <b>.htaccess RewriteRule</b> or equivalent.
536
+ Each directory can contain a hidden file named
537
+ <code>.htaccess</code>.
538
+ These files may include RewriteRule statements that modify the URL
539
+ to change the URL of a site
540
+ as it appears in the Site Visitor's web browser address bar
541
+ from,
542
+ for example,
543
+ <code>http://example.com/wordpress</code>
544
+ to
545
+ <code>http://example.com</code>.
546
+ </li>
547
+ </ul>
548
+ <?php
549
+ }
550
+
551
+ function jr_mt_delete_aliases_expl() {
552
+ ?>
553
+ <p>
554
+ Here you can see,
555
+ and are able to delete,
556
+ any Site Aliases that have been created in the
557
+ Create New Sites Alias Entry section below,
558
+ or were created by default by this Plugin
559
+ for the current Site Address (URL) defined on the
560
+ <a href="options-general.php">General Settings</a>
561
+ Admin panel:
562
+ <?php
563
+ echo '<code>' . JR_MT_HOME_URL. '</code></p>';
564
+ }
565
+
566
+ function jr_mt_echo_delete_alias_entry() {
567
+ $settings = get_option( 'jr_mt_settings' );
568
+ echo '<p>In addition to the <a href="options-general.php">Site Address (URL)</a> <code>'
569
+ . JR_MT_HOME_URL
570
+ . '</code>, this Plugin will also control Themes for the following Site Aliases:</p><ol>';
571
+ foreach ( $settings['aliases'] as $array_index => $alias ) {
572
+ /* Do not allow the Site URL ("Home") alias to be deleted.
573
+ In fact, do not even display it.
574
+ */
575
+ if ( !$alias['home'] ) {
576
+ echo '<li>Delete <input type="checkbox" id="del_alias_entry" name="jr_mt_settings[del_alias_entry][]" value="'
577
+ . $array_index
578
+ . '"> <code>'
579
+ . $alias['url']
580
+ . '</code></li>';
581
+ }
582
+ }
583
+ echo '</ol>';
584
+ }
585
+
586
+ function jr_mt_create_alias_expl() {
587
+ echo '<p>To add another Site Alias, cut and paste its URL below.</p>';
588
+ }
589
+
590
+ function jr_mt_echo_add_alias() {
591
+ ?>
592
+ <input id="add_alias" name="jr_mt_settings[add_alias]" type="text" size="75" maxlength="256" value="" />
593
+ <br />
594
+ &nbsp;
595
+ (cut and paste URL of a new Site Alias here)
596
+ <br />
597
+ &nbsp;
598
+ URL must begin with
599
+ <code>http://</code>
600
+ or
601
+ <code>https://</code>
602
+ <?php
603
+ }
604
+
605
+ /**
606
+ * Section text for Section6
607
+ *
608
+ * Display an explanation of this Section
609
+ *
610
+ */
611
+ function jr_mt_sticky_expl() {
612
+ /* "Membership System V2" is a paid plugin that blocks (our sticky) Cookies
613
+ */
614
+ global $jr_mt_plugins_cache;
615
+ foreach ( $jr_mt_plugins_cache as $rel_path => $plugin_data ) {
616
+ if ( 0 === strncasecmp( 'memberium', $rel_path, 9 ) ) {
617
+ echo '<b><u>IMPORTANT</u></b>: The Sticky feature of this plugin does not work with the <b>Membership System V2</b> plugin, which blocks the required Cookies. At least one plugin from memberium.com appears to have been installed: '
618
+ . $plugin_data['Name'];
619
+ break;
620
+ }
621
+ }
622
+ ?>
623
+ <p>
624
+ If one of the
625
+ <b>
626
+ Keyword=Value Entries
627
+ </b>
628
+ shown below
629
+ (if any)
630
+ is present in the URL of a WordPress non-Admin webpage on the current WordPress Site
631
+ and that Entry is:
632
+ <ol>
633
+ <li>
634
+ <b>Sticky</b>,
635
+ then the specified Theme will continue to be displayed for subsequent
636
+ WordPress non-Admin webpages
637
+ viewed by the same Visitor
638
+ until an Override entry is encountered by the same Visitor.
639
+ </li>
640
+ <li>
641
+ <b>Override</b>,
642
+ then the specified Theme will be displayed,
643
+ effectively ending any previous Sticky Theme that was being displayed
644
+ for the same Visitor.
645
+ </li>
646
+ </ol>
647
+ <b>
648
+ Note
649
+ </b>
650
+ that,
651
+ as explained in the
652
+ Query Keyword=Value
653
+ section on the Settings tab,
654
+ Query Keyword=Value already takes precedence over all other Theme selection entries,
655
+ even without the Override checkbox selected.
656
+ Override is only intended to cancel a Sticky entry
657
+ and display the specified Theme on the current WordPress non-Admin webpage.
658
+ </p>
659
+ <p>
660
+ Implementation Notes:
661
+ <ol>
662
+ <li>
663
+ The term "Same Visitor",
664
+ used above,
665
+ refers to a single combination of
666
+ computer, browser and possibly computer user name,
667
+ if the visitor's computer has multiple accounts or user names.
668
+ A computer could be a smartphone, tablet, laptop, desktop or other Internet access device used by the Visitor.
669
+ </li>
670
+ <li>
671
+ When Sticky is active for a given Visitor,
672
+ the associated Query Keyword=Value is added to the
673
+ URL of links displayed on the current WordPress non-Admin webpage.
674
+ With the following exceptions:
675
+ <ul>
676
+ <li>
677
+ a)
678
+ Only links pointing to non-Admin webpages of the current WordPress Site are altered.
679
+ </li>
680
+ <li>
681
+ b)
682
+ The
683
+ "When to add Sticky Query to a URL"
684
+ setting below also controls when a Sticky Keyword=Value is added to a URL.
685
+ </li>
686
+ </ul>
687
+ <li>
688
+ Cookies are used for Sticky entries. If the visitor's browser refuses Cookies,
689
+ or another Plugin blocks cookies,
690
+ this setting will not work and no error messages will be displayed.
691
+ </li>
692
+ </ol>
693
+ </p>
694
+ <p>
695
+ <b>
696
+ Important:
697
+ </b>
698
+ the Sticky feature cannot be made to work in all WordPress environments.
699
+ Timing, Cookie and other issues may be caused by other plugins, themes and visitor browser settings,
700
+ so please test carefully and realize that the solution to some problems will involve a choice between not using the Sticky feature and not using a particular plugin or theme.
701
+ </p>
702
+ <?php
703
+ }
704
+
705
+ function jr_mt_echo_query_present() {
706
+ $settings = get_option( 'jr_mt_settings' );
707
+ /*
708
+ FALSE if Setting "Append if no question mark ("?") found in URL", or
709
+ TRUE if Setting "Append if no Override keyword=value found in URL"
710
+ */
711
+ echo '<input type="radio" id="query_present" name="jr_mt_settings[query_present]" value="false" ';
712
+ checked( $settings['query_present'], FALSE );
713
+ echo ' /> Append if no question mark ("?") found in URL<br/><input type="radio" id="query_present" name="jr_mt_settings[query_present]" value="true" ';
714
+ checked( $settings['query_present'] );
715
+ echo ' /> Append if no Override <code>keyword=value</code> found in URL';
716
+ }
717
+
718
+ function jr_mt_echo_sticky_query_entry() {
719
+ global $jr_mt_kwvalsep;
720
+ $settings = get_option( 'jr_mt_settings' );
721
+ $three_dots = '&#133;';
722
+ $first = TRUE;
723
+ if ( !empty( $settings['query'] ) ) {
724
+ foreach ( $settings['query'] as $keyword => $value_array ) {
725
+ foreach ( $value_array as $value => $theme ) {
726
+ if ( '*' !== $value ) {
727
+ if ( $first ) {
728
+ $first = FALSE;
729
+ } else {
730
+ echo '<br />';
731
+ }
732
+ echo 'Sticky <input type="checkbox" id="sticky_query_entry" name="jr_mt_settings[sticky_query_entry][]" value="'
733
+ . "$keyword$jr_mt_kwvalsep$value"
734
+ . '" ';
735
+ checked( isset( $settings['remember']['query'][$keyword][$value] ) );
736
+ echo ' /> &nbsp; Override <input type="checkbox" id="override_query_entry" name="jr_mt_settings[override_query_entry][]" value="'
737
+ . "$keyword$jr_mt_kwvalsep$value"
738
+ . '" ';
739
+ checked( isset( $settings['override']['query'][$keyword][$value] ) );
740
+ echo ' /> &nbsp; Theme='
741
+ . wp_get_theme( $theme )->Name . '; '
742
+ . 'Query='
743
+ . '<code>'
744
+ . JR_MT_HOME_URL
745
+ . "/</code>$three_dots<code>/?"
746
+ . "<b><input type='text' readonly='readonly' disable='disabled' name='jr_mt_stkw' value='$keyword' size='"
747
+ . jr_mt_strlen( $keyword )
748
+ . "' /></b>"
749
+ . '='
750
+ . "<b><input type='text' readonly='readonly' disable='disabled' name='jr_mt_stkwval' value='$value' size='"
751
+ . jr_mt_strlen( $value )
752
+ . "' /></b></code>";
753
+ }
754
+ }
755
+ }
756
+ }
757
+ if ( $first ) {
758
+ echo 'None';
759
+ }
760
+ }
761
+
762
+ function jr_mt_everything_expl() {
763
+ ?>
764
+ <p>
765
+ <b>Theme for Everything</b>
766
+ simplifies the use of a Theme with Theme Settings that you need to change frequently,
767
+ when the Theme is only going to be used on one or more Pages or Posts.
768
+ The Theme can be set as the WordPress Active Theme through the Appearance-Themes admin panel,
769
+ and set for specific Pages or Posts using this plugin's settings (on Settings tab),
770
+ with another Theme specified below as the plugin's default theme ("Theme for Everything").
771
+ </p>
772
+ <?php
773
+ }
774
+
775
+ function jr_mt_echo_current() {
776
+ $settings = get_option( 'jr_mt_settings' );
777
+ jr_mt_themes_field( 'current', $settings['current'], 'jr_mt_settings', TRUE );
778
+ echo '<br /> &nbsp; (select blank entry for default: WordPress Active Theme defined in Appearance-Themes, currently <b>' . wp_get_theme()->Name . '</b>)';
779
+ }
780
+
781
+ function jr_mt_all_settings_expl() {
782
+ ?>
783
+ <p>
784
+ These are
785
+ <b>
786
+ Advanced Setting
787
+ </b>
788
+ because they may not work with every other plugin, theme or permalinks setting.
789
+ This plugin is only able to determine whether what is about to be displayed at the current URL
790
+ is a Page or Post
791
+ after all other Plugins have been loaded;
792
+ the one exception to this is the Default setting for Permalinks,
793
+ when <code>?p=</code> and <code>?page_id=</code> are used.
794
+ </p>
795
+ <p>
796
+ Some other plugins and themes request the name of the current Theme
797
+ <i>
798
+ too early,
799
+ </i>
800
+ while they are being loaded,
801
+ which is before this plugin is able to determine if it is on a Page or Post.
802
+ For this reason,
803
+ using either of these settings may not work properly for all other plugins and themes.
804
+ As a result,
805
+ if you choose to use either or both of these two settings,
806
+ careful testing is advised immediately
807
+ <u>and</u>
808
+ whenever you change the Permalink setting, activate a plugin or start using a different theme.
809
+ </p>
810
+ <p>
811
+ In this section, you can select a different Theme for All Pages and/or All Posts.
812
+ To remove a previously selected Theme, select the blank entry from the drop-down list.
813
+ </p>
814
+ <p>
815
+ On the Settings tab, you were able to select a Theme, including WordPress' Active Theme, to override any choice you make here, for individual Pages, Posts or
816
+ any other non-Admin pages that have their own Permalink; for example, specific Archive or Category pages.
817
+ Or groups of Pages, Posts or any other non-Admin pages that share the same URL Prefix.
818
+ </p>
819
+ <p>
820
+ The Settings tab also has a Query Keyword section
821
+ that allows
822
+ you to select a Theme to use whenever a specified
823
+ Query Keyword (<code>?keyword=value</code> or <code>&keyword=value</code>)
824
+ appears in the URL of any Page, Post or other non-Admin page.
825
+ </p>
826
+ <?php
827
+ }
828
+
829
+ function jr_mt_echo_all_things( $thing ) {
830
+ $settings = get_option( 'jr_mt_settings' );
831
+ $field = 'all_' . jr_mt_strtolower( $thing['thing'] );
832
+ jr_mt_themes_field( $field, $settings[$field], 'jr_mt_settings', TRUE );
833
+ }
834
+
835
+ ?>
includes/admin-validate.php ADDED
@@ -0,0 +1,452 @@