Version Description
- Remove Cleanup code for Settings for non-existent Themes, as it conflicts with delete/reinstall theme version upgrades, and certain caching plugins
Download this release
Release Info
Developer | dgewirtz |
Plugin | Multiple Themes |
Version | 5.0.3 |
Comparing to | |
See all releases |
Version 5.0.3
- includes/admin-functions.php +170 -0
- includes/admin.php +1712 -0
- includes/functions.php +450 -0
- includes/index.html +0 -0
- includes/old-wp.php +20 -0
- includes/select-theme.php +484 -0
- includes/upgradev5.php +127 -0
- index.html +0 -0
- jonradio-multiple-themes.php +193 -0
- js/index.html +0 -0
- js/sticky.js +135 -0
- js/tabs.js +21 -0
- readme.txt +407 -0
- uninstall.php +27 -0
includes/admin-functions.php
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Exit if .php file accessed directly
|
4 |
+
*/
|
5 |
+
if ( !defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
function jr_mt_theme_entry( $type, $theme = '', $display1 = NULL, $display2 = NULL ) {
|
10 |
+
$three_dots = '…';
|
11 |
+
$before = '<li>Delete <input type="checkbox" id="del_entry" name="jr_mt_settings[del_entry][]" value="';
|
12 |
+
$after = '" /> ';
|
13 |
+
/* Fortunately, wp_get_theme() creates an Object if $theme does not exist,
|
14 |
+
complete with a Name entry that matches the folder name.
|
15 |
+
|
16 |
+
TODO: flag the situation of a non-existent Theme (i.e. - was deleted after entry was created)
|
17 |
+
*/
|
18 |
+
$theme_equals = 'Theme=' . wp_get_theme( $theme )->Name . '; ';
|
19 |
+
switch ( $type ) {
|
20 |
+
case 'Query':
|
21 |
+
echo $before
|
22 |
+
. 'query'
|
23 |
+
. '='
|
24 |
+
. $display1
|
25 |
+
. '='
|
26 |
+
. $display2
|
27 |
+
. $after
|
28 |
+
. $theme_equals;
|
29 |
+
if ( '*' !== $display2 ) {
|
30 |
+
$settings = get_option( 'jr_mt_settings' );
|
31 |
+
$sticky = isset( $settings['remember']['query'][ $display1 ][ $display2 ] );
|
32 |
+
$override = isset( $settings['override']['query'][ $display1 ][ $display2 ] );
|
33 |
+
if ( $sticky ) {
|
34 |
+
if ( $override ) {
|
35 |
+
echo 'Sticky/Override ';
|
36 |
+
} else {
|
37 |
+
echo 'Sticky ';
|
38 |
+
}
|
39 |
+
} else {
|
40 |
+
if ( $override ) {
|
41 |
+
echo 'Override ';
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
45 |
+
echo 'Query='
|
46 |
+
. '<code>'
|
47 |
+
. home_url()
|
48 |
+
. "/</code>$three_dots<code>/?"
|
49 |
+
. '<b><input type="text" readonly="readonly" disable="disabled" name="jr_mt_delkw" value="'
|
50 |
+
. $display1
|
51 |
+
. '" size="'
|
52 |
+
. jr_mt_strlen( $display1 )
|
53 |
+
. '" /></b>'
|
54 |
+
. '=';
|
55 |
+
if ( '*' === $display2 ) {
|
56 |
+
echo '</code>' . $three_dots;
|
57 |
+
} else {
|
58 |
+
echo '<b><input type="text" readonly="readonly" disable="disabled" name="jr_mt_delkwval" value="'
|
59 |
+
. $display2
|
60 |
+
. '" size="'
|
61 |
+
. jr_mt_strlen( $display2 )
|
62 |
+
. '" /></b></code>';
|
63 |
+
}
|
64 |
+
break;
|
65 |
+
case 'url':
|
66 |
+
case 'url_prefix':
|
67 |
+
case 'url_asterisk':
|
68 |
+
echo $before
|
69 |
+
. $type
|
70 |
+
. '='
|
71 |
+
. 'url'
|
72 |
+
. '='
|
73 |
+
. $display1
|
74 |
+
. $after
|
75 |
+
. $theme_equals
|
76 |
+
. $display2
|
77 |
+
. '=<code>' . $display1 . '</code>';
|
78 |
+
break;
|
79 |
+
case 'wordpress':
|
80 |
+
echo '<li><a href="'
|
81 |
+
. get_admin_url()
|
82 |
+
. 'themes.php" class="button-primary">Change</a> '
|
83 |
+
. 'Theme='
|
84 |
+
. wp_get_theme()->Name
|
85 |
+
. ', the Theme chosen as Active from Appearance-Themes in the WordPress Admin panels';
|
86 |
+
break;
|
87 |
+
default:
|
88 |
+
echo $before
|
89 |
+
. $type
|
90 |
+
. $after
|
91 |
+
. $theme_equals
|
92 |
+
. $display1;
|
93 |
+
if ( 'site_home' === $type ) {
|
94 |
+
echo ' (<code>' . home_url() . '</code>) setting';
|
95 |
+
} else {
|
96 |
+
echo ' setting (see Advanced Settings tab)';
|
97 |
+
}
|
98 |
+
break;
|
99 |
+
}
|
100 |
+
echo '</li>';
|
101 |
+
}
|
102 |
+
|
103 |
+
// $theme_name is the name of the Theme's folder within the Theme directory
|
104 |
+
function jr_mt_themes_field( $field_name, $theme_name, $setting, $excl_current_theme ) {
|
105 |
+
echo "<select id='$field_name' name='$setting" . "[$field_name]' size='1'>";
|
106 |
+
if ( empty( $theme_name ) ) {
|
107 |
+
$selected = 'selected="selected"';
|
108 |
+
} else {
|
109 |
+
$selected = '';
|
110 |
+
}
|
111 |
+
echo "<option value='' $selected></option>";
|
112 |
+
foreach ( jr_mt_all_themes() as $folder => $theme_obj ) {
|
113 |
+
if ( $excl_current_theme ) {
|
114 |
+
if ( ( jr_mt_current_theme( 'stylesheet' ) == $theme_obj['stylesheet'] ) && ( jr_mt_current_theme( 'template' ) == $theme_obj['template'] ) ) {
|
115 |
+
// Skip the Current Theme
|
116 |
+
continue;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
if ( $theme_name === $folder ) {
|
120 |
+
$selected = 'selected="selected"';
|
121 |
+
} else {
|
122 |
+
$selected = '';
|
123 |
+
}
|
124 |
+
$name = $theme_obj->Name;
|
125 |
+
echo "<option value='$folder' $selected>$name</option>";
|
126 |
+
}
|
127 |
+
echo '</select>' . PHP_EOL;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Update available for Plugin?
|
132 |
+
*
|
133 |
+
* @return bool - TRUE if an update is available in the WordPress Repository,
|
134 |
+
* FALSE if no update is available or if the update_plugins transient is not available
|
135 |
+
* (which also results in an error message).
|
136 |
+
**/
|
137 |
+
function jr_mt_plugin_update_available() {
|
138 |
+
global $jr_mt_update_plugins;
|
139 |
+
if ( !isset( $jr_mt_update_plugins ) ) {
|
140 |
+
$transient = get_site_transient( 'update_plugins' );
|
141 |
+
if ( FALSE === $transient ) {
|
142 |
+
// Error
|
143 |
+
return FALSE;
|
144 |
+
} else {
|
145 |
+
$jr_mt_update_plugins = $transient;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
if ( empty( $jr_mt_update_plugins->response ) ) {
|
149 |
+
return FALSE;
|
150 |
+
}
|
151 |
+
return array_key_exists( jr_mt_plugin_basename(), $jr_mt_update_plugins->response );
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Prepare URL Query Value
|
156 |
+
*
|
157 |
+
* Sanitize and standardize a URL Query Value for storage in a database.
|
158 |
+
* Does not support ?keyword[]=value, i.e. - $value cannot be an Array.
|
159 |
+
*
|
160 |
+
* @param string $value URL Query Value to be sanitized and standardized; will fail if array
|
161 |
+
* @return string URL Query Value after being sanitized and standardized
|
162 |
+
*/
|
163 |
+
function jr_mt_prep_query_value( $value ) {
|
164 |
+
return str_ireplace( '%e2%80%8e', '', jr_mt_strtolower( trim( $value ) ) );
|
165 |
+
}
|
166 |
+
function jr_mt_prep_query_keyword( $keyword ) {
|
167 |
+
return jr_mt_prep_query_value( $keyword );
|
168 |
+
}
|
169 |
+
|
170 |
+
?>
|
includes/admin.php
ADDED
@@ -0,0 +1,1712 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if .php file accessed directly
|
3 |
+
if ( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
// Add Link to the plugin's entry on the Admin "Plugins" Page, for easy access
|
6 |
+
add_filter( 'plugin_action_links_' . jr_mt_plugin_basename(), 'jr_mt_plugin_action_links', 10, 1 );
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Creates Settings entry right on the Plugins Page entry.
|
10 |
+
*
|
11 |
+
* Helps the user understand where to go immediately upon Activation of the Plugin
|
12 |
+
* by creating entries on the Plugins page, right beside Deactivate and Edit.
|
13 |
+
*
|
14 |
+
* @param array $links Existing links for our Plugin, supplied by WordPress
|
15 |
+
* @param string $file Name of Plugin currently being processed
|
16 |
+
* @return string $links Updated set of links for our Plugin
|
17 |
+
*/
|
18 |
+
function jr_mt_plugin_action_links( $links ) {
|
19 |
+
// The "page=" query string value must be equal to the slug
|
20 |
+
// of the Settings admin page.
|
21 |
+
array_push( $links, '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=jr_mt_settings' . '">Settings</a>' );
|
22 |
+
return $links;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
// Admin Page
|
27 |
+
|
28 |
+
add_action( 'admin_menu', 'jr_mt_admin_hook' );
|
29 |
+
// Runs just before admin_init (below)
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Add Admin Menu item for plugin
|
33 |
+
*
|
34 |
+
* Plugin needs its own Page in the Settings section of the Admin menu.
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
function jr_mt_admin_hook() {
|
38 |
+
// Add Settings Page for this Plugin
|
39 |
+
global $jr_mt_plugin_data;
|
40 |
+
add_theme_page( $jr_mt_plugin_data['Name'], 'Multiple Themes plugin', 'switch_themes', 'jr_mt_settings', 'jr_mt_settings_page' );
|
41 |
+
add_options_page( $jr_mt_plugin_data['Name'], 'Multiple Themes plugin', 'switch_themes', 'jr_mt_settings', 'jr_mt_settings_page' );
|
42 |
+
}
|
43 |
+
|
44 |
+
global $jr_mt_kwvalsep;
|
45 |
+
/* Everything is converted to lower-case, so upper-case letter makes a good keyword-value separator
|
46 |
+
*/
|
47 |
+
$jr_mt_kwvalsep = 'A';
|
48 |
+
|
49 |
+
add_action( 'admin_enqueue_scripts', 'jr_mt_admin_enqueue_scripts' );
|
50 |
+
function jr_mt_admin_enqueue_scripts() {
|
51 |
+
global $jr_mt_plugin_data;
|
52 |
+
wp_enqueue_script( 'jr_mt_tabs', plugins_url() . '/' . dirname( jr_mt_plugin_basename() ) . '/js/tabs.js', array(), $jr_mt_plugin_data['Version'] );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Settings page for plugin
|
57 |
+
*
|
58 |
+
* Display and Process Settings page for this plugin.
|
59 |
+
*
|
60 |
+
*/
|
61 |
+
function jr_mt_settings_page() {
|
62 |
+
global $jr_mt_plugin_data, $jr_mt_plugins_cache;
|
63 |
+
$jr_mt_plugins_cache = get_plugins();
|
64 |
+
add_thickbox();
|
65 |
+
echo '<div class="wrap">';
|
66 |
+
echo '<h2>' . $jr_mt_plugin_data['Name'] . '</h2>';
|
67 |
+
|
68 |
+
// Required because it is only called automatically for Admin Pages in the Settings section
|
69 |
+
settings_errors( 'jr_mt_settings' );
|
70 |
+
|
71 |
+
$theme_obj = wp_get_theme();
|
72 |
+
$theme = $theme_obj->Name;
|
73 |
+
$theme_version = $theme_obj->Version;
|
74 |
+
global $jr_mt_options_cache;
|
75 |
+
|
76 |
+
$current_wp_version = get_bloginfo( 'version' );
|
77 |
+
|
78 |
+
global $jr_mt_plugins_cache;
|
79 |
+
|
80 |
+
$compatible = TRUE;
|
81 |
+
|
82 |
+
// Check for incompatible plugins that have been activated: BuddyPress and Theme Test Drive
|
83 |
+
global $jr_mt_incompat_plugins;
|
84 |
+
foreach ( $jr_mt_plugins_cache as $rel_path => $plugin_data ) {
|
85 |
+
if ( in_array( $plugin_data['Name'], $jr_mt_incompat_plugins ) && is_plugin_active( $rel_path ) ) {
|
86 |
+
if ( $compatible ) {
|
87 |
+
echo '<h3>Plugin Conflict Error Detected</h3>';
|
88 |
+
$compatible = FALSE;
|
89 |
+
}
|
90 |
+
echo '<p>This Plugin (' . $jr_mt_plugin_data['Name'] . ') cannot be used when the <b>' . $plugin_data['Name']
|
91 |
+
. '</b> plugin is Activated. If you wish to use the ' . $jr_mt_plugin_data['Name']
|
92 |
+
. ' plugin, please deactivate the ' . $plugin_data['Name']
|
93 |
+
. ' plugin (not just when viewing this Settings page, but whenever the '
|
94 |
+
. $jr_mt_plugin_data['Name'] . ' plugin is activated).</p>';
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( $compatible ) {
|
99 |
+
$settings = get_option( 'jr_mt_settings' );
|
100 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
101 |
+
?>
|
102 |
+
<h2 class="nav-tab-wrapper">
|
103 |
+
<a href="#" class="nav-tab nav-tab-active" id="jr-mt-tabs1"
|
104 |
+
onClick="jrMtTabs( 1, 5 );">Settings</a><a href="#" class="nav-tab" id="jr-mt-tabs2"
|
105 |
+
onClick="jrMtTabs( 2, 5 );">Advanced Settings</a><a href="#" class="nav-tab" id="jr-mt-tabs3"
|
106 |
+
onClick="jrMtTabs( 3, 5 );">Theme Options</a><a href="#" class="nav-tab" id="jr-mt-tabs4"
|
107 |
+
onClick="jrMtTabs( 4, 5 );">System Information</a><a href="#" class="nav-tab" id="jr-mt-tabs5"
|
108 |
+
onClick="jrMtTabs( 5, 5 );">New in V5</a>
|
109 |
+
</h2>
|
110 |
+
<div id="jr-mt-settings1">
|
111 |
+
<h3>Settings</h3>
|
112 |
+
<p>
|
113 |
+
This is the main Settings tab.
|
114 |
+
Additional Settings are available on the
|
115 |
+
<a href="#" onClick="jrMtTabs( 2, 5 );">Advanced Settings tab</a>,
|
116 |
+
but they can cause problems,
|
117 |
+
so should be used with care.
|
118 |
+
</p>
|
119 |
+
<h3>Overview</h3>
|
120 |
+
<p>This Plugin allows you to selectively display Themes on your web site
|
121 |
+
other than the Theme shown as
|
122 |
+
<b>
|
123 |
+
Active
|
124 |
+
</b>
|
125 |
+
on
|
126 |
+
<b>
|
127 |
+
Appearance-Themes
|
128 |
+
</b>
|
129 |
+
in the WordPress Admin panels.
|
130 |
+
</p>
|
131 |
+
<p>
|
132 |
+
Below,
|
133 |
+
Theme Selection entries can be created
|
134 |
+
where each Entry specifies which of the installed themes shown on the Appearance-Themes Admin panel will be applied to:
|
135 |
+
<ul>
|
136 |
+
<li> » The Site Home</li>
|
137 |
+
<li> » An exact URL of any non-Admin page on this WordPress Site</li>
|
138 |
+
<li> » One or more URLs that begin with the partial URL you specify ("URL Prefix")</li>
|
139 |
+
<li> » One or more URLs that begin with the wildcard URL you specify ("URL Prefix*")</li>
|
140 |
+
<li> » Any URL containing a Specific Query Keyword (<code>?keyword</code> or <code>&keyword</code>)</li>
|
141 |
+
<li> » Any URL containing a Specific Query Keyword/Value pair (<code>?keyword=value</code> or <code>&keyword=value</code>)</li>
|
142 |
+
<li> » For the same site visitor, all non-Admin pages after a <b>Sticky</b> Query Keyword/Value pair is specified in any URL (Advanced Settings tab)</li>
|
143 |
+
<li> » All Pages (Advanced Settings tab)</li>
|
144 |
+
<li> » All Posts (Advanced Settings tab)</li>
|
145 |
+
<li> » Everything else, except what is specified above (Advanced Settings tab)</li>
|
146 |
+
</ul>
|
147 |
+
</p>
|
148 |
+
<h3>Important Notes</h3>
|
149 |
+
<form action="options.php" method="POST">
|
150 |
+
<?php
|
151 |
+
$permalink = get_option( 'permalink_structure' );
|
152 |
+
if ( isset( $internal_settings['permalink'] ) ) {
|
153 |
+
if ( $internal_settings['permalink'] !== $permalink ) {
|
154 |
+
/* Permalink Structure has been changed.
|
155 |
+
*/
|
156 |
+
if ( empty( $settings['url'] ) && empty( $settings['url_prefix'] ) && empty( $settings['url_asterisk'] ) ) {
|
157 |
+
$update = TRUE;
|
158 |
+
} else {
|
159 |
+
?>
|
160 |
+
<p>
|
161 |
+
Permalink Structure has been changed.
|
162 |
+
In the
|
163 |
+
<b>
|
164 |
+
Current Theme Selection Entries
|
165 |
+
</b>
|
166 |
+
Section just below,
|
167 |
+
please review all
|
168 |
+
URL=,
|
169 |
+
URL Prefix=
|
170 |
+
and
|
171 |
+
URL Prefix*=
|
172 |
+
entries,
|
173 |
+
as they may need to be changed to reflect the new Permalink Structure.
|
174 |
+
<br />
|
175 |
+
<input type="checkbox" id="permalink" name="jr_mt_settings[permalink]" value="true" />
|
176 |
+
Dismiss Warning
|
177 |
+
</p>
|
178 |
+
<?php
|
179 |
+
$update = FALSE;
|
180 |
+
}
|
181 |
+
} else {
|
182 |
+
$update = FALSE;
|
183 |
+
}
|
184 |
+
} else {
|
185 |
+
/* Permalink Internal Setting for Plugin not set,
|
186 |
+
so initialize it to current Permalink Structure.
|
187 |
+
*/
|
188 |
+
$update = TRUE;
|
189 |
+
}
|
190 |
+
if ( $update ) {
|
191 |
+
$internal_settings['permalink'] = $permalink;
|
192 |
+
update_option( 'jr_mt_internal_settings', $internal_settings );
|
193 |
+
}
|
194 |
+
if ( function_exists('is_multisite') && is_multisite() ) {
|
195 |
+
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.";
|
196 |
+
}
|
197 |
+
echo '<p>';
|
198 |
+
echo "The Active Theme, defined to WordPress in the Appearance-Themes admin panel, is <b>$theme</b>.";
|
199 |
+
if ( trim( $settings['current'] ) ) {
|
200 |
+
echo " But it is being overridden by the Theme for Everything setting (see Advanced Settings tab), which set the plugin's default Theme to <b>";
|
201 |
+
echo wp_get_theme( $settings['current'] )->Name;
|
202 |
+
echo '</b>. You will not normally need to specify this default Theme in any of the other Settings on this page, though you will need to specify the WordPress Active Theme wherever you want it to appear. Or, if you specify, on the Advanced Settings tab, a different Theme for All Pages, All Posts or Everything, and wish to use the default Theme for one or more specific Pages, Posts or other non-Admin pages.';
|
203 |
+
} else {
|
204 |
+
echo ' You will not normally need to specify it in any of the Settings on this page. The only exception would be if you specify, on the Advanced Settings tab, a different Theme for All Pages, All Posts or Everything, and wish to use the Active Theme for one or more specific Pages, Posts or other non-Admin pages.';
|
205 |
+
}
|
206 |
+
echo '</p>';
|
207 |
+
|
208 |
+
if ( jr_mt_plugin_update_available() ) {
|
209 |
+
echo '<p>A new version of this Plugin (' . $jr_mt_plugin_data['Name'] . ') is available from the WordPress Repository.'
|
210 |
+
. ' Updating as quickly as possible is strongly recommend because new versions fix problems that users like you have already reported.'
|
211 |
+
. ' <a class="thickbox" title="' . $jr_mt_plugin_data['Name'] . '" href="' . network_admin_url()
|
212 |
+
. 'plugin-install.php?tab=plugin-information&plugin=' . $jr_mt_plugin_data['slug']
|
213 |
+
. '§ion=changelog&TB_iframe=true&width=640&height=768">Click here</a> for more details.</p>';
|
214 |
+
}
|
215 |
+
?>
|
216 |
+
<p>
|
217 |
+
If a newly-added Theme Selection does not seem to be working,
|
218 |
+
especially if the associated web page does not display properly,
|
219 |
+
try deactivating any plugins that provide Caching.
|
220 |
+
You may find that you have to flush the plugin's Cache whenever you add or change a Theme Selection setting.
|
221 |
+
Also note that some Caching plugins only cache for visitors who are not logged in,
|
222 |
+
so be sure to check your site after logging out.
|
223 |
+
</p>
|
224 |
+
<p>
|
225 |
+
Need more help?
|
226 |
+
Please scroll to the bottom of this Settings page for more information.
|
227 |
+
</p>
|
228 |
+
<hr />
|
229 |
+
<?php
|
230 |
+
|
231 |
+
// Plugin Settings are displayed and entered here:
|
232 |
+
settings_fields( 'jr_mt_settings' );
|
233 |
+
do_settings_sections( 'jr_mt_settings_page' );
|
234 |
+
echo '<p><input name="save" type="submit" value="Save All Changes" class="button-primary" /></p></form>';
|
235 |
+
}
|
236 |
+
|
237 |
+
?>
|
238 |
+
</div>
|
239 |
+
<div id="jr-mt-settings3" style="display: none;">
|
240 |
+
<h3>
|
241 |
+
Theme Options and Template Selection
|
242 |
+
</h3>
|
243 |
+
<p>
|
244 |
+
This tab provides information on changing Theme Options
|
245 |
+
(Widgets, Sidebars, Menus, Background, Header, etc.)
|
246 |
+
for all the different Themes used on a WordPress site.
|
247 |
+
</p>
|
248 |
+
<p>
|
249 |
+
Information on changing the Template for each Page or Post
|
250 |
+
is found near the bottom of this tab.
|
251 |
+
</p>
|
252 |
+
<h3>
|
253 |
+
Changing Theme Options
|
254 |
+
</h3>
|
255 |
+
<p>
|
256 |
+
For the Active Theme, nothing changes when using the jonradio Multiple Themes plugin.
|
257 |
+
Options for the Active Theme,
|
258 |
+
including Widgets, Sidebars, Menus, Background, Header and other Customizations supported by the Theme,
|
259 |
+
can be modified in the Admin panel using the Appearance menu items on the left sidebar.
|
260 |
+
Some Themes also provide their own menu items in the left sidebar of the Admin panel,
|
261 |
+
and these will still appear for the Active Theme when using this plugin.
|
262 |
+
</p>
|
263 |
+
<p>
|
264 |
+
It is more difficult to modify Options for installed Themes that are not the WordPress Active Theme.
|
265 |
+
Building this functionality into this plugin is in the plans for a future Version,
|
266 |
+
but it is not clear just how practical that is, so the best that can be said is:
|
267 |
+
<i>
|
268 |
+
Maybe</i>.
|
269 |
+
</p>
|
270 |
+
<p>
|
271 |
+
For now, there are three approaches that can be used to change Options for an installed Theme that is not the Active Theme.
|
272 |
+
The first works best if only one Theme has a lot of Options that need to be changed frequently:
|
273 |
+
</p>
|
274 |
+
<ol>
|
275 |
+
<li>
|
276 |
+
Make that Theme the Active Theme defined in the Appearance-Themes WordPress admin panel;
|
277 |
+
</li>
|
278 |
+
<li>
|
279 |
+
If that meant changing the Active Theme,
|
280 |
+
the previous Active Theme can be selected on the plugin's
|
281 |
+
<b>
|
282 |
+
Advanced Settings
|
283 |
+
</b>
|
284 |
+
tab
|
285 |
+
in the
|
286 |
+
<b>
|
287 |
+
Select Theme for Everything
|
288 |
+
</b>
|
289 |
+
field
|
290 |
+
and it will be used everywhere except where you have specified
|
291 |
+
another Theme in the Theme Selection entries for this plugin.
|
292 |
+
</li>
|
293 |
+
</ol>
|
294 |
+
<p>
|
295 |
+
For other situations,
|
296 |
+
two multi-step Methods are available,
|
297 |
+
and are described in the two Sections below.
|
298 |
+
Both Methods work for most Theme Options,
|
299 |
+
with the following exceptions:
|
300 |
+
</p>
|
301 |
+
<ol>
|
302 |
+
<li>
|
303 |
+
Menus really work well with Method #1,
|
304 |
+
but are severely restricted with Method #2;
|
305 |
+
</li>
|
306 |
+
<li>
|
307 |
+
Widgets normally only work with Method #2;
|
308 |
+
</li>
|
309 |
+
<li>
|
310 |
+
Using both Methods may cause conflicts;
|
311 |
+
</li>
|
312 |
+
<li>
|
313 |
+
No matter which Method you choose,
|
314 |
+
you may lose previously-set Theme Options.
|
315 |
+
A Backup and Recovery of your WordPress Database
|
316 |
+
would be required to avoid such a loss.
|
317 |
+
</li>
|
318 |
+
</ol>
|
319 |
+
<h4>
|
320 |
+
<u>
|
321 |
+
Method #1</u>:
|
322 |
+
Set the Theme Options with Live Preview.
|
323 |
+
</h4>
|
324 |
+
<p>
|
325 |
+
Note: Widgets cannot be placed using this Method.
|
326 |
+
</p>
|
327 |
+
<ol>
|
328 |
+
<li>
|
329 |
+
Go to Appearance-Themes in the WordPress Admin panels.
|
330 |
+
</li>
|
331 |
+
<li>
|
332 |
+
Mouse over the Theme that you wish to change
|
333 |
+
and click the Live Preview button that appears.
|
334 |
+
</li>
|
335 |
+
<li>
|
336 |
+
Use the left sidebar to modify the Theme Options.
|
337 |
+
Note that
|
338 |
+
<b>
|
339 |
+
Navigation
|
340 |
+
</b>
|
341 |
+
will not appear in the Live Preview sidebar until a Menu has been defined in Appearance-Menus.
|
342 |
+
Navigation is where you would set the custom menu(s) to be used for the Theme you are currently previewing.
|
343 |
+
</li>
|
344 |
+
<li>
|
345 |
+
Click the Save & Activate button.
|
346 |
+
</li>
|
347 |
+
<li>
|
348 |
+
Go immediately to Appearance-Themes in the WordPress Admin panels.
|
349 |
+
</li>
|
350 |
+
<li>
|
351 |
+
Mouse over the Theme that had previously been the Active Theme
|
352 |
+
and click the Activate button that appears
|
353 |
+
to reactivate the Active Theme.
|
354 |
+
</li>
|
355 |
+
</ol>
|
356 |
+
<h4>
|
357 |
+
<u>
|
358 |
+
Method #2</u>:
|
359 |
+
Use the Theme Test Drive plugin.
|
360 |
+
</h4>
|
361 |
+
<p>
|
362 |
+
Note: this approach only allows Menus to be set for one Theme. Using this method to assign one or more menus to a Theme will unassign menus for all other Themes.
|
363 |
+
</p>
|
364 |
+
<p>
|
365 |
+
The jonradio Multiple Themes plugin (i.e. - this plugin) must be Deactivated,
|
366 |
+
and the Theme Test Drive plugin installed and activated.
|
367 |
+
This enables each Theme to be selected with the Theme Test Drive plugin,
|
368 |
+
allowing the Theme's Options to be set
|
369 |
+
<i>
|
370 |
+
as if
|
371 |
+
</i>
|
372 |
+
it were the Active Theme.
|
373 |
+
</p>
|
374 |
+
<ol>
|
375 |
+
<li>
|
376 |
+
Deactivate the jonradio Multiple Themes plugin.
|
377 |
+
</li>
|
378 |
+
<li>
|
379 |
+
Install the Theme Test Drive plugin found at
|
380 |
+
<a target="_blank" href="http://wordpress.org/plugins/theme-test-drive/">http://wordpress.org/plugins/theme-test-drive/</a>.
|
381 |
+
</li>
|
382 |
+
<li>
|
383 |
+
Activate the Theme Test Drive plugin.
|
384 |
+
</li>
|
385 |
+
<li>
|
386 |
+
Go to
|
387 |
+
<b>
|
388 |
+
Appearance-Theme Test Drive
|
389 |
+
</b>
|
390 |
+
in the WordPress Admin panels.
|
391 |
+
</li>
|
392 |
+
<li>
|
393 |
+
In the Usage section, select a Theme whose Options you wish to change.
|
394 |
+
</li>
|
395 |
+
<li>
|
396 |
+
Push the Enable Theme Drive button at the bottom of the Admin panel.
|
397 |
+
</li>
|
398 |
+
<li>
|
399 |
+
Make your changes to the Theme Options, including Widgets, Sidebars, Menus (see note above about Menus), Background, Header and other Customizations for this alternate Theme
|
400 |
+
using the Appearance submenu
|
401 |
+
in the WordPress Admin panels,
|
402 |
+
just as you would for the Active Theme.
|
403 |
+
</li>
|
404 |
+
<li>
|
405 |
+
If more than one Theme has Options that need changing, repeat Steps 4-8 for each Theme
|
406 |
+
(except the Active Theme,
|
407 |
+
which should be only changed
|
408 |
+
<i>
|
409 |
+
without
|
410 |
+
</i>
|
411 |
+
the Theme Test Drive plugin activated).
|
412 |
+
</li>
|
413 |
+
<li>
|
414 |
+
Deactivate the Theme Test Drive plugin.
|
415 |
+
</li>
|
416 |
+
<li>
|
417 |
+
Activate this plugin (jonradio Multiple Themes).
|
418 |
+
</li>
|
419 |
+
<li>
|
420 |
+
Changes to the Options for the Active Theme can now be made normally, just as you would without either plugin.
|
421 |
+
</li>
|
422 |
+
<li>
|
423 |
+
Both the alternate and Active Themes should now display all Theme options properly when selected through the jonradio Multiple Themes plugin.
|
424 |
+
</li>
|
425 |
+
</ol>
|
426 |
+
<h3>
|
427 |
+
Changing Templates
|
428 |
+
</h3>
|
429 |
+
<p>
|
430 |
+
Many Themes provide more than one Template.
|
431 |
+
For each Page or Post, you can select the Template you want to use for that Page or Post.
|
432 |
+
</p>
|
433 |
+
<p>
|
434 |
+
For the Active Theme, nothing changes when using the jonradio Multiple Themes plugin.
|
435 |
+
Select an alternate Template from the drop-down list in the Template field of the Page Attributes section of the Add New Page, Edit Page, Add New Post or Edit Post page of the Admin panels.
|
436 |
+
Or the Template field in Quick Edit.
|
437 |
+
</p>
|
438 |
+
<p>
|
439 |
+
It is more difficult to change Templates for Pages or Posts defined with the jonradio Multiple Themes plugin to use Installed Themes that are not the Active Theme.
|
440 |
+
Building this functionality into this plugin is in the plans for a future Version.
|
441 |
+
</p>
|
442 |
+
<p>
|
443 |
+
Use the Theme Test Drive plugin.
|
444 |
+
The jonradio Multiple Themes plugin (i.e. - this plugin) must be Deactivated, and the Theme Test Drive plugin installed and activated,
|
445 |
+
so that each Theme can be selected with the Theme Test Drive plugin,
|
446 |
+
allowing the Theme's Template to be set for each Page or Post using that Theme
|
447 |
+
<i>
|
448 |
+
as if
|
449 |
+
</i>
|
450 |
+
it were the Active Theme.
|
451 |
+
</p>
|
452 |
+
<ol>
|
453 |
+
<li>
|
454 |
+
Deactivate the jonradio Multiple Themes plugin.
|
455 |
+
</li>
|
456 |
+
<li>
|
457 |
+
Install the Theme Test Drive plugin found at
|
458 |
+
<a target="_blank" href="http://wordpress.org/plugins/theme-test-drive/">http://wordpress.org/plugins/theme-test-drive/</a>.
|
459 |
+
</li>
|
460 |
+
<li>
|
461 |
+
Activate the Theme Test Drive plugin.
|
462 |
+
</li>
|
463 |
+
<li>
|
464 |
+
Go to
|
465 |
+
<b>
|
466 |
+
Appearance-Theme Test Drive
|
467 |
+
</b>
|
468 |
+
in the WordPress Admin panels.
|
469 |
+
</li>
|
470 |
+
<li>
|
471 |
+
In the Usage section, select a Theme whose Templates need to be changed for a Post or Page.
|
472 |
+
</li>
|
473 |
+
<li>
|
474 |
+
Push the Enable Theme Drive button at the bottom of the Admin panel.
|
475 |
+
</li>
|
476 |
+
<li>
|
477 |
+
Go to Posts-All Posts or Pages-All Pages in the WordPress Admin panels.
|
478 |
+
</li>
|
479 |
+
<li>
|
480 |
+
For each Page or Post where a Template needs to be changed for this Theme,
|
481 |
+
mouse over the Page or Post title and click on Quick Edit.
|
482 |
+
</li>
|
483 |
+
<li>
|
484 |
+
Change the Template field.
|
485 |
+
</li>
|
486 |
+
<li>
|
487 |
+
Click the Update button.
|
488 |
+
</li>
|
489 |
+
<li>
|
490 |
+
Repeat Steps 8-10 for each Page or Post that requires a change to Template for this Theme.
|
491 |
+
</li>
|
492 |
+
<li>
|
493 |
+
If more than one Theme has Pages or Posts with Templates that need to be changed,
|
494 |
+
repeat Steps 4-11 for each Theme
|
495 |
+
(except the Active Theme,
|
496 |
+
where Template changes should only be made
|
497 |
+
<i>
|
498 |
+
without
|
499 |
+
</i>
|
500 |
+
the Theme Test Drive plugin activated).
|
501 |
+
</li>
|
502 |
+
<li>
|
503 |
+
Deactivate the Theme Test Drive plugin.
|
504 |
+
</li>
|
505 |
+
<li>
|
506 |
+
Activate this plugin (jonradio Multiple Themes).
|
507 |
+
</li>
|
508 |
+
<li>
|
509 |
+
Changing Templates for the Active Theme can now be made normally, just as you would without either plugin.
|
510 |
+
</li>
|
511 |
+
<li>
|
512 |
+
Both the alternate and Active Themes should now display the correct Template when selected through the jonradio Multiple Themes plugin.
|
513 |
+
</li>
|
514 |
+
</ol>
|
515 |
+
</div>
|
516 |
+
<div id="jr-mt-settings4" style="display: none;">
|
517 |
+
<h3>
|
518 |
+
System Information
|
519 |
+
</h3>
|
520 |
+
<?php
|
521 |
+
$posix = function_exists( 'posix_uname' );
|
522 |
+
echo '<p>You are currently running:<ul>';
|
523 |
+
echo "<li> » The {$jr_mt_plugin_data['Name']} plugin Version {$jr_mt_plugin_data['Version']}</li>";
|
524 |
+
echo "<li> »» The Path to the plugin's directory is <code>" . rtrim( jr_mt_path(), '/' ) . '</code></li>';
|
525 |
+
echo "<li> »» The URL to the plugin's directory is <code>" . plugins_url() . "/{$jr_mt_plugin_data['slug']}</code></li>";
|
526 |
+
echo "<li> » The Active Theme is $theme Version $theme_version</li>";
|
527 |
+
echo "<li> »» The Path to the Active Theme's stylesheet directory is <code>" . get_stylesheet_directory() . '</code></li>';
|
528 |
+
echo "<li> »» The Path to the Active Theme's template directory is <code>" . get_template_directory() . '</code></li>';
|
529 |
+
$permalink = get_option( 'permalink_structure' );
|
530 |
+
if ( empty( $permalink ) ) {
|
531 |
+
$permalink = 'Default (Query <code>/?p=123</code>)';
|
532 |
+
} else {
|
533 |
+
$permalink = "<code>$permalink</code>";
|
534 |
+
}
|
535 |
+
echo "<li> » The current Permalink Structure is $permalink";
|
536 |
+
echo "<li> » WordPress Version $current_wp_version</li>";
|
537 |
+
echo '<li> »» WordPress language is set to ' , get_bloginfo( 'language' ) . '</li>';
|
538 |
+
echo '<li> » ' . php_uname( 's' ) . ' operating system, Release/Version ' . php_uname( 'r' ) . ' / ' . php_uname( 'v' ) . '</li>';
|
539 |
+
if ( $posix ) {
|
540 |
+
$array = posix_getpwuid( posix_getuid() );
|
541 |
+
$user = $array['name'];
|
542 |
+
echo "<li> » Real operating system User ID that runs WordPress is $user</li>";
|
543 |
+
$array = posix_getpwuid( posix_geteuid() );
|
544 |
+
$user = $array['name'];
|
545 |
+
echo "<li> » Effective operating system User ID that runs WordPress is $user</li>";
|
546 |
+
}
|
547 |
+
echo '<li> » ' . php_uname( 'm' ) . ' computer hardware</li>';
|
548 |
+
echo '<li> » Host name ' . php_uname( 'n' ) . '</li>';
|
549 |
+
echo '<li> » php Version ' . phpversion() . '</li>';
|
550 |
+
echo '<li> »» php memory_limit ' . ini_get('memory_limit') . '</li>';
|
551 |
+
if ( !$posix ) {
|
552 |
+
echo '<li> »» POSIX functions are not available</li>';
|
553 |
+
}
|
554 |
+
echo '<li> » Zend engine Version ' . zend_version() . '</li>';
|
555 |
+
echo '<li> » Web Server software is ' . getenv( 'SERVER_SOFTWARE' ) . '</li>';
|
556 |
+
if ( function_exists( 'apache_get_version' ) && ( FALSE !== $apache = apache_get_version() ) ) {
|
557 |
+
echo "<li> »» Apache Version $apache</li>";
|
558 |
+
}
|
559 |
+
global $wpdb;
|
560 |
+
echo '<li> » MySQL Version ' . $wpdb->get_var( 'SELECT VERSION();', 0, 0 ) . '</li>';
|
561 |
+
|
562 |
+
echo '</ul></p>';
|
563 |
+
|
564 |
+
$paths = array(
|
565 |
+
'/..',
|
566 |
+
'/',
|
567 |
+
'/wp-content/',
|
568 |
+
'/wp-content/plugins/',
|
569 |
+
'/wp-content/plugins/' . dirname( jr_mt_plugin_basename() ),
|
570 |
+
'/wp-content/plugins/' . dirname( jr_mt_plugin_basename() ) . '/readme.txt'
|
571 |
+
);
|
572 |
+
echo '<h3>File Permissions</h3><p>All of the Paths shown below are relative to the WordPress Site Path <code>'
|
573 |
+
. ABSPATH
|
574 |
+
. '</code><br />The first is the Parent Directory <code>'
|
575 |
+
. dirname( ABSPATH )
|
576 |
+
. '/</code> and the second is the WordPress Site Path itself.</p><table class="widefat"><thead><tr><th>Path</th><th>Type</th><th>Read</th><th>Write</th>';
|
577 |
+
if ( $posix ) {
|
578 |
+
echo '<th>Owner</th><th>Group</th>';
|
579 |
+
}
|
580 |
+
echo '</tr></thead><tbody>';
|
581 |
+
foreach ( $paths as $path ) {
|
582 |
+
$full_path = ABSPATH . substr( $path, 1 );
|
583 |
+
if ( is_dir( $full_path ) ) {
|
584 |
+
$type = 'Directory';
|
585 |
+
} else {
|
586 |
+
$type = 'File';
|
587 |
+
}
|
588 |
+
if ( is_readable( $full_path ) ) {
|
589 |
+
$read = 'Yes';
|
590 |
+
} else {
|
591 |
+
$read = 'No';
|
592 |
+
}
|
593 |
+
if ( is_writeable( $full_path ) ) {
|
594 |
+
$write = 'Yes';
|
595 |
+
} else {
|
596 |
+
$write = 'No';
|
597 |
+
}
|
598 |
+
if ( $posix ) {
|
599 |
+
if ( FALSE === ( $uid = fileowner( $full_path ) ) ) {
|
600 |
+
$user = '-';
|
601 |
+
$group = '-';
|
602 |
+
} else {
|
603 |
+
$array = posix_getpwuid( $uid );
|
604 |
+
$user = $array['name'];
|
605 |
+
$array = posix_getgrgid( filegroup( $full_path ) );
|
606 |
+
$group = $array['name'];
|
607 |
+
}
|
608 |
+
}
|
609 |
+
echo "<tr><td>$path</td><td>$type</td><td>$read</td><td>$write</td>";
|
610 |
+
if ( $posix ) {
|
611 |
+
echo "<td>$user</td><td>$group</td>";
|
612 |
+
}
|
613 |
+
echo '<tr>';
|
614 |
+
}
|
615 |
+
echo '</tbody></table>';
|
616 |
+
?>
|
617 |
+
</div>
|
618 |
+
<div id="jr-mt-settings5" style="display: none;">
|
619 |
+
<p>
|
620 |
+
It is possible to downgrade from Version 5 to Version 4.12.
|
621 |
+
<a href="http://downloads.wordpress.org/plugin/jonradio-multiple-themes.4.12.zip">Click here</a>
|
622 |
+
to download Version 4.12.
|
623 |
+
</p>
|
624 |
+
<h3>
|
625 |
+
What's New in Version 5?
|
626 |
+
</h3>
|
627 |
+
<p>
|
628 |
+
Version 5.0 of the jonradio Multiple Themes plugin
|
629 |
+
saw a major rewrite of the Theme Selection logic,
|
630 |
+
the first since the plugin was originally written,
|
631 |
+
and the addition of Tabs to the Settings page,
|
632 |
+
for easier navigation.
|
633 |
+
</p>
|
634 |
+
<p>
|
635 |
+
Major improvements include:
|
636 |
+
</p>
|
637 |
+
<ol>
|
638 |
+
<li>
|
639 |
+
Greatly expanded compatibility with other Plugins and Themes;
|
640 |
+
</li>
|
641 |
+
<li>
|
642 |
+
Allow <code>?keyword=value&keyword=value</code> Queries
|
643 |
+
in URL, URL Prefix and URL Prefix with Asterisk ("*")
|
644 |
+
Theme Selection entries;
|
645 |
+
</li>
|
646 |
+
<li>
|
647 |
+
Accurate Theme Selection even for plugins and themes that request
|
648 |
+
Stylesheet or Template information before WordPress is fully loaded;
|
649 |
+
</li>
|
650 |
+
<li>
|
651 |
+
Tabs for the Setting page written in JavaScript
|
652 |
+
for instant switching between tabs
|
653 |
+
and preservation of input data,
|
654 |
+
e.g. - switch between Settings and Advanced Settings tabs
|
655 |
+
without having to retype your changes when you switch back;
|
656 |
+
</li>
|
657 |
+
<li>
|
658 |
+
Plugin's Theme Selection entries, if any,
|
659 |
+
displayed in the order in which they are processed,
|
660 |
+
to clarify which Theme will be displayed for any given URL;
|
661 |
+
</li>
|
662 |
+
<li>
|
663 |
+
Complete How-To details on
|
664 |
+
Theme Option and Template selection
|
665 |
+
right on the Settings page,
|
666 |
+
replacing the FAQs
|
667 |
+
in the WordPress Plugin Directory;
|
668 |
+
</li>
|
669 |
+
<li>
|
670 |
+
Automatic deletion of Theme Selection entries
|
671 |
+
for Themes that have been deleted;
|
672 |
+
</li>
|
673 |
+
<li>
|
674 |
+
Enhanced performance with tighter code,
|
675 |
+
and less of it,
|
676 |
+
on the public side of your WordPress site.
|
677 |
+
</li>
|
678 |
+
</ol>
|
679 |
+
<p>
|
680 |
+
The only disadvantages of the new Theme Selection methods used in Version 5 are:
|
681 |
+
</p>
|
682 |
+
<ol>
|
683 |
+
<li>
|
684 |
+
Changing Permalinks invalidates more Theme Selection settings than in previous versions;
|
685 |
+
</li>
|
686 |
+
<li>
|
687 |
+
Changing the Theme for an Entry
|
688 |
+
requires Deletion of the old Entry
|
689 |
+
before or after
|
690 |
+
adding the same Entry
|
691 |
+
with the new Theme specified;
|
692 |
+
</li>
|
693 |
+
<li>
|
694 |
+
The new Theme Selection logic,
|
695 |
+
based on URL Matching rather than Page, Post, Attachment, Category and Archive IDs,
|
696 |
+
requires a conversion of some Settings from prior versions of the plugin.
|
697 |
+
This conversion to the new format occurs automatically
|
698 |
+
the first time that Version 5 runs.
|
699 |
+
Old format settings are retained,
|
700 |
+
transparently without being displayed on the Settings page,
|
701 |
+
to allow downgrading to Version 4 from Version 5.
|
702 |
+
</li>
|
703 |
+
</ol>
|
704 |
+
</div>
|
705 |
+
<hr />
|
706 |
+
<h3>
|
707 |
+
Need Help?
|
708 |
+
</h3>
|
709 |
+
<p>
|
710 |
+
Need help with this plugin?
|
711 |
+
Check the
|
712 |
+
<a href="#" onClick="jrMtTabs( 3, 5 );">Theme Options</a>
|
713 |
+
and
|
714 |
+
<a href="#" onClick="jrMtTabs( 5, 5 );">New in V5</a>
|
715 |
+
tabs above,
|
716 |
+
and the
|
717 |
+
<a target="_blank" href="http://wordpress.org/plugins/jonradio-multiple-themes/">Description</a>,
|
718 |
+
<a target="_blank" href="http://wordpress.org/plugins/jonradio-multiple-themes/faq/">FAQ</a>,
|
719 |
+
<a target="_blank" href="http://wordpress.org/plugins/jonradio-multiple-themes/installation/">Installation</a>
|
720 |
+
and
|
721 |
+
<a target="_blank" href="http://wordpress.org/support/plugin/jonradio-multiple-themes">Support</a>
|
722 |
+
tabs
|
723 |
+
in the <a target="_blank" href="http://wordpress.org/plugins/jonradio-multiple-themes/">WordPress Directory entry for this plugin</a>.
|
724 |
+
All of this information is based on the many support questions that jonradio has answered both on-line and via e-mail since this plugin was first released in 2012.
|
725 |
+
</p>
|
726 |
+
<p>
|
727 |
+
Please be sure to check them all out if you have any unanswered questions.
|
728 |
+
If you cannot find the answers to all of your questions there,
|
729 |
+
simply post your question in the
|
730 |
+
<a target="_blank" href="http://wordpress.org/support/plugin/jonradio-multiple-themes">Support Forum</a>
|
731 |
+
or
|
732 |
+
<a target="_blank" href="http://zatzlabs.com/contact-us/">contact jonradio directly</a>
|
733 |
+
(be sure to mention which plugin your question pertains to).
|
734 |
+
</p>
|
735 |
+
<p>
|
736 |
+
For information on other jonradio plugins,
|
737 |
+
including Contact and Donation information,
|
738 |
+
<a target="_blank" href="http://zatzlabs.com/plugins/">click here</a>.
|
739 |
+
</p>
|
740 |
+
<h3>
|
741 |
+
Want to Help?
|
742 |
+
</h3>
|
743 |
+
<p>
|
744 |
+
As well as <a target="_blank" href="http://zatzlabs.com/plugins/">Donations</a>,
|
745 |
+
you can also help by
|
746 |
+
<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/jonradio-multiple-themes">Reviewing this plugin</a>
|
747 |
+
for the WordPress Plugin Directory,
|
748 |
+
and telling other people that it works for your particular combination of Plugin version and WordPress version
|
749 |
+
in the Compability section of the
|
750 |
+
<a target="_blank" href="http://wordpress.org/plugins/jonradio-multiple-themes/">WordPress Directory entry for this plugin</a>.
|
751 |
+
</p>
|
752 |
+
</div>
|
753 |
+
<?php
|
754 |
+
/* </div> ends the <div class="wrap"> at the beginning
|
755 |
+
*/
|
756 |
+
}
|
757 |
+
|
758 |
+
add_action( 'admin_init', 'jr_mt_admin_init' );
|
759 |
+
|
760 |
+
/**
|
761 |
+
* Register and define the settings
|
762 |
+
*
|
763 |
+
* Everything to be stored and/or can be set by the user
|
764 |
+
*
|
765 |
+
*/
|
766 |
+
function jr_mt_admin_init() {
|
767 |
+
register_setting( 'jr_mt_settings', 'jr_mt_settings', 'jr_mt_validate_settings' );
|
768 |
+
$settings = get_option( 'jr_mt_settings' );
|
769 |
+
foreach ( array( 'query', 'url', 'url_prefix', 'url_asterisk' ) as $key ) {
|
770 |
+
if ( !empty( $settings[ $key ] ) ) {
|
771 |
+
$found = TRUE;
|
772 |
+
}
|
773 |
+
}
|
774 |
+
if ( isset( $found ) ) {
|
775 |
+
add_settings_section(
|
776 |
+
'jr_mt_delete_settings_section',
|
777 |
+
'Current Theme Selection Entries',
|
778 |
+
'jr_mt_delete_settings_expl',
|
779 |
+
'jr_mt_settings_page'
|
780 |
+
);
|
781 |
+
add_settings_field(
|
782 |
+
'del_entry',
|
783 |
+
'Theme Selection Entries:',
|
784 |
+
'jr_mt_echo_delete_entry',
|
785 |
+
'jr_mt_settings_page',
|
786 |
+
'jr_mt_delete_settings_section'
|
787 |
+
);
|
788 |
+
}
|
789 |
+
add_settings_section(
|
790 |
+
'jr_mt_site_home_section',
|
791 |
+
'Site Home',
|
792 |
+
'jr_mt_site_home_expl',
|
793 |
+
'jr_mt_settings_page'
|
794 |
+
);
|
795 |
+
add_settings_field(
|
796 |
+
'site_home',
|
797 |
+
'Select Theme for Site Home<br /><code>' . home_url() . '</code>',
|
798 |
+
'jr_mt_echo_site_home',
|
799 |
+
'jr_mt_settings_page',
|
800 |
+
'jr_mt_site_home_section'
|
801 |
+
);
|
802 |
+
add_settings_section(
|
803 |
+
'jr_mt_single_settings_section',
|
804 |
+
'<input name="save" type="submit" value="Save All Changes" class="button-primary" /></h3><h3>For An Individual Page, Post or other non-Admin page;<br />or a group of pages, specified by URL Prefix, optionally with Asterisk(s)',
|
805 |
+
'jr_mt_single_settings_expl',
|
806 |
+
'jr_mt_settings_page'
|
807 |
+
);
|
808 |
+
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' );
|
809 |
+
add_settings_field( 'add_theme', 'Theme', 'jr_mt_echo_add_theme', 'jr_mt_settings_page', 'jr_mt_single_settings_section' );
|
810 |
+
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' );
|
811 |
+
add_settings_section( 'jr_mt_querykw_section',
|
812 |
+
'For A Query Keyword on any Page, Post or other non-Admin page',
|
813 |
+
'jr_mt_querykw_expl',
|
814 |
+
'jr_mt_settings_page'
|
815 |
+
);
|
816 |
+
add_settings_field( 'add_querykw_theme', 'Theme', 'jr_mt_echo_add_querykw_theme', 'jr_mt_settings_page', 'jr_mt_querykw_section' );
|
817 |
+
add_settings_field( 'add_querykw_keyword', 'Query Keyword', 'jr_mt_echo_add_querykw_keyword', 'jr_mt_settings_page', 'jr_mt_querykw_section' );
|
818 |
+
add_settings_section( 'jr_mt_query_section',
|
819 |
+
'For A Query Keyword=Value on any Page, Post or other non-Admin page',
|
820 |
+
'jr_mt_query_expl',
|
821 |
+
'jr_mt_settings_page'
|
822 |
+
);
|
823 |
+
add_settings_field( 'add_query_theme', 'Theme', 'jr_mt_echo_add_query_theme', 'jr_mt_settings_page', 'jr_mt_query_section' );
|
824 |
+
add_settings_field( 'add_query_keyword', 'Query Keyword', 'jr_mt_echo_add_query_keyword', 'jr_mt_settings_page', 'jr_mt_query_section' );
|
825 |
+
add_settings_field( 'add_query_value', 'Query Value', 'jr_mt_echo_add_query_value', 'jr_mt_settings_page', 'jr_mt_query_section' );
|
826 |
+
add_settings_section( 'jr_mt_sticky_section',
|
827 |
+
'<input name="save" type="submit" value="Save All Changes" class="button-primary" /></h3></div><div id="jr-mt-settings2" 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',
|
828 |
+
'jr_mt_sticky_expl',
|
829 |
+
'jr_mt_settings_page'
|
830 |
+
);
|
831 |
+
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' );
|
832 |
+
add_settings_field( 'sticky_query', 'Keyword=Value Entries:', 'jr_mt_echo_sticky_query_entry', 'jr_mt_settings_page', 'jr_mt_sticky_section' );
|
833 |
+
add_settings_section( 'jr_mt_everything_section',
|
834 |
+
'Theme for Everything',
|
835 |
+
'jr_mt_everything_expl',
|
836 |
+
'jr_mt_settings_page'
|
837 |
+
);
|
838 |
+
add_settings_field( 'current',
|
839 |
+
'Select Theme for Everything, to Override WordPress Current Theme (<b>' . wp_get_theme()->Name . '</b>)',
|
840 |
+
'jr_mt_echo_current',
|
841 |
+
'jr_mt_settings_page',
|
842 |
+
'jr_mt_everything_section'
|
843 |
+
);
|
844 |
+
add_settings_section( 'jr_mt_all_settings_section',
|
845 |
+
'For All Pages and/or All Posts',
|
846 |
+
'jr_mt_all_settings_expl',
|
847 |
+
'jr_mt_settings_page'
|
848 |
+
);
|
849 |
+
$suffix = array(
|
850 |
+
'Pages' => '<br />(Pages created with Add Page)',
|
851 |
+
'Posts' => ''
|
852 |
+
);
|
853 |
+
foreach ( array( 'Pages', 'Posts' ) as $thing ) {
|
854 |
+
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',
|
855 |
+
array( 'thing' => $thing ) );
|
856 |
+
}
|
857 |
+
}
|
858 |
+
|
859 |
+
/**
|
860 |
+
* Section text for Section1
|
861 |
+
*
|
862 |
+
* Display an explanation of this Section
|
863 |
+
*
|
864 |
+
*/
|
865 |
+
function jr_mt_delete_settings_expl() {
|
866 |
+
?>
|
867 |
+
<p>
|
868 |
+
All Theme Selection entries are displayed below,
|
869 |
+
in the exact order in which they will be processed.
|
870 |
+
For example,
|
871 |
+
if a match is made with the first Entry,
|
872 |
+
the first Entry's Theme will be used,
|
873 |
+
no matter what Theme the Second and subsequent Entries specify.
|
874 |
+
</p>
|
875 |
+
<p>
|
876 |
+
You can delete any of these entries by filling in the check box beside the entry
|
877 |
+
and clicking any of the <b>Save All Changes</b> buttons.
|
878 |
+
To change the Theme for an entry,
|
879 |
+
you will need to delete the entry
|
880 |
+
and add the same entry with a different Theme in the relevant section
|
881 |
+
on this or the Advanced Settings tab.
|
882 |
+
</p>
|
883 |
+
<p>
|
884 |
+
To add or remove (or to learn about) the Sticky or Override setting for a Query,
|
885 |
+
see the Advanced Settings tab.
|
886 |
+
</p>
|
887 |
+
<?php
|
888 |
+
}
|
889 |
+
|
890 |
+
function jr_mt_echo_delete_entry() {
|
891 |
+
echo 'In order of Selection:<ol>';
|
892 |
+
$settings = get_option( 'jr_mt_settings' );
|
893 |
+
/* Display any Override entries first,
|
894 |
+
because they have the highest priority.
|
895 |
+
*/
|
896 |
+
foreach ( $settings['override']['query'] as $override_keyword => $override_value_array ) {
|
897 |
+
foreach ( $override_value_array as $override_value => $bool ) {
|
898 |
+
jr_mt_theme_entry(
|
899 |
+
'Query',
|
900 |
+
wp_get_theme( $settings['query'][ $override_keyword ][ $override_value ] )->Name,
|
901 |
+
$override_keyword,
|
902 |
+
$override_value
|
903 |
+
);
|
904 |
+
}
|
905 |
+
}
|
906 |
+
/* Display Non-Overrides:
|
907 |
+
first, keyword=value query in URL with matching setting entry.
|
908 |
+
*/
|
909 |
+
foreach ( $settings['query'] as $keyword => $value_array ) {
|
910 |
+
foreach ( $value_array as $value => $theme ) {
|
911 |
+
/* Wildcard Keyword=* entries come later
|
912 |
+
*/
|
913 |
+
if ( '*' !== $value ) {
|
914 |
+
if ( !isset( $settings['override']['query'][ $keyword ][ $value ] ) ) {
|
915 |
+
jr_mt_theme_entry(
|
916 |
+
'Query',
|
917 |
+
wp_get_theme( $theme )->Name,
|
918 |
+
$keyword,
|
919 |
+
$value
|
920 |
+
);
|
921 |
+
}
|
922 |
+
}
|
923 |
+
}
|
924 |
+
}
|
925 |
+
/* Display Non-Overrides:
|
926 |
+
second, wildcard keyword=* query in URL with matching setting entry.
|
927 |
+
*/
|
928 |
+
foreach ( $settings['query'] as $keyword => $value_array ) {
|
929 |
+
foreach ( $value_array as $value => $theme ) {
|
930 |
+
/* Wildcard Keyword=* entries
|
931 |
+
Overrides are not allowed, so no need to check.
|
932 |
+
*/
|
933 |
+
if ( '*' === $value ) {
|
934 |
+
jr_mt_theme_entry(
|
935 |
+
'Query',
|
936 |
+
wp_get_theme( $theme )->Name,
|
937 |
+
$keyword,
|
938 |
+
'*'
|
939 |
+
);
|
940 |
+
}
|
941 |
+
}
|
942 |
+
}
|
943 |
+
/* Display URL entries:
|
944 |
+
first, exact match URL entries;
|
945 |
+
second, prefix URL entries;
|
946 |
+
then, prefix URL entries with asterisk wildcards.
|
947 |
+
*/
|
948 |
+
foreach ( array(
|
949 |
+
'url' => 'URL',
|
950 |
+
'url_prefix' => 'URL Prefix',
|
951 |
+
'url_asterisk' => 'URL Prefix*'
|
952 |
+
) as $key => $description ) {
|
953 |
+
foreach ( $settings[ $key ] as $settings_array ) {
|
954 |
+
jr_mt_theme_entry(
|
955 |
+
$key,
|
956 |
+
wp_get_theme( $settings_array['theme'] )->Name,
|
957 |
+
$settings_array['url'],
|
958 |
+
$description
|
959 |
+
);
|
960 |
+
}
|
961 |
+
}
|
962 |
+
/* Home Entry, then All Posts and Pages, and Everything Else
|
963 |
+
*/
|
964 |
+
foreach ( array(
|
965 |
+
'site_home' => 'Home',
|
966 |
+
'all_posts' => 'All Posts',
|
967 |
+
'all_pages' => 'All Pages',
|
968 |
+
'current' => 'Everything Else'
|
969 |
+
) as $key => $description ) {
|
970 |
+
if ( '' !== $settings[ $key ] ) {
|
971 |
+
jr_mt_theme_entry(
|
972 |
+
$key,
|
973 |
+
wp_get_theme( $settings[ $key ] )->Name,
|
974 |
+
$description
|
975 |
+
);
|
976 |
+
}
|
977 |
+
}
|
978 |
+
if ( '' === $settings['current'] ) {
|
979 |
+
jr_mt_theme_entry(
|
980 |
+
'wordpress'
|
981 |
+
);
|
982 |
+
}
|
983 |
+
echo '</ol>';
|
984 |
+
}
|
985 |
+
|
986 |
+
/**
|
987 |
+
* Section text for Section2
|
988 |
+
*
|
989 |
+
* Display an explanation of this Section
|
990 |
+
*
|
991 |
+
*/
|
992 |
+
function jr_mt_site_home_expl() {
|
993 |
+
?>
|
994 |
+
<p>
|
995 |
+
In this section, you can select a different Theme for Site Home.
|
996 |
+
To remove a previously selected Theme, select the blank entry from the drop-down list.
|
997 |
+
</p>
|
998 |
+
<p>
|
999 |
+
In the <i>next</i> section, you will be able to select a Theme, including the Current Theme, for individual Pages, Posts or
|
1000 |
+
any other non-Admin pages that have their own Permalink; for example, specific Archive or Category pages.
|
1001 |
+
Or groups of Pages, Posts or any other non-Admin pages that share the same URL Prefix.
|
1002 |
+
</p>
|
1003 |
+
<p>
|
1004 |
+
There is also a Query Keyword section
|
1005 |
+
farther down this Settings page
|
1006 |
+
that allows
|
1007 |
+
you to select a Theme to use whenever a specified
|
1008 |
+
Query Keyword (<code>?keyword=value</code> or <code>&keyword=value</code>)
|
1009 |
+
appears in the URL of any Page, Post or other non-Admin page.
|
1010 |
+
Query entries will even override the Site Home entry,
|
1011 |
+
if the Query Keyword follows the Site Home URL.
|
1012 |
+
</p>
|
1013 |
+
<?php
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
function jr_mt_echo_site_home() {
|
1017 |
+
$settings = get_option( 'jr_mt_settings' );
|
1018 |
+
jr_mt_themes_field( 'site_home', $settings['site_home'], 'jr_mt_settings', FALSE );
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
/**
|
1022 |
+
* Section text for Section3
|
1023 |
+
*
|
1024 |
+
* Display an explanation of this Section
|
1025 |
+
*
|
1026 |
+
*/
|
1027 |
+
function jr_mt_single_settings_expl() {
|
1028 |
+
?>
|
1029 |
+
<p>
|
1030 |
+
Select a Theme for an individual Page, Post or
|
1031 |
+
any other non-Admin page that has its own Permalink; for example, a specific Archive or Category page.
|
1032 |
+
Or for a group of pages which have URLs that all begin with the same characters ("Prefix"),
|
1033 |
+
optionally specifying an Asterisk ("*") to match all subdirectories at specific levels.
|
1034 |
+
</p>
|
1035 |
+
<p>
|
1036 |
+
Then cut and paste the URL of the desired Page, Post, Prefix or other non-Admin page.
|
1037 |
+
And click any of the <b>Save All Changes</b> buttons to add the entry.
|
1038 |
+
</p>
|
1039 |
+
There are three types of Entries that you can specify here:
|
1040 |
+
<ol>
|
1041 |
+
<li>
|
1042 |
+
<b>URL</b> - if Visitor URL matches this URL, use this Theme
|
1043 |
+
</li>
|
1044 |
+
<li>
|
1045 |
+
<b>URL Prefix</b> - any Visitor URL that begins with this URL Prefix will use this Theme
|
1046 |
+
</li>
|
1047 |
+
<li>
|
1048 |
+
<b>URL Prefix with Asterisk(s)</b> - URL Prefix that matches any subdirectory where Asterisk ("*") is specified
|
1049 |
+
</li>
|
1050 |
+
</ol>
|
1051 |
+
For the third type, an Asterisk can only be specified to match the entire subdirectory name, not parts of the name:
|
1052 |
+
<blockquote>
|
1053 |
+
For example, using a Permalink structure that uses dates,
|
1054 |
+
where a typical Post might be at URL
|
1055 |
+
<code>http://example.com/wp/2014/04/13/daily-thoughts/</code>,
|
1056 |
+
a URL Prefix with Asterisk entry of
|
1057 |
+
<code>http://example.com/wp/*/04/*/d</code>
|
1058 |
+
would match all April Posts with Titles that begin with the letter "d", no matter what year they were posted.
|
1059 |
+
</blockquote>
|
1060 |
+
</p>
|
1061 |
+
<?php
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
function jr_mt_echo_add_is_prefix() {
|
1065 |
+
echo '<input type="radio" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="false" checked="checked" /> URL';
|
1066 |
+
?>
|
1067 |
+
<br/>
|
1068 |
+
<input type="radio" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="prefix" /> URL Prefix<br/>
|
1069 |
+
<input type="radio" id="add_is_prefix" name="jr_mt_settings[add_is_prefix]" value="*" /> URL Prefix with Asterisk ("*")
|
1070 |
+
<?php
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
function jr_mt_echo_add_theme() {
|
1074 |
+
jr_mt_themes_field( 'add_theme', '', 'jr_mt_settings', FALSE );
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
function jr_mt_echo_add_path_id() {
|
1078 |
+
?>
|
1079 |
+
<input id="add_path_id" name="jr_mt_settings[add_path_id]" type="text" size="100" maxlength="256" value="" />
|
1080 |
+
<br />
|
1081 |
+
(cut and paste URL here of Page, Post, Prefix or other)
|
1082 |
+
<br />
|
1083 |
+
URL must begin with
|
1084 |
+
<?php
|
1085 |
+
echo '<code>' . home_url() . '/</code>.';
|
1086 |
+
echo '<br />Beginning with Version 5.0, <code>keyword=value</code> Queries are now supported in all URLs.';
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
/**
|
1090 |
+
* Section text for Section4
|
1091 |
+
*
|
1092 |
+
* Display an explanation of this Section
|
1093 |
+
*
|
1094 |
+
*/
|
1095 |
+
function jr_mt_querykw_expl() {
|
1096 |
+
?>
|
1097 |
+
<p>
|
1098 |
+
Select a Theme to use
|
1099 |
+
whenever the specified Query Keyword (<code>?keyword=</code> or <code>&keyword=</code>)
|
1100 |
+
is found in the URL of
|
1101 |
+
any Page, Post or
|
1102 |
+
any other non-Admin page.
|
1103 |
+
And click any of the <b>Save All Changes</b> buttons to add the entry.
|
1104 |
+
</p>
|
1105 |
+
<p>
|
1106 |
+
<b>
|
1107 |
+
Note
|
1108 |
+
</b>
|
1109 |
+
that Query Keyword takes precedence over all other types of Theme selection entries.
|
1110 |
+
For example,
|
1111 |
+
<?php
|
1112 |
+
echo '<code>' . home_url() . '?firstname=dorothy</code>'
|
1113 |
+
. ' would use the Theme specified for the <code>firstname</code> keyword, not the Theme specified for Site Home.'
|
1114 |
+
. ' Query matching is case-insensitive, so all Keywords entered are stored in lower-case.</p>';
|
1115 |
+
}
|
1116 |
+
function jr_mt_echo_add_querykw_theme() {
|
1117 |
+
jr_mt_themes_field( 'add_querykw_theme', '', 'jr_mt_settings', FALSE );
|
1118 |
+
}
|
1119 |
+
function jr_mt_echo_add_querykw_keyword() {
|
1120 |
+
$three_dots = '…';
|
1121 |
+
echo '<code>'
|
1122 |
+
. home_url()
|
1123 |
+
. "/</code>$three_dots<code>/?"
|
1124 |
+
. '<input id="add_querykw_keyword" name="jr_mt_settings[add_querykw_keyword]" type="text" size="20" maxlength="64" value="" />=</code>'
|
1125 |
+
. $three_dots;
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
/**
|
1129 |
+
* Section text for Section5
|
1130 |
+
*
|
1131 |
+
* Display an explanation of this Section
|
1132 |
+
*
|
1133 |
+
*/
|
1134 |
+
function jr_mt_query_expl() {
|
1135 |
+
?>
|
1136 |
+
<p>
|
1137 |
+
Select a Theme to use
|
1138 |
+
whenever the specified Query Keyword <b>and</b> Value (<code>?keyword=value</code> or <code>&keyword=value</code>)
|
1139 |
+
are found in the URL of
|
1140 |
+
any Page, Post or
|
1141 |
+
any other non-Admin page.
|
1142 |
+
And click any of the <b>Save All Changes</b> buttons to add the entry.
|
1143 |
+
</p>
|
1144 |
+
<p>
|
1145 |
+
<b>
|
1146 |
+
Note
|
1147 |
+
</b>
|
1148 |
+
that Query Keyword=Value takes precedence over all other Theme selection entries,
|
1149 |
+
including a Query Keyword entry for the same Keyword.
|
1150 |
+
For example,
|
1151 |
+
<?php
|
1152 |
+
echo '<code>' . home_url() . '?firstname=dorothy</code>'
|
1153 |
+
. ' would use the Theme specified for the <code>firstname=dorothy</code> keyword=value pair,'
|
1154 |
+
. ' not the Theme specified for Site Home nor even the Theme specified for the Keyword <code>firstname</code>.'
|
1155 |
+
. ' Query matching is case-insensitive, so all Keywords and Values entered are stored in lower-case.</p>';
|
1156 |
+
}
|
1157 |
+
function jr_mt_echo_add_query_theme() {
|
1158 |
+
jr_mt_themes_field( 'add_query_theme', '', 'jr_mt_settings', FALSE );
|
1159 |
+
}
|
1160 |
+
function jr_mt_echo_add_query_keyword() {
|
1161 |
+
$three_dots = '…';
|
1162 |
+
echo '<code>'
|
1163 |
+
. home_url()
|
1164 |
+
. "/</code>$three_dots<code>/?"
|
1165 |
+
. '<input id="add_query_keyword" name="jr_mt_settings[add_query_keyword]" type="text" size="20" maxlength="64" value="" /></code>';
|
1166 |
+
}
|
1167 |
+
function jr_mt_echo_add_query_value() {
|
1168 |
+
echo '<code>'
|
1169 |
+
. '='
|
1170 |
+
. '<input id="add_query_value" name="jr_mt_settings[add_query_value]" type="text" size="20" maxlength="64" value="" /></code>';
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
/**
|
1174 |
+
* Section text for Section6
|
1175 |
+
*
|
1176 |
+
* Display an explanation of this Section
|
1177 |
+
*
|
1178 |
+
*/
|
1179 |
+
function jr_mt_sticky_expl() {
|
1180 |
+
/* "Membership System V2" is a paid plugin that blocks (our sticky) Cookies
|
1181 |
+
*/
|
1182 |
+
global $jr_mt_plugins_cache;
|
1183 |
+
foreach ( $jr_mt_plugins_cache as $rel_path => $plugin_data ) {
|
1184 |
+
if ( 0 === strncasecmp( 'memberium', $rel_path, 9 ) ) {
|
1185 |
+
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: '
|
1186 |
+
. $plugin_data['Name'];
|
1187 |
+
break;
|
1188 |
+
}
|
1189 |
+
}
|
1190 |
+
?>
|
1191 |
+
<p>
|
1192 |
+
If one of the
|
1193 |
+
<b>
|
1194 |
+
Keyword=Value Entries
|
1195 |
+
</b>
|
1196 |
+
shown below
|
1197 |
+
(if any)
|
1198 |
+
is present in the URL of a WordPress non-Admin webpage on the current WordPress Site
|
1199 |
+
and that Entry is:
|
1200 |
+
<ol>
|
1201 |
+
<li>
|
1202 |
+
<b>Sticky</b>,
|
1203 |
+
then the specified Theme will continue to be displayed for subsequent
|
1204 |
+
WordPress non-Admin webpages
|
1205 |
+
viewed by the same Visitor
|
1206 |
+
until an Override entry is encountered by the same Visitor.
|
1207 |
+
</li>
|
1208 |
+
<li>
|
1209 |
+
<b>Override</b>,
|
1210 |
+
then the specified Theme will be displayed,
|
1211 |
+
effectively ending any previous Sticky Theme that was being displayed
|
1212 |
+
for the same Visitor.
|
1213 |
+
</li>
|
1214 |
+
</ol>
|
1215 |
+
<b>
|
1216 |
+
Note
|
1217 |
+
</b>
|
1218 |
+
that,
|
1219 |
+
as explained in the
|
1220 |
+
Query Keyword=Value
|
1221 |
+
section on the Settings tab,
|
1222 |
+
Query Keyword=Value already takes precedence over all other Theme selection entries,
|
1223 |
+
even without the Override checkbox selected.
|
1224 |
+
Override is only intended to cancel a Sticky entry
|
1225 |
+
and display the specified Theme on the current WordPress non-Admin webpage.
|
1226 |
+
</p>
|
1227 |
+
<p>
|
1228 |
+
Implementation Notes:
|
1229 |
+
<ol>
|
1230 |
+
<li>
|
1231 |
+
The term "Same Visitor",
|
1232 |
+
used above,
|
1233 |
+
refers to a single combination of
|
1234 |
+
computer, browser and possibly computer user name,
|
1235 |
+
if the visitor's computer has multiple accounts or user names.
|
1236 |
+
A computer could be a smartphone, tablet, laptop, desktop or other Internet access device used by the Visitor.
|
1237 |
+
</li>
|
1238 |
+
<li>
|
1239 |
+
When Sticky is active for a given Visitor,
|
1240 |
+
the associated Query Keyword=Value is added to the
|
1241 |
+
URL of links displayed on the current WordPress non-Admin webpage.
|
1242 |
+
With the following exceptions:
|
1243 |
+
<ul>
|
1244 |
+
<li>
|
1245 |
+
a)
|
1246 |
+
Only links pointing to non-Admin webpages of the current WordPress Site are altered.
|
1247 |
+
</li>
|
1248 |
+
<li>
|
1249 |
+
b)
|
1250 |
+
The
|
1251 |
+
"When to add Sticky Query to a URL"
|
1252 |
+
setting below also controls when a Sticky Keyword=Value is added to a URL.
|
1253 |
+
</li>
|
1254 |
+
</ul>
|
1255 |
+
<li>
|
1256 |
+
Cookies are used for Sticky entries. If the visitor's browser refuses Cookies,
|
1257 |
+
or another Plugin blocks cookies,
|
1258 |
+
this setting will not work and no error messages will be displayed.
|
1259 |
+
</li>
|
1260 |
+
</ol>
|
1261 |
+
</p>
|
1262 |
+
<p>
|
1263 |
+
<b>
|
1264 |
+
Important:
|
1265 |
+
</b>
|
1266 |
+
the Sticky feature cannot be made to work in all WordPress environments.
|
1267 |
+
Timing, Cookie and other issues may be caused by other plugins, themes and visitor browser settings,
|
1268 |
+
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.
|
1269 |
+
</p>
|
1270 |
+
<?php
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
function jr_mt_echo_query_present() {
|
1274 |
+
$settings = get_option( 'jr_mt_settings' );
|
1275 |
+
/*
|
1276 |
+
FALSE if Setting "Append if no question mark ("?") found in URL", or
|
1277 |
+
TRUE if Setting "Append if no Override keyword=value found in URL"
|
1278 |
+
*/
|
1279 |
+
echo '<input type="radio" id="query_present" name="jr_mt_settings[query_present]" value="false" ';
|
1280 |
+
checked( $settings['query_present'], FALSE );
|
1281 |
+
echo ' /> Append if no question mark ("?") found in URL<br/><input type="radio" id="query_present" name="jr_mt_settings[query_present]" value="true" ';
|
1282 |
+
checked( $settings['query_present'] );
|
1283 |
+
echo ' /> Append if no Override <code>keyword=value</code> found in URL';
|
1284 |
+
}
|
1285 |
+
|
1286 |
+
function jr_mt_echo_sticky_query_entry() {
|
1287 |
+
global $jr_mt_kwvalsep;
|
1288 |
+
$settings = get_option( 'jr_mt_settings' );
|
1289 |
+
$three_dots = '…';
|
1290 |
+
$first = TRUE;
|
1291 |
+
if ( !empty( $settings['query'] ) ) {
|
1292 |
+
foreach ( $settings['query'] as $keyword => $value_array ) {
|
1293 |
+
foreach ( $value_array as $value => $theme ) {
|
1294 |
+
if ( '*' !== $value ) {
|
1295 |
+
if ( $first ) {
|
1296 |
+
$first = FALSE;
|
1297 |
+
} else {
|
1298 |
+
echo '<br />';
|
1299 |
+
}
|
1300 |
+
echo 'Sticky <input type="checkbox" id="sticky_query_entry" name="jr_mt_settings[sticky_query_entry][]" value="'
|
1301 |
+
. "$keyword$jr_mt_kwvalsep$value"
|
1302 |
+
. '" ';
|
1303 |
+
checked( isset( $settings['remember']['query'][$keyword][$value] ) );
|
1304 |
+
echo ' /> Override <input type="checkbox" id="override_query_entry" name="jr_mt_settings[override_query_entry][]" value="'
|
1305 |
+
. "$keyword$jr_mt_kwvalsep$value"
|
1306 |
+
. '" ';
|
1307 |
+
checked( isset( $settings['override']['query'][$keyword][$value] ) );
|
1308 |
+
echo ' /> Theme='
|
1309 |
+
. wp_get_theme( $theme )->Name . '; '
|
1310 |
+
. 'Query='
|
1311 |
+
. '<code>'
|
1312 |
+
. home_url()
|
1313 |
+
. "/</code>$three_dots<code>/?"
|
1314 |
+
. "<b><input type='text' readonly='readonly' disable='disabled' name='jr_mt_stkw' value='$keyword' size='"
|
1315 |
+
. jr_mt_strlen( $keyword )
|
1316 |
+
. "' /></b>"
|
1317 |
+
. '='
|
1318 |
+
. "<b><input type='text' readonly='readonly' disable='disabled' name='jr_mt_stkwval' value='$value' size='"
|
1319 |
+
. jr_mt_strlen( $value )
|
1320 |
+
. "' /></b></code>";
|
1321 |
+
}
|
1322 |
+
}
|
1323 |
+
}
|
1324 |
+
}
|
1325 |
+
if ( $first ) {
|
1326 |
+
echo 'None';
|
1327 |
+
}
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
function jr_mt_everything_expl() {
|
1331 |
+
?>
|
1332 |
+
<p>
|
1333 |
+
<b>Theme for Everything</b>
|
1334 |
+
simplifies the use of a Theme with Theme Settings that you need to change frequently,
|
1335 |
+
when the Theme is only going to be used on one or more Pages or Posts.
|
1336 |
+
The Theme can be set as the WordPress Active Theme through the Appearance-Themes admin panel,
|
1337 |
+
and set for specific Pages or Posts using this plugin's settings (on Settings tab),
|
1338 |
+
with another Theme specified below as the plugin's default theme ("Theme for Everything").
|
1339 |
+
</p>
|
1340 |
+
<?php
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
function jr_mt_echo_current() {
|
1344 |
+
$settings = get_option( 'jr_mt_settings' );
|
1345 |
+
jr_mt_themes_field( 'current', $settings['current'], 'jr_mt_settings', TRUE );
|
1346 |
+
echo '<br />(select blank entry for default: WordPress Active Theme defined in Appearance-Themes, currently <b>' . wp_get_theme()->Name . '</b>)';
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
function jr_mt_all_settings_expl() {
|
1350 |
+
?>
|
1351 |
+
<p>
|
1352 |
+
These are
|
1353 |
+
<b>
|
1354 |
+
Advanced Setting
|
1355 |
+
</b>
|
1356 |
+
because they may not work with every other plugin, theme or permalinks setting.
|
1357 |
+
This plugin is only able to determine whether what is about to be displayed at the current URL
|
1358 |
+
is a Page or Post
|
1359 |
+
after all other Plugins have been loaded;
|
1360 |
+
the one exception to this is the Default setting for Permalinks,
|
1361 |
+
when <code>?p=</code> and <code>?page_id=</code> are used.
|
1362 |
+
</p>
|
1363 |
+
<p>
|
1364 |
+
Some other plugins and themes request the name of the current Theme
|
1365 |
+
<i>
|
1366 |
+
too early,
|
1367 |
+
</i>
|
1368 |
+
while they are being loaded,
|
1369 |
+
which is before this plugin is able to determine if it is on a Page or Post.
|
1370 |
+
For this reason,
|
1371 |
+
using either of these settings may not work properly for all other plugins and themes.
|
1372 |
+
As a result,
|
1373 |
+
if you choose to use either or both of these two settings,
|
1374 |
+
careful testing is advised immediately
|
1375 |
+
<u>and</u>
|
1376 |
+
whenever you change the Permalink setting, activate a plugin or start using a different theme.
|
1377 |
+
</p>
|
1378 |
+
<p>
|
1379 |
+
In this section, you can select a different Theme for All Pages and/or All Posts.
|
1380 |
+
To remove a previously selected Theme, select the blank entry from the drop-down list.
|
1381 |
+
</p>
|
1382 |
+
<p>
|
1383 |
+
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
|
1384 |
+
any other non-Admin pages that have their own Permalink; for example, specific Archive or Category pages.
|
1385 |
+
Or groups of Pages, Posts or any other non-Admin pages that share the same URL Prefix.
|
1386 |
+
</p>
|
1387 |
+
<p>
|
1388 |
+
The Settings tab also has a Query Keyword section
|
1389 |
+
that allows
|
1390 |
+
you to select a Theme to use whenever a specified
|
1391 |
+
Query Keyword (<code>?keyword=value</code> or <code>&keyword=value</code>)
|
1392 |
+
appears in the URL of any Page, Post or other non-Admin page.
|
1393 |
+
</p>
|
1394 |
+
<?php
|
1395 |
+
}
|
1396 |
+
|
1397 |
+
function jr_mt_echo_all_things( $thing ) {
|
1398 |
+
$settings = get_option( 'jr_mt_settings' );
|
1399 |
+
$field = 'all_' . strtolower( $thing['thing'] );
|
1400 |
+
jr_mt_themes_field( $field, $settings[$field], 'jr_mt_settings', TRUE );
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
function jr_mt_validate_settings( $input ) {
|
1404 |
+
global $jr_mt_kwvalsep;
|
1405 |
+
$valid = array();
|
1406 |
+
|
1407 |
+
if ( isset( $input['permalink'] ) ) {
|
1408 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
1409 |
+
$internal_settings['permalink'] = get_option( 'permalink_structure' );
|
1410 |
+
update_option( 'jr_mt_internal_settings', $internal_setting );
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
foreach ( array( 'all_pages', 'all_posts', 'site_home', 'current' ) as $thing ) {
|
1414 |
+
$valid[$thing] = $input[$thing];
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
$settings = get_option( 'jr_mt_settings' );
|
1418 |
+
$prefix_types = array(
|
1419 |
+
'false' => 'url',
|
1420 |
+
'prefix' => 'url_prefix',
|
1421 |
+
'*' => 'url_asterisk'
|
1422 |
+
);
|
1423 |
+
foreach ( $prefix_types as $key => $thing ) {
|
1424 |
+
$valid[$thing] = $settings[$thing];
|
1425 |
+
}
|
1426 |
+
$query = $settings['query'];
|
1427 |
+
$remember = array( 'query' => array() );
|
1428 |
+
if ( isset( $input['sticky_query_entry'] ) ) {
|
1429 |
+
foreach ( $input['sticky_query_entry'] as $query_entry ) {
|
1430 |
+
list( $keyword, $value ) = explode( $jr_mt_kwvalsep, $query_entry );
|
1431 |
+
/* Data Sanitization not required as
|
1432 |
+
Keyword and Value are not entered by a human,
|
1433 |
+
but extracted from previously-generated HTML.
|
1434 |
+
*/
|
1435 |
+
$remember['query'][$keyword][$value] = TRUE;
|
1436 |
+
}
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
$override = array( 'query' => array() );
|
1440 |
+
if ( isset( $input['override_query_entry'] ) ) {
|
1441 |
+
foreach ( $input['override_query_entry'] as $query_entry ) {
|
1442 |
+
list( $keyword, $value ) = explode( $jr_mt_kwvalsep, $query_entry );
|
1443 |
+
/* Data Sanitization not required as
|
1444 |
+
Keyword and Value are not entered by a human,
|
1445 |
+
but extracted from previously-generated HTML.
|
1446 |
+
*/
|
1447 |
+
$override['query'][$keyword][$value] = TRUE;
|
1448 |
+
}
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
if ( isset ( $input['del_entry'] ) ) {
|
1452 |
+
foreach ( $input['del_entry'] as $del_entry ) {
|
1453 |
+
$del_array = explode( '=', $del_entry, 3 );
|
1454 |
+
if ( 'query' === $del_array[0] ) {
|
1455 |
+
unset( $query[ $del_array[1] ][ $del_array[2] ] );
|
1456 |
+
if ( empty( $query[ $del_array[1] ] ) ) {
|
1457 |
+
unset( $query[ $del_array[1] ] );
|
1458 |
+
}
|
1459 |
+
/* unset() does nothing if a variable or array element does not exist.
|
1460 |
+
*/
|
1461 |
+
unset( $remember['query'][ $del_array[1] ][ $del_array[2] ] );
|
1462 |
+
if ( empty( $remember['query'][ $del_array[1] ] ) ) {
|
1463 |
+
unset( $remember['query'][ $del_array[1] ] );
|
1464 |
+
}
|
1465 |
+
unset( $override['query'][ $del_array[1] ][ $del_array[2] ] );
|
1466 |
+
if ( empty( $override['query'][ $del_array[1] ] ) ) {
|
1467 |
+
unset( $override['query'][ $del_array[1] ] );
|
1468 |
+
}
|
1469 |
+
} else {
|
1470 |
+
/* Check for a URL entry
|
1471 |
+
*/
|
1472 |
+
if ( 'url' === substr( $del_array[0], 0, 3 ) ) {
|
1473 |
+
foreach ( $valid[ $del_array[0] ] as $i => $entry_array ) {
|
1474 |
+
if ( $entry_array['url'] === $del_array[2] ) {
|
1475 |
+
/* Cannot unset $entry_array, even if prefixed by & in foreach
|
1476 |
+
*/
|
1477 |
+
unset( $valid[ $del_array[0] ][ $i ] );
|
1478 |
+
break;
|
1479 |
+
}
|
1480 |
+
}
|
1481 |
+
} else {
|
1482 |
+
/* Must be Home, All Pages or Posts, or Everything
|
1483 |
+
*/
|
1484 |
+
$valid[ $del_array[0] ] = '';
|
1485 |
+
}
|
1486 |
+
}
|
1487 |
+
}
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
/* Handle troublesome %E2%80%8E UTF Left-to-right Mark (LRM) suffix first.
|
1491 |
+
*/
|
1492 |
+
if ( FALSE === stripos( $input['add_path_id'], '%E2%80%8E' ) ) {
|
1493 |
+
if ( FALSE === stripos( rawurlencode( $input['add_path_id'] ), '%E2%80%8E' ) ) {
|
1494 |
+
$url = $input['add_path_id'];
|
1495 |
+
} else {
|
1496 |
+
$url = rawurldecode( str_ireplace( '%E2%80%8E', '', rawurlencode( $input['add_path_id'] ) ) );
|
1497 |
+
}
|
1498 |
+
} else {
|
1499 |
+
$url = str_ireplace( '%E2%80%8E', '', $input['add_path_id'] );
|
1500 |
+
}
|
1501 |
+
$url = rawurldecode( trim( $url ) );
|
1502 |
+
|
1503 |
+
if ( ( empty( $input['add_theme'] ) && !empty( $url ) ) || ( !empty( $input['add_theme'] ) && empty( $url ) ) ) {
|
1504 |
+
add_settings_error(
|
1505 |
+
'jr_mt_settings',
|
1506 |
+
'jr_mt_emptyerror',
|
1507 |
+
'Both URL and Theme must be specified to add an Individual entry',
|
1508 |
+
'error'
|
1509 |
+
);
|
1510 |
+
} else {
|
1511 |
+
if ( !empty( $url ) ) {
|
1512 |
+
if ( jr_mt_same_prefix_url( home_url(), $url ) ) {
|
1513 |
+
if ( ( '*' !== $input['add_is_prefix'] ) && ( FALSE !== strpos( $url, '*' ) ) ) {
|
1514 |
+
add_settings_error(
|
1515 |
+
'jr_mt_settings',
|
1516 |
+
'jr_mt_queryerror',
|
1517 |
+
'Asterisk ("*") only allowed when "URL Prefix with Asterisk" selected: <code>' . $url . '</code>',
|
1518 |
+
'error'
|
1519 |
+
);
|
1520 |
+
} else {
|
1521 |
+
$prep_url = jr_mt_prep_url( $url );
|
1522 |
+
if ( 'false' === $input['add_is_prefix'] ) {
|
1523 |
+
if ( jr_mt_same_url( $prep_url, home_url() ) ) {
|
1524 |
+
add_settings_error(
|
1525 |
+
'jr_mt_settings',
|
1526 |
+
'jr_mt_homeerror',
|
1527 |
+
'Please use "Select Theme for Site Home" field instead of specifying Site Home URL as an individual entry.',
|
1528 |
+
'error'
|
1529 |
+
);
|
1530 |
+
} else {
|
1531 |
+
if ( jr_mt_same_prefix_url( $prep_url, admin_url() ) ) {
|
1532 |
+
add_settings_error(
|
1533 |
+
'jr_mt_settings',
|
1534 |
+
'jr_mt_adminerror',
|
1535 |
+
'Admin Page URLs are not allowed because no known Themes alter the appearance of Admin pages: <code>' . $url . '</code>',
|
1536 |
+
'error'
|
1537 |
+
);
|
1538 |
+
}
|
1539 |
+
}
|
1540 |
+
} else {
|
1541 |
+
if ( '*' === $input['add_is_prefix'] ) {
|
1542 |
+
$url_dirs = explode( '/', str_replace( '\\', '/', $url ) );
|
1543 |
+
foreach ( $url_dirs as $dir ) {
|
1544 |
+
if ( FALSE !== strpos( $dir, '*' ) ) {
|
1545 |
+
$asterisk_found = TRUE;
|
1546 |
+
if ( '*' !== $dir ) {
|
1547 |
+
$asterisk_not_alone = TRUE;
|
1548 |
+
}
|
1549 |
+
break;
|
1550 |
+
}
|
1551 |
+
}
|
1552 |
+
if ( isset( $asterisk_found ) ) {
|
1553 |
+
if ( isset( $asterisk_not_alone ) ) {
|
1554 |
+
add_settings_error(
|
1555 |
+
'jr_mt_settings',
|
1556 |
+
'jr_mt_queryerror',
|
1557 |
+
'An Asterisk ("*") may only replace a full subdirectory name, not just a portion of it: <code>' . $url . '</code>',
|
1558 |
+
'error'
|
1559 |
+
);
|
1560 |
+
}
|
1561 |
+
} else {
|
1562 |
+
add_settings_error(
|
1563 |
+
'jr_mt_settings',
|
1564 |
+
'jr_mt_queryerror',
|
1565 |
+
'No Asterisk ("*") specified but "URL Prefix with Asterisk" selected: <code>' . $url . '</code>',
|
1566 |
+
'error'
|
1567 |
+
);
|
1568 |
+
}
|
1569 |
+
}
|
1570 |
+
}
|
1571 |
+
|
1572 |
+
function jr_mt_settings_errors() {
|
1573 |
+
$errors = get_settings_errors();
|
1574 |
+
if ( !empty( $errors ) ) {
|
1575 |
+
foreach ( $errors as $error_array ) {
|
1576 |
+
if ( 'error' === $error_array['type'] ) {
|
1577 |
+
return TRUE;
|
1578 |
+
}
|
1579 |
+
}
|
1580 |
+
}
|
1581 |
+
return FALSE;
|
1582 |
+
}
|
1583 |
+
|
1584 |
+
if ( !jr_mt_settings_errors() ) {
|
1585 |
+
/* ['url'], ['url_prefix'] or ['url_asterisk']
|
1586 |
+
*/
|
1587 |
+
$key = $prefix_types[ $input['add_is_prefix'] ];
|
1588 |
+
$valid[ $key ][] = array(
|
1589 |
+
'url' => $url,
|
1590 |
+
'prep' => $prep_url,
|
1591 |
+
'theme' => $input['add_theme']
|
1592 |
+
);
|
1593 |
+
}
|
1594 |
+
}
|
1595 |
+
} else {
|
1596 |
+
add_settings_error(
|
1597 |
+
'jr_mt_settings',
|
1598 |
+
'jr_mt_urlerror',
|
1599 |
+
' URL specified is not part of current WordPress web site: <code>'
|
1600 |
+
. $url
|
1601 |
+
. '</code>. URL must begin with <code>'
|
1602 |
+
. home_url()
|
1603 |
+
. '</code>.',
|
1604 |
+
'updated'
|
1605 |
+
);
|
1606 |
+
}
|
1607 |
+
}
|
1608 |
+
}
|
1609 |
+
|
1610 |
+
/* Make sure reserved characters are not used
|
1611 |
+
in URL Query keyword or value fields on Settings page.
|
1612 |
+
*/
|
1613 |
+
function jr_mt_query_chars( $element, $where ) {
|
1614 |
+
foreach (
|
1615 |
+
array(
|
1616 |
+
'=' => 'Equals Sign' ,
|
1617 |
+
'?' => 'Question Mark' ,
|
1618 |
+
'&' => 'Ampersand' ,
|
1619 |
+
' ' => 'Blank' ,
|
1620 |
+
'#' => 'Number Sign' ,
|
1621 |
+
'/' => 'Slash' ,
|
1622 |
+
'\\' => 'Backslash' ,
|
1623 |
+
'[' => 'Square Bracket',
|
1624 |
+
']' => 'Square Bracket',
|
1625 |
+
) as $char => $name ) {
|
1626 |
+
if ( FALSE !== strpos( $element, $char ) ) {
|
1627 |
+
add_settings_error(
|
1628 |
+
'jr_mt_settings',
|
1629 |
+
'jr_mt_queryerror',
|
1630 |
+
'Illegal character used in '
|
1631 |
+
. $where
|
1632 |
+
. ': '
|
1633 |
+
. $name
|
1634 |
+
. ' ("' . $char . '") in "'
|
1635 |
+
. $element
|
1636 |
+
. '"',
|
1637 |
+
'error'
|
1638 |
+
);
|
1639 |
+
return FALSE;
|
1640 |
+
}
|
1641 |
+
}
|
1642 |
+
return TRUE;
|
1643 |
+
}
|
1644 |
+
/* Data Sanitization needed here
|
1645 |
+
*/
|
1646 |
+
$keyword = jr_mt_prep_query_keyword( $input['add_querykw_keyword'] );
|
1647 |
+
if ( !empty( $input['add_querykw_theme'] ) && !empty( $keyword ) ) {
|
1648 |
+
if ( jr_mt_query_chars( $keyword, 'Query Keyword' ) ) {
|
1649 |
+
/* If there is an existing entry for the Keyword,
|
1650 |
+
then replace it.
|
1651 |
+
Otherwise, create a new entry.
|
1652 |
+
*/
|
1653 |
+
$query[$keyword]['*'] = $input['add_querykw_theme'];
|
1654 |
+
}
|
1655 |
+
} else {
|
1656 |
+
if ( !( empty( $input['add_querykw_theme'] ) && empty( $keyword ) ) ) {
|
1657 |
+
add_settings_error(
|
1658 |
+
'jr_mt_settings',
|
1659 |
+
'jr_mt_emptyerror',
|
1660 |
+
'Both Query Keyword and Theme must be specified to add an Individual Query Keyword entry',
|
1661 |
+
'error'
|
1662 |
+
);
|
1663 |
+
}
|
1664 |
+
}
|
1665 |
+
|
1666 |
+
/* Data Sanitization needed here
|
1667 |
+
*/
|
1668 |
+
$keyword = jr_mt_prep_query_keyword( $input['add_query_keyword'] );
|
1669 |
+
$value = jr_mt_prep_query_value( $input['add_query_value'] );
|
1670 |
+
if ( !empty( $input['add_query_theme'] ) && !empty( $keyword ) && !empty( $value ) ) {
|
1671 |
+
if ( jr_mt_query_chars( $keyword, 'Query Keyword' ) && jr_mt_query_chars( $value, 'Query Value' ) ) {
|
1672 |
+
/* If there is an existing entry for the Keyword and Value pair,
|
1673 |
+
then replace it.
|
1674 |
+
Otherwise, create a new entry.
|
1675 |
+
*/
|
1676 |
+
$query[$keyword][$value] = $input['add_query_theme'];
|
1677 |
+
}
|
1678 |
+
} else {
|
1679 |
+
if ( !( empty( $input['add_query_theme'] ) && empty( $keyword ) && empty( $value ) ) ) {
|
1680 |
+
add_settings_error(
|
1681 |
+
'jr_mt_settings',
|
1682 |
+
'jr_mt_emptyerror',
|
1683 |
+
'Query Keyword, Value and Theme must all be specified to add an Individual Query entry',
|
1684 |
+
'error'
|
1685 |
+
);
|
1686 |
+
}
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
if ( 'true' === $input['query_present'] ) {
|
1690 |
+
$valid['query_present'] = TRUE;
|
1691 |
+
} else {
|
1692 |
+
if ( 'false' === $input['query_present'] ) {
|
1693 |
+
$valid['query_present'] = FALSE;
|
1694 |
+
}
|
1695 |
+
}
|
1696 |
+
|
1697 |
+
$errors = get_settings_errors();
|
1698 |
+
if ( empty( $errors ) ) {
|
1699 |
+
add_settings_error(
|
1700 |
+
'jr_mt_settings',
|
1701 |
+
'jr_mt_saved',
|
1702 |
+
'Settings Saved',
|
1703 |
+
'updated'
|
1704 |
+
);
|
1705 |
+
}
|
1706 |
+
$valid['query'] = $query;
|
1707 |
+
$valid['remember'] = $remember;
|
1708 |
+
$valid['override'] = $override;
|
1709 |
+
return $valid;
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
?>
|
includes/functions.php
ADDED
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Exit if .php file accessed directly
|
4 |
+
*/
|
5 |
+
if ( !defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
global $jr_mt_path;
|
10 |
+
$jr_mt_path = plugin_dir_path( JR_MT_FILE );
|
11 |
+
/**
|
12 |
+
* Return Plugin's full directory path with trailing slash
|
13 |
+
*
|
14 |
+
* Local XAMPP install might return:
|
15 |
+
* C:\xampp\htdocs\wpbeta\wp-content\plugins\jonradio-multiple-themes/
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
function jr_mt_path() {
|
19 |
+
global $jr_mt_path;
|
20 |
+
return $jr_mt_path;
|
21 |
+
}
|
22 |
+
|
23 |
+
global $jr_mt_plugin_basename;
|
24 |
+
$jr_mt_plugin_basename = plugin_basename( JR_MT_FILE );
|
25 |
+
/**
|
26 |
+
* Return Plugin's Basename
|
27 |
+
*
|
28 |
+
* For this plugin, it would be:
|
29 |
+
* jonradio-multiple-themes/jonradio-multiple-themes.php
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
function jr_mt_plugin_basename() {
|
33 |
+
global $jr_mt_plugin_basename;
|
34 |
+
return $jr_mt_plugin_basename;
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( !function_exists( 'get_plugin_data' ) ) {
|
38 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
39 |
+
}
|
40 |
+
|
41 |
+
global $jr_mt_plugin_data;
|
42 |
+
$jr_mt_plugin_data = get_plugin_data( JR_MT_FILE );
|
43 |
+
$jr_mt_plugin_data['slug'] = basename( dirname( JR_MT_FILE ) );
|
44 |
+
|
45 |
+
global $jr_mt_options_cache;
|
46 |
+
$all_options = wp_load_alloptions();
|
47 |
+
$jr_mt_options_cache['stylesheet'] = $all_options['stylesheet'];
|
48 |
+
$jr_mt_options_cache['template'] = $all_options['template'];
|
49 |
+
|
50 |
+
/* Handle this Odd Situation:
|
51 |
+
For WordPress 4.0 and all previous versions,
|
52 |
+
wp_get_themes() returns array() when this plugin is Network Activated.
|
53 |
+
Waiting until Action 'plugins_loaded' overcomes this problem,
|
54 |
+
but potentially creates other problems.
|
55 |
+
*/
|
56 |
+
if ( is_plugin_active_for_network( $jr_mt_plugin_basename ) ) {
|
57 |
+
add_action( JR_MT_WP_GET_THEMES_ACTION, 'jr_mt_wp_get_themes_fix', JR_MT_RUN_FIRST );
|
58 |
+
function jr_mt_wp_get_themes_fix() {
|
59 |
+
DEFINE( 'JR_MT_WP_GET_THEMES_WORKS', TRUE );
|
60 |
+
/* Force the next request for Stylesheet or Template
|
61 |
+
to process the Theme Selection logic,
|
62 |
+
even if previous requests have cached the Theme.
|
63 |
+
*/
|
64 |
+
unset( $GLOBALS['jr_mt_theme'] );
|
65 |
+
if ( is_admin() ) {
|
66 |
+
global $jr_mt_all_themes_cache;
|
67 |
+
$jr_mt_all_themes_cache = wp_get_themes();
|
68 |
+
update_option( 'jr_mt_all_themes', $jr_mt_all_themes_cache );
|
69 |
+
}
|
70 |
+
}
|
71 |
+
} else {
|
72 |
+
DEFINE( 'JR_MT_WP_GET_THEMES_WORKS', TRUE );
|
73 |
+
}
|
74 |
+
function jr_mt_all_themes() {
|
75 |
+
if ( defined( 'JR_MT_WP_GET_THEMES_WORKS' ) ) {
|
76 |
+
global $jr_mt_all_themes_cache;
|
77 |
+
if ( isset( $jr_mt_all_themes_cache ) ) {
|
78 |
+
$return = $jr_mt_all_themes_cache;
|
79 |
+
} else {
|
80 |
+
$return = wp_get_themes();
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
/* Probably not valid,
|
84 |
+
typically empty array.
|
85 |
+
Better to store and retrieve from Settings myself.
|
86 |
+
*/
|
87 |
+
if ( FALSE === ( $return = get_option( 'jr_mt_all_themes' ) ) ) {
|
88 |
+
$return = wp_get_themes();
|
89 |
+
}
|
90 |
+
}
|
91 |
+
return $return;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Check for missing Settings and set them to defaults
|
96 |
+
*
|
97 |
+
* Ensures that the Named Setting exists, and populates it with defaults for any missing values.
|
98 |
+
* Safe to use on every execution of a plugin because it only does an expensive Database Write
|
99 |
+
* when it finds missing Settings.
|
100 |
+
*
|
101 |
+
* Does not delete any key not found in $defaults.
|
102 |
+
*
|
103 |
+
* @param string $name Name of Settings as looked up with get_option()
|
104 |
+
* @param array $defaults Each default Settings value in [key] => value format
|
105 |
+
* @return bool/Null Return value from update_option(), or NULL if update_option() not called
|
106 |
+
*/
|
107 |
+
function jr_mt_missing_settings( $name, $defaults ) {
|
108 |
+
$updated = FALSE;
|
109 |
+
if ( FALSE === ( $settings = get_option( $name ) ) ) {
|
110 |
+
$settings = $defaults;
|
111 |
+
$updated = TRUE;
|
112 |
+
} else {
|
113 |
+
foreach ( $defaults as $key => $value ) {
|
114 |
+
if ( !isset( $settings[$key] ) ) {
|
115 |
+
$settings[$key] = $value;
|
116 |
+
$updated = TRUE;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
if ( $updated ) {
|
121 |
+
$return = update_option( $name, $settings );
|
122 |
+
} else {
|
123 |
+
$return = NULL;
|
124 |
+
}
|
125 |
+
return $return;
|
126 |
+
}
|
127 |
+
|
128 |
+
/* As well as dealing with the low probability that a single mb_ function has been disabled in a php.ini,
|
129 |
+
this also supports older versions of PHP as mb_ functions were introduced one by one over a number of php versions.
|
130 |
+
*/
|
131 |
+
if ( function_exists( 'mb_substr' ) ) {
|
132 |
+
function jr_mt_substr() {
|
133 |
+
$args = func_get_args();
|
134 |
+
if ( isset( $args[2] ) ) {
|
135 |
+
return mb_substr( $args[0], $args[1], $args[2] );
|
136 |
+
} else {
|
137 |
+
return mb_substr( $args[0], $args[1] );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
} else {
|
141 |
+
function jr_mt_substr() {
|
142 |
+
$args = func_get_args();
|
143 |
+
if ( isset( $args[2] ) ) {
|
144 |
+
return substr( $args[0], $args[1], $args[2] );
|
145 |
+
} else {
|
146 |
+
return substr( $args[0], $args[1] );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
if ( function_exists( 'mb_strlen' ) ) {
|
151 |
+
function jr_mt_strlen( $string ) {
|
152 |
+
return mb_strlen( $string );
|
153 |
+
}
|
154 |
+
} else {
|
155 |
+
function jr_mt_strlen( $string ) {
|
156 |
+
return strlen( $string );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
if ( function_exists( 'mb_strtolower' ) ) {
|
160 |
+
function jr_mt_strtolower( $string ) {
|
161 |
+
return mb_strtolower( $string );
|
162 |
+
}
|
163 |
+
} else {
|
164 |
+
function jr_mt_strtolower( $string ) {
|
165 |
+
return strtolower( $string );
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Return WordPress Current Theme, as defined in Appearance Admin panels
|
171 |
+
*
|
172 |
+
* Obtains Folder Name of Current Theme, from 'template' option of wp_load_alloptions().
|
173 |
+
*
|
174 |
+
* @param string $option parameter to select current template or stylesheet
|
175 |
+
* @return string type Folder Name of Current Theme
|
176 |
+
*/
|
177 |
+
function jr_mt_current_theme( $option ) {
|
178 |
+
global $jr_mt_options_cache;
|
179 |
+
return $jr_mt_options_cache[$option];
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* What Themes are defined to Plugin?
|
184 |
+
*
|
185 |
+
* @return arr - a list of Themes (folder names) defined in Settings of Plugin, plus Active WordPress Theme
|
186 |
+
**/
|
187 |
+
function jr_mt_themes_defined() {
|
188 |
+
$themes = array( jr_mt_current_theme( 'stylesheet' ), jr_mt_current_theme( 'template' ) );
|
189 |
+
$settings = get_option( 'jr_mt_settings' );
|
190 |
+
foreach ( $settings as $key => $value ) {
|
191 |
+
switch ( $key ) {
|
192 |
+
case 'url':
|
193 |
+
case 'url_prefix':
|
194 |
+
case 'url_asterisk':
|
195 |
+
foreach ( $value as $arr ) {
|
196 |
+
$themes[] = $arr['theme'];
|
197 |
+
}
|
198 |
+
break;
|
199 |
+
case 'query':
|
200 |
+
foreach ( $value as $keyword => $arr1 ) {
|
201 |
+
foreach ( $arr1 as $value => $theme ) {
|
202 |
+
$themes[] = $theme;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
break;
|
206 |
+
case 'all_pages':
|
207 |
+
case 'all_posts':
|
208 |
+
case 'site_home':
|
209 |
+
case 'current':
|
210 |
+
if ( !empty( $value ) ) {
|
211 |
+
$themes[] = $value;
|
212 |
+
}
|
213 |
+
break;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
return array_unique( $themes );
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Do two URLs point at the same location on a web site?
|
221 |
+
*
|
222 |
+
* Preps URL, if string
|
223 |
+
*
|
224 |
+
* @param string/array $url1 URL to compare, a string, or an array in special format created by companion function
|
225 |
+
* @param string/array $url2 URL to compare, a string, or an array in special format created by companion function
|
226 |
+
* @return bool bool TRUE if URL matches prefix; FALSE otherwise
|
227 |
+
*/
|
228 |
+
function jr_mt_same_url( $url1, $url2 ) {
|
229 |
+
if ( is_string( $url1 ) ) {
|
230 |
+
$url1 = jr_mt_prep_url( $url1 );
|
231 |
+
}
|
232 |
+
if ( is_string( $url2 ) ) {
|
233 |
+
$url2 = jr_mt_prep_url( $url2 );
|
234 |
+
}
|
235 |
+
return ( $url1 == $url2 );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Does a specified Prefix URL match the given URL?
|
240 |
+
*
|
241 |
+
* Preps URL, if string.
|
242 |
+
* Note: parameters MUST be in the right order
|
243 |
+
*
|
244 |
+
* @param string/array $prefix front part of a URL to compare, a string, or an array in special format created by companion function
|
245 |
+
* @param string/array $url full URL to compare, a string, or an array in special format created by companion function
|
246 |
+
* @return bool bool TRUE if Prefix matches first part of URL; FALSE otherwise
|
247 |
+
*/
|
248 |
+
function jr_mt_same_prefix_url( $prefix, $url ) {
|
249 |
+
if ( is_string( $prefix ) ) {
|
250 |
+
$prefix = jr_mt_prep_url( $prefix );
|
251 |
+
}
|
252 |
+
if ( is_string( $url ) ) {
|
253 |
+
$url = jr_mt_prep_url( $url );
|
254 |
+
}
|
255 |
+
if ( $url['host'] === $prefix['host'] ) {
|
256 |
+
if ( $url['path'] === $prefix['path'] ) {
|
257 |
+
/* Host and Path both exactly match for URL and Prefix specified.
|
258 |
+
*/
|
259 |
+
if ( array() === $prefix['query'] ) {
|
260 |
+
$match = TRUE;
|
261 |
+
} else {
|
262 |
+
/* Now the hard part: determining a legitimate prefix match for Query
|
263 |
+
*/
|
264 |
+
foreach ( $prefix['query'] as $prefix_keyword => $prefix_value ) {
|
265 |
+
$one_match = FALSE;
|
266 |
+
foreach ( $url['query'] as $url_keyword => $url_value ) {
|
267 |
+
if ( $prefix_keyword === jr_mt_substr( $url_keyword, 0, jr_mt_strlen( $prefix_keyword ) ) ) {
|
268 |
+
if ( $prefix_value === jr_mt_substr( $url_value, 0, jr_mt_strlen( $prefix_value ) ) ) {
|
269 |
+
$one_match = TRUE;
|
270 |
+
}
|
271 |
+
}
|
272 |
+
}
|
273 |
+
/* All Prefix Queries must match.
|
274 |
+
*/
|
275 |
+
if ( FALSE === $one_match ) {
|
276 |
+
return FALSE;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
$match = TRUE;
|
280 |
+
}
|
281 |
+
} else {
|
282 |
+
/* Paths must exactly match if Prefix specifies Query
|
283 |
+
*/
|
284 |
+
if ( array() === $prefix['query'] ) {
|
285 |
+
/* No Query in Prefix, so check Path for Prefix match
|
286 |
+
*/
|
287 |
+
$match = ( $prefix['path'] === jr_mt_substr( $url['path'], 0, jr_mt_strlen( $prefix['path'] ) ) );
|
288 |
+
} else {
|
289 |
+
$match = FALSE;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
} else {
|
293 |
+
if ( ( '' === $prefix['path'] ) && ( array() === $prefix['query'] ) ) {
|
294 |
+
/* No Path or Query in Prefix, so check Host for Prefix match
|
295 |
+
*/
|
296 |
+
$match = ( $prefix['host'] === jr_mt_substr( $url['host'], 0, jr_mt_strlen( $prefix['host'] ) ) );
|
297 |
+
} else {
|
298 |
+
/* Hosts must exactly match if Prefix specifies Path or Query
|
299 |
+
*/
|
300 |
+
$match = FALSE;
|
301 |
+
}
|
302 |
+
}
|
303 |
+
return $match;
|
304 |
+
}
|
305 |
+
|
306 |
+
function jr_mt_same_prefix_url_asterisk( $prefix, $url ) {
|
307 |
+
if ( is_string( $prefix ) ) {
|
308 |
+
$prefix = jr_mt_prep_url( $prefix );
|
309 |
+
}
|
310 |
+
if ( is_string( $url ) ) {
|
311 |
+
$url = jr_mt_prep_url( $url );
|
312 |
+
}
|
313 |
+
$path_prefix = explode( '/', $prefix['path'] );
|
314 |
+
$path_url = explode( '/', $url['path'] );
|
315 |
+
foreach ( $path_prefix as $i => $directory ) {
|
316 |
+
if ( '*' === $directory ) {
|
317 |
+
$path_url[ $i ] = '*';
|
318 |
+
}
|
319 |
+
}
|
320 |
+
$url['path'] = implode( '/', $path_url );
|
321 |
+
return jr_mt_same_prefix_url( $prefix, $url );
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Standardize a URL into an array of values that can be accurately compared with another
|
326 |
+
*
|
327 |
+
* Preps URL, by removing any UTF Left-to-right Mark (LRM), usually found as a suffix,
|
328 |
+
* translating the URL to lower-case, removing prefix http[s]//:[www.],
|
329 |
+
* any embedded index.php and any trailing slash or #bookmark,
|
330 |
+
* and breaks up ?keyword=value queries into array elements.
|
331 |
+
*
|
332 |
+
* Structure/Elements of Array returned:
|
333 |
+
* [host] - domain.com - www. is removed, but all other subdomains are included
|
334 |
+
* [path] - dir/file.ext
|
335 |
+
* [query] - any Queries (e.g. - "?kw=val&kw2=val2") broken up as follows:
|
336 |
+
* [$keyword] => $value with preceding equals sign, only if equals sign was present
|
337 |
+
* To simplify processing of this Array, zero length strings and empty arrays are used,
|
338 |
+
* rather than NULL entries or missing array elements.
|
339 |
+
*
|
340 |
+
* @param string $url URL to create an array from, in special format for accurate comparison
|
341 |
+
* @return array array of standardized attributes of the URL (see structure above)
|
342 |
+
*/
|
343 |
+
function jr_mt_prep_url( $url ) {
|
344 |
+
/* Handle troublesome %E2%80%8E UTF Left-to-right Mark (LRM) suffix first.
|
345 |
+
*/
|
346 |
+
if ( FALSE === strpos( $url, '%E2%80%8E' ) ) {
|
347 |
+
if ( FALSE === strpos( rawurlencode( $url ), '%E2%80%8E' ) ) {
|
348 |
+
$url_clean = $url;
|
349 |
+
} else {
|
350 |
+
$url_clean = rawurldecode( str_replace( '%E2%80%8E', '', rawurlencode( $url ) ) );
|
351 |
+
/* mb_str_replace() does not exist because str_replace() is binary-safe.
|
352 |
+
*/
|
353 |
+
}
|
354 |
+
} else {
|
355 |
+
$url_clean = str_replace( '%E2%80%8E', '', $url );
|
356 |
+
}
|
357 |
+
$url_clean = str_replace( '\\', '/', trim( $url_clean ) );
|
358 |
+
|
359 |
+
/* parse_url(), especially before php Version 5.4.7,
|
360 |
+
has a history of problems when Scheme is not present,
|
361 |
+
especially for LocalHost as a Host,
|
362 |
+
so add a prefix of http:// if :// is not found
|
363 |
+
*/
|
364 |
+
if ( FALSE === strpos( $url_clean, '://' ) ) {
|
365 |
+
$url_clean = "http://$url_clean";
|
366 |
+
}
|
367 |
+
|
368 |
+
$parse_array = parse_url( jr_mt_strtolower( $url_clean ) );
|
369 |
+
/* Get rid of URL components that do not matter to us in our comparison of URLs
|
370 |
+
*/
|
371 |
+
foreach ( array( 'scheme', 'port', 'user', 'pass', 'fragment' ) as $component ) {
|
372 |
+
unset ( $parse_array[$component] );
|
373 |
+
}
|
374 |
+
/* Remove www. from host
|
375 |
+
*/
|
376 |
+
if ( 'www.' === substr( $parse_array['host'], 0, 4 ) ) {
|
377 |
+
$parse_array['host'] = substr( $parse_array['host'], 4 );
|
378 |
+
}
|
379 |
+
if ( isset( $parse_array['path'] ) ) {
|
380 |
+
/* Remove any index.php occurences in path, since these can be spurious in IIS
|
381 |
+
and perhaps other environments.
|
382 |
+
*/
|
383 |
+
$parse_array['path'] = str_replace( 'index.php', '', $parse_array['path'] );
|
384 |
+
/* Remove leading and trailing slashes from path
|
385 |
+
*/
|
386 |
+
$parse_array['path'] = trim( $parse_array['path'], "/\\" );
|
387 |
+
} else {
|
388 |
+
$parse_array['path'] = '';
|
389 |
+
}
|
390 |
+
/* Take /?keyword=value&keyword=value URL query parameters
|
391 |
+
and break them up into array( keyword => value, keyword => value )
|
392 |
+
*/
|
393 |
+
if ( isset( $parse_array['query'] ) ) {
|
394 |
+
$parms = explode( '&', $parse_array['query'] );
|
395 |
+
$parse_array['query'] = array();
|
396 |
+
foreach( $parms as $parm ) {
|
397 |
+
if ( FALSE === ( $cursor = strpos( $parm, '=' ) ) ) {
|
398 |
+
$parse_array['query'][$parm] = '';
|
399 |
+
} else {
|
400 |
+
/* Include the Equals Sign ("=") as the first character of the Query Value
|
401 |
+
to differentiate between a URL Prefix with a Query Keyword followed by
|
402 |
+
an Equals Sign, and one without. For example, "address" would match
|
403 |
+
address2=abc, while "address=" would not.
|
404 |
+
*/
|
405 |
+
$parse_array['query'][jr_mt_substr( $parm, 0, $cursor + 1 )] = jr_mt_substr( $parm, $cursor + 1 );
|
406 |
+
}
|
407 |
+
}
|
408 |
+
} else {
|
409 |
+
$parse_array['query'] = array();
|
410 |
+
}
|
411 |
+
return $parse_array;
|
412 |
+
}
|
413 |
+
|
414 |
+
/** Build Query Array
|
415 |
+
|
416 |
+
$array[keyword] = array( value, value, ... )
|
417 |
+
Sets both keyword and value to lower-case as
|
418 |
+
that is how they are stored in Settings.
|
419 |
+
|
420 |
+
Supports only & separator, not proposed semi-colon separator.
|
421 |
+
|
422 |
+
Handles duplicate keywords in all four of these forms:
|
423 |
+
kw=val1&kw=val2 kw[]=val1&kw[]=val2 kw=val1&kw=val1 kw[]=val1&kw[]=val1
|
424 |
+
but nothing else, e.g. - kw=val1,val2 is not valid;
|
425 |
+
it returns "val1,val2" as the Value.
|
426 |
+
Also handles kw1&kw2
|
427 |
+
|
428 |
+
Tests of parse_str() in PHP 5.5.9 proved that semi-colon and comma
|
429 |
+
are not supported. But, neither is kw=val1,kw=val2 which is why
|
430 |
+
this function is written without the use of parse_str.
|
431 |
+
*/
|
432 |
+
function jr_mt_query_array() {
|
433 |
+
/* Remove array entry indicators ("[]") as we properly handle duplicate keywords,
|
434 |
+
and covert to lower-case for comparison purposes.
|
435 |
+
*/
|
436 |
+
$queries = array();
|
437 |
+
if ( !empty( $_SERVER['QUERY_STRING'] ) ) {
|
438 |
+
$query = explode( '&', jr_mt_strtolower( str_replace( '[]', '', $_SERVER['QUERY_STRING'] ) ) );
|
439 |
+
foreach ( $query as $kwval ) {
|
440 |
+
$query_entry = explode( '=', $kwval );
|
441 |
+
if ( !isset( $query_entry[1] ) ) {
|
442 |
+
$query_entry[1] = '';
|
443 |
+
}
|
444 |
+
$queries[ $query_entry[0] ][] = $query_entry[1];
|
445 |
+
}
|
446 |
+
}
|
447 |
+
return $queries;
|
448 |
+
}
|
449 |
+
|
450 |
+
?>
|
includes/index.html
ADDED
File without changes
|
includes/old-wp.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if .php file accessed directly
|
3 |
+
if ( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
/* A Version of WordPress older than the first one supported by the Plugin
|
6 |
+
is being run.
|
7 |
+
*/
|
8 |
+
|
9 |
+
add_action( 'all_admin_notices', 'jr_mt_all_admin_notice' );
|
10 |
+
// Runs after admin_menu hook
|
11 |
+
add_action( 'admin_notices', 'jr_mt_all_admin_notice' ); // for older versions
|
12 |
+
|
13 |
+
function jr_mt_all_admin_notice() {
|
14 |
+
// Only displayed in Admin panels:
|
15 |
+
echo '<div class="error">Deactivated the <b>jonradio Multiple Themes</b> plugin: requires WordPress Version 3.4 or newer; you are running Version '
|
16 |
+
. get_bloginfo( 'version' ) . '</div>';
|
17 |
+
deactivate_plugins( JR_MT_FILE );
|
18 |
+
}
|
19 |
+
|
20 |
+
?>
|
includes/select-theme.php
ADDED
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Exit if .php file accessed directly
|
3 |
+
*/
|
4 |
+
if ( !defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
+
/* Select the relevant Theme
|
9 |
+
These hooks must be available immediately
|
10 |
+
as some Themes check them very early.
|
11 |
+
Also must be available in Admin for p2.
|
12 |
+
*/
|
13 |
+
add_filter( 'pre_option_stylesheet', 'jr_mt_stylesheet' );
|
14 |
+
add_filter( 'pre_option_template', 'jr_mt_template' );
|
15 |
+
|
16 |
+
if ( !is_admin() ) {
|
17 |
+
/* Hooks below shown in order of execution */
|
18 |
+
|
19 |
+
/* Only do this if All Posts or All Pages setting is present.
|
20 |
+
*/
|
21 |
+
if ( get_option( 'permalink_structure' ) && jr_mt_all_posts_pages() ) {
|
22 |
+
/* 'setup_theme' is the earliest Action that I could find where url_to_postid( $url )
|
23 |
+
is valid. get_post() works by then, too.
|
24 |
+
*/
|
25 |
+
add_action( 'setup_theme', 'jr_mt_page_conditional', JR_MT_RUN_FIRST );
|
26 |
+
function jr_mt_page_conditional() {
|
27 |
+
/* In case any requests for Theme came before this hook,
|
28 |
+
make sure that Theme Selection is repeated the next time
|
29 |
+
it is needed.
|
30 |
+
Because url_to_postid() and possibly get_post() don't work until now.
|
31 |
+
|
32 |
+
Note: in PHP, you cannot directly unset a global variable,
|
33 |
+
hence the cryptic code below.
|
34 |
+
*/
|
35 |
+
unset( $GLOBALS['jr_mt_theme'] );
|
36 |
+
DEFINE( 'JR_MT_PAGE_CONDITIONAL', TRUE );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
add_action( 'wp_loaded', 'jr_mt_wp_loaded', JR_MT_RUN_LAST );
|
41 |
+
function jr_mt_wp_loaded() {
|
42 |
+
/* Purpose of this hook is to output any required Cookie before it is too late
|
43 |
+
(after the <html> or any other HTML is generated).
|
44 |
+
There is no performance impact because this effectively pre-caches values
|
45 |
+
for use later.
|
46 |
+
This timing is also used to enqueue JavaScript related to the Sticky feature.
|
47 |
+
*/
|
48 |
+
global $jr_mt_theme;
|
49 |
+
if ( !isset( $jr_mt_theme ) ) {
|
50 |
+
$settings = get_option( 'jr_mt_settings' );
|
51 |
+
if ( !empty( $settings['remember']['query'] ) ) {
|
52 |
+
jr_mt_template();
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
DEFINE( 'JR_MT_TOO_LATE_FOR_COOKIES', TRUE );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
function jr_mt_stylesheet() {
|
61 |
+
return jr_mt_theme( 'stylesheet' );
|
62 |
+
}
|
63 |
+
|
64 |
+
function jr_mt_template() {
|
65 |
+
return jr_mt_theme( 'template' );
|
66 |
+
}
|
67 |
+
|
68 |
+
function jr_mt_theme( $option ) {
|
69 |
+
/* The hooks that (indirectly) call this function are called repeatedly by WordPress,
|
70 |
+
so do the checking once and store the values in a global array.
|
71 |
+
$jt_mt_theme['stylesheet'] - Stylesheet Name of Theme chosen
|
72 |
+
$jt_mt_theme['template'] - Template Name of Theme chosen
|
73 |
+
|
74 |
+
Very important note:
|
75 |
+
- get_option( 'jr_mt_settings' ) ['ids']['theme'] is the Theme Subdirectory Name,
|
76 |
+
as opposed to the Template or Stylesheet Name for the Theme.
|
77 |
+
- likewise, the variable local variable $theme
|
78 |
+
These three different values for each Theme must be clearly separated, as all three usually
|
79 |
+
match, but do not have to, e.g. - Child Themes.
|
80 |
+
*/
|
81 |
+
global $jr_mt_theme;
|
82 |
+
if ( !isset( $jr_mt_theme ) ) {
|
83 |
+
$jr_mt_theme = array();
|
84 |
+
}
|
85 |
+
if ( !isset( $jr_mt_theme[$option] ) ) {
|
86 |
+
$theme = jr_mt_chosen();
|
87 |
+
$jr_mt_all_themes = jr_mt_all_themes();
|
88 |
+
/* Check to be sure that Theme is still installed.
|
89 |
+
If not:
|
90 |
+
return Everywhere theme if set and it exists,
|
91 |
+
otherwise, FALSE to indicate WordPress Active Theme.
|
92 |
+
*/
|
93 |
+
if ( ( FALSE !== $theme ) && ( !isset( $jr_mt_all_themes[ $theme ] ) ) ) {
|
94 |
+
$settings = get_option( 'jr_mt_settings' );
|
95 |
+
$everything = $settings['current'];
|
96 |
+
if ( ( '' !== $everything ) && ( isset( $jr_mt_all_themes[ $everything ] ) ) ) {
|
97 |
+
$theme = $everything;
|
98 |
+
} else {
|
99 |
+
$theme = FALSE;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
if ( FALSE === $theme ) {
|
103 |
+
// Get both at once, to save a repeat of this logic later:
|
104 |
+
$jr_mt_theme['stylesheet'] = jr_mt_current_theme( 'stylesheet' );
|
105 |
+
$jr_mt_theme['template'] = jr_mt_current_theme( 'template' );
|
106 |
+
} else {
|
107 |
+
$jr_mt_theme['stylesheet'] = $jr_mt_all_themes[ $theme ]->stylesheet;
|
108 |
+
$jr_mt_theme['template'] = $jr_mt_all_themes[ $theme ]->template;
|
109 |
+
}
|
110 |
+
if ( !is_admin() ) {
|
111 |
+
jr_mt_cookie( 'all', 'clean' );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
$theme = $jr_mt_theme[$option];
|
115 |
+
return $theme;
|
116 |
+
}
|
117 |
+
|
118 |
+
// Returns FALSE for Current Theme
|
119 |
+
function jr_mt_chosen() {
|
120 |
+
$settings = get_option( 'jr_mt_settings' );
|
121 |
+
|
122 |
+
/* $queries - array of [keyword] => array( value, value, ... )
|
123 |
+
in the current URL.
|
124 |
+
*/
|
125 |
+
$queries = jr_mt_query_array();
|
126 |
+
|
127 |
+
/* P2 free Theme special processing:
|
128 |
+
for both Admin and Public site,
|
129 |
+
check for P2 keyword p2ajax=,
|
130 |
+
and select P2 theme, if present.
|
131 |
+
*/
|
132 |
+
if ( isset( $queries['p2ajax'] ) && array_key_exists( 'p2', jr_mt_all_themes() ) ) {
|
133 |
+
return 'p2';
|
134 |
+
}
|
135 |
+
/* Otherwise, Admin gets current ("Active") WordPress Theme
|
136 |
+
*/
|
137 |
+
if ( is_admin() ) {
|
138 |
+
return FALSE;
|
139 |
+
}
|
140 |
+
|
141 |
+
/* KnowHow ThemeForest Paid Theme special processing:
|
142 |
+
if s= is present, and 'knowhow' is either the active WordPress Theme
|
143 |
+
or is specified in any Settings, then automatically select the KnowHow theme.
|
144 |
+
*/
|
145 |
+
if ( isset( $queries['s'] ) && in_array( 'knowhow', jr_mt_themes_defined() ) ) {
|
146 |
+
return 'knowhow';
|
147 |
+
}
|
148 |
+
|
149 |
+
/* Non-Admin page, i.e. - Public Site, etc.
|
150 |
+
|
151 |
+
Begin by checking for any Query keywords specified by the Admin in Settings,
|
152 |
+
complicated by the fact that Override entries take precedence.
|
153 |
+
*/
|
154 |
+
if ( !empty( $settings['query'] ) ) {
|
155 |
+
if ( '' !== $_SERVER['QUERY_STRING'] ) {
|
156 |
+
/* Check Override entries
|
157 |
+
*/
|
158 |
+
foreach ( $settings['override']['query'] as $override_keyword => $override_value_array ) {
|
159 |
+
if ( isset( $queries[ $override_keyword ] ) ) {
|
160 |
+
foreach ( $override_value_array as $override_value => $bool ) {
|
161 |
+
if ( in_array( $override_value, $queries[ $override_keyword ] ) ) {
|
162 |
+
$override_found[] = array( $override_keyword, $override_value );
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
if ( !isset( $overrides_found ) ) {
|
168 |
+
/* Look for both keyword=value settings and keyword=* settings,
|
169 |
+
with keyword=value taking precedence (sorted out later).
|
170 |
+
*/
|
171 |
+
foreach ( $settings['query'] as $query_settings_keyword => $value_array ) {
|
172 |
+
if ( isset( $queries[ $query_settings_keyword ] ) ) {
|
173 |
+
foreach ( $value_array as $query_settings_value => $theme ) {
|
174 |
+
if ( in_array( $query_settings_value, $queries[ $query_settings_keyword ] ) ) {
|
175 |
+
$query_found[] = array( $query_settings_keyword, $query_settings_value );
|
176 |
+
}
|
177 |
+
}
|
178 |
+
if ( isset( $value_array['*'] ) ) {
|
179 |
+
$keyword_found[] = $query_settings_keyword;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
/* Handle Overrides:
|
188 |
+
First, for Override keyword=value query in URL.
|
189 |
+
Second, for previous Override detected by PHP cookie.
|
190 |
+
*/
|
191 |
+
if ( isset( $override_found ) ) {
|
192 |
+
/* If sticky, create JavaScript Sticky Cookie,
|
193 |
+
and PHP Sticky Cookie.
|
194 |
+
No matter what:
|
195 |
+
return Theme from the first Override found.
|
196 |
+
*/
|
197 |
+
$keyword = $override_found[0][0];
|
198 |
+
$value = $override_found[0][1];
|
199 |
+
if ( isset( $settings['remember']['query'][ $keyword ][ $value ] ) ) {
|
200 |
+
jr_mt_js_sticky_query( $keyword, $value );
|
201 |
+
jr_mt_cookie( 'php', 'put', "$keyword=$value" );
|
202 |
+
}
|
203 |
+
return $settings['query'][ $keyword ][ $value ];
|
204 |
+
} else {
|
205 |
+
/* Is there a previous Override Query for this Site Visitor?
|
206 |
+
If so, use it, but only if it is still valid.
|
207 |
+
*/
|
208 |
+
if ( FALSE !== ( $cookie = jr_mt_cookie( 'php', 'get' ) ) ) {
|
209 |
+
list( $keyword, $value ) = explode( '=', $cookie );
|
210 |
+
if ( isset( $settings['override']['query'][ $keyword ][ $value ] ) ) {
|
211 |
+
/* If sticky, create JavaScript Sticky Cookie,
|
212 |
+
and renew PHP Sticky Cookie.
|
213 |
+
No matter what:
|
214 |
+
Return Theme
|
215 |
+
*/
|
216 |
+
if ( isset( $settings['remember']['query'][ $keyword ][ $value ] ) ) {
|
217 |
+
jr_mt_js_sticky_query( $keyword, $value );
|
218 |
+
jr_mt_cookie( 'php', 'put', "$keyword=$value" );
|
219 |
+
}
|
220 |
+
return $settings['query'][ $keyword ][ $value ];
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
/* Handle Non-Overrides:
|
226 |
+
keyword=value query in URL with matching setting entry.
|
227 |
+
*/
|
228 |
+
if ( isset( $query_found ) ) {
|
229 |
+
$query_keyword_found = $query_found[0][0];
|
230 |
+
$query_value_found = $query_found[0][1];
|
231 |
+
/* Probably makes sense to give preference to the Sticky ones
|
232 |
+
*/
|
233 |
+
foreach ( $query_found as $query_kwval_array ) {
|
234 |
+
if ( isset( $settings['remember']['query'][ $query_kwval_array[0] ][ $query_kwval_array[1] ] ) ) {
|
235 |
+
$query_keyword_found = $query_kwval_array[0];
|
236 |
+
$query_value_found = $query_kwval_array[1];
|
237 |
+
/* Create JavaScript Sticky Cookie,
|
238 |
+
and PHP Sticky Cookie.
|
239 |
+
*/
|
240 |
+
jr_mt_js_sticky_query( $query_keyword_found, $query_value_found );
|
241 |
+
jr_mt_cookie( 'php', 'put', "$query_keyword_found=$query_value_found" );
|
242 |
+
break;
|
243 |
+
}
|
244 |
+
}
|
245 |
+
/* Return Theme
|
246 |
+
*/
|
247 |
+
return $settings['query'][ $query_keyword_found ][ $query_value_found ];
|
248 |
+
}
|
249 |
+
|
250 |
+
/* Handle Keyword wildcards:
|
251 |
+
keyword=* setting entry that matches keyword in URL query.
|
252 |
+
*/
|
253 |
+
if ( isset( $keyword_found ) ) {
|
254 |
+
return $settings['query'][ $keyword_found[0] ]['*'];
|
255 |
+
}
|
256 |
+
|
257 |
+
/* Now look at URL entries: $settings['url'] and ['url_prefix']
|
258 |
+
*/
|
259 |
+
|
260 |
+
$home_url = home_url();
|
261 |
+
$prep_url = jr_mt_prep_url( $current_url = parse_url( $home_url, PHP_URL_SCHEME ) . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] );
|
262 |
+
foreach ( $settings['url'] as $settings_array ) {
|
263 |
+
if ( jr_mt_same_url( $settings_array['prep'], $prep_url ) ) {
|
264 |
+
return $settings_array['theme'];
|
265 |
+
}
|
266 |
+
}
|
267 |
+
foreach ( $settings['url_prefix'] as $settings_array ) {
|
268 |
+
if ( jr_mt_same_prefix_url( $settings_array['prep'], $prep_url ) ) {
|
269 |
+
return $settings_array['theme'];
|
270 |
+
}
|
271 |
+
}
|
272 |
+
foreach ( $settings['url_asterisk'] as $settings_array ) {
|
273 |
+
if ( jr_mt_same_prefix_url_asterisk( $settings_array['prep'], $prep_url ) ) {
|
274 |
+
return $settings_array['theme'];
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
/* Must check for Home near the end as queries override
|
279 |
+
*/
|
280 |
+
$prep_url_no_query = $prep_url;
|
281 |
+
$prep_url_no_query['query'] = array();
|
282 |
+
if ( '' !== $settings['site_home'] ) {
|
283 |
+
/* Check for Home Page,
|
284 |
+
with or without Query.
|
285 |
+
*/
|
286 |
+
$prep_url_no_query = $prep_url;
|
287 |
+
$prep_url_no_query['query'] = array();
|
288 |
+
if ( jr_mt_same_url( $home_url, $prep_url_no_query ) ) {
|
289 |
+
return $settings['site_home'];
|
290 |
+
}
|
291 |
+
}
|
292 |
+
/* All Pages and All Posts settings are checked second to last,
|
293 |
+
just before Everything Else.
|
294 |
+
|
295 |
+
url_to_postid() only works after JR_MT_PAGE_CONDITIONAL is set.
|
296 |
+
But alternate means can be used with default Permalinks.
|
297 |
+
|
298 |
+
First, see if any All Pages or All Posts setting exists.
|
299 |
+
*/
|
300 |
+
if ( jr_mt_all_posts_pages() ) {
|
301 |
+
if ( defined( 'JR_MT_PAGE_CONDITIONAL' ) ) {
|
302 |
+
if ( 0 !== ( $id = url_to_postid( $current_url ) ) ) {
|
303 |
+
if ( NULL !== ( $post = get_post( $id ) ) ) {
|
304 |
+
$type = $post->post_type;
|
305 |
+
if ( 'post' === $type ) {
|
306 |
+
if ( '' !== $settings['all_posts'] ) {
|
307 |
+
return $settings['all_posts'];
|
308 |
+
}
|
309 |
+
} else {
|
310 |
+
if ( 'page' === $type ) {
|
311 |
+
if ( '' !== $settings['all_pages'] ) {
|
312 |
+
return $settings['all_pages'];
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
} else {
|
319 |
+
$permalink = get_option( 'permalink_structure' );
|
320 |
+
if ( empty( $permalink ) ) {
|
321 |
+
if ( '' !== $settings['all_posts'] ) {
|
322 |
+
if ( isset( $queries['p'] ) ) {
|
323 |
+
return $settings['all_posts'];
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
if ( '' !== $settings['all_pages'] ) {
|
328 |
+
if ( isset( $queries['page_id'] ) ) {
|
329 |
+
return $settings['all_pages'];
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
/* This is the Theme for Everything Advanced Setting.
|
336 |
+
A Setting of Blank uses WordPress Current Theme value,
|
337 |
+
i.e. - the Setting is not set.
|
338 |
+
*/
|
339 |
+
if ( '' === $settings['current'] ) {
|
340 |
+
return FALSE;
|
341 |
+
} else {
|
342 |
+
return $settings['current'];
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
/** Cookie to JavaScript with Sticky Query and related info.
|
347 |
+
|
348 |
+
Replace Existing or Create New (if no existing) Cookie
|
349 |
+
to remember what Sticky Keyword=Value to use on this Browser on this Visitor Computer.
|
350 |
+
Cookie is an encoding of this array:
|
351 |
+
- keyword=value query to append to URL
|
352 |
+
- FALSE if Setting "Append if no question mark ("?") found in URL", or
|
353 |
+
TRUE if Setting "Append if no Override keyword=value found in URL"
|
354 |
+
- an array of all sticky or override queries (empty array if FALSE)
|
355 |
+
*/
|
356 |
+
function jr_mt_js_sticky_query( $keyword, $value ) {
|
357 |
+
add_action( 'wp_enqueue_scripts', 'jr_mt_wp_enqueue_scripts' );
|
358 |
+
function jr_mt_wp_enqueue_scripts() {
|
359 |
+
global $jr_mt_plugin_data;
|
360 |
+
wp_enqueue_script( 'jr_mt_sticky', plugins_url() . '/' . dirname( jr_mt_plugin_basename() ) . '/js/sticky.js', array(), $jr_mt_plugin_data['Version'] );
|
361 |
+
/* JavaScript needs some values passed in HTML,
|
362 |
+
so add that hook here, too.
|
363 |
+
*/
|
364 |
+
add_action( 'wp_footer', 'jr_mt_wp_footer' );
|
365 |
+
}
|
366 |
+
function jr_mt_wp_footer() {
|
367 |
+
echo '<div style="display: none;"><div id="jr-mt-home-url" title="'
|
368 |
+
. jr_mt_prep_comp_url( home_url() )
|
369 |
+
. '"></div><div id="jr-mt-site-admin" title="'
|
370 |
+
. jr_mt_prep_comp_url( admin_url() )
|
371 |
+
. '"></div></div>';
|
372 |
+
}
|
373 |
+
/** Prepare URL for JavaScript compares
|
374 |
+
|
375 |
+
Remove http[s]//: from beginning
|
376 |
+
Convert rest of URL to lower-case
|
377 |
+
Remove www. from beginning, if present
|
378 |
+
Convert any backslashes to forward slashes
|
379 |
+
Remove any trailing slash(es).
|
380 |
+
*/
|
381 |
+
function jr_mt_prep_comp_url( $url ) {
|
382 |
+
$comp_url = strtolower( substr( $url, 3 + strpos( $url, '://' ) ) );
|
383 |
+
if ( 'www.' === substr( $comp_url, 0, 4 ) ) {
|
384 |
+
$comp_url = substr( $comp_url, 4 );
|
385 |
+
}
|
386 |
+
return rtrim( str_replace( '\\', '/', $comp_url ), '/' );
|
387 |
+
}
|
388 |
+
|
389 |
+
$settings = get_option( 'jr_mt_settings' );
|
390 |
+
|
391 |
+
if ( $settings['query_present'] ) {
|
392 |
+
foreach ( $settings['override']['query'] as $override_keyword => $override_value_array ) {
|
393 |
+
foreach ( $override_value_array as $override_value => $theme ) {
|
394 |
+
$override[] = "$override_keyword=$override_value";
|
395 |
+
}
|
396 |
+
}
|
397 |
+
} else {
|
398 |
+
$override = array();
|
399 |
+
}
|
400 |
+
|
401 |
+
jr_mt_cookie( 'js', 'put', strtr( rawurlencode( json_encode(
|
402 |
+
array( "$keyword=$value", $settings['query_present'], $override ) ) ),
|
403 |
+
array( '%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')' ) )
|
404 |
+
);
|
405 |
+
}
|
406 |
+
|
407 |
+
/* All Cookie Handling occurs here.
|
408 |
+
$action - 'get', 'put', 'del'
|
409 |
+
*/
|
410 |
+
function jr_mt_cookie( $lang, $action, $cookie_value = '' ) {
|
411 |
+
switch ( $lang ) {
|
412 |
+
case 'js':
|
413 |
+
$cookie_name = 'jr-mt-remember-query';
|
414 |
+
$raw = TRUE;
|
415 |
+
$expiry = '+36 hours';
|
416 |
+
$function = 'setrawcookie';
|
417 |
+
break;
|
418 |
+
case 'php':
|
419 |
+
$cookie_name = 'jr_mt_php_override_query';
|
420 |
+
$raw = FALSE;
|
421 |
+
$expiry = '+1 year';
|
422 |
+
$function = 'setcookie';
|
423 |
+
break;
|
424 |
+
}
|
425 |
+
if ( 'get' === $action ) {
|
426 |
+
if ( isset( $_COOKIE[ $cookie_name ] ) ) {
|
427 |
+
return $_COOKIE[ $cookie_name ];
|
428 |
+
} else {
|
429 |
+
return FALSE;
|
430 |
+
}
|
431 |
+
} else {
|
432 |
+
global $jr_mt_cookie_track;
|
433 |
+
if ( defined( 'JR_MT_TOO_LATE_FOR_COOKIES' ) ) {
|
434 |
+
return FALSE;
|
435 |
+
}
|
436 |
+
/* Determine Path off Domain to WordPress Address, not Site Address, for Cookie Path value.
|
437 |
+
Using home_url().
|
438 |
+
*/
|
439 |
+
$cookie_path = parse_url( home_url(), PHP_URL_PATH ) . '/';
|
440 |
+
switch ( $action ) {
|
441 |
+
case 'put':
|
442 |
+
if ( empty( $cookie_value ) ) {
|
443 |
+
return FALSE;
|
444 |
+
} else {
|
445 |
+
return ( $jr_mt_cookie_track[ $lang ] = $function( $cookie_name, $cookie_value, strtotime( $expiry ), $cookie_path, $_SERVER['SERVER_NAME'] ) );
|
446 |
+
}
|
447 |
+
break;
|
448 |
+
case 'del':
|
449 |
+
/* Don't clutter up output to browser with a Cookie Delete request if a Cookie does not exist.
|
450 |
+
*/
|
451 |
+
if ( isset( $_COOKIE[ $cookie_name ] ) ) {
|
452 |
+
return ( $jr_mt_cookie_track[ $lang ] = setrawcookie( $cookie_name, '', strtotime( '-2 days' ), $cookie_path, $_SERVER['SERVER_NAME'] ) );
|
453 |
+
}
|
454 |
+
break;
|
455 |
+
case 'clean':
|
456 |
+
if ( 'all' === $lang ) {
|
457 |
+
$clean_langs = array( 'php', 'js' );
|
458 |
+
} else {
|
459 |
+
$clean_langs = array( $lang );
|
460 |
+
}
|
461 |
+
foreach ( $clean_langs as $clean_lang ) {
|
462 |
+
if ( !isset( $jr_mt_cookie_track[ $clean_lang ] ) ) {
|
463 |
+
jr_mt_cookie( $clean_lang, 'del' );
|
464 |
+
}
|
465 |
+
}
|
466 |
+
break;
|
467 |
+
}
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
/** Will the url_to_postid() function be required?
|
472 |
+
*
|
473 |
+
* Only if:
|
474 |
+
* - Pretty Permalinks are being used, AND
|
475 |
+
* - ( All Posts setting is set, OR
|
476 |
+
* - All Pages setting is set )
|
477 |
+
* @return bool if add_action is required
|
478 |
+
*/
|
479 |
+
function jr_mt_all_posts_pages() {
|
480 |
+
$settings = get_option( 'jr_mt_settings' );
|
481 |
+
return ( $settings['all_posts'] || $settings['all_pages'] );
|
482 |
+
}
|
483 |
+
|
484 |
+
?>
|
includes/upgradev5.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Exit if .php file accessed directly
|
4 |
+
*/
|
5 |
+
if ( !defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
/* setup_theme is the earliest Action where
|
10 |
+
all functions in jr_mt_convert_ids() work properly.
|
11 |
+
*/
|
12 |
+
add_action( 'setup_theme', 'jr_mt_convert_ids', JR_MT_RUN_FIRST );
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Convert pre-Version 5 ['ids'] Settings to new Version 5 format.
|
16 |
+
*
|
17 |
+
* Mainly, it involves converting Post ID to URL.
|
18 |
+
*
|
19 |
+
*/
|
20 |
+
function jr_mt_convert_ids() {
|
21 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
22 |
+
if ( isset( $internal_settings['ids'] ) ) {
|
23 |
+
$settings = get_option( 'jr_mt_settings' );
|
24 |
+
foreach ( $settings['ids'] as $key => $ids_array ) {
|
25 |
+
/* Be sure that Theme has not been deleted.
|
26 |
+
*/
|
27 |
+
$jr_mt_all_themes = jr_mt_all_themes();
|
28 |
+
if ( isset( $jr_mt_all_themes[ $ids_array['theme'] ] ) ) {
|
29 |
+
/* $key:
|
30 |
+
'' - Home entry
|
31 |
+
*/
|
32 |
+
if ( '' === $key ) {
|
33 |
+
if ( '' === $settings['site_home'] ) {
|
34 |
+
$settings['site_home'] = $ids_array['theme'];
|
35 |
+
}
|
36 |
+
} else {
|
37 |
+
if ( isset( $ids_array['type'] ) ) {
|
38 |
+
switch ( $ids_array['type'] ) {
|
39 |
+
case 'admin':
|
40 |
+
/* Ignore as Admin pages are ignored
|
41 |
+
*/
|
42 |
+
break;
|
43 |
+
case 'prefix':
|
44 |
+
/* URL Prefix
|
45 |
+
*/
|
46 |
+
$url = get_home_url() . "/$key";
|
47 |
+
$settings['url_prefix'][] = array(
|
48 |
+
'url' => $url,
|
49 |
+
'prep' => jr_mt_prep_url( $url ),
|
50 |
+
'theme' => $ids_array['theme']
|
51 |
+
);
|
52 |
+
break;
|
53 |
+
case '*':
|
54 |
+
/* URL Prefix with Asterisk
|
55 |
+
*/
|
56 |
+
$url = get_home_url() . "/$key";
|
57 |
+
$settings['url_asterisk'][] = array(
|
58 |
+
'url' => $url,
|
59 |
+
'prep' => jr_mt_prep_url( $url ),
|
60 |
+
'theme' => $ids_array['theme']
|
61 |
+
);
|
62 |
+
break;
|
63 |
+
case 'cat':
|
64 |
+
if ( !is_wp_error( get_the_category_by_ID( $key ) ) ) {
|
65 |
+
$url = get_category_link( $key );
|
66 |
+
$settings['url'][] = array(
|
67 |
+
'url' => $url,
|
68 |
+
'prep' => jr_mt_prep_url( $url ),
|
69 |
+
'theme' => $ids_array['theme']
|
70 |
+
);
|
71 |
+
}
|
72 |
+
/* Ignore non-existent Categories.
|
73 |
+
They were likely deleted.
|
74 |
+
*/
|
75 |
+
break;
|
76 |
+
case 'archive':
|
77 |
+
/* From ?m=yyyymm query originally
|
78 |
+
*/
|
79 |
+
$yyyymm = $ids_array['id'];
|
80 |
+
$year = intval( $yyyymm / 100 );
|
81 |
+
$month = $yyyymm % 100;
|
82 |
+
$url = get_month_link( $year, $month );
|
83 |
+
$settings['url'][] = array(
|
84 |
+
'url' => $url,
|
85 |
+
'prep' => jr_mt_prep_url( $url ),
|
86 |
+
'theme' => $ids_array['theme']
|
87 |
+
);
|
88 |
+
break;
|
89 |
+
default:
|
90 |
+
if ( FALSE === $ids_array['id'] ) {
|
91 |
+
/* Exact URL
|
92 |
+
*/
|
93 |
+
$url = get_home_url() . "/$key";
|
94 |
+
$settings['url'][] = array(
|
95 |
+
'url' => $url,
|
96 |
+
'prep' => jr_mt_prep_url( $url ),
|
97 |
+
'theme' => $ids_array['theme']
|
98 |
+
);
|
99 |
+
} else {
|
100 |
+
/* Some Post type
|
101 |
+
|
102 |
+
get_permalink() can be used as early as Action Hook 'setup_theme',
|
103 |
+
but not in 'plugins_loaded' (Fatal Error).
|
104 |
+
*/
|
105 |
+
if ( FALSE !== ( $url = get_permalink( $key ) ) ) {
|
106 |
+
$settings['url'][] = array(
|
107 |
+
'url' => $url,
|
108 |
+
'prep' => jr_mt_prep_url( $url ),
|
109 |
+
'theme' => $ids_array['theme']
|
110 |
+
);
|
111 |
+
}
|
112 |
+
/* Ignore any non-existent IDs, typically deleted.
|
113 |
+
*/
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
update_option( 'jr_mt_settings', $settings );
|
121 |
+
|
122 |
+
unset( $internal_settings['ids'] );
|
123 |
+
update_option( 'jr_mt_internal_settings', $internal_settings );
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
?>
|
index.html
ADDED
File without changes
|
jonradio-multiple-themes.php
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 WordPress Pages, Posts or other non-Admin pages. Or Site Home.
|
6 |
+
Version: 5.0.3
|
7 |
+
Author: David Gewirtz
|
8 |
+
Author URI: http://zatzlabs.com/plugins/
|
9 |
+
License: GPLv2
|
10 |
+
*/
|
11 |
+
|
12 |
+
/* Copyright 2014 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 |
+
/* Exit if .php file accessed directly
|
30 |
+
*/
|
31 |
+
if ( !defined( 'ABSPATH' ) ) {
|
32 |
+
exit;
|
33 |
+
}
|
34 |
+
|
35 |
+
/* For Hooks, when it needs to run first or last.
|
36 |
+
*/
|
37 |
+
DEFINE( 'JR_MT_RUN_FIRST', 1 );
|
38 |
+
DEFINE( 'JR_MT_RUN_SECOND', JR_MT_RUN_FIRST + 1 );
|
39 |
+
DEFINE( 'JR_MT_RUN_LAST', 999 );
|
40 |
+
|
41 |
+
DEFINE( 'JR_MT_WP_GET_THEMES_ACTION', 'plugins_loaded' );
|
42 |
+
|
43 |
+
DEFINE( 'JR_MT_FILE', __FILE__ );
|
44 |
+
|
45 |
+
/* Catch old unsupported version of WordPress before any damage can be done.
|
46 |
+
*/
|
47 |
+
if ( version_compare( get_bloginfo( 'version' ), '3.4', '<' ) ) {
|
48 |
+
require_once( plugin_dir_path( JR_MT_FILE ) . 'includes/old-wp.php' );
|
49 |
+
} else {
|
50 |
+
/* Use $plugin_data['Name'] for the array of incompatible plugins
|
51 |
+
*/
|
52 |
+
global $jr_mt_incompat_plugins;
|
53 |
+
$jr_mt_incompat_plugins = array( 'Theme Test Drive' ); // removed for V5: 'BuddyPress', 'Polylang'
|
54 |
+
|
55 |
+
require_once( plugin_dir_path( JR_MT_FILE ) . 'includes/functions.php' );
|
56 |
+
|
57 |
+
/* Check for missing Settings and set them to defaults.
|
58 |
+
On first use, this means initializing all Settings to their defaults.
|
59 |
+
*/
|
60 |
+
jr_mt_missing_settings( 'jr_mt_settings',
|
61 |
+
array(
|
62 |
+
/* Settings structure:
|
63 |
+
code - get_option( 'jr_mt_settings' )
|
64 |
+
['all_pages'] => zero length string or folder in Themes directory containing theme to use for All Pages
|
65 |
+
['all_posts'] => zero length string or folder in Themes directory containing theme to use for All Posts
|
66 |
+
['site_home'] => zero length string or folder in Themes directory containing theme to use for Home Page
|
67 |
+
['current'] => zero length string or folder in Themes directory containing theme to override WordPress Current Theme
|
68 |
+
['query']
|
69 |
+
[keyword]
|
70 |
+
[value] or ['*'] => folder in Themes directory containing theme to use
|
71 |
+
['remember']
|
72 |
+
['query']
|
73 |
+
[keyword]
|
74 |
+
[value] => TRUE
|
75 |
+
['override']
|
76 |
+
['query']
|
77 |
+
[keyword]
|
78 |
+
[value] => TRUE
|
79 |
+
['query_present'] => TRUE or FALSE
|
80 |
+
['url'], ['url_prefix'] and ['url_asterisk']
|
81 |
+
['url'] => URL
|
82 |
+
['prep'] => URL array created by jr_mt_prep_url()
|
83 |
+
['theme'] => folder in Themes directory containing theme to use
|
84 |
+
Prior to Version 5.0:
|
85 |
+
['ids']
|
86 |
+
[id] - zero length string or WordPress ID of Page, Post, etc.
|
87 |
+
['type'] => 'page' or 'post' or 'admin' or 'cat' or 'archive' or 'prefix' or other
|
88 |
+
['theme'] => folder in Themes directory containing theme to use
|
89 |
+
['id'] => FALSE or WordPress ID of Page, Post, etc.
|
90 |
+
['page_url'] => relative URL WordPress page, post, admin, etc. or FALSE
|
91 |
+
['rel_url'] => URL relative to WordPress home
|
92 |
+
['url'] => original full URL, from Settings page entry by user
|
93 |
+
*/
|
94 |
+
'all_pages' => '',
|
95 |
+
'all_posts' => '',
|
96 |
+
'site_home' => '',
|
97 |
+
'current' => '',
|
98 |
+
'query' => array(),
|
99 |
+
'remember' => array( 'query' => array() ),
|
100 |
+
'override' => array( 'query' => array() ),
|
101 |
+
'query_present' => FALSE,
|
102 |
+
'url' => array(),
|
103 |
+
'url_prefix' => array(),
|
104 |
+
'url_asterisk' => array()
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
/* Detect initial activation or a change in plugin's Version number
|
109 |
+
|
110 |
+
Sometimes special processing is required when the plugin is updated to a new version of the plugin.
|
111 |
+
Also used in place of standard activation and new site creation exits provided by WordPress.
|
112 |
+
Once that is complete, update the Version number in the plugin's Network-wide settings.
|
113 |
+
*/
|
114 |
+
if ( FALSE === ( $internal_settings = get_option( 'jr_mt_internal_settings' ) ) ) {
|
115 |
+
/* New install or Plugin was deleted previously, erasing all its Settings
|
116 |
+
*/
|
117 |
+
$old_version = $jr_mt_plugin_data['Version'];
|
118 |
+
$version_change = TRUE;
|
119 |
+
$update_version_setting = FALSE;
|
120 |
+
} else {
|
121 |
+
if ( empty( $internal_settings['version'] ) ) {
|
122 |
+
/* Internal Settings are corrupt, or extremely old.
|
123 |
+
*/
|
124 |
+
$old_version = '0';
|
125 |
+
$version_change = TRUE;
|
126 |
+
$update_version_setting = TRUE;
|
127 |
+
} else {
|
128 |
+
$old_version = $internal_settings['version'];
|
129 |
+
$version_change = version_compare( $old_version, $jr_mt_plugin_data['Version'], '!=' );
|
130 |
+
$update_version_setting = $version_change;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
/* Create and initialize any or all internal settings that do not exist.
|
134 |
+
*/
|
135 |
+
jr_mt_missing_settings( 'jr_mt_internal_settings',
|
136 |
+
array(
|
137 |
+
'version' => $jr_mt_plugin_data['Version'],
|
138 |
+
'permalink' => get_option( 'permalink_structure' )
|
139 |
+
)
|
140 |
+
);
|
141 |
+
|
142 |
+
if ( $version_change ) {
|
143 |
+
/* Handle all Settings changes made in old plugin versions
|
144 |
+
*/
|
145 |
+
if ( version_compare( $old_version, '5.0', '<' ) ) {
|
146 |
+
$settings = get_option( 'jr_mt_settings' );
|
147 |
+
if ( !empty( $settings['ids'] ) ) {
|
148 |
+
/* Convert 'ids' array to 'urls' array in Settings jr_mt_settings
|
149 |
+
|
150 |
+
Signal that a conversion is required.
|
151 |
+
*/
|
152 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
153 |
+
$internal_settings['ids'] = TRUE;
|
154 |
+
update_option( 'jr_mt_internal_settings', $internal_settings );
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
/* Only Update if I have to.
|
160 |
+
*/
|
161 |
+
if ( $update_version_setting ) {
|
162 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
163 |
+
$internal_settings['version'] = $jr_mt_plugin_data['Version'];
|
164 |
+
update_option( 'jr_mt_internal_settings', $internal_settings );
|
165 |
+
}
|
166 |
+
|
167 |
+
/* Do the Version 5.0 Upgrade, if required.
|
168 |
+
*/
|
169 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
170 |
+
if ( isset( $internal_settings['ids'] ) ) {
|
171 |
+
require_once( jr_mt_path() . 'includes/upgradev5.php' );
|
172 |
+
}
|
173 |
+
|
174 |
+
/* p2 runs in Admin, so must also execute this code in Admin, too.
|
175 |
+
*/
|
176 |
+
require_once( jr_mt_path() . 'includes/select-theme.php' );
|
177 |
+
|
178 |
+
if ( is_admin() ) {
|
179 |
+
require_once( jr_mt_path() . 'includes/admin-functions.php' );
|
180 |
+
// Admin panel
|
181 |
+
require_once( jr_mt_path() . 'includes/admin.php' );
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
/*
|
186 |
+
Research Notes:
|
187 |
+
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:
|
188 |
+
- is_admin()
|
189 |
+
- is_user_logged_in()
|
190 |
+
- get_option("page_on_front") - ID of home page; zero if Reading Settings NOT set to a Static Page of a WordPress Page
|
191 |
+
*/
|
192 |
+
|
193 |
+
?>
|
js/index.html
ADDED
File without changes
|
js/sticky.js
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* When the page has fully loaded,
|
2 |
+
check if the Plugin's cookie is present
|
3 |
+
and decipher it into values that will
|
4 |
+
control processing:
|
5 |
+
an array consisting of:
|
6 |
+
- keyword=value query to append to URL
|
7 |
+
- FALSE if Setting "append if question mark ("?") not present", or
|
8 |
+
TRUE if Setting "append if another Override query not present"
|
9 |
+
- an array of all sticky or override queries (empty array if FALSE)
|
10 |
+
If cookie is present, look at all <a> tag href= URLs.
|
11 |
+
Restriction: ignore all Relative URLs - those without ://
|
12 |
+
For each one, check if it is in the current WordPress site,
|
13 |
+
but not in Admin panels (/wp-admin/):
|
14 |
+
- strip up to and including ://
|
15 |
+
- convert to lower-case
|
16 |
+
- if present, strip leading www.
|
17 |
+
- convert \ to /
|
18 |
+
- remove trailing / of Home URL and Site Admin URL
|
19 |
+
If so, append the current Query (keyword=value) specified in
|
20 |
+
the plugin's Cookie, to the href= URL, except when:
|
21 |
+
- a ? is present in the URL if the plugin Setting is set to that;
|
22 |
+
- an override query is already present in the URL, if the plugin
|
23 |
+
Setting allows ? in the URL
|
24 |
+
- the same sticky query is already present in the URL
|
25 |
+
Appending a Query to the URL is done by:
|
26 |
+
- inserting it before any # (Fragment, i.e. - Bookmark) in the URL
|
27 |
+
- appending to URL otherwise
|
28 |
+
- prefixed by ? is ? is not already present
|
29 |
+
- prefixed by & if ? is already present
|
30 |
+
In addition, hidden text in the HTML provides:
|
31 |
+
- WordPress Site Address (URL)
|
32 |
+
- WordPress /wp-admin/ URL
|
33 |
+
These values are not available for the Cookie, because WordPress must be
|
34 |
+
loaded before these values are available.
|
35 |
+
|
36 |
+
Whether pre-processed in PHP when passed, or within this JavaScript,
|
37 |
+
all comparisons are effectively case-insensitive, by converting
|
38 |
+
all values to lower-case.
|
39 |
+
*/
|
40 |
+
window.onload =
|
41 |
+
function ( ) {
|
42 |
+
var allCookies, keywordMatch, pos, valueStart, cookieArray, query, homeUrl, siteAdmin, appendSetting, overrideQueries, overrideQueriesEmpty, hrefs, i, max, href, colonSlashSlash, hrefCompare, addQuery, posQuestionMark, posNumberSign, hrefQueries,
|
43 |
+
cookieEquals = 'jr-mt-remember-query=',
|
44 |
+
cookieSplit = '; ';
|
45 |
+
|
46 |
+
/* Check if there are any Cookies at all.
|
47 |
+
*/
|
48 |
+
if ( '' !== allCookies ) {
|
49 |
+
allCookies = cookieSplit + document.cookie + cookieSplit;
|
50 |
+
keywordMatch = cookieSplit + cookieEquals;
|
51 |
+
pos = allCookies.indexOf( keywordMatch );
|
52 |
+
/* Check if our cookie is present.
|
53 |
+
*/
|
54 |
+
if ( -1 !== pos ) {
|
55 |
+
valueStart = pos + keywordMatch.length;
|
56 |
+
/* Extract Value of Cookie, which is found after the equals sign and before the semicolon
|
57 |
+
*/
|
58 |
+
cookieArray = JSON.parse( decodeURIComponent( allCookies.substring( pos + keywordMatch.length, allCookies.indexOf( cookieSplit, pos + cookieSplit.length ) ) ) );
|
59 |
+
/* Assign Cookie array elements to meaningfully-named variables.
|
60 |
+
*/
|
61 |
+
query = cookieArray[0];
|
62 |
+
appendSetting = cookieArray[1];
|
63 |
+
overrideQueries = cookieArray[2];
|
64 |
+
overrideQueriesEmpty = ( 0 === overrideQueries.length );
|
65 |
+
|
66 |
+
homeUrl = document.getElementById( 'jr-mt-home-url' )['title'];
|
67 |
+
siteAdmin = document.getElementById( 'jr-mt-site-admin' )['title'];
|
68 |
+
|
69 |
+
hrefs = document.getElementsByTagName ( 'a' );
|
70 |
+
for ( i = 0, max = hrefs.length; i < max; i++ ) {
|
71 |
+
href = hrefs [ i ] ['href'];
|
72 |
+
colonSlashSlash = href.indexOf( '://' );
|
73 |
+
/* Ignore Relative URLs: those without ://
|
74 |
+
*/
|
75 |
+
if ( -1 !== colonSlashSlash ) {
|
76 |
+
hrefCompare = href.substring( colonSlashSlash + 3 ).toLowerCase();
|
77 |
+
if ( 'www.' === hrefCompare.substring( 0, 4 ) ) {
|
78 |
+
hrefCompare = hrefCompare.substring( 4 );
|
79 |
+
}
|
80 |
+
hrefCompare = hrefCompare.replace( /\\/g, '/' );
|
81 |
+
addQuery = '';
|
82 |
+
if ( hrefCompare.substring( 0, homeUrl.length ) === homeUrl ) {
|
83 |
+
if ( hrefCompare.substring( 0, siteAdmin.length ) !== siteAdmin ) {
|
84 |
+
posQuestionMark = href.indexOf( '?' );
|
85 |
+
posNumberSign = href.indexOf( '#' );
|
86 |
+
if ( -1 === posNumberSign ) {
|
87 |
+
posNumberSign = href.length;
|
88 |
+
}
|
89 |
+
/* Only add a Query if one does not already exist.
|
90 |
+
*/
|
91 |
+
if ( -1 === posQuestionMark ) {
|
92 |
+
/* Query must be before the Fragment (#anchor),
|
93 |
+
when one exists.
|
94 |
+
*/
|
95 |
+
addQuery = '?';
|
96 |
+
} else {
|
97 |
+
/* Query exists because "?" found in URL.
|
98 |
+
Check if setting set to add query when one already exists.
|
99 |
+
If not, don't touch this URL.
|
100 |
+
*/
|
101 |
+
if ( appendSetting ) {
|
102 |
+
addQuery = '&';
|
103 |
+
hrefQueries = href.substring( posQuestionMark + 1, posNumberSign ).split( '&' );
|
104 |
+
/* Don't append Sticky query if it is already present in the URL
|
105 |
+
*/
|
106 |
+
if ( -1 !== hrefQueries.indexOf( query ) ) {
|
107 |
+
addQuery = '';
|
108 |
+
} else {
|
109 |
+
if ( !overrideQueriesEmpty ) {
|
110 |
+
for ( j = 0, hrefQueriesLength = hrefQueries.length; j < hrefQueriesLength; j++ ) {
|
111 |
+
/* Don't append Sticky query if an Override query is present in URL
|
112 |
+
*/
|
113 |
+
if ( -1 !== overrideQueries.indexOf( hrefQueries[ j ].toLowerCase() ) ) {
|
114 |
+
/* Override query already in URL.
|
115 |
+
*/
|
116 |
+
addQuery = '';
|
117 |
+
break;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
if ( '' !== addQuery ) {
|
127 |
+
/* No override or sticky query already in URL, so safe to add current sticky query.
|
128 |
+
*/
|
129 |
+
hrefs [ i ] ['href'] = href.substring( 0, posNumberSign ) + addQuery + query + href.substring( posNumberSign );
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
};
|
js/tabs.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Hide all but the Tab selected.
|
2 |
+
<div> is used in the HTML to enclose the HTML peculiar to a Tab,
|
3 |
+
with id=jr-mt-settingsn where the last "n" is a unique number from 1 to the number of Tabs.
|
4 |
+
onClick is used on a <a> to activate this function.
|
5 |
+
|
6 |
+
Bold only the Tab selected,
|
7 |
+
actually it is Bolder and Bold, instead of Bold and Normal.
|
8 |
+
*/
|
9 |
+
function jrMtTabs( tab, ntabs ) {
|
10 |
+
for ( i = 1; i <= ntabs; i++ ) {
|
11 |
+
if ( i === tab ) {
|
12 |
+
show = 'block';
|
13 |
+
classes = 'nav-tab nav-tab-active';
|
14 |
+
} else {
|
15 |
+
show = 'none';
|
16 |
+
classes = 'nav-tab';
|
17 |
+
}
|
18 |
+
document.getElementById( 'jr-mt-settings' + i ).style.display = show;
|
19 |
+
document.getElementById( 'jr-mt-tabs' + i ).className = classes;
|
20 |
+
}
|
21 |
+
};
|
readme.txt
ADDED
@@ -0,0 +1,407 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
6 |
+
Tested up to: 4.0
|
7 |
+
Stable tag: 5.0.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 WordPress Pages, Posts or other non-Admin pages. Or Site Home.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
**Version 5 was a major rewrite that now supports nearly all plugins and themes, including BuddyPress.** In the unlikely situation that such a massive change introduces unforeseen issues for your site, it is possible to downgrade to Version 4.12 until the issue is resolved. [Click here](http://downloads.wordpress.org/plugin/jonradio-multiple-themes.4.12.zip "Downgrade") to download Version 4.12.
|
16 |
+
|
17 |
+
Settings provide many different ways to Select which Theme should appear where on your WordPress web site:
|
18 |
+
|
19 |
+
* Just for Site Home
|
20 |
+
* By URL (Version 5 adds support for Query keyword=value as part of a unique URL);
|
21 |
+
* By Prefix URL, matching all URLs that begin with the same characters ("Prefix URL");
|
22 |
+
* By Wildcard Prefix URL with one or more Asterisks ("*") representing arbritrary subdirectories in the URL;
|
23 |
+
* By Query Keyword found in any URL, not matter what the Value;
|
24 |
+
* By Query keyword=value found in any URL;
|
25 |
+
* By Sticky Query keyword=value that sets the Theme for a given Visitor until an Override Query keyword=value is found in a future URL (Advanced Setting requiring the Visitor's browser to accept Cookies; incompatible with certain plugins that block Cookies);
|
26 |
+
* Everywhere (Advanced Setting that overrides the WordPress Active Theme);
|
27 |
+
* All Pages (Advanced Setting that works with most, but not all, Themes and Plugins);
|
28 |
+
* All Posts (Advanced Setting that works with most, but not all, Themes and Plugins).
|
29 |
+
|
30 |
+
None of the Themes in the WordPress Theme Directory alter the appearance of the WordPress Admin panels. As a result, this plugin does not allow Theme Selection entries to specify URLs for WordPress Admin panels.
|
31 |
+
|
32 |
+
**Use with Paid Themes**: On-going full scale testing of Themes by this plugin's author is only possible if the Theme is found in the WordPress Theme Directory. Although (Version 5 of) this plugin should now work with all Themes, any problems encountered while using Paid Themes will be difficult to diagnose. As described in the FAQ tab, a WordPress Network (Multisite) is an alternative to this plugin, as a way to create a single web site with more than one Theme.
|
33 |
+
|
34 |
+
A similar situation exists with Paid Plugins.
|
35 |
+
|
36 |
+
**Use with Plugins that Cache**: You may find that you have to flush the Cache whenever you change Settings in the *jonradio Multiple Themes* plugin. Some Caching plugins only cache for visitors who are not logged in as users, so be sure to log out before testing the results of your *jonradio Multiple Themes* settings.
|
37 |
+
|
38 |
+
**Changing Theme Options (Widgets, Sidebars, Menus, Templates, Background, Header, etc.)?**: After installing and activating the plugin, see the plugin's Settings page and click on the **Theme Options** tab for important information on changing Options for Themes other than the Active Theme.
|
39 |
+
|
40 |
+
**How it Works**: The plugin does not change the Active Theme defined to WordPress in the Appearances-Themes Admin panel. Instead, it dynamically (and selectively) overrides that setting. Which means that simply deactivating (or deleting) this plugin will restore the way that Themes were displayed prior to installing this plugin. However, in some situations, it is possible to inadvertently alter Theme Options for the Active Theme when using either of the Methods described on the plugin's Setting page Theme Options tab.
|
41 |
+
|
42 |
+
== Installation ==
|
43 |
+
|
44 |
+
This section describes how to install the *jonradio Multiple Themes* plugin and get it working.
|
45 |
+
|
46 |
+
1. Use **Add Plugin** within the WordPress Admin panel to download and install this *jonradio Multiple Themes* 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.
|
47 |
+
1. Activate the *jonradio Multiple Themes* plugin through the **Installed Plugins** Admin panel in WordPress. If you have a WordPress Network ("Multisite"), you can either **Network Activate** this plugin through the **Installed Plugins** Network Admin panel, 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. Alternatively, to avoid this confusion, you can install the *jonradio Reveal Network Activated Plugins* plugin.
|
48 |
+
1. Be sure that all Themes you plan to use have been installed.
|
49 |
+
1. Select Themes to be used on the Settings or Advanced Settings tab of the plugin's **Multiple Themes plugin** Settings page in the WordPress Admin panels, which is found in both the **Appearance** and **Settings** sections. You can also get to this Settings page by clicking on the **Settings** link for this plugin on the **Installed Plugins** page of the Admin panel.
|
50 |
+
1. If you need to change Theme Options (Widgets, Sidebars, Menus, Templates, Background, Header, etc.) for any Theme *other than* the Active Theme, see the plugin's Settings page and click on the **Theme Options** tab for important information.
|
51 |
+
|
52 |
+
== Frequently Asked Questions ==
|
53 |
+
|
54 |
+
= What if my Themes or other plugins don't seem to be working with the jonradio Multiple Themes plugin? =
|
55 |
+
|
56 |
+
Please ask before giving up. Either by [posting a Support question](http://wordpress.org/support/plugin/jonradio-multiple-themes "Support Forum") or contacting us directly by filling out this [Contact Form (click here)](http://zatzlabs.com/contact-us/ "Contact Form").
|
57 |
+
|
58 |
+
If we cannot solve the problem, please consider using a WordPress Network. One install of WordPress allows you to have multiple separate Sites ("MultiSite"), each with a different Theme, without using the jonradio Multiple Themes plugin. The sites can look to the outside world as if they are just one web site by using the Sub-directories option. For example, Site 1 would be at example.com, and Site 2 could be at example.com/forum.
|
59 |
+
|
60 |
+
= Will this plugin work with Paid Themes? =
|
61 |
+
|
62 |
+
With the massive rewrite of Theme Selection logic in Version 5 of this plugin, it should now work with all Paid Themes and Plugins. But we have only tested the few Paid Themes whose authors have provided us with permission to use, without charge, their themes for test purposes. Elegant, for example, allows us to accept copies of its Themes provided by its customers who require assistance with the jonradio Multiple Themes plugin. On the other hand, some other Paid Theme authors have simply ignored our requests, despite our stated willingness to sign a non-disclosure agreement.
|
63 |
+
|
64 |
+
We do encourage you to contact us if you run into problems when using the jonradio Multiple Themes plugin with a Paid Theme, as the problem may not be unique to the Paid Theme.
|
65 |
+
|
66 |
+
To state the obvious, the cost of purchasing a license for all Paid Themes for testing purposes is prohibitive for an Open Source plugin such as this one.
|
67 |
+
|
68 |
+
= How do I change the Theme Options (Widgets, Sidebars, Menus, Background, Header, etc.) used for each Theme? =
|
69 |
+
|
70 |
+
For the Active Theme, nothing changes when using the jonradio Multiple Themes plugin. For other Themes, selected using this plugin, changing Theme Options is explained, in detail, on the Theme Options tab of the plugin's Settings page.
|
71 |
+
|
72 |
+
= How do I change the Template for a specific Page or Post? =
|
73 |
+
|
74 |
+
For the Current Theme, nothing changes when using the jonradio Multiple Themes plugin. For a Page or Post where another Theme is displayed, as selected by this plugin's Settings, specifying the Template to be used is explained, in detail, on the Theme Options tab of the plugin's Settings page.
|
75 |
+
|
76 |
+
= How do I select a Theme for a Category of Posts? =
|
77 |
+
|
78 |
+
That functionality, to directly specify a Theme for a Category on the Settings page, is being investigated for a future version of the jonradio Multiple Themes plugin. But there is already a solution based on Permalinks:
|
79 |
+
|
80 |
+
1. In the WordPress Admin panels, go to Settings-Permalinks
|
81 |
+
1. Specify a Permalinks structure that begins with /%category%/
|
82 |
+
1. Push the Save Changes button
|
83 |
+
1. Go to Settings-Multiple Themes plugin
|
84 |
+
1. In the Section "For An Individual Page, Post or other non-Admin page", select the Theme for the Category of Posts
|
85 |
+
1. Enter the URL of the Categories page, e.g. - http://domain.com/news/
|
86 |
+
1. Click the checkbox "Select here if URL is a Prefix"
|
87 |
+
1. Push the Save Changes button
|
88 |
+
|
89 |
+
= How do I Edit a Theme? =
|
90 |
+
|
91 |
+
WordPress includes a built-in Theme Editor. Select Editor in the Admin panel's Appearance menu items on the left sidebar.
|
92 |
+
|
93 |
+
By default, the style.css file of the Current Theme is displayed. You can edit other Themes by selecting them in the "Select theme to edit" field and clicking the Select button.
|
94 |
+
|
95 |
+
Alternatively, you can edit any Theme on your own computer. If your computer runs Windows, NotePad++ and FileZilla run very well together, using FileZilla's View/Edit feature to provide a Theme Editor with syntax highlighting and other advanced features.
|
96 |
+
|
97 |
+
If one or more of the Active Themes have their own Theme Editor or other type of Theme Options panels, such as Elegant's epanel, please read the next FAQ.
|
98 |
+
|
99 |
+
= How do I use Elegant's epanel? =
|
100 |
+
|
101 |
+
Nothing changes for the Current Theme. epanel can be accessed just as it would be without the jonradio Multiple Themes plugin, simply by selecting the WordPress Admin panel's Appearance submenu item titled Theme Options preceded by the name of your Elegant Theme.
|
102 |
+
|
103 |
+
To make changes to other Active Themes that you will be specifying with the jonradio Multiple Themes plugin:
|
104 |
+
|
105 |
+
1. Deactivate jonradio Multiple Themes
|
106 |
+
1. Install the Theme Test Drive plugin found at http://wordpress.org/extend/plugins/theme-test-drive/
|
107 |
+
1. Activate the Theme Test Drive plugin
|
108 |
+
1. Go to Appearance-Theme Test Drive
|
109 |
+
1. In the Usage section, select an alternate Theme you will be using with jonradio Multiple Themes
|
110 |
+
1. Push the Enable Theme Drive button at the bottom
|
111 |
+
1. Click on the Appearance menu item on the left sidebar of the WordPress Admin panel to refresh the submenu
|
112 |
+
1. Click on the submenu item titled with your Elegant theme's name followed by "Theme Options"
|
113 |
+
1. Elegant's epanel will now appear
|
114 |
+
1. Make all the changes for this Theme, being sure to push the Save button
|
115 |
+
1. If you have more than one alternate Theme with Options you wish to change, repeat Steps 4-10 for each alternate Theme
|
116 |
+
1. Deactivate the Theme Test Drive plugin
|
117 |
+
1. Activate jonradio Multiple Themes
|
118 |
+
1. Changes to the Options for the Current Theme can now be made normally, just as you would without either plugin
|
119 |
+
1. Both the alternate and Current Themes should now display all Theme options properly when selected through the jonradio Multiple Themes plugin
|
120 |
+
|
121 |
+
Thanks to Elegant for allowing us to test copies of any of their Themes provided by their customers.
|
122 |
+
|
123 |
+
= What happens when I change Permalinks? =
|
124 |
+
|
125 |
+
Although it depends on what kind of change you make to your Permalink structure, you should expect to have to replace (delete and add) all of the plugin's Settings that specify a URL.
|
126 |
+
|
127 |
+
= I added a new entry but why doesn't it appear in the list of entries? =
|
128 |
+
|
129 |
+
You should have seen an explanatory error message after hitting the Save Changes button.
|
130 |
+
|
131 |
+
= How can I change the Theme for an entry? =
|
132 |
+
|
133 |
+
You will need to delete the entry and add it again, with the new Theme specified.
|
134 |
+
|
135 |
+
== Screenshots ==
|
136 |
+
|
137 |
+
1. Top of Settings tab on Plugin's Settings page
|
138 |
+
2. Bottom of Settings tab on Plugin's Settings page
|
139 |
+
3. Advanced Settings tab on Plugin's Settings page
|
140 |
+
4. Theme Options tab on Plugin's Settings page
|
141 |
+
5. System Information tab on Plugin's Settings page
|
142 |
+
6. New in V5 tab on Plugin's Settings page
|
143 |
+
|
144 |
+
== Changelog ==
|
145 |
+
|
146 |
+
= 5.0.3 =
|
147 |
+
* Remove Cleanup code for Settings for non-existent Themes, as it conflicts with delete/reinstall theme version upgrades, and certain caching plugins
|
148 |
+
|
149 |
+
= 5.0.2 =
|
150 |
+
* Remove /downgrade/ directory in case it caused the reported PCLZIP_ERR_BAD_FORMAT errors
|
151 |
+
|
152 |
+
= 5.0.1 =
|
153 |
+
* Fix All Pages and All Posts by complete rewrite of Theme Selection logic for those Advanced Settings
|
154 |
+
|
155 |
+
= 5.0 =
|
156 |
+
* Major rewrite of the Theme Selection logic
|
157 |
+
* Tabs added to the Settings page, for easier navigation
|
158 |
+
* Greatly expanded compatibility with other Plugins and Themes
|
159 |
+
* Allow ?keyword=value&keyword=value Queries in URL, URL Prefix and URL Prefix with Asterisk ("*") Theme Selection entries
|
160 |
+
* Accurate Theme Selection even for plugins and themes that request Stylesheet or Template information before WordPress is fully loaded
|
161 |
+
* Tabs for the Setting page written in JavaScript for instant switching between tabs and preservation of input data, e.g. - switch between Settings and Advanced Settings tabs without having to retype your changes when you switch back
|
162 |
+
* Theme Selection entries, if any, displayed in the order in which they are processed, to clarify which Theme will be displayed for any given URL
|
163 |
+
* Complete How-To details on Theme Option and Template selection right on the Settings page, replacing the FAQs in the WordPress Plugin Directory
|
164 |
+
* Automatic deletion of Theme Selection entries for Themes that have been deleted
|
165 |
+
* Enhanced performance with tighter code, and less of it, on the public side of your WordPress site
|
166 |
+
* Changing Permalinks invalidates more Theme Selection settings than in previous versions
|
167 |
+
* Changing the Theme for an Entry requires Deletion of the old Entry before or after adding the same Entry with the new Theme specified
|
168 |
+
* The new Theme Selection logic, based on URL Matching rather than Page, Post, Attachment, Category and Archive IDs, requires a conversion of some Settings from prior versions of the plugin. This conversion to the new format occurs automatically the first time that Version 5 runs. Old format settings are retained, transparently without being displayed on the Settings page, to allow downgrading to Version 4 from Version 5.
|
169 |
+
|
170 |
+
= 4.11.3 =
|
171 |
+
* Fix Array to String Warning on some Search plugins by rewriting jt_mt_themes_defined() which creates list of Themes referenced in plugin Settings
|
172 |
+
* Add More Diagnostic Information to Settings page
|
173 |
+
* Suggest "URL Prefix" setting when "URL" setting does not work, especially for WooCommerce
|
174 |
+
* Detect Memberium plugins and explain that Sticky will not work with Membership System V2 because it blocks Cookies
|
175 |
+
* Add Warning and change one confusing Error Message when Query is incorrectly included in URL of Page/Post entry
|
176 |
+
|
177 |
+
= 4.11.2 =
|
178 |
+
* Made all Query comparisons (URL match Setting) case insensitive
|
179 |
+
* Eliminate Connection Info prompt from Settings page that occurred for certain User Permissions
|
180 |
+
* Add File Permissions table to Settings
|
181 |
+
|
182 |
+
= 4.11.1 =
|
183 |
+
* Correct foreach() error
|
184 |
+
|
185 |
+
= 4.11 =
|
186 |
+
* Complete Rewrite of Sticky logic, adding additional Settings, including Override
|
187 |
+
|
188 |
+
= 4.10.1 =
|
189 |
+
* Sticky: add a unique Query to URL so that Caching plugins will cache separate copies for each Theme used on a particular page
|
190 |
+
|
191 |
+
= 4.10 =
|
192 |
+
* Add a Sticky option (Advanced Setting) for URL Queries (keyword=value) that will select the same Theme for all subsequent pages viewed by the same Visitor
|
193 |
+
* Enhance performance by eliminating processing related to each Type of Setting when no Setting entries of that Type exist
|
194 |
+
|
195 |
+
= 4.9 =
|
196 |
+
* Add an Asterisk ("*") to match any Subdirectory at a given level of the File Hierarchy, as another form of the Prefix URL option
|
197 |
+
* Reorganize Settings page
|
198 |
+
|
199 |
+
= 4.8 =
|
200 |
+
* Delay intercept of get_options 'stylesheet' and 'template' until 'plugins_loaded' (NextGen Gallery conflict)
|
201 |
+
* Check for illegal characters in Keyword and Value of Query portion of URL in Settings fields
|
202 |
+
|
203 |
+
= 4.7.3 =
|
204 |
+
* Add support for dot in URL Queries (keyword or value) by replacing parse_str()
|
205 |
+
* Removed subfolder /includes/debug/
|
206 |
+
|
207 |
+
= 4.7.2 =
|
208 |
+
* Do not execute select-theme.php on Admin panels, to eliminate error message whenever any plugin is uninstalled
|
209 |
+
* Handle URL Query Keyword[]=Value
|
210 |
+
* Add Polylang to list of incompatible plugins
|
211 |
+
|
212 |
+
= 4.7.1 =
|
213 |
+
* Handle PHP without mbstring extension
|
214 |
+
|
215 |
+
= 4.7 =
|
216 |
+
* Add option to select a Theme based on Query Keyword and Value pair in URL
|
217 |
+
* Redesign how Query entries are stored
|
218 |
+
* Full testing completed with WordPress Version 3.8
|
219 |
+
|
220 |
+
= 4.6 =
|
221 |
+
* Add option to select a Theme based on Query Keyword in URL
|
222 |
+
* Rearrange Settings page
|
223 |
+
|
224 |
+
= 4.5.2 =
|
225 |
+
* Eliminate Fatal Error if php zip_open() function is not available, when readme.txt is out of date
|
226 |
+
|
227 |
+
= 4.5.1 =
|
228 |
+
* Remove %E2%80%8E suffix from URLs being entered
|
229 |
+
|
230 |
+
= 4.5 =
|
231 |
+
* Check with get_page_by_path() and get_posts( array( 'name' => $page_url ) ) if url_to_postid() fails to find URL input
|
232 |
+
|
233 |
+
= 4.4 =
|
234 |
+
* Rewrite Plugin's handling of its own version number to fix issues when new sites are activated in a Network and plugin is Network-Activated
|
235 |
+
* Prevent Fatal Error for Versions of WordPress before 3.4, and Deactivate Plugin instead, because plugin requires at least 3.4 to function
|
236 |
+
* Security: require "switch_themes" Capability rather than "manage_options" Capability to access plugin's Settings page
|
237 |
+
|
238 |
+
= 4.3 =
|
239 |
+
* Add SSL support so that visitors can view the WordPress site with https:// URLs and Site URL can be https://
|
240 |
+
|
241 |
+
= 4.2 =
|
242 |
+
* Add option to override WordPress Current Theme
|
243 |
+
* Security enhancements to eliminate direct execution of .php files
|
244 |
+
|
245 |
+
= 4.1.1 =
|
246 |
+
* Handle situations where readme.txt file in plugin's directory cannot be read or written
|
247 |
+
|
248 |
+
= 4.1 =
|
249 |
+
* Support for non-alphanumeric characters in URLs, e.g. - languages using characters not in the English alphabet
|
250 |
+
* Support for Live Search feature of KnowHow Theme
|
251 |
+
* Display errors, not settings, on plugin's Admin page for activated BuddyPress or Theme Test Drive plugins, or old versions of WordPress
|
252 |
+
* Add error checking/messages and diagnostic information to plugin's Admin page
|
253 |
+
|
254 |
+
= 4.0.2 =
|
255 |
+
* Prevent Warning and Notice by initializing global $wp
|
256 |
+
|
257 |
+
= 4.0.1 =
|
258 |
+
* Prevent Fatal Error by initializing global $wp_rewrite
|
259 |
+
|
260 |
+
= 4 =
|
261 |
+
* Discovered url_to_postid() function, to address situations where Slug differed from Permalink, such as Posts with Year/Month folders
|
262 |
+
|
263 |
+
= 3.3.1 =
|
264 |
+
* Fix White Screen of Death on a Page selected by plugin
|
265 |
+
|
266 |
+
= 3.3 =
|
267 |
+
* Support Child Themes and any other situation where stylesheet and template names are not the same
|
268 |
+
|
269 |
+
= 3.2 =
|
270 |
+
* Correct Problem with P2 Theme, and its logged on verification at wp-admin/admin-ajax.php?p2ajax=true&action=logged_in_out&_loggedin={nonce}
|
271 |
+
* Add "Settings Saved" message to Admin page
|
272 |
+
* Tested with WordPress Version 3.5 beta
|
273 |
+
|
274 |
+
= 3.1 =
|
275 |
+
* Add Support for Prefixes, where all URLs beginning with the specified characters ("Prefix") can be assigned to a specified Theme
|
276 |
+
|
277 |
+
= 3.0 =
|
278 |
+
* Add Support for Categories and Archives when no Permalinks exist (support already existed Categories and Archives with Permalinks)
|
279 |
+
* Resolve several minor bugs
|
280 |
+
|
281 |
+
= 2.9 =
|
282 |
+
* Rewrite much of the Settings page and Plugin Directory documentation
|
283 |
+
* Add Support for IIS which returns incorrect values in $_SERVER['REQUEST_URI']
|
284 |
+
* Make it easier to select the Theme for the Site Home by providing a new Settings field
|
285 |
+
* 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
|
286 |
+
* Add version upgrade detection to add, remove and update Settings fields
|
287 |
+
* Move Settings link on Plugins page from beginning to end of links
|
288 |
+
|
289 |
+
= 2.0 =
|
290 |
+
* Address pecularities of wp_make_link_relative() related to root-based WordPress sites using Permalinks
|
291 |
+
|
292 |
+
= 1.1 =
|
293 |
+
* Fix foreach failing on some systems, based on PHP warning level
|
294 |
+
|
295 |
+
= 1.0 =
|
296 |
+
* Make plugin conform to WordPress plugin repository standards.
|
297 |
+
* Beta testing completed.
|
298 |
+
|
299 |
+
== Upgrade Notice ==
|
300 |
+
|
301 |
+
= 5.0.3 =
|
302 |
+
Remove cleanup of non-existent themes specified in Settings
|
303 |
+
|
304 |
+
= 5.0.2 =
|
305 |
+
Remove /downgrade/ directory that may have caused PCLZIP_ERR_BAD_FORMAT errors on some web hosts
|
306 |
+
|
307 |
+
= 5.0.1 =
|
308 |
+
Correct All Pages and All Posts (Advanced) Setting bug
|
309 |
+
|
310 |
+
= 5.0 =
|
311 |
+
Greatly expanded compatibility with other Plugins and Themes
|
312 |
+
|
313 |
+
= 4.11.2 =
|
314 |
+
Standardize to case insensitive Query comparisons and eliminate Connection Info prompt on Settings page
|
315 |
+
|
316 |
+
= 4.11.1 =
|
317 |
+
Fix foreach() error
|
318 |
+
|
319 |
+
= 4.11 =
|
320 |
+
Complete rewrite of Sticky logic
|
321 |
+
|
322 |
+
= 4.10.1 =
|
323 |
+
Make Sticky work with Caching plugins
|
324 |
+
|
325 |
+
= 4.10 =
|
326 |
+
Performance improvements and add Sticky Queries
|
327 |
+
|
328 |
+
= 4.9 =
|
329 |
+
Allow Prefix URLs to match all subdirectories with an Asterisk ("*")
|
330 |
+
|
331 |
+
= 4.8 =
|
332 |
+
Compatibility with NextGen Gallery plugin
|
333 |
+
|
334 |
+
= 4.7.3 =
|
335 |
+
Allow dots in URL Queries
|
336 |
+
|
337 |
+
= 4.7.2 =
|
338 |
+
Avoid Error Message during Uninstall of other Plugins
|
339 |
+
|
340 |
+
= 4.7.1 =
|
341 |
+
Avoid mb_ function errors for PHP without mbstring extension
|
342 |
+
|
343 |
+
= 4.7 =
|
344 |
+
Select Theme by Query Keyword/Value pair in URL
|
345 |
+
|
346 |
+
= 4.6 =
|
347 |
+
Select Theme by Query Keyword in URL
|
348 |
+
|
349 |
+
= 4.5.2 =
|
350 |
+
Fix zip_open Fatal Error
|
351 |
+
|
352 |
+
= 4.5.1 =
|
353 |
+
Fix %E2%80%8E suffix problem on input URLs
|
354 |
+
|
355 |
+
= 4.5 =
|
356 |
+
Handle URL input for non-standard Pages and Posts
|
357 |
+
|
358 |
+
= 4.4 =
|
359 |
+
Fix errors when new Network site created or old WordPress version used, and correct Setting page Permissions to "switch_themes"
|
360 |
+
|
361 |
+
= 4.3 =
|
362 |
+
Add SSL support for sites with https:// URLs
|
363 |
+
|
364 |
+
= 4.2 =
|
365 |
+
Add "Select Theme for Everything" feature and improve security
|
366 |
+
|
367 |
+
= 4.1.1 =
|
368 |
+
Resolve issues with readme.txt permissions introduced in Version 4.1's compatibility checking
|
369 |
+
|
370 |
+
= 4.1 =
|
371 |
+
Support non-English alphabet in URLs and Live Search feature in KnowHow Theme
|
372 |
+
|
373 |
+
= 4.0.2 =
|
374 |
+
Fix "Warning: in_array() expects parameter 2 to be array, null given in domain.com/wp-includes/rewrite.php on line 364"
|
375 |
+
|
376 |
+
= 4.0.1 =
|
377 |
+
Fix "Fatal error: Call to a member function wp_rewrite_rules() on a non-object in domain.com/wp-includes/rewrite.php on line 294"
|
378 |
+
|
379 |
+
= 4 =
|
380 |
+
Fix Posts not working in some Permalink setups, most notably Year/Month
|
381 |
+
|
382 |
+
= 3.3.1 =
|
383 |
+
Fix White Screen of Death on a Page, Post or other element selected by plugin
|
384 |
+
|
385 |
+
= 3.3 =
|
386 |
+
Remove Restriction that Stylesheet Name must match Template Name, which it does not with Child Themes
|
387 |
+
|
388 |
+
= 3.2 =
|
389 |
+
Add Support for P2 Theme and provide "Settings Saved" message
|
390 |
+
|
391 |
+
= 3.1 =
|
392 |
+
Allow Prefix URLs to be used to specify where a Theme will be displayed
|
393 |
+
|
394 |
+
= 3.0 =
|
395 |
+
Improve support for Categories and Archives, and eliminate all known bugs.
|
396 |
+
|
397 |
+
= 2.9 =
|
398 |
+
Improve Settings fields, correct display of wrong Current Theme in Appearance-Themes Admin panel, and add IIS Support.
|
399 |
+
|
400 |
+
= 2.0 =
|
401 |
+
Selecting Individual Pages and Posts on a WordPress site installed in the root and using Permalinks now works correctly.
|
402 |
+
|
403 |
+
= 1.1 =
|
404 |
+
Eliminate possibility of foreach error message if PHP warning level is set at a high level
|
405 |
+
|
406 |
+
= 1.0 =
|
407 |
+
Beta version 0.9 had not been tested when installed from the WordPress Plugin Repository
|
uninstall.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Ensure call comes from WordPress, not a hacker or anyone else trying direct access.
|
3 |
+
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
4 |
+
exit ();
|
5 |
+
|
6 |
+
|
7 |
+
/* Remove any tables, options, and such created by this Plugin */
|
8 |
+
$setting_names = array(
|
9 |
+
'jr_mt_settings',
|
10 |
+
'jr_mt_internal_settings',
|
11 |
+
'jr_mt_all_themes'
|
12 |
+
);
|
13 |
+
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
14 |
+
global $wpdb, $site_id;
|
15 |
+
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = $site_id" );
|
16 |
+
foreach ( $blogs as $blog_obj ) {
|
17 |
+
foreach ( $setting_names as $name ) {
|
18 |
+
delete_blog_option( $blog_obj->blog_id, $name );
|
19 |
+
}
|
20 |
+
}
|
21 |
+
} else {
|
22 |
+
foreach ( $setting_names as $name ) {
|
23 |
+
delete_option( $name );
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
?>
|