Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //* Start the engine
- include_once( get_template_directory() . '/lib/init.php' );
- //* Child theme (do not remove)
- define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
- define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
- define( 'CHILD_THEME_VERSION', '2.0.1' );
- //* Enqueue Lato Google font
- add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
- function genesis_sample_google_fonts() {
- wp_enqueue_style( 'google-font-lato', '//fonts.googleapis.com/css?family=Lato:300,700', array(), CHILD_THEME_VERSION );
- }
- //* Add HTML5 markup structure
- add_theme_support( 'html5' );
- //* Add viewport meta tag for mobile browsers
- add_theme_support( 'genesis-responsive-viewport' );
- //* Add support for custom background
- add_theme_support( 'custom-background' );
- //* Add support for 3-column footer widgets
- add_theme_support( 'genesis-footer-widgets', 3 );
- //* Display a custom favicon
- add_filter( 'genesis_pre_load_favicon', 'sp_favicon_filter' );
- function sp_favicon_filter( $favicon_url ) {
- return 'http://localhost/Circleurbana/wp-content/themes/genesis-sample/images/favicon.ico';
- }
- //* Add post navigation (requires HTML5 theme support)
- add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );
- //* Customize the next page link
- add_filter ( 'genesis_next_link_text' , 'sp_next_page_link' );
- function sp_next_page_link ( $text ) {
- return __( 'Custom Next Page Link', CHILD_DOMAIN ) . g_ent( ' »' );
- }
- //* Display author box on single posts
- add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
- //* Change the footer text
- add_filter('genesis_footer_creds_text', 'sp_footer_creds_filter');
- function sp_footer_creds_filter( $creds ) {
- $creds = '[footer_copyright] · <a href="http://circleurbana.com">Circle Urbana</a> · Built on the Genesis Framework by Santosh Vallury';
- return $creds;
- }
- //** Read More changed to Continue Reading...
- add_filter( 'excerpt_more', 'child_read_more_link' );
- add_filter( 'get_the_content_more_link', 'child_read_more_link' );
- add_filter( 'the_content_more_link', 'child_read_more_link' );
- function child_read_more_link() {
- return '… <a class="more-link" href="' . get_permalink() . '" rel="nofollow">Continue Reading …</a>';
- }
- //* Enqueue and initialize jQuery Masonry script
- add_action( 'wp_enqueue_scripts', 'sk_masonry_script' );
- function sk_masonry_script() {
- if ( is_singular( 'post' ) ) {
- wp_enqueue_script( 'masonry-init', get_stylesheet_directory_uri().'/js/masonry-init.js', array( 'jquery-masonry' ), '1.0', true );
- }
- }
- //* Define custom image size for featured image in Related Posts
- add_image_size( 'related', 300, 0, true );
- add_action( 'genesis_after_entry_content', 'child_related_posts' );
- /**
- * Outputs related posts with thumbnail
- *
- * @author Nick the Geek
- * @url http://designsbynickthegeek.com/tutorials/related-posts-genesis
- * @global object $post
- */
- function child_related_posts() {
- if ( is_singular ( 'post' ) ) {
- global $post;
- $count = 0;
- $postIDs = array( $post->ID );
- $related = '';
- $tags = wp_get_post_tags( $post->ID );
- $cats = wp_get_post_categories( $post->ID );
- if ( $tags ) {
- foreach ( $tags as $tag ) {
- $tagID[] = $tag->term_id;
- }
- $args = array(
- 'tag__in' => $tagID,
- 'post__not_in' => $postIDs,
- 'showposts' => 8,
- 'ignore_sticky_posts' => 1,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'post_format',
- 'field' => 'slug',
- 'terms' => array(
- 'post-format-link',
- 'post-format-status',
- 'post-format-aside',
- 'post-format-quote'
- ),
- 'operator' => 'NOT IN'
- )
- )
- );
- $tag_query = new WP_Query( $args );
- if ( $tag_query->have_posts() ) {
- while ( $tag_query->have_posts() ) {
- $tag_query->the_post();
- // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
- $img = genesis_get_image( array( 'size' => 'related' ) );
- $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';
- $postIDs[] = $post->ID;
- $count++;
- }
- }
- }
- if ( $count <= 7 ) {
- $catIDs = array( );
- foreach ( $cats as $cat ) {
- if ( 6 == $cat )
- continue;
- $catIDs[] = $cat;
- }
- $showposts = 8 - $count;
- $args = array(
- 'category__in' => $catIDs,
- 'post__not_in' => $postIDs,
- 'showposts' => $showposts,
- 'ignore_sticky_posts' => 1,
- 'orderby' => 'rand',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'post_format',
- 'field' => 'slug',
- 'terms' => array(
- 'post-format-link',
- 'post-format-status',
- 'post-format-aside',
- 'post-format-quote' ),
- 'operator' => 'NOT IN'
- )
- )
- );
- $cat_query = new WP_Query( $args );
- if ( $cat_query->have_posts() ) {
- while ( $cat_query->have_posts() ) {
- $cat_query->the_post();
- // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
- $img = genesis_get_image( array( 'size' => 'related' ) );
- $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';
- }
- }
- }
- if ( $related ) {
- printf( '<div class="related"><h3 class="related-title">Related Posts</h3><div class="related-posts-list" data-columns>%s</div></div>', $related );
- }
- wp_reset_query();
- }
- }
- //* Register Home Slider widget area
- genesis_register_sidebar( array(
- 'id' => 'home-parallax-section',
- 'name' => __( 'Home Parallax Section', 'your-theme-slug' ),
- 'description' => __( 'This is the home parallax widget area.', 'your-theme-slug' ),
- ) );
- //* Display Home Parallax Section below Header (+Nav)
- add_action ( 'genesis_after_header', 'sk_parallax_section' );
- function sk_parallax_section() {
- if ( ! ( is_home() || is_front_page() ) )
- return;
- genesis_widget_area( 'home-parallax-section', array(
- 'before' => '<div id="home-parallax-section" class="parallax-section" data-stellar-background-ratio="0.5"><div class="wrap"',
- 'after' => '</div></div>',
- ) );
- }
- add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
- function sk_enqueue_scripts() {
- if ( is_home() ) {
- wp_enqueue_style( 'animate', get_stylesheet_directory_uri() . '/css/animate.min.css' );
- // load Waypoints
- // Source: http://imakewebthings.com/jquery-waypoints/
- wp_enqueue_script( 'waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array( 'jquery' ), '1.0.0' );
- wp_enqueue_script( 'waypoints-init', get_stylesheet_directory_uri() .'/js/waypoints-init.js' , array( 'jquery', 'waypoints' ), '1.0.0' );
- }
- }
- //* Sticky Header
- add_action( 'wp_enqueue_scripts', 'custom_enqueue_script' );
- function custom_enqueue_script() {
- wp_enqueue_script( 'sticky-nav', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-nav.js', array( 'jquery' ), '', true );
- }
- //* Adding Google Translator to Primary Nav Menu
- add_filter( 'genesis_nav_items', 'sk_google_translator', 10, 2 );
- add_filter( 'wp_nav_menu_items', 'sk_google_translator', 10, 2 );
- function sk_google_translator($menu, $args) {
- $args = (array)$args;
- if ( 'primary' !== $args['theme_location'] )
- return $menu;
- ob_start();
- echo '<div id="google-translator">' . do_shortcode("[google-translator]") . '</div>';
- $google_translator = ob_get_clean();
- return $menu . $google_translator;
- }
- //* Fade in side bar widget
- add_action( 'wp_enqueue_scripts', 'enqueue_sticky_last_widget' );
- function enqueue_sticky_last_widget() {
- wp_enqueue_style( 'animate', get_stylesheet_directory_uri() . '/css/animate.min.css' );
- wp_enqueue_script( 'waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array( 'jquery' ), '1.0.0' );
- wp_enqueue_script( 'waypoints-initi', get_stylesheet_directory_uri() .'/js/waypoints-initi.js', array('jquery', 'waypoints' ), '1.0.0' );
- }
- //* For Sliding-in Posts from left (Sridhar Katakam)
- add_action( 'wp_enqueue_scripts', 'enqueue_scroll_animations' );
- function enqueue_scroll_animations() {
- if ( is_handheld() )
- return;
- wp_enqueue_style( 'animate', get_stylesheet_directory_uri() . '/css/animate.min.css' );
- wp_enqueue_script( 'waypoints', get_stylesheet_directory_uri() . '/js/waypoints.min.js', array( 'jquery' ), '1.0.0' );
- wp_enqueue_script( 'waypoints-initp', get_stylesheet_directory_uri() .'/js/waypoints-initp.js' , array( 'jquery', 'waypoints' ), '1.0.0' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement