get_theme(); if ( empty( $theme ) ) { return $stylesheet; } $theme = wp_get_theme( $theme ); // Don't let people peek at unpublished themes. if ( isset( $theme['Status'] ) && $theme['Status'] != 'publish' ) return $stylesheet; if ( empty( $theme ) ) { return $stylesheet; } return $theme['Stylesheet']; } function get_template( $template ) { $theme = $this->get_theme(); if ( empty( $theme ) ) { return $template; } $theme = wp_get_theme( $theme ); if ( empty( $theme ) ) { return $template; } // Don't let people peek at unpublished themes. if ( isset( $theme['Status'] ) && $theme['Status'] != 'publish' ) { return $template; } return $theme['Template']; } function get_theme() { if ( ! empty( $_COOKIE['wptheme' . COOKIEHASH] ) ) { return $_COOKIE['wptheme' . COOKIEHASH]; } else { return ''; } } function switcher_dropdown() { global $wp_admin_bar, $wpdb; if ( ! is_super_admin() || ! is_admin_bar_showing() ) { return; } /* Add the main siteadmin menu item */ $wp_admin_bar->add_menu( array( 'id' => 'switch_themes', 'title' => 'Switch Theme', 'href' => '#', 'meta' => array ( 'class' => 'themeswitchermenumain' ) ) ); $wp_admin_bar->add_menu( array( 'id' => 'switch_themes_dropdown', 'parent' => 'switch_themes', 'title' => $this->theme_switcher_markup( 'dropdown' ), 'href' => '#', 'meta' => array ( 'class' => 'themeswitchermenu' ) ) ); } function theme_switcher_markup( $style = 'text', $instance = array() ) { if ( ! $theme_data = get_transient( 'theme-switcher-themes-data' ) ) { $themes = (array) wp_get_themes(); if ( function_exists( 'is_site_admin' ) ) { $allowed_themes = (array) get_site_option( 'allowedthemes' ); foreach( $themes as $key => $theme ) { if ( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) { unset( $themes[ $key ] ); } } } $default_theme = wp_get_theme()->get( 'Name' ); $theme_data = array(); foreach ( (array) $themes as $theme_name => $data ) { // Skip unpublished themes. if ( empty( $theme_name ) || isset( $themes[ $theme_name ]['Status'] ) && $themes[ $theme_name ]['Status'] != 'publish' ) { continue; } $theme_data[ add_query_arg( 'wptheme', $theme_name ) ] = $theme_name; } asort( $theme_data ); set_transient( 'theme-switcher-themes-data', $theme_data, DAY_IN_SECONDS ); } $ts = ''; if ( $style == 'dropdown' ) { $ts .= ''; } return $ts; } function hide_switcher_a_tag() { ?>