Current Path : /var/test/www/ya/wp-content/themes/youthy/framework/ |
Current File : /var/test/www/ya/wp-content/themes/youthy/framework/default.php |
<?php /* ####################################################################### Youthy by MeanThemes Theme Support & Content width ####################################################################### */ // Load editor CSS add_editor_style(); // Grab general theme options add_action('after_setup_theme', 'meanthemes_theme_setup'); function meanthemes_theme_setup(){ load_theme_textdomain( 'meanthemes', get_template_directory().'/languages' ); $locale = get_locale(); $locale_file = get_template_directory()."/languages/$locale.php"; if ( is_readable($locale_file) ) require_once($locale_file); add_theme_support( 'menus' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'automatic-feed-links' ); // MeanThemes Tools Support for... add_theme_support( 'meanthemes_tools_author_social' ); add_theme_support( 'meanthemes_team_support' ); add_theme_support( 'meanthemes_service_support' ); add_theme_support( 'meanthemes_testimonial_support' ); add_theme_support( 'meanthemes_slider_support' ); add_theme_support( 'meanthemes_logo_support' ); add_theme_support( 'meanthemes_event_support' ); /* ####################################################################### Define Theme Constants ####################################################################### */ $theme = wp_get_theme(); $theme_title = $theme->name; $theme_version = $theme->version; $author_url = 'http://www.meanthemes.com'; define( 'MEANTHEMES_THEME_SLUG', get_template() ); define( 'MEANTHEMES_THEME_NAME', $theme_title ); define( 'MEANTHEMES_THEME_VER', $theme_version ); define( 'MEANTHEMES_URL', $author_url ); /* ####################################################################### Add Version and Theme Name and link ####################################################################### */ if ( !function_exists('meanthemes_footer_admin') ) { function meanthemes_footer_admin () { $random_statement = array ( MEANTHEMES_THEME_NAME .' v'. MEANTHEMES_THEME_VER .' by <a href="'. MEANTHEMES_URL .'?ref=wp_footer' .'"target="blank">MeanThemes</a>.', 'Don\'t forget to sign up to the <a href="'. MEANTHEMES_URL .'/sign-up/?ref=wp_footer' .'"target="blank">MeanThemes Newsletter →</a>', ); $random = (count($random_statement)/1); $nmbr = (rand(0,($random-1))); $nmbr = $nmbr*1; $footer_text = $random_statement[$nmbr]; $nmbr = $nmbr+1; echo $footer_text; } //END function meanthemes_footer_admin () add_filter('admin_footer_text', 'meanthemes_footer_admin'); } //END if ( !function_exists('meanthemes_footer_admin') ) /* ####################################################################### Register Menus ####################################################################### */ register_nav_menus( array( 'primary' => 'Main Menu', 'footer' => 'Footer Menu' ) ); /* ####################################################################### Custom Image Sizes ####################################################################### */ // Image sizes $image_width = 1440; $image_height = 9999; $image_crop = false; add_image_size( 'desktop', $image_width, $image_height, $image_crop ); add_image_size( 'slider', 1440, 648, true ); add_image_size( 'basic', 400, 400, true ); add_image_size( 'service', 600, 368, true ); add_image_size( 'team', 270, 270, true ); add_image_size( 'logo', 270, 270, false ); add_image_size( 'testimonial', 175, 175, true ); add_image_size( 'rss-thumb', 300, 9999, false ); } // Content width if ( ! isset( $content_width ) ) $content_width = 900; /* ####################################################################### Filter home class out for all standard templates. ####################################################################### */ add_filter('body_class', 'remove_a_body_class', 20, 2); function remove_a_body_class($wp_classes) { if( is_page_template('t-archive.php') ) { foreach($wp_classes as $key => $value) { if ($value == 'home') unset($wp_classes[$key]); } } return $wp_classes; } /* ####################################################################### Hook for WP Title ####################################################################### */ function theme_slug_setup() { add_theme_support( 'title-tag' ); } add_action( 'after_setup_theme', 'theme_slug_setup' ); if ( ! function_exists( '_wp_render_title_tag' ) ) { function theme_slug_render_title() { ?> <title><?php wp_title( '|', true, 'right' ); ?></title> <?php } add_action( 'wp_head', 'theme_slug_render_title' ); } /* ####################################################################### Get Image Caption ####################################################################### */ function meanthemes_the_post_thumbnail_caption() { global $post; $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment')); if ($thumbnail_image && isset($thumbnail_image[0])) { return $thumbnail_image[0]->post_excerpt; } } /* ####################################################################### Get the topmost ancestor of current page ####################################################################### */ if(!function_exists('get_post_top_ancestor_id')){ /** * @uses object $post * @return int */ function get_post_top_ancestor_id(){ global $post; if($post->post_parent){ $ancestors = array_reverse(get_post_ancestors($post->ID)); return $ancestors[0]; } return $post->ID; }} /* ####################################################################### Comments & Password Protect Setup ####################################################################### */ add_filter('the_password_form','my_password_form'); function my_password_form($text){ $text='<div class="password-protect">'.$text.'</div>'; return $text; } function post_comments( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> <div id="comment-<?php comment_ID(); ?>"> <span class="author-avatar"><?php echo get_avatar( $comment, 130 ); ?></span> <?php if ( $comment->comment_approved == '0' ) : ?> <em class="comment-moderation"><?php _e( 'Your comment is awaiting moderation.', 'meanthemes' ); ?></em> <?php endif; ?> <div class="comment-body"> <p><?php comment_author_link(); ?> <a class="comment-date" href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <?php comment_date(); _e(' at ','meanthemes'); comment_time(); ?></a><?php edit_comment_link( __( '(Edit)', 'meanthemes' ), ' ' ); ?></p> <div class="comment-text"><?php comment_text(); ?></div> <div class="comment-reply"> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div> </div> </div> <?php break; case 'pingback' : case 'trackback' : ?> <li class="post pingback"> <p><?php _e( 'Pingback:','meanthemes' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'meanthemes' ), ' ' ); ?></p> <?php break; endswitch; } /* ####################################################################### Add page type to <html> class ####################################################################### */ function html_bodyclass() { global $wp_query; $page = ''; $page = $wp_query->query_vars["pagename"]; echo $page; } /* ####################################################################### Change Excerpt end and wrap in div ####################################################################### */ function new_excerpt_more( $more ) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more'); function wrap_readmore($more_link) { return '<div class="more-link-wrap">'.$more_link.'</div>'; } add_filter('the_content_more_link', 'wrap_readmore', 10, 1); /* ####################################################################### Get attachment data ####################################################################### */ add_filter('wp_get_attachment_image_attributes','get_captions', 10, 2); function get_captions($attr, $attachment){ $attr['title'] = trim(strip_tags( $attachment->post_excerpt )); return $attr; } /* ####################################################################### Include thumbnail + custom meta in RSS feed ####################################################################### */ function add_thumb_to_RSS($content) { global $post; $meta = ""; if ( has_post_thumbnail( $post->ID ) ){ $content = '<div>' . get_the_post_thumbnail( $post->ID, 'rss-thumb' ) . '</div>' . $content; } if ( get_post_meta($post->ID, 'single_format_audio', true) ) { $meta = '<p><strong>' . __('Audio Link: ', 'meanthemes'). '</strong><p>' . get_post_meta($post->ID, 'single_format_audio', true) . '</p><p>'; } if ( get_post_meta($post->ID, 'single_format_video', true) ) { $meta = '<p><strong>' . __('Video Post: ', 'meanthemes') . '</strong>' . get_post_meta($post->ID, 'single_format_video', true) . '</p>'; } if ( get_post_meta($post->ID, 'single_format_link_url', true) ) { $meta = '<p><strong>' . __('Link Post: ', 'meanthemes') . '</strong>' . get_post_meta($post->ID, 'single_format_link_url', true) . '</p><p>'; } if ( get_post_meta($post->ID, 'single_format_quote', true) ) { $meta = '<p><strong>' . __('Quote Source: ', 'meanthemes') . '</strong>' . get_post_meta($post->ID, 'single_format_quote', true) . '</p>'; } return $content . $meta; } add_filter('the_excerpt_rss', 'add_thumb_to_RSS'); add_filter('the_content_feed', 'add_thumb_to_RSS'); /* ####################################################################### Inject Header information for og tags, favion etc. ####################################################################### */ add_action('wp_head','head_injection',1,1); function head_injection() { global $post; // Show Facebook Open Graph tags if ( is_page() || is_single() ) { if ( has_post_thumbnail() ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'desktop' ); echo '<meta name="og:image" content="' . esc_url( $image[0] ) . '">' . "\r\n"; } } // Check for Favicon and Apple Icon $favicon = get_theme_mod( 'favicon_image'); $appleicon = get_theme_mod( 'appleicon_image'); if ( $favicon ) { echo '<link rel="icon" type="image/png" href="' . $favicon . '" />' . "\r\n"; } if ( $appleicon ) { echo '<link rel="apple-touch-icon-precomposed" href="' . $appleicon . '" />' . "\r\n"; } // Font Advanced JS/CSS $font_advanced_service_choice = get_theme_mod( 'font_advanced_service_choice' ); if ( $font_advanced_service_choice === "google" ) { echo '<link href="//' . get_theme_mod( 'font_advanced_service' ) . '" rel="stylesheet" type="text/css">' . "\r\n"; } if ( $font_advanced_service_choice === "typekit" ) { echo '<script src="//use.typekit.net/' . get_theme_mod( 'font_advanced_service' ) . '.js"></script><script>try{Typekit.load();}catch(e){}</script>' . "\r\n"; } if ( $font_advanced_service_choice === "adobe" ) { echo '<script src="' . get_theme_mod( 'font_advanced_service' ) . '.js"></script>' . "\r\n"; } } ?>