Independent's Function File
<?php
// Start the engine
require_once( get_template_directory() . '/lib/init.php' );
load_child_theme_textdomain( 'metro', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'metro' ) );
// Child theme (do not remove)
define( 'CHILD_THEME_NAME', __( 'Metro Theme', 'metro' ) );
define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/metro/' );
include_once( CHILD_DIR . '/lib/featured-post-widget.php' );
//* Remove Featured Post widget
add_action( 'widgets_init', 'remove_featured_post_widget', 20 );
function remove_featured_post_widget() {
unregister_widget( 'Genesis_Featured_Post' );
}
// register our custom widget..
register_widget( 'Genesis_Child_Featured_Post' );
// Add Viewport meta tag for mobile browsers
add_action( 'genesis_meta', 'metro_viewport_meta_tag' );
function metro_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
// Add new image sizes
add_image_size( 'home-bottom', 150, 150, TRUE );
add_image_size( 'home-middle', 385, 187, TRUE );
add_image_size( 'home-top', 800, 400, TRUE );
// Add support for custom background
add_theme_support( 'custom-background', array( 'wp-head-callback' => '__return_false' ) );
// // Add support for custom header
// add_theme_support( 'genesis-custom-header', array(
// 'flex-height' => true,
// 'height' => 87,
// 'width' => 1080
// ) );
//
//
/* LogIn - LogOut - Register - Add New - mybloggerblog.com */
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
global $current_user;
get_currentuserinfo();
if (is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li class="grey"><a href="'. get_bloginfo('url'). '/my-account/">My Account</a><ul class="sub-menu"><li><a href="'. get_bloginfo('url'). '/my-account/" title="Go to your account Profile">Update Profile</a></li><li><a href="'. get_bloginfo('url'). '/cancel-account/">Cancel Account</a></li><li><a href="'. wp_logout_url() .'" title="Log out of this account">Log Out ?</a></li></ul></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li class="grey"><a href="'. site_url('wp-login.php') .'" title="Log In Now">Log In</a></li>';
// $items .= '<li><a href="'. site_url('wp-login.php?action=register') .'" title="Register Now">Register</a></li>';
}
return $items;
}
//* Modify the way posts are displayed
//* Show featured image on posts
add_action( 'genesis_before_post_content', 'wpsites_before_post_content_image', 5 );
function wpsites_before_post_content_image() {
if ( is_page() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
//* Remove the post info function
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
//* Remove the post meta function
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
// Remove the site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
remove_action( 'genesis_footer', 'genesis_do_footer' );
// Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
// Reposition the footer widgets
remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );
add_action( 'genesis_footer', 'genesis_footer_widget_areas' );
// Add span class to widget headlines
add_filter( 'widget_title', 'metro_widget_title' );
function metro_widget_title( $title ){
if( $title )
return sprintf('<span class="widget-headline">%s</span>', $title );
}
// Load Backstretch script and prepare images for loading
add_action( 'wp_enqueue_scripts', 'metro_enqueue_scripts' );
function metro_enqueue_scripts() {
// Load scripts only if custom background is being used
if ( ! get_background_image() )
return;
wp_enqueue_script( 'metro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'metro-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'metro-backstretch' ), '1.0.0' );
wp_localize_script( 'metro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
}
// Register widget areas
genesis_register_sidebar( array(
'id' => 'home-top',
'name' => __( 'Home - Top', 'metro' ),
'description' => __( 'This is the top section of the homepage.', 'metro' ),
) );
genesis_register_sidebar( array(
'id' => 'home-bottom',
'name' => __( 'Home - Bottom', 'metro' ),
'description' => __( 'This is the bottom section of the homepage.', 'metro' ),
'before_title' => __( '<h4 class="widget-title widgettitle"><a href="/new-site/recent-news/">'),
'after_title' => __( '</a></h4>'),
) );
genesis_register_sidebar( array(
'id' => 'home-middle-left',
'name' => __( 'Home - Middle Left', 'metro' ),
'description' => __( 'This is the middle left section of the homepage.', 'metro' ),
'before_title' => __( '<h4 class="widget-title widgettitle"><a href="http://www.youtube.com/user/MoCoIndependent?feature=watch" target="_blank">'),
'after_title' => __( '</a></h4>'),
) );
genesis_register_sidebar( array(
'id' => 'home-middle-right',
'name' => __( 'Home - Middle Right', 'metro' ),
'description' => __( 'This is the middle right section of the homepage.', 'metro' ),
'before_title' => __( '<h4 class="widget-title widgettitle"><a href="/new-site/family-news/">'),
'after_title' => __( '</a></h4>'),
) );
// Customize the format dropdown items
if( !function_exists('base_custom_mce_format') ){
function base_custom_mce_format($init) {
// Add block format elements you want to show in dropdown
$init['theme_advanced_blockformats'] = 'p,h2,h3,h4,h5,h6,div,address';
// Add elements not included in standard tinyMCE dropdown p,h1,h2,h3,h4,h5,h6
$init['extend_valid_elements'] = 'a[class],-p';
return $init;
}
add_filter('tiny_mce_before_init', 'base_custom_mce_format' );
}
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>(\s| )*+(<br\s*/*>)?(\s| )*</p>#i', '', $content);
}
// Custom WordPress Login Logo
function login_css() {
wp_enqueue_style( 'login_css', get_stylesheet_directory_uri() . '/login.css' );
}
add_action('login_head', 'login_css');
function custom_login_message() {
$message = "<p>Certain sections of the website and the E-newsletter updates are available only to paid mail delivery subscribers. Please sign if you are a subscriber. </p><p>You may also click the 'Register' button under the login box to get registered.</p>";
return $message;
}
add_filter('login_message', 'custom_login_message');
// Register a new sidebar
genesis_register_sidebar( array(
'id' => 'home-sidebar',
'name' => 'Home Sidebar',
'description' => 'This is the home sidebar widget area.'
) );
add_action( 'get_header', 'child_sidebar_logic' );
/**
* Add Home Sidebar
*
* @author Brian Lis
* @link http://dev.studiopress.com/add-unique-sidebar-to-home-page.htm
*/
function child_sidebar_logic() {
if ( is_home() ) {
remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
add_action( 'genesis_after_content', 'child_get_home_sidebar' );
}
}
/**
* Retrieve our unique home page sidebar.
*/
function child_get_home_sidebar() {
get_sidebar( 'home-sidebar' );
}
/** Remove secondary sidebar */
unregister_sidebar( 'sidebar-alt' );
// Enqueue the mobile menu
add_action( 'wp_enqueue_scripts', 'amethyst_load_mobile_nav_script' );
function amethyst_load_mobile_nav_script() {
//Add mobile button script to primary navigation menu
wp_enqueue_script( 'nav_for_mobile', get_bloginfo( 'stylesheet_directory' ) . '/js/drop-down-nav.js', array('jquery'), '0.5' );
}
function new_excerpt_more( $more ) {
global $post;
return '... <a class="more-link" href="'. get_permalink( get_the_ID() ) . '">Read More</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
// Body class :: adding to page-parent and sub pages //
function cc_body_class( $classes ) {
global $post;
if ( is_page() ) {
// Has parent / is sub-page
if ( $post->post_parent ) {
# Parent post name/slug
$parent = get_post( $post->post_parent );
$classes[] = 'photo-seller';
}
}
return $classes;
}
add_filter( 'body_class', 'cc_body_class' );
function remove_featured_image_archives( $post ) {
if( !has_post_thumbnail() )
$post = '';
return $post;
}
add_filter( 'genesis_pre_get_image', 'remove_featured_image_archives', 10, 3 );
?>