Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2013
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.66 KB | None | 0 0
  1. <?php
  2.  
  3. /////////////////////////////////////
  4.  
  5. // Enqueue Javascript Files
  6.  
  7. /////////////////////////////////////
  8.  
  9. function my_scripts_method() {
  10.  
  11.         wp_enqueue_script( 'jquery' );
  12.  
  13.     wp_enqueue_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array('jquery'));
  14.  
  15.     wp_enqueue_script('elastislide', get_template_directory_uri() . '/js/jquery.elastislide.js', array('jquery'));
  16.  
  17.     wp_enqueue_script('maxmag', get_template_directory_uri() . '/js/scripts.js', array('jquery'));
  18.  
  19.     wp_enqueue_script('ticker', get_template_directory_uri() . '/js/ticker.js', array('jquery'));
  20.  
  21.     wp_enqueue_script('respond', get_template_directory_uri() . '/js/respond.min.js', array('jquery'));
  22.  
  23. }
  24.  
  25. add_action('wp_enqueue_scripts', 'my_scripts_method');
  26.  
  27. /////////////////////////////////////
  28.  
  29. // Theme Options
  30.  
  31. /////////////////////////////////////
  32.  
  33. require_once(TEMPLATEPATH . '/admin/admin-functions.php');
  34.  
  35. require_once(TEMPLATEPATH . '/admin/admin-interface.php');
  36.  
  37. require_once(TEMPLATEPATH . '/admin/theme-settings.php');
  38.  
  39. function my_wp_head() {
  40.  
  41.     $bloginfo = get_template_directory_uri();
  42.  
  43.     $link = get_option('mm_link_color');
  44.  
  45.     $primarymenu = get_option('mm_primary_menu');
  46.  
  47.     $primarytheme = get_option('mm_primary_theme');
  48.  
  49.     $wallad = get_option('mm_wall_ad');
  50.  
  51.     echo "
  52.  
  53.         <style type='text/css'>
  54.  
  55.         a, a:visited, #twtr-widget-1 .twtr-tweet a { color: $link; }
  56.  
  57.         h3.category-heading { background: $primarytheme; }
  58.  
  59.         .home-widget h3, .home-widget h3 a, .middle-widget h3, .middle-widget h3 a, .sidebar-widget h3, .sidebar-widget h3 a, .bottom-widget h3, .bottom-widget h3 a, .widget-container h3, .widget-container h3 a, .multi-category h3,  ul.tabs li.active h4 a, #related-posts h3, h3#reply-title, h2.comments { color: $primarytheme; }
  60.  
  61.         #main-nav ul li:hover, #main-nav .current-menu-item, #main-nav .current-post-parent { background: $primarytheme url($bloginfo/images/nav-bg.png) top repeat-x; }
  62.  
  63.         #main-nav ul li:hover ul { border-top: 5px solid $primarytheme; }
  64.  
  65.         #main-nav-wrapper { background: $primarymenu url($bloginfo/images/nav-bg.png) top repeat-x; border-bottom: 5px solid $primarytheme; }
  66.  
  67.         ul.tabs li { background: $primarytheme; }
  68.  
  69.         #wallpaper { background: url($wallad) no-repeat 50% 0; }
  70.  
  71.         </style>";
  72.  
  73. }
  74.  
  75. add_action( 'wp_head', 'my_wp_head' );
  76.  
  77. /////////////////////////////////////
  78.  
  79. // Footer JS Code
  80.  
  81. /////////////////////////////////////
  82.  
  83. function my_wp_footer() {
  84.  
  85. echo "
  86.  
  87. <script type='text/javascript'>
  88.  
  89. jQuery(document).ready(function($){
  90.  
  91.  $(window).load(function(){
  92.  
  93.    $('.flexslider').flexslider({
  94.  
  95.     animation: 'slide',
  96.  
  97.     slideshowSpeed: 8000,
  98.  
  99.    });
  100.  
  101.  });
  102.  
  103.     var aboveHeight = $('#leader-wrapper').outerHeight();
  104.  
  105.        $(window).scroll(function(){
  106.  
  107.                if ($(window).scrollTop() > aboveHeight){
  108.  
  109.                $('#nav').addClass('fixed-nav').css('top','0').next()
  110.  
  111.                .css('padding-top','43px');
  112.  
  113.                } else {
  114.  
  115.                $('#nav').removeClass('fixed-nav').next()
  116.  
  117.                .css('padding-top','0');
  118.  
  119.                }
  120.  
  121.        });
  122.  
  123. });
  124.  
  125. </script>";
  126.  
  127. }
  128.  
  129. add_action( 'wp_footer', 'my_wp_footer' );
  130.  
  131. /////////////////////////////////////
  132.  
  133. // Register Widgets
  134.  
  135. /////////////////////////////////////
  136.  
  137. if ( function_exists('register_sidebar') ) {
  138.  
  139.     register_sidebar(array(
  140.  
  141.         'name' => 'Homepage Widget Area',
  142.  
  143.         'before_widget' => '<div class="home-widget">',
  144.  
  145.         'after_widget' => '</div>',
  146.  
  147.         'before_title' => '<h3>',
  148.  
  149.         'after_title' => '</h3>',
  150.  
  151.     ));
  152.  
  153. }
  154.  
  155. if ( function_exists('register_sidebar') ) {
  156.  
  157.     register_sidebar(array(
  158.  
  159.         'name' => 'Middle Widget Area',
  160.  
  161.         'before_widget' => '<div class="middle-widget">',
  162.  
  163.         'after_widget' => '</div>',
  164.  
  165.         'before_title' => '<h3>',
  166.  
  167.         'after_title' => '</h3>',
  168.  
  169.     ));
  170.  
  171. }
  172.  
  173. if ( function_exists('register_sidebar') ) {
  174.  
  175.     register_sidebar(array(
  176.  
  177.         'name' => 'Sidebar Home Widget Area',
  178.  
  179.         'before_widget' => '<div class="sidebar-widget">',
  180.  
  181.         'after_widget' => '</div>',
  182.  
  183.         'before_title' => '<h3>',
  184.  
  185.         'after_title' => '</h3>',
  186.  
  187.     ));
  188.  
  189. }
  190.  
  191. if ( function_exists('register_sidebar') ) {
  192.  
  193.     register_sidebar(array(
  194.  
  195.         'name' => 'Sidebar Widget Area',
  196.  
  197.         'before_widget' => '<div class="sidebar-widget">',
  198.  
  199.         'after_widget' => '</div>',
  200.  
  201.         'before_title' => '<h3>',
  202.  
  203.         'after_title' => '</h3>',
  204.  
  205.     ));
  206.  
  207. }
  208.  
  209. if ( function_exists('register_sidebar') ) {
  210.  
  211.     register_sidebar(array(
  212.  
  213.         'name' => 'Homepage Bottom Widget Area',
  214.  
  215.         'before_widget' => '<div class="sidebar-widget">',
  216.  
  217.         'after_widget' => '</div>',
  218.  
  219.         'before_title' => '<h3>',
  220.  
  221.         'after_title' => '</h3>',
  222.  
  223.     ));
  224.  
  225. }
  226.  
  227. if ( function_exists('register_sidebar') ) {
  228.  
  229.     register_sidebar(array(
  230.  
  231.         'name' => 'Footer Widget Area',
  232.  
  233.         'before_widget' => '<div class="footer-widget">',
  234.  
  235.         'after_widget' => '</div>',
  236.  
  237.         'before_title' => '<h3>',
  238.  
  239.         'after_title' => '</h3>',
  240.  
  241.     ));
  242.  
  243. }
  244.  
  245. include("widgets/widget-2column.php");
  246.  
  247. include("widgets/widget-ad160.php");
  248.  
  249. include("widgets/widget-ad300.php");
  250.  
  251. include("widgets/widget-blog.php");
  252.  
  253. include("widgets/widget-carousel.php");
  254.  
  255. include("widgets/widget-cat4.php");
  256.  
  257. include("widgets/widget-catfeat.php");
  258.  
  259. include("widgets/widget-catlist.php");
  260.  
  261. include("widgets/widget-facebook.php");
  262.  
  263. include("widgets/widget-multicat.php");
  264.  
  265. include("widgets/widget-recent.php");
  266.  
  267. include("widgets/widget-sidecat.php");
  268.  
  269. include("widgets/widget-tabs.php");
  270.  
  271. include("widgets/widget-tags.php");
  272.  
  273. include("widgets/widget-twitter.php");
  274.  
  275. /////////////////////////////////////
  276.  
  277. // Register Custom Menus
  278.  
  279. /////////////////////////////////////
  280.  
  281. function register_menus() {
  282.  
  283.     register_nav_menus(
  284.  
  285.         array(
  286.  
  287.             'main-menu' => __( 'Primary Menu' ),
  288.  
  289.             'secondary-menu' => __( 'Secondary Menu' ),)
  290.  
  291.         );
  292.  
  293.       }
  294.  
  295. add_action( 'init', 'register_menus' );
  296.  
  297. /////////////////////////////////////
  298.  
  299. // Register Thumbnails
  300.  
  301. /////////////////////////////////////
  302.  
  303. if ( function_exists( 'add_theme_support' ) ) {
  304.  
  305. add_theme_support( 'post-thumbnails' );
  306.  
  307. set_post_thumbnail_size( 420, 470, true );
  308.  
  309. add_image_size( 'slider-thumb', 420, 470, true );
  310.  
  311. add_image_size( 'post-thumb', 300, 336, true );
  312.  
  313. add_image_size( 'medium-thumb', 200, 224, true );
  314.  
  315. add_image_size( 'small-thumb', 120, 134, true );
  316.  
  317. }
  318.  
  319. /////////////////////////////////////
  320.  
  321. // Add Bread Crumbs
  322.  
  323. /////////////////////////////////////
  324.  
  325. function dimox_breadcrumbs() {
  326.  
  327.   $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
  328.  
  329.   $delimiter = '   >   '; // delimiter between crumbs
  330.  
  331.   $home = 'Home'; // text for the 'Home' link
  332.  
  333.   $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
  334.  
  335.   $before = '<span class="current">'; // tag before the current crumb
  336.  
  337.   $after = '</span>'; // tag after the current crumb
  338.  
  339.   global $post;
  340.  
  341.   $homeLink = home_url();
  342.  
  343.   if (is_home() || is_front_page()) {
  344.  
  345.     if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';
  346.  
  347.   } else {
  348.  
  349.     echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
  350.  
  351.     if ( is_category() ) {
  352.  
  353.       $thisCat = get_category(get_query_var('cat'), false);
  354.  
  355.       if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
  356.  
  357.       echo $before . single_cat_title('', false) . $after;
  358.  
  359.     } elseif ( is_search() ) {
  360.  
  361.       echo $before . 'Search results for "' . get_search_query() . '"' . $after;
  362.  
  363.     } elseif ( is_day() ) {
  364.  
  365.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  366.  
  367.       echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  368.  
  369.       echo $before . get_the_time('d') . $after;
  370.  
  371.     } elseif ( is_month() ) {
  372.  
  373.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  374.  
  375.       echo $before . get_the_time('F') . $after;
  376.  
  377.     } elseif ( is_year() ) {
  378.  
  379.       echo $before . get_the_time('Y') . $after;
  380.  
  381.     } elseif ( is_single() && !is_attachment() ) {
  382.  
  383.       if ( get_post_type() != 'post' ) {
  384.  
  385.         $post_type = get_post_type_object(get_post_type());
  386.  
  387.         $slug = $post_type->rewrite;
  388.  
  389.         echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
  390.  
  391.         if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  392.  
  393.       } else {
  394.  
  395.         $cat = get_the_category(); $cat = $cat[0];
  396.  
  397.         $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  398.  
  399.         if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
  400.  
  401.         echo $cats;
  402.  
  403.         if ($showCurrent == 1) echo $before . get_the_title() . $after;
  404.  
  405.       }
  406.  
  407.     } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
  408.  
  409.       $post_type = get_post_type_object(get_post_type());
  410.  
  411.       echo $before . $post_type->labels->singular_name . $after;
  412.  
  413.     } elseif ( is_attachment() ) {
  414.  
  415.       $parent = get_post($post->post_parent);
  416.  
  417.       $cat = get_the_category($parent->ID); $cat = $cat[0];
  418.  
  419.       echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  420.  
  421.       echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
  422.  
  423.       if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  424.  
  425.     } elseif ( is_page() && !$post->post_parent ) {
  426.  
  427.       if ($showCurrent == 1) echo $before . get_the_title() . $after;
  428.  
  429.     } elseif ( is_page() && $post->post_parent ) {
  430.  
  431.       $parent_id  = $post->post_parent;
  432.  
  433.       $breadcrumbs = array();
  434.  
  435.       while ($parent_id) {
  436.  
  437.         $page = get_page($parent_id);
  438.  
  439.         $breadcrumbs[] = '<a>ID) . '">' . get_the_title($page->ID) . '</a>';
  440.  
  441.        $parent_id  = $page->post_parent;
  442.  
  443.      }
  444.  
  445.      $breadcrumbs = array_reverse($breadcrumbs);
  446.  
  447.      for ($i = 0; $i < count($breadcrumbs); $i++) {
  448.  
  449.        echo $breadcrumbs[$i];
  450.  
  451.        if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
  452.  
  453.      }
  454.  
  455.      if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  456.  
  457.    } elseif ( is_tag() ) {
  458.  
  459.      echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
  460.  
  461.    } elseif ( is_author() ) {
  462.  
  463.       global $author;
  464.  
  465.      $userdata = get_userdata($author);
  466.  
  467.      echo $before . 'Articles posted by ' . $userdata->display_name . $after;
  468.  
  469.    } elseif ( is_404() ) {
  470.  
  471.      echo $before . 'Error 404' . $after;
  472.  
  473.    }
  474.  
  475.    if ( get_query_var('paged') ) {
  476.  
  477.      if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  478.  
  479.      echo __('Page') . ' ' . get_query_var('paged');
  480.  
  481.      if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  482.  
  483.    }
  484.  
  485.    echo '</div>';
  486.  
  487.  }
  488.  
  489. } // end dimox_breadcrumbs()
  490.  
  491. /////////////////////////////////////
  492.  
  493. // Add Custom Meta Box
  494.  
  495. /////////////////////////////////////
  496.  
  497. /* Fire our meta box setup function on the post editor screen. */
  498.  
  499. add_action( 'load-post.php', 'maxmag_post_meta_boxes_setup' );
  500.  
  501. add_action( 'load-post-new.php', 'maxmag_post_meta_boxes_setup' );
  502.  
  503. /* Meta box setup function. */
  504.  
  505. function maxmag_post_meta_boxes_setup() {
  506.  
  507.     /* Add meta boxes on the 'add_meta_boxes' hook. */
  508.  
  509.     add_action( 'add_meta_boxes', 'maxmag_add_post_meta_boxes' );
  510.  
  511.     /* Save post meta on the 'save_post' hook. */
  512.  
  513.     add_action( 'save_post', 'maxmag_save_featured_headline_meta', 10, 2 );
  514.  
  515. }
  516.  
  517. /* Create one or more meta boxes to be displayed on the post editor screen. */
  518.  
  519. function maxmag_add_post_meta_boxes() {
  520.  
  521.     add_meta_box(
  522.  
  523.         'maxmag-featured-headline',         // Unique ID
  524.  
  525.         esc_html__( 'Featured Headline', 'example' ),       // Title
  526.  
  527.         'maxmag_featured_headline_meta_box',        // Callback function
  528.  
  529.         'post',                 // Admin page (or post type)
  530.  
  531.         'normal',                   // Context
  532.  
  533.         'high'                  // Priority
  534.  
  535.     );
  536.  
  537. }
  538.  
  539. /* Display the post meta box. */
  540.  
  541. function maxmag_featured_headline_meta_box( $object, $box ) { ?>
  542.  
  543.     <?php wp_nonce_field( basename( __FILE__ ), 'maxmag_featured_headline_nonce' ); ?>
  544.  
  545.     <p>
  546.  
  547.         <label for="maxmag-featured-headline"><?php _e( "Add a custom featured headline that will be displayed in the featured slider.", 'example' ); ?></label>
  548.  
  549.         <input class="widefat" type="text" name="maxmag-featured-headline" id="maxmag-featured-headline" value="<?php echo esc_html__( get_post_meta( $object->ID, 'maxmag_featured_headline', true ) ); ?>" size="30" />
  550.  
  551.     </p>
  552.  
  553. <?php }
  554.  
  555. /* Save the meta box's post metadata. */
  556.  
  557. function maxmag_save_featured_headline_meta( $post_id, $post ) {
  558.  
  559.     /* Verify the nonce before proceeding. */
  560.  
  561.     if ( !isset( $_POST['maxmag_featured_headline_nonce'] ) || !wp_verify_nonce( $_POST['maxmag_featured_headline_nonce'], basename( __FILE__ ) ) )
  562.  
  563.         return $post_id;
  564.  
  565.     /* Get the post type object. */
  566.  
  567.     $post_type = get_post_type_object( $post->post_type );
  568.  
  569.     /* Check if the current user has permission to edit the post. */
  570.  
  571.     if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
  572.  
  573.         return $post_id;
  574.  
  575.     /* Get the posted data and sanitize it for use as an HTML class. */
  576.  
  577.     $new_meta_value = ( isset( $_POST['maxmag-featured-headline'] ) ? balanceTags( $_POST['maxmag-featured-headline'] ) : '' );
  578.  
  579.     /* Get the meta key. */
  580.  
  581.     $meta_key = 'maxmag_featured_headline';
  582.  
  583.     /* Get the meta value of the custom field key. */
  584.  
  585.     $meta_value = get_post_meta( $post_id, $meta_key, true );
  586.  
  587.     /* If a new meta value was added and there was no previous value, add it. */
  588.  
  589.     if ( $new_meta_value && '' == $meta_value )
  590.  
  591.         add_post_meta( $post_id, $meta_key, $new_meta_value, true );
  592.  
  593.     /* If the new meta value does not match the old value, update it. */
  594.  
  595.     elseif ( $new_meta_value && $new_meta_value != $meta_value )
  596.  
  597.         update_post_meta( $post_id, $meta_key, $new_meta_value );
  598.  
  599.     /* If there is no new meta value but an old value exists, delete it. */
  600.  
  601.     elseif ( '' == $new_meta_value && $meta_value )
  602.  
  603.         delete_post_meta( $post_id, $meta_key, $meta_value );
  604.  
  605. }
  606.  
  607. /////////////////////////////////////
  608.  
  609. // Add Content Limit
  610.  
  611. /////////////////////////////////////
  612.  
  613. function excerpt($limit) {
  614.  
  615.   $excerpt = explode(' ', get_the_excerpt(), $limit);
  616.  
  617.   if (count($excerpt)>=$limit) {
  618.  
  619.     array_pop($excerpt);
  620.  
  621.     $excerpt = implode(" ",$excerpt).'...';
  622.  
  623.   } else {
  624.  
  625.     $excerpt = implode(" ",$excerpt);
  626.  
  627.   }
  628.  
  629.   $excerpt = preg_replace('<code>\[[^\]]*\]</code>','',$excerpt);
  630.  
  631.   return $excerpt;
  632.  
  633. }
  634.  
  635. function content($limit) {
  636.  
  637.   $content = explode(' ', get_the_content(), $limit);
  638.  
  639.   if (count($content)>=$limit) {
  640.  
  641.     array_pop($content);
  642.  
  643.     $content = implode(" ",$content).'...';
  644.  
  645.   } else {
  646.  
  647.     $content = implode(" ",$content);
  648.  
  649.   }
  650.  
  651.   $content = preg_replace('/\[.+\]/','', $content);
  652.  
  653.   $content = apply_filters('the_content', $content);
  654.  
  655.   $content = str_replace(']]>', ']]>', $content);
  656.  
  657.   return $content;
  658.  
  659. }
  660.  
  661. /////////////////////////////////////
  662.  
  663. // Comments
  664.  
  665. /////////////////////////////////////
  666.  
  667. function resport_comment( $comment, $args, $depth ) {
  668.  
  669.     $GLOBALS['comment'] = $comment;
  670.  
  671.     switch ( $comment->comment_type ) :
  672.  
  673.         case '' :
  674.  
  675.     ?>
  676.  
  677.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  678.  
  679.         <div class="comment-wrapper" id="comment-<?php comment_ID(); ?>">
  680.  
  681.             <div class="comment-inner">
  682.  
  683.                 <div class="comment-avatar">
  684.  
  685.                     <?php echo get_avatar( $comment, 40 ); ?>
  686.  
  687.                 </div>
  688.  
  689.                 <div class="commentmeta">
  690.  
  691.                     <p class="comment-meta-1">
  692.  
  693.                         <?php printf( __( '%s '), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  694.  
  695.                     </p>
  696.  
  697.                     <p class="comment-meta-2">
  698.  
  699.                         <?php echo get_comment_date(); ?> <?php _e( 'at', 'advanced'); ?> <?php echo get_comment_time(); ?>
  700.  
  701.                         <?php edit_comment_link( __( 'Edit', 'advanced'), '(' , ')'); ?>
  702.  
  703.                     </p>
  704.  
  705.                 </div>
  706.  
  707.                 <div class="text">
  708.  
  709.                     <?php if ( $comment->comment_approved == '0' ) : ?>
  710.  
  711.                         <p class="waiting_approval"><?php _e( 'Your comment is awaiting moderation.', 'advanced' ); ?></p>
  712.  
  713.                     <?php endif; ?>
  714.  
  715.                     <div class="c">
  716.  
  717.                         <?php comment_text(); ?>
  718.  
  719.                     </div>
  720.  
  721.                 </div><!-- .text  -->
  722.  
  723.                 <div class="clear"></div>
  724.  
  725.                 <div class="comment-reply"><span class="reply"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></span></div>
  726.  
  727.             </div><!-- comment-inner  -->
  728.  
  729.         </div><!-- comment-wrapper  -->
  730.  
  731.     <?php
  732.  
  733.             break;
  734.  
  735.         case 'pingback'  :
  736.  
  737.         case 'trackback' :
  738.  
  739.     ?>
  740.  
  741.     <li class="post pingback">
  742.  
  743.         <p><?php _e( 'Pingback:', 'advanced' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'advanced' ), ' ' ); ?></p>
  744.  
  745.     <?php
  746.  
  747.             break;
  748.  
  749.     endswitch;
  750.  
  751. }
  752.  
  753. /////////////////////////////////////
  754.  
  755. // Popular Posts
  756.  
  757. /////////////////////////////////////
  758.  
  759. function popularPosts($num) {
  760.  
  761.     global $wpdb;
  762.  
  763.     $posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");
  764.  
  765.     foreach ($posts as $post) {
  766.  
  767.         setup_postdata($post);
  768.  
  769.         $id = $post->ID;
  770.  
  771.         $title = $post->post_title;
  772.  
  773.         $count = $post->comment_count;
  774.  
  775.         if ($count != 0) {
  776.  
  777.             $popular .= '
  778. <li>';
  779.  
  780.             $popular .= '<a href="' . get_permalink($id) . '" title="' . $title . '">' . $title . '</a> ';
  781.  
  782.             $popular .= '</li>
  783. ';
  784.  
  785.         }
  786.  
  787.     }
  788.  
  789.     return $popular;
  790.  
  791. }
  792.  
  793. /////////////////////////////////////
  794.  
  795. // Related Posts
  796.  
  797. /////////////////////////////////////
  798.  
  799. function getRelatedPosts( $count=4) {
  800.  
  801.     global $post;
  802.  
  803.     $orig_post = $post;
  804.  
  805.     $tags = wp_get_post_tags($post->ID);
  806.  
  807.     if ($tags) {
  808.  
  809.         $tag_ids = array();
  810.  
  811.         foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
  812.  
  813.         $args=array(
  814.  
  815.             'tag__in' => $tag_ids,
  816.  
  817.             'post__not_in' => array($post->ID),
  818.  
  819.             'posts_per_page'=> $count, // Number of related posts that will be shown.
  820.  
  821.             'ignore_sticky_posts'=>1
  822.  
  823.         );
  824.  
  825.         $my_query = new WP_Query( $args );
  826.  
  827.         if( $my_query->have_posts() ) { ?>
  828.  
  829.             <div id="related-posts">
  830.  
  831.                 <h3>Related Posts</h3>
  832.  
  833. <ul>
  834.                     <?php while( $my_query->have_posts() ) { $my_query->the_post(); ?>
  835.  
  836. <li>
  837.                         <div class="related-image">
  838.  
  839.                     <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
  840.  
  841.                     <a>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('medium-thumb'); ?></a>
  842.  
  843.                     <?php } ?>
  844.  
  845.                     <div class="related-text">
  846.  
  847.                         <a>"><?php the_title(); ?></a>
  848.  
  849.                     </div><!--related-text-->
  850.  
  851.                 </div><!--related-image-->
  852.  
  853.                 <div class="related-small">
  854.  
  855.                     <a>" class="main-headline"><?php the_title(); ?></a>
  856.  
  857.                 </div><!--related-small-->
  858.  
  859. </li>
  860.                     <?php }
  861.  
  862.             echo '</ul>
  863. </div>';
  864.  
  865.         }
  866.  
  867.     }
  868.  
  869.     $post = $orig_post;
  870.  
  871.     wp_reset_query();
  872.  
  873. }
  874.  
  875. /////////////////////////////////////
  876.  
  877. // Shortcodes
  878.  
  879. /////////////////////////////////////
  880.  
  881. //--SWS IN A THEME--------------------------------------------------------------------------------------------------------------------
  882.  
  883. if(!defined('WPCSS')):
  884.  
  885. $sws_settings = array(
  886.  
  887.     'show_ui'=>true, // show the shortcodes creation tool
  888.  
  889.     'options'=>array(
  890.  
  891.         'show_in_metabox'=>true,  //show the shortcode insert tool in a metabox instead of the s icon
  892.  
  893.         'option_show_in_metabox'=>false,//enable the option to choose between showing the insert tool in metabox or S icon
  894.  
  895.         'metabox_title'=> __('Styles with shortcodes','css')
  896.  
  897.     ),
  898.  
  899.     'options_parameters'=>array(
  900.  
  901.         'page_title'            =>'SWS Options', //the page title of the options menu
  902.  
  903.         'menu_text'             =>'SWS Options', //the options menu text on the admin menu
  904.  
  905.         'option_menu_parent'    =>'plugins.php'  //where does the Options menu should show?
  906.  
  907.     )
  908.  
  909. );
  910.  
  911. //--- If you place the plugin folder into a diferent location, adjust the following 2 lines:
  912.  
  913. define('WPCSS_PATH', dirname( __FILE__ ). "/shortcodes/" );
  914.  
  915. define("WPCSS_URL", get_bloginfo('stylesheet_directory') . '/shortcodes/' );
  916.  
  917. require WPCSS_PATH.'styles-with-shortcodes-theme.php';
  918.  
  919. global $sws_plugin;
  920.  
  921. $sws_plugin = new custom_shortcode_styling($sws_settings);
  922.  
  923. $sws_plugin->plugins_loaded();
  924.  
  925. //-- SWS Bundle Installation script:---------------------------------
  926.  
  927. function sws_install(){
  928.  
  929.     global $bundle;
  930.  
  931.     require_once WPCSS_PATH.'includes/bundle.php';
  932.  
  933.     require_once WPCSS_PATH.'includes/class.ImportExport.php';
  934.  
  935.     require_once WPCSS_PATH.'includes/class.CSShortcodes.php';
  936.  
  937.     CSShortcodes::init_taxonomy();
  938.  
  939.     CSShortcodes::init_post_type(true);
  940.  
  941.     $o = new ImportExport();
  942.  
  943.     $o->import_bundle($bundle,$error);
  944.  
  945.     //--custom capabilities
  946.  
  947.     global $wp_roles;
  948.  
  949.     $wp_roles->add_cap('administrator','manage_sws' );
  950.  
  951.     //--
  952.  
  953.     return true;
  954.  
  955. }
  956.  
  957. if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
  958.  
  959. //workaround until finding a hook for activation of themes.
  960.  
  961.     sws_install();
  962.  
  963. }
  964.  
  965. //--------------------------------------------------------
  966.  
  967. endif;
  968.  
  969. //--------------------------------------------------------------------------------------------------------------------
  970.  
  971. /////////////////////////////////////
  972.  
  973. // Miscellaneous
  974.  
  975. /////////////////////////////////////
  976.  
  977. // Set Content Width
  978.  
  979. if ( ! isset( $content_width ) ) $content_width = 620;
  980.  
  981. // Add RSS links to <head> section
  982.  
  983. add_theme_support( 'automatic-feed-links' );
  984.  
  985. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement