Multiple Themes - Version 3.3

Version Description

  • Support Child Themes and any other situation where stylesheet and template names are not the same
Download this release

Release Info

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

Version 3.3

includes/admin.php ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Admin Page
3
+
4
+ add_action( 'admin_menu', 'jr_mt_admin_hook' );
5
+
6
+ /**
7
+ * Add Admin Menu item for plugin
8
+ *
9
+ * Plugin needs its own Page in the Settings section of the Admin menu.
10
+ *
11
+ */
12
+ function jr_mt_admin_hook() {
13
+ // Add Settings Page for this Plugin
14
+ add_theme_page( 'jonradio Multiple Themes', 'Multiple Themes plugin', 'manage_options', 'jr_mt_settings', 'jr_mt_settings_page' );
15
+ add_options_page( 'jonradio Multiple Themes', 'Multiple Themes plugin', 'manage_options', 'jr_mt_settings', 'jr_mt_settings_page' );
16
+ }
17
+
18
+ /**
19
+ * Settings page for plugin
20
+ *
21
+ * Display and Process Settings page for this plugin.
22
+ *
23
+ */
24
+ function jr_mt_settings_page() {
25
+ echo '<div class="wrap">';
26
+ screen_icon( 'plugins' );
27
+ echo '<h2>jonradio Multiple Themes</h2>';
28
+
29
+ // Required because it is only called automatically for Admin Pages in the Settings section
30
+ settings_errors( 'jr_mt_settings' );
31
+
32
+ $theme = wp_get_theme()->Name;
33
+ global $jr_mt_options_cache;
34
+ ?>
35
+ <p>This plugin allows you to selectively change the Theme you have selected as your <b>Current Theme</b> in <b>Appearance-Themes</b> on the Admin panels.
36
+ You can choose from any of the <b>Available Themes</b> listed on the Appearance-Themes Admin panel for:
37
+ <ul>
38
+ <li> &raquo; All Pages</li>
39
+ <li> &raquo; All Posts</li>
40
+ <li> &raquo; The Site Home</li>
41
+ <li> &raquo; A Specific Page</li>
42
+ <li> &raquo; A Specific Post</li>
43
+ <li> &raquo; Any other non-Admin page that has its own Permalink; for example, a specific Archive or Category page</li>
44
+ </ul>
45
+ <?php
46
+ if ( function_exists('is_multisite') && is_multisite() ) {
47
+ echo "In a WordPress Network (AKA Multisite), Themes must be <b>Network Enabled</b> before they will appear as Available Themes on individual sites' Appearance-Themes panel.";
48
+ }
49
+ echo '</p>';
50
+ echo '<p>';
51
+ echo "The Current Theme is <b>$theme</b>. You will not normally need to specify it in any of the Settings on this page. The only exception would be if you specify a different Theme for All Pages or All Posts and wish to use the Current Theme for a specific Page, Post or other non-Admin page.";
52
+ echo '</p>';
53
+ echo '<form action="options.php" method="POST">';
54
+
55
+ // Plugin Settings are displayed and entered here:
56
+ settings_fields( 'jr_mt_settings' );
57
+ do_settings_sections( 'jr_mt_settings_page' );
58
+ echo '<p><input name="save" type="submit" value="Save Changes" class="button-primary" /></p></form>';
59
+ }
60
+
61
+ add_action( 'admin_init', 'jr_mt_admin_init' );
62
+
63
+ /**
64
+ * Register and define the settings
65
+ *
66
+ * Everything to be stored and/or can be set by the user
67
+ *
68
+ */
69
+ function jr_mt_admin_init() {
70
+ register_setting( 'jr_mt_settings', 'jr_mt_settings', 'jr_mt_validate_settings' );
71
+ add_settings_section( 'jr_mt_all_settings_section',
72
+ 'For All Pages, All Posts and/or Site Home',
73
+ 'jr_mt_all_settings_expl',
74
+ 'jr_mt_settings_page'
75
+ );
76
+ $suffix = array(
77
+ 'Pages' => '<br />(Pages created with Add Page)',
78
+ 'Posts' => ''
79
+ );
80
+ foreach ( array( 'Pages', 'Posts' ) as $thing ) {
81
+ add_settings_field( 'all_' . strtolower( $thing ), "Select Theme for All $thing" . $suffix[$thing], 'jr_mt_echo_all_things', 'jr_mt_settings_page', 'jr_mt_all_settings_section',
82
+ array( 'thing' => $thing ) );
83
+ }
84
+ add_settings_field( 'site_home',
85
+ 'Select Theme for Site Home<br />(' . get_home_url() . ')',
86
+ 'jr_mt_echo_site_home',
87
+ 'jr_mt_settings_page',
88
+ 'jr_mt_all_settings_section'
89
+ );
90
+ $settings = get_option( 'jr_mt_settings' );
91
+ $ids = $settings['ids'];
92
+ if ( !empty( $ids) ) {
93
+ add_settings_section( 'jr_mt_delete_settings_section',
94
+ 'To Display or Delete Theme Selections for Individual Pages or Posts',
95
+ 'jr_mt_delete_settings_expl',
96
+ 'jr_mt_settings_page'
97
+ );
98
+ add_settings_field( 'del_entry', 'Entries:', 'jr_mt_echo_delete_entry', 'jr_mt_settings_page', 'jr_mt_delete_settings_section' );
99
+ }
100
+ add_settings_section( 'jr_mt_single_settings_section',
101
+ 'For An Individual Page, Post or other non-Admin page',
102
+ 'jr_mt_single_settings_expl',
103
+ 'jr_mt_settings_page'
104
+ );
105
+ add_settings_field( 'add_theme', 'Theme', 'jr_mt_echo_add_theme', 'jr_mt_settings_page', 'jr_mt_single_settings_section' );
106
+ 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' );
107
+ 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' );
108
+ }
109
+
110
+ /**
111
+ * Section text for Section1
112
+ *
113
+ * Display an explanation of this Section
114
+ *
115
+ */
116
+ function jr_mt_all_settings_expl() {
117
+ ?>
118
+ <p>
119
+ In this section, you can select a different Theme for All Pages, All Posts and/or Site Home.
120
+ To remove a previously selected Theme, select the blank entry from the drop-down list.
121
+ </p>
122
+ <p>
123
+ In the <i>next</i> section, you will be able to select a Theme, including the Current Theme, to override any choice you make here, for individual Pages, Posts or
124
+ any other non-Admin pages that have their own Permalink; for example, specific Archive or Category pages.
125
+ </p>
126
+ <?php
127
+ }
128
+
129
+ function jr_mt_echo_all_things( $thing ) {
130
+ $settings = get_option( 'jr_mt_settings' );
131
+ $field = 'all_' . strtolower( $thing['thing'] );
132
+ jr_mt_themes_field( $field, $settings[$field], 'jr_mt_settings', TRUE );
133
+ }
134
+
135
+ function jr_mt_echo_site_home() {
136
+ $settings = get_option( 'jr_mt_settings' );
137
+ jr_mt_themes_field( 'site_home', $settings['site_home'], 'jr_mt_settings', FALSE );
138
+ }
139
+
140
+ /**
141
+ * Section text for Section2
142
+ *
143
+ * Display an explanation of this Section
144
+ *
145
+ */
146
+ function jr_mt_delete_settings_expl() {
147
+ ?>
148
+ <p>
149
+ In this section, all entries are displayed for Themes selected for individual Pages, Posts
150
+ and any other non-Admin pages that have their own Permalink; for example, specific Archive or Category pages.
151
+ </p>
152
+ <p>
153
+ You can delete any of these entries by filling in the check box beside each one.
154
+ To change the Theme for an entry, add the same entry with a different Theme in the section below this one.</p>
155
+ <?php
156
+ }
157
+
158
+ function jr_mt_echo_delete_entry() {
159
+ $entry_num = 0;
160
+ $settings = get_option( 'jr_mt_settings' );
161
+ foreach ( $settings['ids'] as $path_id => $opt_array ) {
162
+ ++$entry_num;
163
+ echo "Delete <input type='checkbox' id='del_entry' name='jr_mt_settings[del_entry][]' value='$path_id' /> &nbsp; Theme="
164
+ . wp_get_theme( $opt_array['theme'] )->Name . '; ';
165
+ if ( $path_id == '' ) {
166
+ echo 'Site=<a href="' . get_home_url() . '" target="_blank">Home</a>';
167
+ } else {
168
+ if ( $opt_array['type'] == 'prefix' ) {
169
+ echo 'Prefix=<a href="' . get_home_url() . "/$path_id" . '" target="_blank">' . "$path_id</a>";
170
+ } else {
171
+ if ( $opt_array['type'] == 'cat' ) {
172
+ echo 'Category=<a href="' . get_home_url() . '/?cat=' . $opt_array['id'] . '" target="_blank">' . get_cat_name( $opt_array['id'] ) . '</a>';
173
+ } else {
174
+ if ( $opt_array['type'] == 'archive' ) {
175
+ echo 'Archive=<a href="' . get_home_url() . '/?m=' . $opt_array['id'] . '" target="_blank">' . $opt_array['id'] . '</a>';
176
+ } else {
177
+ $p_array = get_posts( array( 'post_type' => 'any', 'include' => array( $path_id ) ) );
178
+ if ( empty( $p_array ) ) {
179
+ if ( $opt_array['type'] == 'admin' ) {
180
+ echo 'Admin=<a href="' . get_home_url() . '/' . $opt_array['rel_url'] . '" target="_blank">' . "$path_id</a>";
181
+ } else {
182
+ echo 'Path=<a href="' . get_home_url() . "/$path_id" . '" target="_blank">' . "$path_id</a>";
183
+ }
184
+ } else {
185
+ echo ucfirst( $p_array[0]->post_type ) . '=<a href="' . get_permalink( $path_id ) . '" target="_blank">' . $p_array[0]->post_title . '</a>';
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ echo '<br />';
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Section text for Section3
197
+ *
198
+ * Display an explanation of this Section
199
+ *
200
+ */
201
+ function jr_mt_single_settings_expl() {
202
+ ?>
203
+ <p>
204
+ Select a Theme for an individual Page, Post or
205
+ any other non-Admin pages that has its own Permalink; for example, a specific Archive or Category page.
206
+ <p>
207
+ </p>
208
+ Then cut and paste the URL of the desired Page, Post or other non-Admin page.
209
+ And click the <b>Save Changes</b> button to add the entry.
210
+ </p>
211
+ <?php
212
+ }
213
+
214
+ function jr_mt_echo_add_theme() {
215
+ jr_mt_themes_field( 'add_theme', '', 'jr_mt_settings', FALSE );
216
+ }
217
+
218
+ function jr_mt_echo_add_path_id() {
219
+ ?>
220
+ <input id="add_path_id" name="jr_mt_settings[add_path_id]" type="text" size="100" maxlength="256" value="" />
221
+ <br />
222
+ (cut and paste URL here of Page, Post, Prefix or other)
223
+ <br />
224
+ URL must begin with
225
+ <?php
226
+ echo trim( get_home_url(), '\ /' ) . '/';
227
+ }
228
+
229
+ function jr_mt_echo_add_is_prefix() {
230
+ ?>
231
+ <input type="checkbox" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="true" /> Anything that begins with this URL will use this Theme
232
+ <?php
233
+ }
234
+
235
+ function jr_mt_validate_settings( $input ) {
236
+ $valid = array();
237
+ foreach ( array( 'all_pages', 'all_posts', 'site_home' ) as $thing ) {
238
+ $valid[$thing] = $input[$thing];
239
+ }
240
+
241
+ $settings = get_option( 'jr_mt_settings' );
242
+ $ids = $settings['ids'];
243
+ if ( isset ( $input['del_entry'] ) ) {
244
+ foreach ( $input['del_entry'] as $del_entry ) {
245
+ unset( $ids[$del_entry] );
246
+ }
247
+ }
248
+
249
+ $url = trim( $input['add_path_id'] );
250
+ if ( ( empty( $input['add_theme'] ) && !empty( $url ) ) || ( !empty( $input['add_theme'] ) && empty( $url ) ) ) {
251
+ add_settings_error(
252
+ 'jr_mt_settings',
253
+ 'jr_mt_emptyerror',
254
+ 'Both URL and Theme must be specified to add an Individual entry',
255
+ 'error'
256
+ );
257
+ } else {
258
+ if ( !empty( $url ) ) {
259
+ $validate_url = jr_mt_site_url( $url );
260
+ if ( $validate_url === TRUE ) {
261
+ extract( jr_mt_url_to_id( $url ) );
262
+ if ( isset ( $input['add_is_prefix'] ) && ( $input['add_is_prefix'] == "true" ) ) {
263
+ if ( parse_url( $url, PHP_URL_QUERY ) === NULL ) {
264
+ $ids[$rel_url] = array(
265
+ 'theme' => $input['add_theme'],
266
+ 'type' => 'prefix',
267
+ 'id' => $id,
268
+ 'page_url' => $page_url,
269
+ 'rel_url' => $rel_url,
270
+ 'url' => $url
271
+ );
272
+ } else {
273
+ add_settings_error(
274
+ 'jr_mt_settings',
275
+ 'jr_mt_queryerror',
276
+ '?key=val&key=val Queries are not supported in a URL Prefix',
277
+ 'error'
278
+ );
279
+
280
+ }
281
+ } else {
282
+ if ( $home ) {
283
+ add_settings_error(
284
+ 'jr_mt_settings',
285
+ 'jr_mt_homeerror',
286
+ 'Please use "Select Theme for Site Home" field instead of specifying Site Home URL as an individual entry.',
287
+ 'error'
288
+ );
289
+ } else {
290
+ if ( $type == 'admin' ) {
291
+ add_settings_error(
292
+ 'jr_mt_settings',
293
+ 'jr_mt_adminerror',
294
+ 'Admin Page URLs are not allowed because no known Themes alter the appearance of Admin pages.',
295
+ 'error'
296
+ );
297
+ } else {
298
+ if ( $id === FALSE ) {
299
+ $key = $page_url;
300
+ } else {
301
+ $key = $id;
302
+ }
303
+ $ids[$key] = array(
304
+ 'theme' => $input['add_theme'],
305
+ 'type' => $type,
306
+ 'id' => $id,
307
+ 'page_url' => $page_url,
308
+ 'rel_url' => $rel_url,
309
+ 'url' => $url
310
+ );
311
+ }
312
+ }
313
+ }
314
+ } else {
315
+ add_settings_error(
316
+ 'jr_mt_settings',
317
+ 'jr_mt_urlerror',
318
+ "Invalid URL specified for Individual page/post: '$url'. $validate_url",
319
+ 'error'
320
+ );
321
+ }
322
+ }
323
+ }
324
+ $errors = get_settings_errors();
325
+ if ( empty( $errors ) ) {
326
+ add_settings_error(
327
+ 'jr_mt_settings',
328
+ 'jr_mt_saved',
329
+ 'Settings Saved',
330
+ 'updated'
331
+ );
332
+ }
333
+ $valid['ids'] = $ids;
334
+ return $valid;
335
+ }
336
+
337
+ // Add Link to the plugin's entry on the Admin "Plugins" Page, for easy access
338
+ global $jr_mt_plugin_basename;
339
+ add_filter( "plugin_action_links_$jr_mt_plugin_basename", 'jr_mt_plugin_action_links', 10, 1 );
340
+
341
+ /**
342
+ * Creates Settings entry right on the Plugins Page entry.
343
+ *
344
+ * Helps the user understand where to go immediately upon Activation of the Plugin
345
+ * by creating entries on the Plugins page, right beside Deactivate and Edit.
346
+ *
347
+ * @param array $links Existing links for our Plugin, supplied by WordPress
348
+ * @param string $file Name of Plugin currently being processed
349
+ * @return string $links Updated set of links for our Plugin
350
+ */
351
+ function jr_mt_plugin_action_links( $links ) {
352
+ // The "page=" query string value must be equal to the slug
353
+ // of the Settings admin page.
354
+ array_push( $links, '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=jr_mt_settings' . '">Settings</a>' );
355
+ return $links;
356
+ }
357
+
358
+ // $theme_name is the name of the Theme's folder within the Theme directory
359
+ function jr_mt_themes_field( $field_name, $theme_name, $setting, $excl_current_theme ) {
360
+ echo "<select id='$field_name' name='$setting" . "[$field_name]' size='1'>";
361
+ if ( empty( $theme_name ) ) {
362
+ $selected = 'selected="selected"';
363
+ } else {
364
+ $selected = '';
365
+ }
366
+ echo "<option value='' $selected></option>";
367
+ foreach ( wp_get_themes() as $folder => $theme_obj ) {
368
+ if ( $excl_current_theme ) {
369
+ if ( ( jr_mt_current_theme( 'stylesheet' ) == $theme_obj['stylesheet'] ) && ( jr_mt_current_theme( 'template' ) == $theme_obj['template'] ) ) {
370
+ // Skip the Current Theme
371
+ continue;
372
+ }
373
+ }
374
+ if ( $theme_name == $folder ) {
375
+ $selected = 'selected="selected"';
376
+ } else {
377
+ $selected = '';
378
+ }
379
+ $name = $theme_obj->Name;
380
+ echo "<option value='$folder' $selected>$name</option>";
381
+ }
382
+ echo '</select>' . PHP_EOL;
383
+ }
384
+
385
+ ?>
includes/debug/debug.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* require_once( jr_mt_path() . 'includes/debug/debug.php' );
3
+ jr_dump( 'jr_mt_validate_settings $input', $input );
4
+ */
5
+
6
+ function jr_dump( $comment, $dump_var ) {
7
+ $file_name = 'jonradio-dump.txt';
8
+
9
+ $header = '***' . current_time('mysql') . ': ' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
10
+ ob_start();;
11
+ echo "$comment: ";
12
+ var_dump( $dump_var );
13
+ $output = ob_get_clean() . jr_dump_env();
14
+ if ( function_exists('is_multisite') && is_multisite() ) {
15
+ global $site_id, $blog_id;
16
+ $file_name = $site_id . '-' . $blog_id . '-' . $file_name;
17
+ }
18
+ $file = fopen( plugin_dir_path( __FILE__ ) . $file_name, 'at' );
19
+ fwrite( $file, $header . PHP_EOL . $output );
20
+ fclose( $file );
21
+
22
+ return;
23
+ }
24
+
25
+ function jr_dump_env() {
26
+ global $jr_dump_env_first;
27
+ if ( isset( $jr_dump_env_first ) ) {
28
+ $output = '';
29
+ } else {
30
+ $jr_dump_env_first = FALSE;
31
+ $output = PHP_EOL;
32
+
33
+ }
34
+ return $output;
35
+ }
36
+ ?>
includes/functions.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Return WordPress Current Theme, as defined in Appearance Admin panels
4
+ *
5
+ * Obtains Folder Name of Current Theme, from 'template' option of wp_load_alloptions().
6
+ *
7
+ * @param string $option parameter to select current template or stylesheet
8
+ * @return string type Folder Name of Current Theme
9
+ */
10
+ function jr_mt_current_theme( $option ) {
11
+ global $jr_mt_options_cache;
12
+ return $jr_mt_options_cache[$option];
13
+ }
14
+
15
+ /**
16
+ * Given URL, return post or page ID, if possible, and relative path if not
17
+ *
18
+ * Calls jr_mt_query_keywords.
19
+ *
20
+ * @param string $url full URL of WordPress page, post, admin, etc.
21
+ * @return array array with keys of "type", "id" and "page_url":
22
+ * string type "pages", "posts" or "admin"
23
+ * string id Page ID or Post ID or FALSE
24
+ * string page_url relative URL WordPress page, post, admin, etc. or FALSE
25
+ * string rel_url URL relative to WordPress home
26
+ * bool home is URL Site Home?
27
+ */
28
+ function jr_mt_url_to_id( $url_orig ) {
29
+ // Some hosts, likely only IIS, insert an erroneous "/index.php" into the middle of the Permalink in $_SERVER['REQUEST_URI']
30
+ $url = str_replace( '/index.php', '', $url_orig );
31
+
32
+ $trim = '\ /'; // remove leading and trailing backslashes, blanks and forward slashes
33
+
34
+ $is_home = FALSE;
35
+
36
+ // get_home_url() returns "https://subdomain.domain.com/wp" - the full URL of the home page of the site
37
+ $home = trim( parse_url( get_home_url(), PHP_URL_PATH ), $trim ); // "wp"
38
+
39
+ $admin_home = trim( parse_url( admin_url(), PHP_URL_PATH ), $trim );
40
+ $page_url = trim( parse_url( $url, PHP_URL_PATH ), $trim ); // "wp/fruit/apples"
41
+ $is_admin = ( $admin_home == substr( $page_url, 0, strlen( $admin_home ) ) );
42
+ if ( !empty( $home ) ) { // Only if WordPress is installed in a subfolder, NOT in the Root
43
+ $page_url = trim( substr( $page_url, stripos( $page_url, $home ) + strlen( $home ) ), $trim ); // "fruit/apples"
44
+ }
45
+ $rel_url = $page_url;
46
+
47
+ $type = FALSE;
48
+
49
+ $id = jr_mt_query_keywords( parse_url( $url, PHP_URL_QUERY ) );
50
+ if ( $id === NULL ) {
51
+ if ( $is_admin ) {
52
+ $id = FALSE;
53
+ $type = 'admin';
54
+ } else {
55
+ // Check for home page (get_page_by_path() does not work for home page)
56
+ if ( empty( $page_url ) ) {
57
+ $is_home = TRUE;
58
+ $id = get_option('page_on_front');
59
+ if ( $id == 0 ) {
60
+ // There is no home Page; posts are displayed instead on the home page
61
+ $page_url = '';
62
+ $id = FALSE;
63
+ } else {
64
+ $type = 'pages';
65
+ }
66
+ } else {
67
+ $page = get_page_by_path( $page_url );
68
+ if ( $page === NULL ) {
69
+ // get_page_by_path() returns NULL for Posts, Home Page, Admin, etc.
70
+ // So, check for Posts:
71
+ $post = get_posts( array( 'name' => $page_url ) );
72
+ if ( empty( $post ) ) {
73
+ $id = FALSE;
74
+ } else {
75
+ $id = $post[0]->ID;
76
+ $type = 'posts';
77
+ }
78
+ } else {
79
+ $id = $page->ID;
80
+ $type = 'pages';
81
+ }
82
+ }
83
+ }
84
+ } else {
85
+ // id in query of URL (?keyword=value&keyword=value)
86
+ $type = key( $id );
87
+ $id = $id[$type];
88
+ $page_url = FALSE;
89
+ }
90
+ return array(
91
+ 'type' => $type,
92
+ 'id' => $id,
93
+ 'page_url' => $page_url,
94
+ 'rel_url' => $rel_url,
95
+ 'home' => $is_home
96
+ );
97
+ }
98
+
99
+ /**
100
+ * Return page_id= or p= (post ID) or page= (admin page) value from a URL
101
+ *
102
+ * Calls parse_str function in its own variable space because it could create virtually any variable name!
103
+ * Only looks at page_id=, p= and page= now, but could be expanded to other query keywords.
104
+ *
105
+ * @param string $url_query Query portion (after the ?) in a URL
106
+ * @return var array with key of "pages", "posts" or "admin" and value of page_id=, p= or page=, respectively; or NULL if none are present
107
+ */
108
+ function jr_mt_query_keywords( $url_query ) {
109
+ if ( $url_query === NULL ) {
110
+ return NULL;
111
+ } else {
112
+ parse_str( $url_query );
113
+ if ( isset( $page_id ) ) {
114
+ return array( 'pages' => $page_id );
115
+ } else {
116
+ if ( isset( $p ) ) {
117
+ return array( 'posts' => $p );
118
+ } else {
119
+ if ( isset( $page ) ) {
120
+ return array( 'admin' => $page );
121
+ } else {
122
+ if ( isset( $cat ) ) {
123
+ return array( 'cat' => $cat );
124
+ } else {
125
+ if ( isset( $m ) ) {
126
+ return array( 'archive' => $m );
127
+ } else {
128
+ return NULL;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Is the URL on the current WordPress web site?
139
+ *
140
+ * Checks if URL begins with Site Home URL.
141
+ *
142
+ * @param string $url URL to be checked to be sure it is "on" the current WordPress web site
143
+ * @return var bool TRUE if URL on current WordPress web site; string error message otherwise
144
+ */
145
+ function jr_mt_site_url( $url ) {
146
+ $check_url = trim( $url );
147
+ if ( strcasecmp( 'http', substr( $check_url, 0, 4 ) ) != 0 ) {
148
+ return 'URL does not begin with http://';
149
+ }
150
+ $site_home = get_home_url();
151
+ if ( strcasecmp( $site_home, substr( $check_url, 0, strlen( $site_home ) ) ) != 0 ) {
152
+ return "URL specified is not part of current WordPress web site. URL must begin with '$site_home'";
153
+ }
154
+ return TRUE;
155
+ }
156
+ ?>
includes/select-theme.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Select the relevant Theme
3
+
4
+ add_filter( 'pre_option_stylesheet', 'jr_mt_stylesheet' );
5
+ add_filter( 'pre_option_template', 'jr_mt_template' );
6
+
7
+ function jr_mt_stylesheet() {
8
+ return jr_mt_theme( 'stylesheet' );
9
+ }
10
+
11
+ function jr_mt_template() {
12
+ return jr_mt_theme( 'template' );
13
+ }
14
+
15
+ function jr_mt_theme( $option ) {
16
+ /* The hooks that (indirectly) call this function are called repeatedly by WordPress,
17
+ so do the checking once and store the values in a global array.
18
+ $jt_mt_theme['stylesheet'] - Stylesheet Name of Theme chosen
19
+ $jt_mt_theme['template'] - Template Name of Theme chosen
20
+
21
+ Very important note:
22
+ - get_option( 'jr_mt_settings' ) ['ids']['theme'] is the Theme Subdirectory Name,
23
+ as opposed to the Template or Stylesheet Name for the Theme.
24
+ - likewise, the variable local variable $theme
25
+ These three different values for each Theme must be clearly separated, as all three usually
26
+ match, but do not have to, e.g. - Child Themes.
27
+ */
28
+ global $jr_mt_theme;
29
+ if ( !isset( $jr_mt_theme ) ) {
30
+ $jr_mt_theme = array();
31
+ }
32
+ if ( !isset( $jr_mt_theme[$option] ) ) {
33
+ $theme = jr_mt_chosen();
34
+ if ( $theme === FALSE ) {
35
+ // Get both at once, to save a repeat of this logic later:
36
+ $jr_mt_theme['stylesheet'] = jr_mt_current_theme( 'stylesheet' );
37
+ $jr_mt_theme['template'] = jr_mt_current_theme( 'template' );
38
+ } else {
39
+ $themes = wp_get_themes();
40
+ $jr_mt_theme['stylesheet'] = $themes[$theme]->stylesheet;
41
+ $jr_mt_theme['template'] = $themes[$theme]->template;
42
+ }
43
+ }
44
+ return $jr_mt_theme[$option];
45
+ }
46
+
47
+ // Returns FALSE for Current Theme
48
+ function jr_mt_chosen() {
49
+ if ( is_admin() ) {
50
+ // Admin panel
51
+ // return P2 theme if p2ajax= is present; current theme otherwise
52
+ parse_str( $_SERVER['QUERY_STRING'], $keywords );
53
+ if ( isset( $keywords['p2ajax'] ) && array_key_exists( 'p2', wp_get_themes() ) ) {
54
+ $theme = 'p2';
55
+ } else {
56
+ $theme = FALSE; // Current Theme
57
+ }
58
+ } else {
59
+ // Non-Admin page, i.e. - Public Site, etc.
60
+ extract( jr_mt_url_to_id( 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ) );
61
+ $settings = get_option( 'jr_mt_settings' );
62
+ if ( $home ) {
63
+ if ( trim( $settings['site_home'] ) != '' ) {
64
+ return $settings['site_home'];
65
+ }
66
+ }
67
+ $ids = $settings['ids'];
68
+ if ( $id === FALSE ) {
69
+ if ( isset( $ids[$page_url] ) ) {
70
+ $theme = $ids[$page_url][$option];
71
+ } else {
72
+ $theme = jr_mt_check_all( $type, $rel_url, $ids );
73
+ }
74
+ } else {
75
+ if ( isset( $ids[$id] ) ) {
76
+ $theme = $ids[$id][$option];
77
+ } else {
78
+ $theme = jr_mt_check_all( $type, $rel_url, $ids );
79
+ }
80
+ }
81
+ }
82
+ return $theme;
83
+ }
84
+
85
+ // Returns FALSE for Current Theme
86
+ function jr_mt_check_all( $type, $rel_url, $ids ) {
87
+ // Check Prefix entries first, because we already know there is no specific entry for this URL.
88
+ $theme = '';
89
+ $match_length = 0;
90
+ foreach ( $ids as $key => $array ) {
91
+ if ( $array['type'] == 'prefix' ) {
92
+ $this_length = strlen( $array['rel_url'] );
93
+ if ( $array['rel_url'] == substr( $rel_url, 0, $this_length ) ) {
94
+ // Need to find longest match if there are multiple prefix matches.
95
+ if ( $this_length > $match_length ) {
96
+ $theme = $array['theme'];
97
+ $match_length = $this_length;
98
+ }
99
+ }
100
+ }
101
+ }
102
+ // See if a Prefix entry was found
103
+ if ( $match_length == 0 ) {
104
+ if ( $type === FALSE ) {
105
+ $theme = FALSE; // Current Theme
106
+ } else {
107
+ $settings = get_option( 'jr_mt_settings' );
108
+ if ( isset( $settings["all_$type"] ) ) {
109
+ $theme = $settings["all_$type"];
110
+ } else {
111
+ $theme = '';
112
+ }
113
+ if ( empty( $theme ) ) {
114
+ $theme = FALSE; // Current Theme
115
+ }
116
+ }
117
+ }
118
+ return $theme;
119
+ }
120
+
121
+ ?>
jonradio-multiple-themes.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: jonradio Multiple Themes
4
+ Plugin URI: http://zatzlabs.com/plugins/
5
+ Description: Select different Themes for one or more, or all WordPress Pages, Posts or other non-Admin pages. Or Site Home.
6
+ Version: 3.3
7
+ Author: David Gewirtz
8
+ Author URI: http://zatzlabs.com/plugins/
9
+ License: GPLv2
10
+ */
11
+
12
+ /* Copyright 2012 jonradio (email : info@zatz.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ global $jr_mt_plugin_folder;
30
+ $jr_mt_plugin_folder = basename( dirname( __FILE__ ) );
31
+
32
+ function jr_mt_plugin_folder() {
33
+ global $jr_mt_plugin_folder;
34
+ return $jr_mt_plugin_folder;
35
+ }
36
+
37
+ global $jr_mt_path;
38
+ $jr_mt_path = plugin_dir_path( __FILE__ );
39
+ function jr_mt_path() {
40
+ global $jr_mt_path;
41
+ return $jr_mt_path;
42
+ }
43
+
44
+ global $jr_mt_plugin_basename;
45
+ $jr_mt_plugin_basename = plugin_basename( __FILE__ );
46
+
47
+ if ( !function_exists( 'get_plugin_data' ) ) {
48
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
49
+ }
50
+
51
+ global $jr_mt_plugin_data;
52
+ $jr_mt_plugin_data = get_plugin_data( __FILE__ );
53
+
54
+ global $jr_mt_options_cache;
55
+ $all_options = wp_load_alloptions();
56
+ $jr_mt_options_cache['stylesheet'] = $all_options['stylesheet'];
57
+ $jr_mt_options_cache['template'] = $all_options['template'];
58
+
59
+ register_activation_hook( __FILE__, 'jr_mt_activate' );
60
+ register_deactivation_hook( __FILE__, 'jr_mt_deactivate' );
61
+
62
+ function jr_mt_activate( $network_wide ) {
63
+ if ( $network_wide ) {
64
+ global $wpdb, $site_id;
65
+ $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = $site_id" );
66
+ foreach ( $blogs as $blog_obj ) {
67
+ if ( switch_to_blog( $blog_obj->blog_id ) ) {
68
+ // We know the Site actually exists
69
+ jr_mt_activate1();
70
+ }
71
+ }
72
+ restore_current_blog();
73
+ } else {
74
+ jr_mt_activate1();
75
+ }
76
+ }
77
+
78
+ function jr_mt_activate1() {
79
+ $settings = array(
80
+ 'all_pages' => '',
81
+ 'all_posts' => '',
82
+ 'site_home' => '',
83
+ 'ids' => array()
84
+ );
85
+ // Nothing happens if Settings already exist
86
+ add_option( 'jr_mt_settings', $settings );
87
+
88
+ global $jr_mt_plugin_data;
89
+ $internal_settings = array(
90
+ 'version' => $jr_mt_plugin_data['Version']
91
+ ); // Only records you version when plugin installed, not current version
92
+ add_option( 'jr_mt_internal_settings', $internal_settings ); // Nothing happens if Settings already exist
93
+ }
94
+
95
+ add_action( 'wpmu_new_blog', 'jr_mt_new_site', 10, 6 );
96
+
97
+ function jr_mt_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
98
+ if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
99
+ switch_to_blog( $blog_id );
100
+ jr_mt_activate1();
101
+ restore_current_blog();
102
+ }
103
+ }
104
+
105
+ function jr_mt_deactivate() {
106
+ // Nothing (yet)
107
+ }
108
+
109
+ jr_mt_version_check();
110
+
111
+ function jr_mt_version_check() {
112
+ // Check for Plugin Version update (Deactivate and Activate Hooks not fired)
113
+ $internal_settings = get_option( 'jr_mt_internal_settings' );
114
+ if ( $internal_settings ) { // Just in case Activation has not occurred yet
115
+ global $jr_mt_plugin_data;
116
+ if ( version_compare( $internal_settings['version'], $jr_mt_plugin_data['Version'], '<' ) ) {
117
+ $settings = get_option( 'jr_mt_settings' );
118
+ if ( isset( $settings['ids'] ) ) {
119
+ $ids = $settings['ids'];
120
+ } else {
121
+ $ids = array();
122
+ }
123
+ if ( version_compare( $internal_settings['version'], '2.1', '<' ) ) {
124
+ unset( $settings['all_admin'] );
125
+ // Check for Site Home entry, remove it and set Site Home field
126
+ // And remove all Admin entries (no longer supported)
127
+ if ( isset( $ids[''] ) ) {
128
+ $settings['site_home'] = $ids['']['theme'];
129
+ unset( $ids[''] );
130
+ } else {
131
+ $settings['site_home'] = '';
132
+ }
133
+ foreach ( $ids as $key => $arr ) {
134
+ if ( $arr['type'] == 'admin' ) {
135
+ unset( $ids[$key] );
136
+ }
137
+ }
138
+ }
139
+ if ( version_compare( $internal_settings['version'], '3.0', '<' ) ) {
140
+ foreach ( $ids as $key => $arr ) {
141
+ if ( strcasecmp( 'http', substr( $arr['rel_url'], 0, 4 ) ) == 0 ) {
142
+ unset( $ids[$key] );
143
+ }
144
+ }
145
+ }
146
+ $settings['ids'] = $ids;
147
+ update_option( 'jr_mt_settings', $settings );
148
+ $internal_settings['version'] = $jr_mt_plugin_data['Version'];
149
+ update_option( 'jr_mt_internal_settings', $internal_settings );
150
+ }
151
+ }
152
+ }
153
+
154
+ require_once( jr_mt_path() . 'includes/functions.php' );
155
+ require_once( jr_mt_path() . 'includes/select-theme.php' );
156
+
157
+ if ( is_admin() ) {
158
+ // Admin panel
159
+ require_once( jr_mt_path() . 'includes/admin.php' );
160
+ }
161
+
162
+ /*
163
+ Research Notes:
164
+ The first time one of these Filter Hooks fires, pre_option_stylesheet and pre_option_template, only the following functions can be used to help determine "where" you are in the site:
165
+ - is_admin()
166
+ - is_user_logged_in()
167
+ - get_option("page_on_front") - ID of home page; zero if Reading Settings NOT set to a Static Page of a WordPress Page
168
+ */
169
+
170
+ ?>
readme.txt ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === jonradio Multiple Themes ===
2
+ Contributors: dgewirtz
3
+ Donate link: http://zatzlabs.com/plugins/
4
+ Tags: themes, theme, sections, style, template, stylesheet, accessibility
5
+ Requires at least: 3.4.1
6
+ Tested up to: 3.5
7
+ Stable tag: 3.3
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Select different Themes for one or more, or all WordPress Pages, Posts or other non-Admin pages. Or Site Home.
12
+
13
+ == Description ==
14
+
15
+ Allows the Administrator to specify which Theme will be used on specific Pages, Posts, other non-Admin pages (such as Category or Archive pages) or Site Home. Also allows a Theme to be specified for All Pages or All Posts. In turn, even when a Theme is specified for All Pages or All Posts, a different Theme can still be specified for specific Pages or Posts.
16
+
17
+ **Changing Theme Options (Widgets, Sidebars, Menus, Background, Header, etc.)?**: See the FAQ (Frequently-Asked Questions) tab for important information on changing Options on Themes other than the Current Theme.
18
+
19
+ Think what you could do if you could easily use more than one Theme on your WordPress web site or blog:
20
+
21
+ * Divide your site into Sections, each with its own unique look
22
+ * Style individual Pages, Posts, or other elements (Site Home, Category main page, Archive main page) with a different Theme
23
+ * Select a unique Theme for all Pages, Posts, Attachments, Category pages or Archive pages
24
+ * Make slight variations to a Theme, using Child Themes, for one or more Pages, Posts or other elements (Site Home, Category main page, Archive main page)
25
+ * Supports Multiple Stylesheets for Accessibility and other purposes (create one Child Theme for each Stylesheet)
26
+ * Test a new Theme on one or more Pages or Posts
27
+ * Convert to a new Theme a Page or Post at a time
28
+ * Host multiple mini-web sites on your WordPress site, each with a different Theme
29
+ * When a larger version of an image attachment is displayed, for example, when clicking on a gallery image thumbnail, use a different theme to display it, for one or all images attached to a Page or Post
30
+
31
+ To select all Pages, Posts, Archives, Categories, etc. that begin with the same partial URL, a "Prefix URL" can be specified by selecting the Prefix checkbox when creating an entry on the Settings page for the Plugin. Restriction: the Prefix URL cannot contain all or part of a Query, which is the portion of a URL that begins with a question mark ("?"). Although the Prefix cannot contain a Query, URLs containing a Query will be matched by the Prefix.
32
+
33
+ If a Theme is not specified for a Page, Post, Site Home or other WordPress-displayed web page, such as Category or Archive display, the **Current Theme** specified in **Appearance-Themes** on the Admin panels will be used.
34
+
35
+ When selecting a Theme for Site Home or all or specific Pages, Posts or other non-Admin pages, the Theme must be shown in the list of Available Themes on the Appearance-Themes Admin panel. If necessary, install the Theme. In a WordPress Network (AKA Multisite), Themes must be **Network Enabled** before they will appear as Available Themes on individual sites' Appearance-Themes panel.
36
+
37
+ I hesitate to use the term **Theme Switcher** to describe this plugin, because the term has so many meanings. This plugin does **not** alter the standard WordPress options that define what Theme is used on your WordPress site. Instead, it dynamically (and selectively) overrides that choice. Technical details aside, what this means is that deactivating or deleting the plugin will instantly revert to the WordPress Current Theme that you have defined through the standard WordPress Appearance-Themes Admin panel.
38
+
39
+ == Installation ==
40
+
41
+ This section describes how to install the plugin and get it working.
42
+
43
+ 1. Use "Add Plugin" within the WordPress Admin panel to download and install this plugin from the WordPress.org plugin repository (preferred method). Or download and unzip this plugin, then upload the `/jonradio-multiple-themes/` directory to your WordPress web site's `/wp-content/plugins/` directory.
44
+ 1. Activate the plugin through the 'Plugins' menu in WordPress. If you have a WordPress Network ("Multisite"), you can either Network Activate this plugin, or Activate it individually on the sites where you wish to use it. Activating on individual sites within a Network avoids some of the confusion created by WordPress' hiding of Network Activated plugins on the Plugin menu of individual sites.
45
+ 1. Be sure that all Themes you plan to use have been installed and are listed under Available Themes on the WordPress Appearance-Themes Admin panel. In a WordPress Network (AKA Multisite), Themes must be **Network Enabled** before they will appear as Available Themes on individual sites' Appearance-Themes panel.
46
+ 1. Select Themes to be used on the Plugin's "Multiple Themes plugin" page in the WordPress Admin panels, which is found in both the **Appearance** and **Settings** sections. You can also get to this page by clicking on the **Settings** link for this plugin on the **Installed Plugins** page.
47
+ 1. If you need to change Theme Options (Widgets, Sidebars, Menus, Background, Header, etc.) for any Theme other than the Current Theme, see the FAQ (Frequently-Asked Questions) tab for important information.
48
+
49
+ == Frequently Asked Questions ==
50
+
51
+ = How do I change the Theme Options (Widgets, Sidebars, Menus, Background, Header, etc.) used for each Theme? =
52
+
53
+ Options for all Themes, including Widgets, Sidebars, Menus, Background, Header and other Customizations supported by the Theme, can be modified in the Admin panel using the Appearance menu items on the left sidebar and the Customize link displayed beside the Current Theme on the Manage Themes tab of Appearance-Themes.
54
+
55
+ For the Current Theme, there are no issues, as WordPress provides this functionality without any intervention by plugins.
56
+
57
+ However, to modify Options for Active Themes that are *not* the Current Theme, the jonradio Multiple Themes plugin (i.e. - this plugin) must be Deactivated, and the Theme Test Drive plugin installed and activated, so that each Theme can be selected with the Theme Test Drive plugin, allowing the Theme's Options to be set "as if" it were the Current Theme.
58
+
59
+ Design work is currently underway to fully support Theme Options for each Theme used with the jonradio Multiple Themes plugin. Until that work is completed, in a future version of this plugin, the following Workaround using the Theme Test Drive plugin is being provided:
60
+
61
+ 1. Deactivate jonradio Multiple Themes
62
+ 1. Install the Theme Test Drive plugin found at http://wordpress.org/extend/plugins/theme-test-drive/
63
+ 1. Activate the Theme Test Drive plugin
64
+ 1. Go to Appearance-Theme Test Drive
65
+ 1. In the Usage section, select an alternate Theme you will be using with jonradio Multiple Themes
66
+ 1. Push the Enable Theme Drive button at the bottom
67
+ 1. Go to the WordPress Admin panel's Appearance menu (left sidebar)
68
+ 1. Make your changes to the Theme Options, including Widgets, Sidebars, Menus, Background, Header and other Customizations for this alternate Theme (which will appear as if it were the Current Theme)
69
+ 1. If you have more than one alternate Theme with Options you wish to change, repeat Steps 4-8 for each alternate Theme
70
+ 1. Deactivate the Theme Test Drive plugin
71
+ 1. Activate jonradio Multiple Themes
72
+ 1. Changes to the Options for the Current Theme can now be made normally, just as you would without either plugin
73
+ 1. Both the alternate and Current Themes should now display all Theme options properly when selected through the jonradio Multiple Themes plugin
74
+
75
+ = What happens when I change Permalinks? =
76
+
77
+ For entries you have created for individual Pages and Posts with this plugin, you can subsequently change your Permalink structure or you can change the Permalink of a Page or Post, without having to change the plugin's entry. However, for other pages, such as Categories or Archives, you will have to delete your old entries and create new ones with this plugin.
78
+
79
+ = I added a new entry but why doesn't it appear in the list of entries? =
80
+
81
+ If you add an entry that already exists, it merely replaces the previous entry.
82
+
83
+ = How can I change the Theme for an entry? =
84
+
85
+ Simply add the entry again, with the new Theme. It will replace the previous entry.
86
+
87
+ == Screenshots ==
88
+
89
+ 1. Plugin's Admin Page when first installed
90
+ 2. Plugin's Admin Page, adding entries
91
+
92
+ == Changelog ==
93
+
94
+ = 3.3 =
95
+ * Support Child Themes and any other situation where stylesheet and template names are not the same
96
+
97
+ = 3.2 =
98
+ * Correct Problem with P2 Theme, and its logged on verification at wp-admin/admin-ajax.php?p2ajax=true&action=logged_in_out&_loggedin={nonce}
99
+ * Add "Settings Saved" message to Admin page
100
+ * Tested with WordPress Version 3.5 beta
101
+
102
+ = 3.1 =
103
+ * Add Support for Prefixes, where all URLs beginning with the specified characters ("Prefix") can be assigned to a specified Theme
104
+
105
+ = 3.0 =
106
+ * Add Support for Categories and Archives when no Permalinks exist (support already existed Categories and Archives with Permalinks)
107
+ * Resolve several minor bugs
108
+
109
+ = 2.9 =
110
+ * Rewrite much of the Settings page and Plugin Directory documentation
111
+ * Add Support for IIS which returns incorrect values in $_SERVER['REQUEST_URI']
112
+ * Make it easier to select the Theme for the Site Home by providing a new Settings field
113
+ * Remove ability to set Theme for Admin pages since no known Theme provides Admin templates, and because the previous implementation sometimes displayed the incorrect Current Theme in Admin; this feature may be re-added in a future release, and could even be used to change Settings of Themes that are not currently the Current Theme
114
+ * Add version upgrade detection to add, remove and update Settings fields
115
+ * Move Settings link on Plugins page from beginning to end of links
116
+
117
+ = 2.0 =
118
+ * Address pecularities of wp_make_link_relative() related to root-based WordPress sites using Permalinks
119
+
120
+ = 1.1 =
121
+ * Fix foreach failing on some systems, based on PHP warning level
122
+
123
+ = 1.0 =
124
+ * Make plugin conform to WordPress plugin repository standards.
125
+ * Beta testing completed.
126
+
127
+ == Upgrade Notice ==
128
+
129
+ = 3.3 =
130
+ Remove Restriction that Stylesheet Name must match Template Name, which it does not with Child Themes
131
+
132
+ = 3.2 =
133
+ Add Support for P2 Theme and provide "Settings Saved" message
134
+
135
+ = 3.1 =
136
+ Allow Prefix URLs to be used to specify where a Theme will be displayed
137
+
138
+ = 3.0 =
139
+ Improve support for Categories and Archives, and eliminate all known bugs.
140
+
141
+ = 2.9 =
142
+ Improve Settings fields, correct display of wrong Current Theme in Appearance-Themes Admin panel, and add IIS Support.
143
+
144
+ = 2.0 =
145
+ Selecting Individual Pages and Posts on a WordPress site installed in the root and using Permalinks now works correctly.
146
+
147
+ = 1.1 =
148
+ Eliminate possibility of foreach error message if PHP warning level is set at a high level
149
+
150
+ = 1.0 =
151
+ Beta version 0.9 had not been tested when installed from the WordPress Plugin Repository
uninstall.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Ensure call comes from WordPress, not a hacker.
3
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
4
+ exit ();
5
+
6
+ /* Remove any tables, options, and such created by this Plugin */
7
+ if ( function_exists('is_multisite') && is_multisite() ) {
8
+ global $wpdb, $site_id;
9
+ $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = $site_id" );
10
+ foreach ($blogs as $blog_obj) {
11
+ delete_blog_option( $blog_obj->blog_id, 'jr_mt_settings' );
12
+ delete_blog_option( $blog_obj->blog_id, 'jr_mt_internal_settings' );
13
+ }
14
+ } else {
15
+ delete_option( 'jr_mt_settings' );
16
+ delete_option( 'jr_mt_internal_settings' );
17
+ }
18
+ ?>