'Topbar', 'header' => 'Header', 'footer' => 'Footer', ) ); } } add_action( 'after_setup_theme', 'alx_setup' ); /* Register sidebars /* ------------------------------------ */ if ( ! function_exists( 'alx_sidebars' ) ) { function alx_sidebars() { register_sidebar(array( 'name' => 'Primary','id' => 'primary','description' => "Normal full width sidebar", 'before_widget' => '
','before_title' => ''.$link.'
'."\n"; } return $sitename; } } /* Page title /* ------------------------------------ */ if ( ! function_exists( 'alx_page_title' ) ) { function alx_page_title() { global $post; $heading = get_post_meta($post->ID,'_heading',true); $subheading = get_post_meta($post->ID,'_subheading',true); $title = $heading?$heading:the_title(); if($subheading) { $title = $title.' '.$subheading.''; } return $title; } } /* Blog title /* ------------------------------------ */ if ( ! function_exists( 'alx_blog_title' ) ) { function alx_blog_title() { global $post; $heading = ot_get_option('blog-heading'); $subheading = ot_get_option('blog-subheading'); if($heading) { $title = $heading; } else { $title = get_bloginfo('name'); } if($subheading) { $title = $title.' '.$subheading.''; } return $title; } } /* Related posts /* ------------------------------------ */ if ( ! function_exists( 'alx_related_posts' ) ) { function alx_related_posts() { wp_reset_postdata(); global $post; // Define shared post arguments $args = array( 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'rand', 'post__not_in' => array($post->ID), 'posts_per_page' => 3 ); // Related by categories if ( ot_get_option('related-posts') == 'categories' ) { $cats = get_post_meta($post->ID, 'related-cat', true); if ( !$cats ) { $cats = wp_get_post_categories($post->ID, array('fields'=>'ids')); $args['category__in'] = $cats; } else { $args['cat'] = $cats; } } // Related by tags if ( ot_get_option('related-posts') == 'tags' ) { $tags = get_post_meta($post->ID, 'related-tag', true); if ( !$tags ) { $tags = wp_get_post_tags($post->ID, array('fields'=>'ids')); $args['tag__in'] = $tags; } else { $args['tag_slug__in'] = explode(',', $tags); } if ( !$tags ) { $break = true; } } $query = !isset($break)?new WP_Query($args):new WP_Query; return $query; } } /* Get images attached to post /* ------------------------------------ */ if ( ! function_exists( 'alx_post_images' ) ) { function alx_post_images( $args=array() ) { global $post; $defaults = array( 'numberposts' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'post_type' => 'attachment', ); $args = wp_parse_args( $args, $defaults ); return get_posts( $args ); } } /* Get featured post ids /* ------------------------------------ */ if ( ! function_exists( 'alx_get_featured_post_ids' ) ) { function alx_get_featured_post_ids() { $args = array( 'category' => ot_get_option('featured-category'), 'numberposts' => ot_get_option('featured-posts-count') ); $posts = get_posts($args); if ( !$posts ) return false; foreach ( $posts as $post ) $ids[] = $post->ID; return $ids; } } /* ------------------------------------------------------------------------- * * Admin panel functions /* ------------------------------------------------------------------------- */ /* Post formats script /* ------------------------------------ */ if ( ! function_exists( 'alx_post_formats_script' ) ) { function alx_post_formats_script( $hook ) { // Only load on posts, pages if ( !in_array($hook, array('post.php','post-new.php')) ) return; wp_enqueue_script('post-formats', get_template_directory_uri() . '/functions/js/post-formats.js', array( 'jquery' )); } } add_action( 'admin_enqueue_scripts', 'alx_post_formats_script'); /* ------------------------------------------------------------------------- * * Filters /* ------------------------------------------------------------------------- */ /* Body class /* ------------------------------------ */ if ( ! function_exists( 'alx_body_class' ) ) { function alx_body_class( $classes ) { $classes[] = alx_layout_class(); if ( ot_get_option( 'boxed' ) != 'on' ) { $classes[] = 'full-width'; } if ( ot_get_option( 'boxed' ) == 'on' ) { $classes[] = 'boxed'; } if ( has_nav_menu('topbar') ) { $classes[] = 'topbar-enabled'; } if ( ot_get_option( 'mobile-sidebar-hide' ) == 's1' ) { $classes[] = 'mobile-sidebar-hide-s1'; } if ( ot_get_option( 'mobile-sidebar-hide' ) == 's2' ) { $classes[] = 'mobile-sidebar-hide-s2'; } if ( ot_get_option( 'mobile-sidebar-hide' ) == 's1-s2' ) { $classes[] = 'mobile-sidebar-hide'; } return $classes; } } add_filter( 'body_class', 'alx_body_class' ); /* Custom rss feed /* ------------------------------------ */ if ( ! function_exists( 'alx_feed_link' ) ) { function alx_feed_link( $output, $feed ) { // Do not redirect comments feed if ( strpos( $output, 'comments' ) ) return $output; // Return feed url return ot_get_option('rss-feed',$output); } } add_filter( 'feed_link', 'alx_feed_link', 10, 2 ); /* Custom favicon /* ------------------------------------ */ if ( ! function_exists( 'alx_favicon' ) ) { function alx_favicon() { if ( ot_get_option('favicon') ) { echo ''."\n"; } } } add_filter( 'wp_head', 'alx_favicon' ); /* Excerpt ending /* ------------------------------------ */ if ( ! function_exists( 'alx_excerpt_more' ) ) { function alx_excerpt_more( $more ) { return '...'; } } add_filter( 'excerpt_more', 'alx_excerpt_more' ); /* Excerpt length /* ------------------------------------ */ if ( ! function_exists( 'alx_excerpt_length' ) ) { function alx_excerpt_length( $length ) { return ot_get_option('excerpt-length',$length); } } add_filter( 'excerpt_length', 'alx_excerpt_length', 999 ); /* Add wmode transparent to media embeds /* ------------------------------------ */ if ( ! function_exists( 'alx_embed_wmode_transparent' ) ) { function alx_embed_wmode_transparent( $html, $url, $attr ) { if ( strpos( $html, "