-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault-theme.php
More file actions
126 lines (104 loc) · 4.46 KB
/
default-theme.php
File metadata and controls
126 lines (104 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/*
Plugin Name: Standard Theme
Version: 1.0.5
Plugin URI: https://cp-psource.github.io/default-theme/
Description: Ermöglicht die einfache Auswahl eines neuen Standardthemes für neue Blog-Anmeldungen
Author: PSOURCE
Author URI: https://github.com/cp-psource
Network: true
*/
/*
Copyright 2020-2025 PSOURCE (https://github.com/cp-psource)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @@@@@@@@@@@@@@@@@ PS UPDATER 1.3 @@@@@@@@@@@
**/
require 'psource/psource-plugin-update/plugin-update-checker.php';
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
$myUpdateChecker = PucFactory::buildUpdateChecker(
'https://github.com/cp-psource/default-theme',
__FILE__,
'default-theme'
);
//Set the branch that contains the stable release.
$myUpdateChecker->setBranch('master');
/**
* @@@@@@@@@@@@@@@@@ ENDE PS UPDATER 1.3 @@@@@@@@@@@
**/
//force multisite
if ( ! is_multisite() ) {
exit( __( 'Das Standard Theme ist nur mit Multisite-Installationen kompatibel.', 'defaulttheme' ) );
}
//------------------------------------------------------------------------//
//---Hook-----------------------------------------------------------------//
//------------------------------------------------------------------------//
add_action( 'plugins_loaded', 'default_theme_localization' );
add_action( 'wpmu_options', 'default_theme_site_admin_options' );
add_action( 'update_wpmu_options', 'default_theme_site_admin_options_process', 1 );
add_action( 'wpmu_new_blog', 'default_theme_switch_theme', 1, 1 );
//------------------------------------------------------------------------//
//---Functions------------------------------------------------------------//
//------------------------------------------------------------------------//
function default_theme_localization() {
// Load up the localization file if we're using WordPress in a different language
// Place it in this plugin's "languages" folder and name it "defaulttheme-[value in wp-config].mo"
load_plugin_textdomain( 'defaulttheme', false, '/default-theme/languages' );
}
function default_theme_switch_theme( $blog_ID ) {
$default_theme = get_site_option( 'default_theme' );
$themes = wp_get_themes();
//we have to go through all this to handle child themes, otherwise it will throw errors
foreach ( (array) $themes as $key => $theme ) {
$stylesheet = esc_html( $theme['Stylesheet'] );
$template = esc_html( $theme['Template'] );
if ( $default_theme == $stylesheet || $default_theme == $template ) {
$new_stylesheet = $stylesheet;
$new_template = $template;
}
}
//activate it
switch_to_blog( $blog_ID );
switch_theme( $new_template, $new_stylesheet );
restore_current_blog();
}
function default_theme_site_admin_options_process() {
update_site_option( 'default_theme', $_POST['default_theme'] );
}
//------------------------------------------------------------------------//
//---Output Functions-----------------------------------------------------//
//------------------------------------------------------------------------//
function default_theme_site_admin_options() {
$themes = wp_get_themes();
$default_theme = get_site_option( 'default_theme' );
if ( empty( $default_theme ) ) {
$default_theme = 'default';
}
?>
<h3><?php _e( 'Theme Einstellungen', 'defaulttheme' ) ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e( 'Standard Theme', 'defaulttheme' ) ?></th>
<td><select name="default_theme">
<?php
foreach ( $themes as $key => $theme ) {
$theme_key = esc_html( $theme['Stylesheet'] );
echo '<option value="' . $theme_key . '"' . ( $theme_key == $default_theme ? ' selected' : '' ) . '>' . $key . '</option>' . "\n";
}
?>
</select>
<br/><?php _e( 'Standardtheme für neue Blogs.', 'defaulttheme' ); ?></td>
</tr>
</table>
<?php
}