Advertisement
Guest User

dsader

a guest
Aug 28th, 2008
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. /************************
  2. * Theme-Showcase ********
  3. *************************/
  4. // METHOD 1
  5. function list_all_wpmu_themes() {
  6. $themes = get_themes();
  7. $ct = current_theme_info();
  8. $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() );
  9. if( $allowed_themes == false )
  10. $allowed_themes = array();
  11. reset( $themes );
  12. foreach( $themes as $key => $theme ) {
  13. if( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) {
  14. unset( $themes[ $key ] );
  15. }
  16. }
  17. reset( $themes );
  18. $theme_names = array_keys($themes);
  19. natcasesort($theme_names);
  20.  
  21. // Pagination
  22. $themes_per_page = (int) apply_filters('themes_per_page', 30);
  23. $actual_page = (int) ( isset($_GET['pagination']) ) ? $_GET['pagination'] : 1;
  24.  
  25. $found_themes = count($theme_names);
  26. $max_num_pages = ceil($found_themes/$themes_per_page);
  27.  
  28. if( $actual_page != 1 ) {
  29. if($actual_page > $max_num_pages) {
  30. $actual_page = $max_num_pages;
  31. }
  32. }
  33.  
  34. $start = ($actual_page - 1) * $themes_per_page;
  35. $end = $start + $themes_per_page;
  36.  
  37. if ( $max_num_pages > 1 ) {
  38. $output = '<div class="pagination" style="float:right;" >';
  39. $output .= __('Page: ');
  40. for ( $i = 1; $i <= $max_num_pages; $i++ ) {
  41. $page_link = $_SERVER['REQUEST_URI'];
  42. $page_link = add_query_arg( array('pagination' => $i), $page_link );
  43. $output .= '| <a href="'.$page_link.'">'.$i.'</a> ';
  44. }
  45. $output .= '| </div>';
  46. echo $output;
  47. }
  48.  
  49. $i = 0;
  50. foreach ( (array) $theme_names as $theme_name) {
  51. if ( ($i >= $start) && ($i < $end) ) {
  52. $template = $themes[$theme_name]['Template'];
  53. $stylesheet = $themes[$theme_name]['Stylesheet'];
  54. $title = $themes[$theme_name]['Title'];
  55. $version = $themes[$theme_name]['Version'];
  56. $description = $themes[$theme_name]['Description'];
  57. $author = $themes[$theme_name]['Author'];
  58. $screenshot = $themes[$theme_name]['Screenshot'];
  59. $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
  60. $preview_link = clean_url( get_option('home') . '/');
  61. $preview_link = add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 800, 'height' => 600 ), $preview_link );
  62. $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
  63. $thickbox_class = 'thickbox';
  64. ?>
  65. <div class="available-theme">
  66. <h3><a class="<?php echo $thickbox_class; ?>" href="<?php echo $preview_link; ?>"><?php echo $title; ?></a></h3>
  67. <?php if ( $screenshot ) : ?>
  68. <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>
  69. <?php endif; ?>
  70. <p><?php echo $description; ?></p></div>
  71. <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>
  72. <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>
  73. </div>
  74. <?php
  75. }
  76. $i++;
  77. } // end foreach theme_names
  78.  
  79. if ( $max_num_pages > 1 ) {
  80. $output = '<div class="pagination" style="float:right;" >';
  81. $output .= __('Page: ');
  82. for ( $i = 1; $i <= $max_num_pages; $i++ ) {
  83. $page_link = $_SERVER['REQUEST_URI'];
  84. $page_link = add_query_arg( array('pagination' => $i), $page_link );
  85. $output .= '| <a href="'.$page_link.'">'.$i.'</a> '; // add_query_arg instead
  86. }
  87. // $output = str_replace('pagination='.$actual_page.'">', 'pagination='.$actual_page.'" class="current_page">', $output);
  88. $output .= '| </div>';
  89. echo $output;
  90. }
  91. }
  92. function ds_theme_preview_scripts() { ?>
  93. <script src="<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.js" type="text/javascript"></script>
  94. <script src="<?php bloginfo('url'); ?>/wp-includes/js/jquery/jquery.color.js" type="text/javascript"></script>
  95. <script src="<?php bloginfo('url'); ?>/wp-admin/js/theme-preview.js" type="text/javascript"></script>
  96. <script src="<?php bloginfo('url'); ?>/wp-includes/js/thickbox/thickbox.js" type="text/javascript"></script>
  97. <link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-includes/js/thickbox/thickbox.css" type="text/css" media="screen" />
  98. <?php
  99. }
  100. if (strpos($_SERVER['REQUEST_URI'], 'page_id=37') || strpos($_SERVER['REQUEST_URI'], 'theme-showcase'))
  101. add_action('wp_head','ds_theme_preview_scripts');
  102. // METHOD 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement