Version Description
- Fix bug that stripped off Queries in URL Settings
Download this release
Release Info
Developer | dgewirtz |
Plugin | Multiple Themes |
Version | 6.0.2 |
Comparing to | |
See all releases |
Version 6.0.2
- includes/admin-functions.php +204 -0
- includes/admin.php +2031 -0
- includes/functions.php +678 -0
- includes/index.html +0 -0
- includes/old-wp.php +20 -0
- includes/select-theme.php +541 -0
- includes/upgradev5.php +127 -0
- includes/upgradev6.php +94 -0
- index.html +0 -0
- jonradio-multiple-themes.php +285 -0
- js/index.html +0 -0
- js/sticky.js +137 -0
- js/tabs.js +21 -0
- readme.txt +427 -0
- uninstall.php +27 -0
includes/admin-functions.php
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
. JR_MT_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>' . JR_MT_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 |
+
/**
|
171 |
+
* Sanitize a URL from a Text Form field intended for database storage
|
172 |
+
*/
|
173 |
+
function jr_mt_sanitize_url( $url ) {
|
174 |
+
/* Handle troublesome %E2%80%8E UTF Left-to-right Mark (LRM) suffix first.
|
175 |
+
*/
|
176 |
+
if ( FALSE === stripos( $url, '%E2%80%8E' ) ) {
|
177 |
+
if ( FALSE === stripos( rawurlencode( $url ), '%E2%80%8E' ) ) {
|
178 |
+
$clean_url = $url;
|
179 |
+
} else {
|
180 |
+
$clean_url = rawurldecode( str_ireplace( '%E2%80%8E', '', rawurlencode( $url ) ) );
|
181 |
+
}
|
182 |
+
} else {
|
183 |
+
$clean_url = str_ireplace( '%E2%80%8E', '', $url );
|
184 |
+
}
|
185 |
+
$clean_url = rawurldecode( trim( $clean_url ) );
|
186 |
+
|
187 |
+
return $clean_url;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Make URL Relative to Site URL
|
192 |
+
*
|
193 |
+
*/
|
194 |
+
function jr_mt_relative_url( $url, $site_url ) {
|
195 |
+
$url_path_array = parse_url( $url );
|
196 |
+
$url_path = $url_path_array['path'];
|
197 |
+
if ( !empty( $url_path_array['query'] ) ) {
|
198 |
+
$url_path .= '?' . $url_path_array['query'];
|
199 |
+
}
|
200 |
+
$site_url_path = parse_url( $site_url, PHP_URL_PATH );
|
201 |
+
return trim( jr_mt_substr( $url_path, jr_mt_strlen( $site_url_path ) ), '/\\' );
|
202 |
+
}
|
203 |
+
|
204 |
+
?>
|
includes/admin.php
ADDED
@@ -0,0 +1,2031 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if .php file accessed directly
|
3 |
+
if ( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
// Admin Page
|
6 |
+
|
7 |
+
add_action( 'admin_menu', 'jr_mt_admin_hook' );
|
8 |
+
// Runs just before admin_init (below)
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Add Admin Menu item for plugin
|
12 |
+
*
|
13 |
+
* Plugin needs its own Page in the Settings section of the Admin menu.
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
function jr_mt_admin_hook() {
|
17 |
+
// Add Settings Page for this Plugin
|
18 |
+
global $jr_mt_plugin_data;
|
19 |
+
add_theme_page( $jr_mt_plugin_data['Name'], 'Multiple Themes plugin', 'switch_themes', 'jr_mt_settings', 'jr_mt_settings_page' );
|
20 |
+
add_options_page( $jr_mt_plugin_data['Name'], 'Multiple Themes plugin', 'switch_themes', 'jr_mt_settings', 'jr_mt_settings_page' );
|
21 |
+
}
|
22 |
+
|
23 |
+
global $jr_mt_kwvalsep;
|
24 |
+
/* Everything is converted to lower-case, so upper-case letter makes a good keyword-value separator
|
25 |
+
*/
|
26 |
+
$jr_mt_kwvalsep = 'A';
|
27 |
+
|
28 |
+
add_action( 'admin_enqueue_scripts', 'jr_mt_admin_enqueue_scripts' );
|
29 |
+
function jr_mt_admin_enqueue_scripts() {
|
30 |
+
global $jr_mt_plugin_data;
|
31 |
+
wp_enqueue_script( 'jr_mt_tabs', plugins_url() . '/' . dirname( jr_mt_plugin_basename() ) . '/js/tabs.js', array(), $jr_mt_plugin_data['Version'] );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Settings page for plugin
|
36 |
+
*
|
37 |
+
* Display and Process Settings page for this plugin.
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
function jr_mt_settings_page() {
|
41 |
+
global $jr_mt_plugin_data, $jr_mt_plugins_cache;
|
42 |
+
$jr_mt_plugins_cache = get_plugins();
|
43 |
+
add_thickbox();
|
44 |
+
echo '<div class="wrap">';
|
45 |
+
echo '<h2>' . $jr_mt_plugin_data['Name'] . '</h2>';
|
46 |
+
|
47 |
+
/* Required because it is only called automatically for Admin Pages in the Settings section
|
48 |
+
*/
|
49 |
+
settings_errors( 'jr_mt_settings' );
|
50 |
+
|
51 |
+
/* Return to Same Tab where button was pushed.
|
52 |
+
|
53 |
+
TODO: This should be converted to use wp_localize_script()
|
54 |
+
as described on page 356 of "Professional WordPress Plugin Development" 2011.
|
55 |
+
*/
|
56 |
+
$name = 'jr_mt_' . get_current_user_id() . '_tab';
|
57 |
+
if ( FALSE === ( $tab = get_transient( $name ) ) ) {
|
58 |
+
$tab = 1;
|
59 |
+
} else {
|
60 |
+
delete_transient( $name );
|
61 |
+
}
|
62 |
+
echo '<script type="text/javascript">window.onload = function() { jrMtTabs('
|
63 |
+
. $tab . ', 6 ); }</script>';
|
64 |
+
|
65 |
+
$theme_obj = wp_get_theme();
|
66 |
+
$theme = $theme_obj->Name;
|
67 |
+
$theme_version = $theme_obj->Version;
|
68 |
+
global $jr_mt_options_cache;
|
69 |
+
|
70 |
+
$current_wp_version = get_bloginfo( 'version' );
|
71 |
+
|
72 |
+
global $jr_mt_plugins_cache;
|
73 |
+
|
74 |
+
$compatible = TRUE;
|
75 |
+
|
76 |
+
// Check for incompatible plugins that have been activated: BuddyPress and Theme Test Drive
|
77 |
+
global $jr_mt_incompat_plugins;
|
78 |
+
foreach ( $jr_mt_plugins_cache as $rel_path => $plugin_data ) {
|
79 |
+
if ( in_array( $plugin_data['Name'], $jr_mt_incompat_plugins ) && is_plugin_active( $rel_path ) ) {
|
80 |
+
if ( $compatible ) {
|
81 |
+
echo '<h3>Plugin Conflict Error Detected</h3>';
|
82 |
+
$compatible = FALSE;
|
83 |
+
}
|
84 |
+
echo '<p>This Plugin (' . $jr_mt_plugin_data['Name'] . ') cannot be used when the <b>' . $plugin_data['Name']
|
85 |
+
. '</b> plugin is Activated. If you wish to use the ' . $jr_mt_plugin_data['Name']
|
86 |
+
. ' plugin, please deactivate the ' . $plugin_data['Name']
|
87 |
+
. ' plugin (not just when viewing this Settings page, but whenever the '
|
88 |
+
. $jr_mt_plugin_data['Name'] . ' plugin is activated).</p>';
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( $compatible ) {
|
93 |
+
$settings = get_option( 'jr_mt_settings' );
|
94 |
+
$internal_settings = get_option( 'jr_mt_internal_settings' );
|
95 |
+
?>
|
96 |
+
<style type="text/css">
|
97 |
+
<!--
|
98 |
+
ul.jrmtpoints { margin-left: 1em;
|
99 |
+
list-style: disc;}
|
100 |
+
-->
|
101 |
+
</style>
|
102 |
+
<h2 class="nav-tab-wrapper">
|
103 |
+
<a href="#" class="nav-tab nav-tab-active" id="jr-mt-tabs1"
|
104 |
+
onClick="jrMtTabs( 1, 6 );">Settings</a><a href="#" class="nav-tab" id="jr-mt-tabs2"
|
105 |
+
onClick="jrMtTabs( 2, 6 );">Site Aliases</a><a href="#" class="nav-tab" id="jr-mt-tabs3"
|
106 |
+
onClick="jrMtTabs( 3, 6 );">Advanced Settings</a><a href="#" class="nav-tab" id="jr-mt-tabs4"
|
107 |
+
onClick="jrMtTabs( 4, 6 );">Theme Options</a><a href="#" class="nav-tab" id="jr-mt-tabs5"
|
108 |
+
onClick="jrMtTabs( 5, 6 );">System Information</a><a href="#" class="nav-tab" id="jr-mt-tabs6"
|
109 |
+
onClick="jrMtTabs( 6, 6 );">Help</a>
|
110 |
+
</h2>
|
111 |
+
<div id="jr-mt-settings1">
|
112 |
+
<h3>Settings</h3>
|
113 |
+
<p>
|
114 |
+
This is the main Settings tab.
|
115 |
+
You should also review the
|
116 |
+
<a href="#" onClick="jrMtTabs( 2, 6 );">Site Aliases tab</a>:
|
117 |
+
</p>
|
118 |
+
<ul class="jrmtpoints">
|
119 |
+
<li>
|
120 |
+
when first using this plugin,
|
121 |
+
</li>
|
122 |
+
<li>
|
123 |
+
when upgrading to Version 6 of this plugin from a previous version,
|
124 |
+
and
|
125 |
+
</li>
|
126 |
+
<li>
|
127 |
+
whenever you change the
|
128 |
+
<b>
|
129 |
+
Site Address (URL)
|
130 |