Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************
- * Theme-Showcase ********
- *************************/
- // METHOD 1
- function list_all_wpmu_themes() {
- $themes = get_themes();
- $ct = current_theme_info();
- $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() );
- if( $allowed_themes == false )
- $allowed_themes = array();
- reset( $themes );
- foreach( $themes as $key => $theme ) {
- if( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) {
- unset( $themes[ $key ] );
- }
- }
- reset( $themes );
- $theme_names = array_keys($themes);
- natcasesort($theme_names);
- // Pagination
- $themes_per_page = (int) apply_filters('themes_per_page', 30);
- $actual_page = (int) ( isset($_GET['pagination']) ) ? $_GET['pagination'] : 1;
- $found_themes = count($theme_names);
- $max_num_pages = ceil($found_themes/$themes_per_page);
- if( $actual_page != 1 ) {
- if($actual_page > $max_num_pages) {
- $actual_page = $max_num_pages;
- }
- }
- $start = ($actual_page - 1) * $themes_per_page;
- $end = $start + $themes_per_page;
- if ( $max_num_pages > 1 ) {
- $output = '<div class="pagination" style="float:right;" >';
- $output .= __('Page: ');
- for ( $i = 1; $i <= $max_num_pages; $i++ ) {
- $page_link = $_SERVER['REQUEST_URI'];
- $page_link = add_query_arg( array('pagination' => $i), $page_link );
- $output .= '| <a href="'.$page_link.'">'.$i.'</a> ';
- }
- $output .= '| </div>';
- echo $output;
- }
- $i = 0;
- foreach ( (array) $theme_names as $theme_name) {
- if ( ($i >= $start) && ($i < $end) ) {
- $template = $themes[$theme_name]['Template'];
- $stylesheet = $themes[$theme_name]['Stylesheet'];
- $title = $themes[$theme_name]['Title'];
- $version = $themes[$theme_name]['Version'];
- $description = $themes[$theme_name]['Description'];
- $author = $themes[$theme_name]['Author'];
- $screenshot = $themes[$theme_name]['Screenshot'];
- $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
- $preview_link = clean_url( get_option('home') . '/');
- $preview_link = add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 800, 'height' => 600 ), $preview_link );
- $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
- $thickbox_class = 'thickbox';
- ?>
- <div class="available-theme">
- <h3><a class="<?php echo $thickbox_class; ?>" href="<?php echo $preview_link; ?>"><?php echo $title; ?></a></h3>
- <?php if ( $screenshot ) : ?>
- <div class="entry"><p class="themeactions"><a class="<?php echo $thickbox_class; ?>" href='<?php echo $preview_link; ?>' title='<?php echo $preview_text; ?>'><img class="alignleft" style="margin-right:10px" src="<?php echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot; ?>" width="120" alt="<?php echo attribute_escape(strip_tags($title)); ?>" /></a> </p>
- <?php endif; ?>
- <p><?php echo $description; ?></p></div>
- <noscript><p class="themeactions"><a href="<?php echo $preview_link; ?>" title="<?php echo $preview_text; ?>"><?php _e('Preview'); ?></a> <a href="<?php echo $activate_link; ?>" title="<?php echo $activate_text; ?>"><?php _e('Activate'); ?></a></p></noscript>
- <div style="display:none;"><a class="previewlink" href="<?php echo $preview_link; ?>"><?php echo $preview_text; ?></a> <a class="activatelink" href="<?php echo $activate_link; ?>"><?php echo $activate_text; ?></a></div>
- </div>
- <?php
- }
- $i++;
- } // end foreach theme_names
- if ( $max_num_pages > 1 ) {
- $output = '<div class="pagination" style="float:right;" >';
- $output .= __('Page: ');
- for ( $i = 1; $i <= $max_num_pages; $i++ ) {
- $page_link = $_SERVER['REQUEST_URI'];
- $page_link = add_query_arg( array('pagination' => $i), $page_link );
- $output .= '| <a href="'.$page_link.'">'.$i.'</a> '; // add_query_arg instead
- }
- // $output = str_replace('pagination='.$actual_page.'">', 'pagination='.$actual_page.'" class="current_page">', $output);
- $output .= '| </div>';
- echo $output;
- }
- }
- function ds_theme_preview_scripts() { ?>
- <script src="<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.js" type="text/javascript"></script>
- <script src="<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.color.js" type="text/javascript"></script>
- <script src="<?php bloginfo('url'); ?>/wp-admin/js/theme-preview.js" type="text/javascript"></script>
- <script src="<?php bloginfo('url'); ?>/wp-includes/js/thickbox/thickbox.js" type="text/javascript"></script>
- <link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-includes/js/thickbox/thickbox.css" type="text/css" media="screen" />
- <?php
- }
- if (strpos($_SERVER['REQUEST_URI'], 'page_id=37') || strpos($_SERVER['REQUEST_URI'], 'theme-showcase'))
- add_action('wp_head','ds_theme_preview_scripts');
- // METHOD 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement