Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /////////////////////////////////////
- // Enqueue Javascript Files
- /////////////////////////////////////
- function my_scripts_method() {
- wp_enqueue_script( 'jquery' );
- wp_enqueue_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array('jquery'));
- wp_enqueue_script('elastislide', get_template_directory_uri() . '/js/jquery.elastislide.js', array('jquery'));
- wp_enqueue_script('maxmag', get_template_directory_uri() . '/js/scripts.js', array('jquery'));
- wp_enqueue_script('ticker', get_template_directory_uri() . '/js/ticker.js', array('jquery'));
- wp_enqueue_script('respond', get_template_directory_uri() . '/js/respond.min.js', array('jquery'));
- }
- add_action('wp_enqueue_scripts', 'my_scripts_method');
- /////////////////////////////////////
- // Theme Options
- /////////////////////////////////////
- require_once(TEMPLATEPATH . '/admin/admin-functions.php');
- require_once(TEMPLATEPATH . '/admin/admin-interface.php');
- require_once(TEMPLATEPATH . '/admin/theme-settings.php');
- function my_wp_head() {
- $bloginfo = get_template_directory_uri();
- $link = get_option('mm_link_color');
- $primarymenu = get_option('mm_primary_menu');
- $primarytheme = get_option('mm_primary_theme');
- $wallad = get_option('mm_wall_ad');
- echo "
- <style type='text/css'>
- a, a:visited, #twtr-widget-1 .twtr-tweet a { color: $link; }
- h3.category-heading { background: $primarytheme; }
- .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; }
- #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; }
- #main-nav ul li:hover ul { border-top: 5px solid $primarytheme; }
- #main-nav-wrapper { background: $primarymenu url($bloginfo/images/nav-bg.png) top repeat-x; border-bottom: 5px solid $primarytheme; }
- ul.tabs li { background: $primarytheme; }
- #wallpaper { background: url($wallad) no-repeat 50% 0; }
- </style>";
- }
- add_action( 'wp_head', 'my_wp_head' );
- /////////////////////////////////////
- // Footer JS Code
- /////////////////////////////////////
- function my_wp_footer() {
- echo "
- <script type='text/javascript'>
- jQuery(document).ready(function($){
- $(window).load(function(){
- $('.flexslider').flexslider({
- animation: 'slide',
- slideshowSpeed: 8000,
- });
- });
- var aboveHeight = $('#leader-wrapper').outerHeight();
- $(window).scroll(function(){
- if ($(window).scrollTop() > aboveHeight){
- $('#nav').addClass('fixed-nav').css('top','0').next()
- .css('padding-top','43px');
- } else {
- $('#nav').removeClass('fixed-nav').next()
- .css('padding-top','0');
- }
- });
- });
- </script>";
- }
- add_action( 'wp_footer', 'my_wp_footer' );
- /////////////////////////////////////
- // Register Widgets
- /////////////////////////////////////
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Homepage Widget Area',
- 'before_widget' => '<div class="home-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- }
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Middle Widget Area',
- 'before_widget' => '<div class="middle-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- }
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Sidebar Home Widget Area',
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- }
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Sidebar Widget Area',
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- }
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Homepage Bottom Widget Area',
- 'before_widget' => '<div class="sidebar-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- }
- if ( function_exists('register_sidebar') ) {
- register_sidebar(array(
- 'name' => 'Footer Widget Area',
- 'before_widget' => '<div class="footer-widget">',
- 'after_widget' => '</div>',
- 'before_title' => '<h3>',
- 'after_title' => '</h3>',
- ));
- }
- include("widgets/widget-2column.php");
- include("widgets/widget-ad160.php");
- include("widgets/widget-ad300.php");
- include("widgets/widget-blog.php");
- include("widgets/widget-carousel.php");
- include("widgets/widget-cat4.php");
- include("widgets/widget-catfeat.php");
- include("widgets/widget-catlist.php");
- include("widgets/widget-facebook.php");
- include("widgets/widget-multicat.php");
- include("widgets/widget-recent.php");
- include("widgets/widget-sidecat.php");
- include("widgets/widget-tabs.php");
- include("widgets/widget-tags.php");
- include("widgets/widget-twitter.php");
- /////////////////////////////////////
- // Register Custom Menus
- /////////////////////////////////////
- function register_menus() {
- register_nav_menus(
- array(
- 'main-menu' => __( 'Primary Menu' ),
- 'secondary-menu' => __( 'Secondary Menu' ),)
- );
- }
- add_action( 'init', 'register_menus' );
- /////////////////////////////////////
- // Register Thumbnails
- /////////////////////////////////////
- if ( function_exists( 'add_theme_support' ) ) {
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 420, 470, true );
- add_image_size( 'slider-thumb', 420, 470, true );
- add_image_size( 'post-thumb', 300, 336, true );
- add_image_size( 'medium-thumb', 200, 224, true );
- add_image_size( 'small-thumb', 120, 134, true );
- }
- /////////////////////////////////////
- // Add Bread Crumbs
- /////////////////////////////////////
- function dimox_breadcrumbs() {
- $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
- $delimiter = ' > '; // delimiter between crumbs
- $home = 'Home'; // text for the 'Home' link
- $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
- $before = '<span class="current">'; // tag before the current crumb
- $after = '</span>'; // tag after the current crumb
- global $post;
- $homeLink = home_url();
- if (is_home() || is_front_page()) {
- if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';
- } else {
- echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
- if ( is_category() ) {
- $thisCat = get_category(get_query_var('cat'), false);
- if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
- echo $before . single_cat_title('', false) . $after;
- } elseif ( is_search() ) {
- echo $before . 'Search results for "' . get_search_query() . '"' . $after;
- } elseif ( is_day() ) {
- echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
- echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
- echo $before . get_the_time('d') . $after;
- } elseif ( is_month() ) {
- echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
- echo $before . get_the_time('F') . $after;
- } elseif ( is_year() ) {
- echo $before . get_the_time('Y') . $after;
- } elseif ( is_single() && !is_attachment() ) {
- if ( get_post_type() != 'post' ) {
- $post_type = get_post_type_object(get_post_type());
- $slug = $post_type->rewrite;
- echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
- if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
- } else {
- $cat = get_the_category(); $cat = $cat[0];
- $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
- if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
- echo $cats;
- if ($showCurrent == 1) echo $before . get_the_title() . $after;
- }
- } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
- $post_type = get_post_type_object(get_post_type());
- echo $before . $post_type->labels->singular_name . $after;
- } elseif ( is_attachment() ) {
- $parent = get_post($post->post_parent);
- $cat = get_the_category($parent->ID); $cat = $cat[0];
- echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
- echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
- if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
- } elseif ( is_page() && !$post->post_parent ) {
- if ($showCurrent == 1) echo $before . get_the_title() . $after;
- } elseif ( is_page() && $post->post_parent ) {
- $parent_id = $post->post_parent;
- $breadcrumbs = array();
- while ($parent_id) {
- $page = get_page($parent_id);
- $breadcrumbs[] = '<a>ID) . '">' . get_the_title($page->ID) . '</a>';
- $parent_id = $page->post_parent;
- }
- $breadcrumbs = array_reverse($breadcrumbs);
- for ($i = 0; $i < count($breadcrumbs); $i++) {
- echo $breadcrumbs[$i];
- if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
- }
- if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
- } elseif ( is_tag() ) {
- echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
- } elseif ( is_author() ) {
- global $author;
- $userdata = get_userdata($author);
- echo $before . 'Articles posted by ' . $userdata->display_name . $after;
- } elseif ( is_404() ) {
- echo $before . 'Error 404' . $after;
- }
- if ( get_query_var('paged') ) {
- if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
- echo __('Page') . ' ' . get_query_var('paged');
- if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
- }
- echo '</div>';
- }
- } // end dimox_breadcrumbs()
- /////////////////////////////////////
- // Add Custom Meta Box
- /////////////////////////////////////
- /* Fire our meta box setup function on the post editor screen. */
- add_action( 'load-post.php', 'maxmag_post_meta_boxes_setup' );
- add_action( 'load-post-new.php', 'maxmag_post_meta_boxes_setup' );
- /* Meta box setup function. */
- function maxmag_post_meta_boxes_setup() {
- /* Add meta boxes on the 'add_meta_boxes' hook. */
- add_action( 'add_meta_boxes', 'maxmag_add_post_meta_boxes' );
- /* Save post meta on the 'save_post' hook. */
- add_action( 'save_post', 'maxmag_save_featured_headline_meta', 10, 2 );
- }
- /* Create one or more meta boxes to be displayed on the post editor screen. */
- function maxmag_add_post_meta_boxes() {
- add_meta_box(
- 'maxmag-featured-headline', // Unique ID
- esc_html__( 'Featured Headline', 'example' ), // Title
- 'maxmag_featured_headline_meta_box', // Callback function
- 'post', // Admin page (or post type)
- 'normal', // Context
- 'high' // Priority
- );
- }
- /* Display the post meta box. */
- function maxmag_featured_headline_meta_box( $object, $box ) { ?>
- <?php wp_nonce_field( basename( __FILE__ ), 'maxmag_featured_headline_nonce' ); ?>
- <p>
- <label for="maxmag-featured-headline"><?php _e( "Add a custom featured headline that will be displayed in the featured slider.", 'example' ); ?></label>
- <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" />
- </p>
- <?php }
- /* Save the meta box's post metadata. */
- function maxmag_save_featured_headline_meta( $post_id, $post ) {
- /* Verify the nonce before proceeding. */
- if ( !isset( $_POST['maxmag_featured_headline_nonce'] ) || !wp_verify_nonce( $_POST['maxmag_featured_headline_nonce'], basename( __FILE__ ) ) )
- return $post_id;
- /* Get the post type object. */
- $post_type = get_post_type_object( $post->post_type );
- /* Check if the current user has permission to edit the post. */
- if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
- return $post_id;
- /* Get the posted data and sanitize it for use as an HTML class. */
- $new_meta_value = ( isset( $_POST['maxmag-featured-headline'] ) ? balanceTags( $_POST['maxmag-featured-headline'] ) : '' );
- /* Get the meta key. */
- $meta_key = 'maxmag_featured_headline';
- /* Get the meta value of the custom field key. */
- $meta_value = get_post_meta( $post_id, $meta_key, true );
- /* If a new meta value was added and there was no previous value, add it. */
- if ( $new_meta_value && '' == $meta_value )
- add_post_meta( $post_id, $meta_key, $new_meta_value, true );
- /* If the new meta value does not match the old value, update it. */
- elseif ( $new_meta_value && $new_meta_value != $meta_value )
- update_post_meta( $post_id, $meta_key, $new_meta_value );
- /* If there is no new meta value but an old value exists, delete it. */
- elseif ( '' == $new_meta_value && $meta_value )
- delete_post_meta( $post_id, $meta_key, $meta_value );
- }
- /////////////////////////////////////
- // Add Content Limit
- /////////////////////////////////////
- function excerpt($limit) {
- $excerpt = explode(' ', get_the_excerpt(), $limit);
- if (count($excerpt)>=$limit) {
- array_pop($excerpt);
- $excerpt = implode(" ",$excerpt).'...';
- } else {
- $excerpt = implode(" ",$excerpt);
- }
- $excerpt = preg_replace('<code>\[[^\]]*\]</code>','',$excerpt);
- return $excerpt;
- }
- function content($limit) {
- $content = explode(' ', get_the_content(), $limit);
- if (count($content)>=$limit) {
- array_pop($content);
- $content = implode(" ",$content).'...';
- } else {
- $content = implode(" ",$content);
- }
- $content = preg_replace('/\[.+\]/','', $content);
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- return $content;
- }
- /////////////////////////////////////
- // Comments
- /////////////////////////////////////
- function resport_comment( $comment, $args, $depth ) {
- $GLOBALS['comment'] = $comment;
- switch ( $comment->comment_type ) :
- case '' :
- ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
- <div class="comment-wrapper" id="comment-<?php comment_ID(); ?>">
- <div class="comment-inner">
- <div class="comment-avatar">
- <?php echo get_avatar( $comment, 40 ); ?>
- </div>
- <div class="commentmeta">
- <p class="comment-meta-1">
- <?php printf( __( '%s '), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
- </p>
- <p class="comment-meta-2">
- <?php echo get_comment_date(); ?> <?php _e( 'at', 'advanced'); ?> <?php echo get_comment_time(); ?>
- <?php edit_comment_link( __( 'Edit', 'advanced'), '(' , ')'); ?>
- </p>
- </div>
- <div class="text">
- <?php if ( $comment->comment_approved == '0' ) : ?>
- <p class="waiting_approval"><?php _e( 'Your comment is awaiting moderation.', 'advanced' ); ?></p>
- <?php endif; ?>
- <div class="c">
- <?php comment_text(); ?>
- </div>
- </div><!-- .text -->
- <div class="clear"></div>
- <div class="comment-reply"><span class="reply"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></span></div>
- </div><!-- comment-inner -->
- </div><!-- comment-wrapper -->
- <?php
- break;
- case 'pingback' :
- case 'trackback' :
- ?>
- <li class="post pingback">
- <p><?php _e( 'Pingback:', 'advanced' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( 'Edit', 'advanced' ), ' ' ); ?></p>
- <?php
- break;
- endswitch;
- }
- /////////////////////////////////////
- // Popular Posts
- /////////////////////////////////////
- function popularPosts($num) {
- global $wpdb;
- $posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");
- foreach ($posts as $post) {
- setup_postdata($post);
- $id = $post->ID;
- $title = $post->post_title;
- $count = $post->comment_count;
- if ($count != 0) {
- $popular .= '
- <li>';
- $popular .= '<a href="' . get_permalink($id) . '" title="' . $title . '">' . $title . '</a> ';
- $popular .= '</li>
- ';
- }
- }
- return $popular;
- }
- /////////////////////////////////////
- // Related Posts
- /////////////////////////////////////
- function getRelatedPosts( $count=4) {
- global $post;
- $orig_post = $post;
- $tags = wp_get_post_tags($post->ID);
- if ($tags) {
- $tag_ids = array();
- foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
- $args=array(
- 'tag__in' => $tag_ids,
- 'post__not_in' => array($post->ID),
- 'posts_per_page'=> $count, // Number of related posts that will be shown.
- 'ignore_sticky_posts'=>1
- );
- $my_query = new WP_Query( $args );
- if( $my_query->have_posts() ) { ?>
- <div id="related-posts">
- <h3>Related Posts</h3>
- <ul>
- <?php while( $my_query->have_posts() ) { $my_query->the_post(); ?>
- <li>
- <div class="related-image">
- <?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?>
- <a>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('medium-thumb'); ?></a>
- <?php } ?>
- <div class="related-text">
- <a>"><?php the_title(); ?></a>
- </div><!--related-text-->
- </div><!--related-image-->
- <div class="related-small">
- <a>" class="main-headline"><?php the_title(); ?></a>
- </div><!--related-small-->
- </li>
- <?php }
- echo '</ul>
- </div>';
- }
- }
- $post = $orig_post;
- wp_reset_query();
- }
- /////////////////////////////////////
- // Shortcodes
- /////////////////////////////////////
- //--SWS IN A THEME--------------------------------------------------------------------------------------------------------------------
- if(!defined('WPCSS')):
- $sws_settings = array(
- 'show_ui'=>true, // show the shortcodes creation tool
- 'options'=>array(
- 'show_in_metabox'=>true, //show the shortcode insert tool in a metabox instead of the s icon
- 'option_show_in_metabox'=>false,//enable the option to choose between showing the insert tool in metabox or S icon
- 'metabox_title'=> __('Styles with shortcodes','css')
- ),
- 'options_parameters'=>array(
- 'page_title' =>'SWS Options', //the page title of the options menu
- 'menu_text' =>'SWS Options', //the options menu text on the admin menu
- 'option_menu_parent' =>'plugins.php' //where does the Options menu should show?
- )
- );
- //--- If you place the plugin folder into a diferent location, adjust the following 2 lines:
- define('WPCSS_PATH', dirname( __FILE__ ). "/shortcodes/" );
- define("WPCSS_URL", get_bloginfo('stylesheet_directory') . '/shortcodes/' );
- require WPCSS_PATH.'styles-with-shortcodes-theme.php';
- global $sws_plugin;
- $sws_plugin = new custom_shortcode_styling($sws_settings);
- $sws_plugin->plugins_loaded();
- //-- SWS Bundle Installation script:---------------------------------
- function sws_install(){
- global $bundle;
- require_once WPCSS_PATH.'includes/bundle.php';
- require_once WPCSS_PATH.'includes/class.ImportExport.php';
- require_once WPCSS_PATH.'includes/class.CSShortcodes.php';
- CSShortcodes::init_taxonomy();
- CSShortcodes::init_post_type(true);
- $o = new ImportExport();
- $o->import_bundle($bundle,$error);
- //--custom capabilities
- global $wp_roles;
- $wp_roles->add_cap('administrator','manage_sws' );
- //--
- return true;
- }
- if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
- //workaround until finding a hook for activation of themes.
- sws_install();
- }
- //--------------------------------------------------------
- endif;
- //--------------------------------------------------------------------------------------------------------------------
- /////////////////////////////////////
- // Miscellaneous
- /////////////////////////////////////
- // Set Content Width
- if ( ! isset( $content_width ) ) $content_width = 620;
- // Add RSS links to <head> section
- add_theme_support( 'automatic-feed-links' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement