Advertisement
Guest User

Wp3.9.2ThemeMinezille-Functions.php

a guest
Sep 4th, 2014
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.77 KB | None | 0 0
  1. <?php
  2. /**
  3.  * MineZine functions and definitions.
  4.  * @package MineZine
  5.  * @since MineZine 1.0.0
  6. */
  7.  
  8. /**
  9.  * MineZine theme variables.
  10.  *  
  11. */    
  12. $minezine_themename = "MineZine";           //Theme Name
  13. $minezine_themever = "1.1.3";                                   //Theme version
  14. $minezine_shortname = "minezine";                           //Shortname
  15. $minezine_manualurl = get_template_directory_uri() . '/docs/documentation.html';    //Manual Url
  16. // Set path to MineZine Framework and theme specific functions
  17. $minezine_be_path = get_template_directory() . '/functions/be/';                                    //BackEnd Path
  18. $minezine_fe_path = get_template_directory() . '/functions/fe/';                                    //FrontEnd Path
  19. $minezine_be_pathimages = get_template_directory_uri() . '/functions/be/images';        //BackEnd Path
  20. $minezine_fe_pathimages = get_template_directory_uri() . '';    //FrontEnd Path
  21. //Include Framework [BE]
  22. require_once ($minezine_be_path . 'fw-options.php');         // Framework Init  
  23. // Include Theme specific functionality [FE]
  24. require_once ($minezine_fe_path . 'headerdata.php');         // Include css and js
  25. require_once ($minezine_fe_path . 'library.php');          // Include library, functions
  26. require_once ($minezine_fe_path . 'widget-posts-list.php');// Posts-List Widget
  27.  
  28. /**
  29.  * MineZine theme basic setup.
  30.  *  
  31. */
  32. function minezine_setup() {
  33.     // Makes MineZine available for translation.
  34.     load_theme_textdomain( 'minezine', get_template_directory() . '/languages' );
  35.   // This theme styles the visual editor to resemble the theme style.
  36.   add_editor_style( 'editor-style.css' );
  37.     // Adds RSS feed links to <head> for posts and comments.  
  38.     add_theme_support( 'automatic-feed-links' );
  39.     // This theme supports custom background color and image.
  40.     $defaults = array(
  41.     'default-color' => '',
  42.   'default-image' => '',
  43.     'wp-head-callback' => '_custom_background_cb',
  44.     'admin-head-callback' => '',
  45.     'admin-preview-callback' => '' );  
  46.   add_theme_support( 'custom-background', $defaults );
  47.     // This theme uses a custom image size for featured images, displayed on "standard" posts.
  48.     add_theme_support( 'post-thumbnails' );
  49.     set_post_thumbnail_size( 956, 9999 );
  50.   // This theme uses a custom header background image.
  51.   $args = array(
  52.     'width' => 1012,
  53.   'flex-width' => true,
  54.   'flex-height' => true,
  55.   'header-text' => false,
  56.   'random-default' => true,);
  57.   add_theme_support( 'custom-header', $args );
  58.   add_theme_support( 'woocommerce' );
  59.   global $content_width;
  60.   if ( ! isset( $content_width ) ) { $content_width = 628; }
  61. }
  62. add_action( 'after_setup_theme', 'minezine_setup' );
  63.  
  64. /**
  65.  * Enqueues scripts and styles for front-end.
  66.  *
  67. */
  68. function minezine_scripts_styles() {
  69.     global $wp_styles;
  70.     // Adds JavaScript
  71.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  72.         wp_enqueue_script( 'comment-reply' );
  73.     wp_enqueue_script( 'minezine-placeholders', get_template_directory_uri() . '/js/placeholders.js', array(), '2.1.0', true );
  74.     wp_enqueue_script( 'minezine-scroll-to-top', get_template_directory_uri() . '/js/scroll-to-top.js', array( 'jquery' ), '1.0', true );
  75.     wp_enqueue_script( 'minezine-menubox', get_template_directory_uri() . '/js/menubox.js', array(), '1.0', true );
  76.     wp_enqueue_script( 'minezine-selectnav', get_template_directory_uri() . '/js/selectnav.js', array(), '0.1', true );
  77.     wp_enqueue_script( 'minezine-responsive', get_template_directory_uri() . '/js/responsive.js', array(), '1.0', true );
  78.     // Loads the main stylesheet.
  79.       wp_enqueue_style( 'minezine-style', get_stylesheet_uri() );
  80.     wp_enqueue_style( 'minezine-google-font-default', '//fonts.googleapis.com/css?family=Oswald&amp;subset=latin,latin-ext' );
  81.     if ( class_exists( 'woocommerce' ) ) { wp_enqueue_style( 'minezine-woocommerce-custom', get_template_directory_uri() . '/css/woocommerce-custom.css' ); }
  82. }
  83. add_action( 'wp_enqueue_scripts', 'minezine_scripts_styles' );
  84.  
  85. /**
  86.  * Creates a nicely formatted and more specific title element text.
  87.  *  
  88. */
  89. function minezine_wp_title( $title, $sep ) {
  90.     if ( is_feed() )
  91.         return $title;
  92.     $title .= get_bloginfo( 'name' );
  93.     $site_description = get_bloginfo( 'description', 'display' );
  94.     if ( $site_description && ( is_home() || is_front_page() ) )
  95.         $title = "$title $sep $site_description";
  96.     return $title;
  97. }
  98. add_filter( 'wp_title', 'minezine_wp_title', 10, 2 );
  99.  
  100. /**
  101.  * Register our menus.
  102.  *
  103.  */
  104. function minezine_register_my_menus() {
  105.   register_nav_menus(
  106.     array(
  107.       'main-navigation' => __( 'Main Header Menu', 'minezine' ),
  108.       'top-navigation' => __( 'Top Header Menu', 'minezine' )
  109.     )
  110.   );
  111. }
  112. add_action( 'after_setup_theme', 'minezine_register_my_menus' );
  113.  
  114. /**
  115.  * Register our sidebars and widgetized areas.
  116.  *
  117. */
  118. function minezine_widgets_init() {
  119.   register_sidebar( array(
  120.         'name' => __( 'Right Sidebar', 'minezine' ),
  121.         'id' => 'sidebar-1',
  122.         'description' => __( 'Right sidebar which appears on all posts and pages.', 'minezine' ),
  123.         'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s">',
  124.         'after_widget' => '</div>',
  125.         'before_title' => ' <p class="sidebar-headline"><span class="sidebar-headline-text">',
  126.         'after_title' => '</span></p>',
  127.     ) );
  128.   register_sidebar( array(
  129.         'name' => __( 'Footer left widget area', 'minezine' ),
  130.         'id' => 'sidebar-2',
  131.         'description' => __( 'Left column with widgets in footer.', 'minezine' ),
  132.         'before_widget' => '<div id="%1$s" class="footer-widget %2$s">',
  133.         'after_widget' => '</div>',
  134.         'before_title' => '<p class="footer-headline"><span class="footer-headline-text">',
  135.         'after_title' => '</span></p>',
  136.     ) );
  137.   register_sidebar( array(
  138.         'name' => __( 'Footer middle widget area', 'minezine' ),
  139.         'id' => 'sidebar-3',
  140.         'description' => __( 'Middle column with widgets in footer.', 'minezine' ),
  141.         'before_widget' => '<div id="%1$s" class="footer-widget %2$s">',
  142.         'after_widget' => '</div>',
  143.         'before_title' => '<p class="footer-headline"><span class="footer-headline-text">',
  144.         'after_title' => '</span></p>',
  145.     ) );
  146.   register_sidebar( array(
  147.         'name' => __( 'Footer right widget area', 'minezine' ),
  148.         'id' => 'sidebar-4',
  149.         'description' => __( 'Right column with widgets in footer.', 'minezine' ),
  150.         'before_widget' => '<div id="%1$s" class="footer-widget %2$s">',
  151.         'after_widget' => '</div>',
  152.         'before_title' => '<p class="footer-headline"><span class="footer-headline-text">',
  153.         'after_title' => '</span></p>',
  154.     ) );
  155.   register_sidebar( array(
  156.         'name' => __( 'Footer notices', 'minezine' ),
  157.         'id' => 'sidebar-5',
  158.         'description' => __( 'The line for copyright and other notices below the footer widget areas. Insert here one Text widget. The "Title" field at this widget should stay empty.', 'minezine' ),
  159.         'before_widget' => '<div class="footer-signature"><div class="footer-signature-content">',
  160.         'after_widget' => '</div></div>',
  161.         'before_title' => '',
  162.         'after_title' => '',
  163.     ) );
  164.   register_sidebar( array(
  165.         'name' => __( 'Latest Posts Homepage widget area', 'minezine' ),
  166.         'id' => 'sidebar-6',
  167.         'description' => __( 'The area for any MineZine Posts Widgets, which displays latest posts from a specific category below the default Latest Posts area.', 'minezine' ),
  168.         'before_widget' => '',
  169.         'after_widget' => '',
  170.         'before_title' => '',
  171.         'after_title' => '',
  172.     ) );
  173. }
  174. add_action( 'widgets_init', 'minezine_widgets_init' );
  175.  
  176. /**
  177.  * Post excerpt settings.
  178.  *
  179. */
  180. function minezine_custom_excerpt_length( $length ) {
  181. return 40;
  182. }
  183. add_filter( 'excerpt_length', 'minezine_custom_excerpt_length', 999 );
  184. function minezine_new_excerpt_more( $more ) {
  185. global $post;
  186. return '...<br /><a class="read-more-button" href="'. esc_url( get_permalink($post->ID) ) . '">' . __( 'Read more', 'minezine' ) . '</a>';}
  187. add_filter( 'excerpt_more', 'minezine_new_excerpt_more' );
  188.  
  189. if ( ! function_exists( 'minezine_content_nav' ) ) :
  190. /**
  191.  * Displays navigation to next/previous pages when applicable.
  192.  *
  193. */
  194. function minezine_content_nav( $html_id ) {
  195.     global $wp_query;
  196.     $html_id = esc_attr( $html_id );
  197.     if ( $wp_query->max_num_pages > 1 ) : ?>
  198.         <div id="<?php echo $html_id; ?>" class="navigation" role="navigation">
  199.     <div class="navigation-inner">
  200.             <h2 class="navigation-headline section-heading"><?php _e( 'Post navigation', 'minezine' ); ?></h2>
  201.       <div class="nav-wrapper">
  202.              <p class="navigation-links">
  203. <?php $big = 999999999;
  204. echo paginate_links( array(
  205.     'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  206.     'format' => '?paged=%#%',
  207.     'current' => max( 1, get_query_var('paged') ),
  208.   'prev_text' => __( '&larr; Previous', 'minezine' ),
  209.     'next_text' => __( 'Next &rarr;', 'minezine' ),
  210.     'total' => $wp_query->max_num_pages
  211. ) );
  212. ?>
  213.         </p>
  214.       </div>
  215.         </div>
  216.     </div>
  217.     <?php endif;
  218. }
  219. endif;
  220.  
  221. /**
  222.  * Displays navigation to next/previous posts on single posts pages.
  223.  *
  224. */
  225. function minezine_prev_next($nav_id) { ?>
  226. <?php $minezine_previous_post = get_adjacent_post( false, "", true );
  227. $minezine_next_post = get_adjacent_post( false, "", false ); ?>
  228. <div id="<?php echo $nav_id; ?>" class="navigation" role="navigation">
  229.     <div class="nav-wrapper">
  230. <?php if ( !empty($minezine_previous_post) ) { ?>
  231.   <p class="nav-previous"><a href="<?php echo esc_url(get_permalink($minezine_previous_post->ID)); ?>" title="<?php echo esc_attr($minezine_previous_post->post_title); ?>"><?php _e( '&larr; Previous post', 'minezine' ); ?></a></p>
  232. <?php } if ( !empty($minezine_next_post) ) { ?>
  233.     <p class="nav-next"><a href="<?php echo esc_url(get_permalink($minezine_next_post->ID)); ?>" title="<?php echo esc_attr($minezine_next_post->post_title); ?>"><?php _e( 'Next post &rarr;', 'minezine' ); ?></a></p>
  234. <?php } ?>
  235.    </div>
  236. </div>
  237. <?php }
  238.  
  239. if ( ! function_exists( 'minezine_comment' ) ) :
  240. /**
  241.  * Template for comments and pingbacks.
  242.  *
  243. */
  244. function minezine_comment( $comment, $args, $depth ) {
  245.     $GLOBALS['comment'] = $comment;
  246.     switch ( $comment->comment_type ) :
  247.         case 'pingback' :
  248.         case 'trackback' :
  249.     ?>
  250.     <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
  251.         <p><?php _e( 'Pingback:', 'minezine' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'minezine' ), '<span class="edit-link">', '</span>' ); ?></p>
  252.     <?php
  253.             break;
  254.         default :
  255.         global $post;
  256.     ?>
  257.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  258.         <div id="comment-<?php comment_ID(); ?>" class="comment">
  259.             <div class="comment-meta comment-author vcard">
  260.                 <?php
  261.                     echo get_avatar( $comment, 44 );
  262.                     printf( '<span><b class="fn">%1$s</b> %2$s</span>',
  263.                         get_comment_author_link(),
  264.                         ( $comment->user_id === $post->post_author ) ? '<span>' . __( '(Post author)', 'minezine' ) . '</span>' : ''
  265.                     );
  266.                     printf( '<time datetime="%2$s">%3$s</time>',
  267.                         esc_url( get_comment_link( $comment->comment_ID ) ),
  268.                         get_comment_time( 'c' ),
  269.                         // translators: 1: date, 2: time
  270.                         sprintf( __( '%1$s at %2$s', 'minezine' ), get_comment_date(''), get_comment_time() )
  271.                     );
  272.                 ?>
  273.             </div><!-- .comment-meta -->
  274.  
  275.             <?php if ( '0' == $comment->comment_approved ) : ?>
  276.                 <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'minezine' ); ?></p>
  277.             <?php endif; ?>
  278.  
  279.             <div class="comment-content comment">
  280.                 <?php comment_text(); ?>
  281.              <div class="reply">
  282.                <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'minezine' ), 'after' => ' <span>&darr;</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  283.             </div><!-- .reply -->
  284.                <?php edit_comment_link( __( 'Edit', 'minezine' ), '<p class="edit-link">', '</p>' ); ?>
  285.             </div><!-- .comment-content -->
  286.         </div><!-- #comment-## -->
  287.     <?php
  288.         break;
  289.     endswitch;
  290. }
  291. endif;
  292.  
  293. /**
  294.  * Function for adding custom classes to the menu objects.
  295.  *
  296. */
  297. add_filter( 'wp_nav_menu_objects', 'minezine_filter_menu_class', 10, 2 );
  298. function minezine_filter_menu_class( $objects, $args ) {
  299.  
  300.     $ids        = array();
  301.     $parent_ids = array();
  302.     $top_ids    = array();
  303.     foreach ( $objects as $i => $object ) {
  304.  
  305.         if ( 0 == $object->menu_item_parent ) {
  306.             $top_ids[$i] = $object;
  307.             continue;
  308.         }
  309.  
  310.         if ( ! in_array( $object->menu_item_parent, $ids ) ) {
  311.             $objects[$i]->classes[] = 'first-menu-item';
  312.             $ids[]          = $object->menu_item_parent;
  313.         }
  314.  
  315.         if ( in_array( 'first-menu-item', $object->classes ) )
  316.             continue;
  317.  
  318.         $parent_ids[$i] = $object->menu_item_parent;
  319.     }
  320.  
  321.     $sanitized_parent_ids = array_unique( array_reverse( $parent_ids, true ) );
  322.  
  323.     foreach ( $sanitized_parent_ids as $i => $id )
  324.         $objects[$i]->classes[] = 'last-menu-item';
  325.  
  326.     return $objects;
  327. }
  328.  
  329. /**
  330.  * Include the TGM_Plugin_Activation class.
  331.  *  
  332. */
  333. require_once get_template_directory() . '/class-tgm-plugin-activation.php';
  334. add_action( 'tgmpa_register', 'minezine_my_theme_register_required_plugins' );
  335.  
  336. function minezine_my_theme_register_required_plugins() {
  337.  
  338. $plugins = array(
  339.         array(
  340.             'name'     => 'Breadcrumb NavXT',
  341.             'slug'     => 'breadcrumb-navxt',
  342.             'required' => false,
  343.         ),
  344. );
  345.  
  346.  
  347. $config = array(
  348.         'domain'       => 'minezine',
  349.     'menu'         => 'install-my-theme-plugins',
  350.         'strings'        => array(
  351.         'page_title'             => __( 'Install Recommended Plugins', 'minezine' ),
  352.         'menu_title'             => __( 'Install Plugins', 'minezine' ),
  353.         'instructions_install'   => __( 'The %1$s plugin is required for this theme. Click on the big blue button below to install and activate %1$s.', 'minezine' ),
  354.         'instructions_activate'  => __( 'The %1$s is installed but currently inactive. Please go to the <a href="%2$s">plugin administration page</a> page to activate it.', 'minezine' ),
  355.         'button'                 => __( 'Install %s Now', 'minezine' ),
  356.         'installing'             => __( 'Installing Plugin: %s', 'minezine' ),
  357.         'oops'                   => __( 'Something went wrong with the plugin API.', 'minezine' ), // */
  358.         'notice_can_install'     => __( 'This theme requires the %1$s plugin. <a href="%2$s"><strong>Click here to begin the installation process</strong></a>. You may be asked for FTP credentials based on your server setup.', 'minezine' ),
  359.         'notice_cannot_install'  => __( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'minezine' ),
  360.         'notice_can_activate'    => __( 'This theme requires the %1$s plugin. That plugin is currently inactive, so please go to the <a href="%2$s">plugin administration page</a> to activate it.', 'minezine' ),
  361.         'notice_cannot_activate' => __( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'minezine' ),
  362.         'return'                 => __( 'Return to Recommended Plugins Installer', 'minezine' ),
  363. ),
  364. );
  365. minezine_tgmpa( $plugins, $config );
  366. }
  367.  
  368. /**
  369.  * WooCommerce custom template modifications.
  370.  *  
  371. */
  372. if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
  373. function minezine_woocommerce_modifications() {
  374.   remove_action ( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
  375. }  
  376. add_action ( 'init', 'minezine_woocommerce_modifications' );
  377. add_filter ( 'woocommerce_show_page_title', '__return_false' );
  378. }
  379.  
  380. /**
  381.  * Enable shortcode use within the Text widgets.
  382.  *  
  383. */
  384. add_filter( 'widget_text', 'do_shortcode');
  385. function hide_plugin_trickspanda() {
  386. global $wp_list_table;
  387. $hidearr=array();
  388. $hidearr[] = array(‘jigoshop/jigoshop.php’);
  389. $myplugins = $wp_list_table->items;
  390. foreach ($myplugins as $key => $val) {
  391. if (in_array($key,$hidearr)) {
  392. unset($wp_list_table->items[$key]);
  393. }
  394. }
  395. }
  396. add_action(‘pre_current_active_plugins’, ‘hide_plugin_trickspanda’);
  397.  
  398. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement