__( 'Top Menu', 'giornalismo' ), 'main-menu' => __( 'Main Menu', 'giornalismo' ) ) ); //* Add Support for Custom Header $args = array( 'flex-width' => true, 'width' => 530, 'flex-height' => true, 'height' => 150, 'default-image' => '', 'default-text-color' => '777777', 'upload' => true, ); add_theme_support('custom-header', $args); //* Add Support for Featured Images add_theme_support( 'post-thumbnails', array( 'post' ) ); //* Add support for editor styles add_editor_style(); //* Add Support for Automatic Feed Links add_theme_support( 'automatic-feed-links' ); //* Add in the text domain load_theme_textdomain('giornalismo', get_template_directory() . '/languages'); //* Load the file to show the recommended plugins require_once(get_template_directory() . '/admin/class-tgm-plugin-activation.php'); //* Set the content width if ( ! isset( $content_width ) ) $content_width = 640; //* Add Support for Title Tag add_theme_support('title-tag'); //* Add the needed image sizes add_image_size('giornalismo-single', 735, 440, true); } add_action ('after_setup_theme', 'giornalismo_setup_theme'); /** * Returns a custom read more link when the_excerpt() is used. This function is used in conjunction with the excerpt_more WordPress hook. * * @return string, the text to be displayed for the read more link */ function giornalismo_read_more($more) { return '
' . __('Continue Reading››', 'giornalismo') . '
'; } add_action('excerpt_more', 'giornalismo_read_more'); /** * Register the sidebars */ function giornalismo_sidebars() { register_sidebar(array( 'name'=> __('Left Sidebar', 'giornalismo'), 'id' => 'left_sidebar', 'before_widget' => '
', 'after_widget' => '

', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name'=> __('Right Sidebar', 'giornalismo'), 'id' => 'right_sidebar', 'before_widget' => '

', 'after_widget' => '

', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name'=> __('Header Widget Area', 'giornalismo'), 'id' => 'header_widget_area', 'description' => __('Use this area to display an ad in the header area.', 'giornalismo'), 'before_widget' => '

', 'after_widget' => '

', 'before_title' => '

', 'after_title' => '

' )); } add_action('widgets_init', 'giornalismo_sidebars'); /** * Load the theme options */ require_once(get_template_directory() . '/admin/theme-options.php'); /** * Load the necessary scripts */ function giornalismo_enqueue_scripts() { wp_enqueue_style('giornalismo-stylesheet', get_template_directory_uri() . '/style.css'); if (is_singular()) { wp_enqueue_script('comment-reply'); } if (esc_attr(get_theme_mod('giornalismo-layout')) == 'left-sidebar') { wp_enqueue_style('giornalismo-left-sidebar', get_template_directory_uri() . '/css/left-sidebar.css'); } if (esc_attr(get_theme_mod('giornalismo-layout')) == 'two-sidebars') { wp_enqueue_style('giornalismo-two-sidebars', get_template_directory_uri() . '/css/two-sidebars.css'); } wp_register_style('giornalismo-lato', '//fonts.googleapis.com/css?family=Lato:100,300,400,700'); wp_enqueue_style( 'giornalismo-lato'); wp_register_style('giornalismo-oswald', '//fonts.googleapis.com/css?family=Oswald&subset=latin,latin-ext'); wp_enqueue_style( 'giornalismo-oswald'); wp_register_style('giornalismo-roboto', '//fonts.googleapis.com/css?family=Roboto:400,300,700'); wp_enqueue_style( 'giornalismo-roboto'); wp_register_style('giornalismo-source-sans', '//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700'); wp_enqueue_style( 'giornalismo-source-sans-sans'); wp_register_style('giornalismo-quattrocento', '//fonts.googleapis.com/css?family=Quattrocento:700'); wp_enqueue_style( 'giornalismo-quattrocento'); wp_register_script('giornalismo-mobile-nav', get_template_directory_uri() . '/js/mobile-nav.js'); wp_enqueue_script('giornalismo-mobile-nav'); wp_register_script('giornalismo-mobile-sidebar', get_template_directory_uri() . '/js/mobile-sidebar.js'); wp_enqueue_script('giornalismo-mobile-sidebar'); wp_enqueue_script('giornalismo-jquery'); wp_enqueue_script('giornalismo-jquery-ui-core'); wp_register_style('giornalismo-mobile-css', get_template_directory_uri() . '/css/mobile.css'); wp_enqueue_style('giornalismo-mobile-css'); wp_register_style('giornalismo-tablet-css', get_template_directory_uri() . '/css/tablet.css'); wp_enqueue_style('giornalismo-tablet-css'); if ( esc_attr( get_theme_mod( 'giornalismo-color-theme' ) == 'red' ) ) { wp_enqueue_style('giornalismo-red-theme', get_template_directory_uri() . '/css/red.css'); } elseif ( esc_attr( get_theme_mod( 'giornalismo-color-theme' ) == 'green' ) ) { wp_enqueue_style('giornalismo-green-theme', get_template_directory_uri() . '/css/green.css'); } elseif ( esc_attr( get_theme_mod( 'giornalismo-color-theme' ) == 'blue' ) ) { wp_enqueue_style('giornalismo-blur-theme', get_template_directory_uri() . '/css/blue.css'); } elseif ( esc_attr( get_theme_mod( 'giornalismo-color-theme' ) == 'purple' ) ) { wp_enqueue_style('giornalismo-purple-theme', get_template_directory_uri() . '/css/purple.css'); } } add_action( 'wp_enqueue_scripts', 'giornalismo_enqueue_scripts', 1 ); /** * For use to show the recommended plugins for Giornalismo. */ /** * Register the required plugins for this theme. * * In this example, we register two plugins - one included with the TGMPA library * and one from the .org repo. * * The variable passed to tgmpa_register_plugins() should be an array of plugin * arrays. * * This function is hooked into tgmpa_init, which is fired within the * TGM_Plugin_Activation class constructor. */ function giornalismo_register_required_plugins() { $plugins = array( array( 'name' => 'JM Breaking News', 'slug' => 'jm-breaking-news', 'required' => false, ), array( 'name' => 'Simple Ads Manager', 'slug' => 'simple-ads-manager', 'required' => false, ), array( 'name' => 'Extra User Details', 'slug' => 'extra-user-details', 'required' => false, ), array( 'name' => 'Giornalismo Story Details', 'slug' => 'giornalismo-story-details', 'required' => false, ), array( 'name' => 'Category Color', 'slug' => 'category-color', 'required' => false, ), ); /** * Array of configuration settings. Amend each line as needed. * If you want the default strings to be available under your own theme domain, * leave the strings uncommented. * Some of the strings are added into a sprintf, so see the comments at the * end of each line for what each argument will be. */ $config = array( 'default_path' => '', // Default absolute path to pre-packaged plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. ); tgmpa( $plugins, $config ); } add_action( 'tgmpa_register', 'giornalismo_register_required_plugins' ); /** * II. Header Functions */ /** * Returns social links and images based on theme options * * Goes through the social media theme options and adds an image and a link to that social media site if there is an option value for it * @return string, the images and links for each social media site */ if (!function_exists('giornalismo_social_media_links')) { function giornalismo_social_media_links() { $html = ''; $html = '

'; if ( esc_attr( get_theme_mod( 'giornalismo-facebook' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on Facebook', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-twitter' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on Twitter', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-google-plus' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on Google+', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-youtube' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on YouTube', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-linkedin' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on LinkedIn', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-tumblr' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on Tumblr', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-instagram' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on Instagram', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-pinterest' ) ) != '' ) { $html .= '' . get_bloginfo( 'name' ) . __( ' on Pinterest', 'giornalismo' ) . ''; } if ( esc_attr( get_theme_mod( 'giornalismo-rss-feed' ) ) != '' ) { $html .= '' . __( "RSS Feed", 'giornalismo' ) . ''; } else { $html .= '' . __( "RSS Feed", 'giornalismo' ) . ''; } $html .= '
'; return $html; } } /** * Returns the HTML for the breadcrumbs if the theme user wants * * @return string, HTML for breadcrumbs */ if (!function_exists('giornalismo_breadcrumbs')) { // Add function for Breadcrumbs function giornalismo_breadcrumbs() { global $post; $html = ''; return $html; } } /** * Returns the HTML for the masthead * * @return string, HTML for the masthead */ if (!function_exists('giornalismo_header')) { function giornalismo_header() { $html = '
'; if ( get_header_image() ) { $html .= ''; } else { $html .= '

' . get_bloginfo( 'name' ) . '

'; $html .= '

' . get_bloginfo( 'description' ) . '

'; } $html .= '
'; return $html; } } /** * Returns the day's date in HTML if the theme user has the option selected * * @return string, the day's date in HTML */ if (!function_exists('giornalismo_todays_date')) { function giornalismo_todays_date() { if ( esc_attr( get_theme_mod( 'giornalismo-todays-date' ) ) ) { return '

' . date_i18n( "l, F j, Y" ) . '

'; } } } /** * III. Single Functions */ /** * Returns the HTML for the story lines section of the single post * * @return string, HTML and text for the story lines section */ if (!function_exists('giornalismo_story_lines')) { function giornalismo_story_lines() { $html = ""; if ( get_post_meta( get_the_ID(), 'giornalismo_highlight_one', true ) or get_post_meta( get_the_ID(), 'giornalismo_highlight_two', true ) or get_post_meta( get_the_ID(), 'giornalismo_highlight_three', true ) ) { $story_line_one = get_post_meta( get_the_ID(), 'giornalismo_highlight_one', true ); $story_line_two = get_post_meta( get_the_ID(), 'giornalismo_highlight_two', true ); $story_line_three = get_post_meta( get_the_ID(), 'giornalismo_highlight_three', true ); $html .= ''; } return $html; } } /** * Returns the HTML for the related stories section of the single post * * @return string, HTML for the related stories section */ if (!function_exists('giornalismo_related_stories')) { function giornalismo_related_stories( $id ) { $html = ""; if ( esc_attr( get_theme_mod( 'giornalismo-related-stories' ) ) == 1 ) { $tags = wp_get_post_tags( $id ); if ( $tags ) { $first_tag = $tags[0]->term_id; $args = array( 'tag__in' => array( $first_tag ), 'post__not_in' => array( $id ), 'showposts' => 3, 'ignore_sticky_posts' => 1 ); $related_stories = new WP_Query( $args ); if ( $related_stories->have_posts() ) : $html .= ''; endif; wp_reset_postdata(); } } return $html; } } /** * Returns the HTML for the latest stories section of the single post * * @return string, HTML for the latest stories section */ if (!function_exists('giornalismo_latest_stories')) { function giornalismo_latest_stories( $category ) { $html = ''; if ( esc_attr( get_theme_mod( 'giornalismo-latest-stories' ) ) == 1 ) { $cat_name = $category[0]->cat_name; $id = get_the_ID(); $html .= '
'; $html .= '

' . __( 'More Stories From ', 'giornalismo' ) . $cat_name . '

'; $latest_stories_args = array( 'posts_per_page' => 3, 'category_name' => $cat_name, 'post__not_in' => array( $id ), 'orderby' => 'date', 'order' => 'DES' ); $latest_stories = new WP_Query( $latest_stories_args ); if ( $latest_stories->have_posts() ) : while ( $latest_stories->have_posts() ) : $latest_stories->the_post(); $html .= '
'; if ( has_post_thumbnail() ) { $html .= ''; } $html .= '
' . get_the_title() . '
'; $html .= '
'; endwhile; endif; $html .= '
'; wp_reset_postdata(); } return $html; } } /** * Returns the HTML for the author bio area on the single post * * @return string, HTML for the author bio area */ if (!function_exists('giornalismo_author_bio')) { function giornalismo_author_bio() { $html = ''; $html = '
'; if ( get_avatar( get_the_author_meta( 'email' ) ) ) { $html .= '
' . get_avatar( get_the_author_meta( 'email' ), $size = 96 ) . '
'; } if ( esc_attr( get_theme_mod( 'giornalismo-author-position' ) ) ) { $position = ', ' . get_the_author_meta( 'author-position' ); } else { $position = ''; } $html .= '

' . __( 'About ', 'giornalismo' ) . get_the_author_meta( 'display_name' ) . $position . '

'; $html .= '

' . get_the_author_meta( 'description' ) . '

'; $html .= giornalismo_author_social_area(); $html .= '
'; return $html; } } /** * IV. Archive Functions */ /** * Returns the custom output for the archive page titles using the get_the_archive_title filter. * * @return string, HTML for archive page title */ function giornalismo_archive_title($title) { if (is_day()) { $title = __('Archives for ', 'giornalismo') . get_the_time('F j, Y'); } else if (is_month()) { $title = __('Archives for ', 'giornalismo') . get_the_time('F Y'); } else if (is_year()) { $title = __('Archives for ', 'giornalismo') . get_the_time('Y'); } else if (is_category()) { $title = single_cat_title('', false); } else if (is_search()) { $title = __('Search results for ', 'giornalismo') . get_search_query(); } else if (is_tag()) { $title = single_tag_title('', false); } else { $page = get_query_var('paged'); $title = __('Page ', 'giornalismo') . $page; } return $title; } add_filter( 'get_the_archive_title', 'giornalismo_archive_title'); /** * V. Comments Functions */ /** * Sets up the custom comments template */ function giornalismo_advanced_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?>
  • id="li-comment-">
    comment_approved == '0') : ?>
    $depth, 'max_depth' => $args['max_depth']))) ?>
    '; if ( get_the_author_meta( 'facebook' ) ) { $html .= '
    '; } if ( get_the_author_meta( 'twitter-link' ) ) { $html .= '
    '; } if ( get_the_author_meta( 'google-plus' ) ) { $html .= '
    '; } if ( esc_url( get_the_author_meta( 'email' ) ) ) { $html .= '
    '; } $html .= ''; return $html; } } /** * Returns the HTML for the author's byline. * * @return string, text and links for author's byline */ if ( ! function_exists ( 'giornalismo_author_byline' ) ) { function giornalismo_author_byline() { if (esc_attr(get_theme_mod('giornalismo-author-twitter-handle') == 1) and (get_the_author_meta('twitter-handle'))) { $html = __('Written by ', 'giornalismo') . '' . get_the_author_meta('display_name') . ', ' . get_the_author_meta('twitter-handle') . ', '; } else { $html = __('Written by ', 'giornalismo') . '' . get_the_author_meta('display_name') . ', '; } return $html; } } /** * VII. Staff Functions */ /** * Returns the code for the staff page * * @return string, HTML for staff page */ if (!function_exists('giornalismo_staff')) { function giornalismo_staff() { $giornalismo_writer = get_users( array( 'orderby' => 'menu_order', 'order' => 'DESC' ) ); $html = ""; foreach ( $giornalismo_writer as $writer ) { $html .= '
    '; $html .= '
    '; if ( get_avatar( get_the_author_meta( 'email', $writer->ID ) ) ) { $html .= '
    ' . get_avatar( get_the_author_meta( 'email', $writer->ID ), $size = 96 ) . '
    '; } $html .= '
    '; if ( esc_attr( get_theme_mod( 'giornalismo-author-position' ) ) ) { $position = ' — ' . get_the_author_meta( 'author-position', $writer->ID ); } else { $position = ''; } $html .= '

    ' . $writer->display_name . $position . '

    '; $html .= '

    ' . get_the_author_meta( 'description', $writer->ID ) . '

    '; $html .= giornalismo_staff_author_social_area( $writer->ID ); $html .= '
    '; } return $html; } } /** * Returns the HTML for the social media area for the post author. * * @return string, images and links for social media */ if (!function_exists('giornalismo_staff_author_social_area')) { function giornalismo_staff_author_social_area( $id ) { $html = '
    '; if ( get_the_author_meta( 'facebook', $id ) ) { $html .= '
    '; } if ( get_the_author_meta( 'twitter-link', $id ) ) { $html .= '
    '; } if ( get_the_author_meta( 'google-plus', $id ) ) { $html .= '
    '; } if ( get_the_author_meta( 'email', $id ) ) { $html .= '
    '; } $html .= '
    '; return $html; } } ?>