__( 'Primary Menu', 'Blocks' ), ) ); /** * Enable custom background support */ add_theme_support( 'custom-background' ); /*Allows theme developers to link a custom stylesheet file to the TinyMCE visual editor. */ function my_theme_add_editor_styles() { add_editor_style( 'custom-editor-style.css' ); } add_action( 'init', 'my_theme_add_editor_styles' ); } endif; // Blocks_setup add_action( 'after_setup_theme', 'Blocks_setup' ); if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } //Adds thumbnails compatibility to the theme set_post_thumbnail_size( true ); // Sets the Post Main Thumbnails add_image_size( 'recent-thumbnails', 80, 93, true ); // Sets Recent Posts Thumbnails add_image_size( 'related-thumbnails', 110, 75, true ); // Sets Recent Posts Thumbnails /* * Helper function to return the theme option value. If no value has been saved, it returns $default. * Needed because options are saved as serialized strings. * * This code allows the theme to work without errors if the Options Framework plugin has been disabled. */ if ( !function_exists( 'of_get_option' ) ) { function of_get_option($name, $default = false) { $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id $option_name = $optionsframework_settings['id']; if ( get_option($option_name) ) { $options = get_option($option_name); } if ( isset($options[$name]) ) { return $options[$name]; } else { return $default; } } } /* * Loads the Options Panel * * If you're loading from a child theme use stylesheet_directory * instead of template_directory */ if ( !function_exists( 'optionsframework_init' ) ) { define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' ); require_once dirname( __FILE__ ) . '/inc/options-framework.php'; } // Widget - SHORT HEADLINE FROM SPECIFIC CATEGORY AND THUMBNAIL class Posts_From_Category_Thumbnail extends WP_Widget { function Posts_From_Category_Thumbnail() { /* Widget settings. */ $widget_ops = array( 'classname' => 'postsfromcat-thumb', 'description' => 'Allows you to display a list of recent posts within a particular category. Includes Thumbnail on left.'); /* Widget control settings. */ $control_ops = array( 'width' => 250, 'height' => 250, 'id_base' => 'postsfromcat-thumb-widget'); /* Create the widget. */ $this->WP_Widget('postsfromcat-thumb-widget', 'Blocks Theme - Posts from Cat w/ Thumbnail', $widget_ops, $control_ops ); } function form ($instance) { /* Set up some default widget settings. */ $defaults = array('numberposts' => '5','catid'=>'1','title'=>'','rss'=>''); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

get_field_id('catid').'&name='.$this->get_field_name('catid').'&selected='.$instance['catid']); ?>

/>

'; foreach($posts as $post) { $out .= '
  • '.get_the_post_thumbnail($post->ID, 'recent-thumbnails').'

    '.$post->post_title.'

    '.$post->post_excerpt.'

    '.get_the_time('F j, Y', $post->ID);'

  • '; } if ($rss) $out .= '
  • Category RSS
  • '; $out .= 'More News
    '; //print the widget for the sidebar echo $before_widget; echo $before_title.$title.$after_title; echo $out; echo $after_widget; } } function ahspfc_load_widgets() { register_widget('Posts_From_Category_Thumbnail'); } add_action('widgets_init', 'ahspfc_load_widgets'); // Widget - SHORT HEADLINE FROM SPECIFIC CATEGORY class Posts_From_Category extends WP_Widget { function Posts_From_Category() { /* Widget settings. */ $widget_ops = array( 'classname' => 'postsfromcat', 'description' => 'Allows you to display a list of recent posts from within a particular category.'); /* Widget control settings. */ $control_ops = array( 'width' => 250, 'height' => 250, 'id_base' => 'postsfromcat-widget'); /* Create the widget. */ $this->WP_Widget('postsfromcat-widget', 'Blocks Theme - Posts from a Category', $widget_ops, $control_ops ); } function form ($instance) { /* Set up some default widget settings. */ $defaults = array('numberposts' => '5','catid'=>'1','title'=>'','rss'=>''); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

    get_field_id('catid').'&name='.$this->get_field_name('catid').'&selected='.$instance['catid']); ?>

    />

    '; foreach($posts as $post) { $out .= '
  • '.$post->post_title.'
  • '; } if ($rss) $out .= '
  • Category RSS
  • '; $out .= 'More News
    '; //print the widget for the sidebar echo $before_widget; echo $before_title.$title.$after_title; echo $out; echo $after_widget; } } add_action( 'widgets_init', create_function('', 'return register_widget("Posts_From_Category");') ); // Widget - SINGLE POST WIDGET class SinglePostWidget extends WP_Widget { private $num = 5; private $domain = "single-post-widget"; function __construct() { $widget_ops = array( 'description' => __('Display single selected Post or Page from URL.', $this->domain) ); $control_ops = array('width' => 400, 'height' => 350); parent::__construct( false, __('Blocks Theme - Single Post', $this->domain), $widget_ops, $control_ops ); } public function form($instance) { // outputs the options form on admin $postid = (isset($instance['postid'])) ? $instance['postid'] : ''; $pid = $this->get_field_id('postid'); $pf = $this->get_field_name('postid'); echo '

    '; echo __("Post or Page URL", $this->domain); echo "
    "; echo ""; echo '

    '; } public function update($new_instance, $old_instance) { // processes widget options to be saved return $new_instance; } public function widget($args, $instance) { $pid = null; if (isset($instance['postid']) && preg_match("/^[0-9]+$/", $instance['postid'])) { $pid = $instance['postid']; } elseif (isset($instance['postid']) && $instance['postid']) { $pid = url_to_postid($instance['postid']); } if (!$pid) { return ''; } $tpl = ($instance['tpl']) ? $instance['tpl'] : $this->template(); if (!isset($instance['size'])) { $instance['size'] = ''; } $p = apply_filters('single_post_widget_post', get_post($pid)); echo $args['before_widget']; echo $args['before_title']; echo esc_html($p->post_title); echo $args['after_title']; $class = array( $p->post_type.'-'.$pid, $p->post_type, 'single-post-widget' ); if ($instance['size']) { $class[] = 'size-'.$instance['size']; } if ($instance['size']) { $post_thumb = get_the_post_thumbnail($pid, array(296,200)); } else { $post_thumb = get_the_post_thumbnail($pid, array(296,200)); } $tpl = str_replace('%post_title%', esc_html($p->post_title), $tpl); $tpl = str_replace('%post_excerpt%', esc_html($p->post_excerpt), $tpl); $tpl = str_replace('%post_thumb%', $post_thumb, $tpl); $tpl = str_replace('%post_url%', esc_url(get_permalink($pid)), $tpl); $tpl = str_replace('%class%', join(' ', $class), $tpl); echo $tpl; echo $args['after_widget']; } private function template() { $html = '
    '; $html .= '
    %post_thumb%
    '; $html .= '
    %post_title%
    '; $html .= '
    %post_excerpt%
    '; $html .= '
    '; return apply_filters("single-post-widget-template", $html); } } class SinglePostWidgetInit { function __construct() { add_action('widgets_init', array(&$this, "widgets_init")); add_action("plugins_loaded", array(&$this, "plugins_loaded")); add_action("wp_head", array(&$this, "wp_head")); } public function wp_head() { $url = plugins_url("", __FILE__).'/style.css'; printf( ''."\n", apply_filters("single-post-widget-stylesheet", $url) ); } public function widgets_init() { return register_widget("SinglePostWidget"); } public function plugins_loaded() { load_plugin_textdomain( "single-post-widget", false, dirname(plugin_basename(__FILE__)).'/languages' ); } } new SinglePostWidgetInit(); // Homepage Slideshow - FEATURED IMAGE SLIDER function featured_slider_template() { // Query Arguments $args = array( 'post_type' => 'slides', 'posts_per_page' => 5 ); // The Query $the_query = new WP_Query( $args ); // Check if the Query returns any posts if ( $the_query->have_posts() ) { // Start the Slider ?>
    '; bloginfo('name'); echo " > "; if (is_category() || is_single()) { the_category(' , '); if (is_single()) { echo " > "; the_title(); } } elseif (is_page()) { echo the_title(); } echo ''; } } // Related posts feature at bottom of each post function related_posts(){ global $post; $categories = get_the_category($post->ID); if ($categories) { $category_ids = array(); foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id; $args=array( 'category__in' => $category_ids, 'post__not_in' => array($post->ID), 'posts_per_page'=> 4, // Number of related posts that will be shown. 'ignore_sticky_posts'=>1 ); $my_query = new wp_query( $args ); if( $my_query->have_posts() ) { echo ''; } } wp_reset_query(); } /** * Register widgetized area and update sidebar with default widgets * * @since Blocks1.0 */ function blocks_widgets_init() { register_sidebar( array( 'name' => __( 'Advertising', 'Blocks' ), 'id' => 'advert', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Widget Area 1', 'Blocks' ), 'id' => 'sidebar-1', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Widget Area 2', 'Blocks' ), 'id' => 'sidebar-2', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Widget Area 3', 'Blocks' ), 'id' => 'sidebar-3', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Page Sidebar', 'Blocks' ), 'id' => 'sidebar-7', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Footer 1', 'Blocks' ), 'id' => 'footer1', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Footer 2', 'Blocks' ), 'id' => 'footer2', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Footer 3', 'Blocks' ), 'id' => 'footer3', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); register_sidebar( array( 'name' => __( 'Footer 4', 'Blocks' ), 'id' => 'footer4', 'before_widget' => '', 'before_title' => '

    ', 'after_title' => '

    ', ) ); } add_action( 'widgets_init', 'Blocks_widgets_init' ); /** * Enqueue scripts and styles */ function tutorial_scripts() { wp_enqueue_style( 'style', get_stylesheet_uri() ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true ); if ( is_singular() && wp_attachment_is_image() ) { wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' ); } } add_action( 'wp_enqueue_scripts', 'tutorial_scripts' ); // Create Slider Post Type require( get_template_directory() . '/inc/slider/slider_post_type.php' ); // Create Slider require( get_template_directory() . '/inc/slider/slider.php' ); // Remove Website field from comments add_filter('comment_form_default_fields', 'url_filtered'); function url_filtered($fields) { if(isset($fields['url'])) unset($fields['url']); return $fields; } /* * Helper function to return the theme option value. If no value has been saved, it returns $default. * Needed because options are saved as serialized strings. * * This code allows the theme to work without errors if the Options Framework plugin has been disabled. */ if ( !function_exists( 'of_get_option' ) ) { function of_get_option($name, $default = false) { $optionsframework_settings = get_option('optionsframework'); // Gets the unique option id $option_name = $optionsframework_settings['id']; if ( get_option($option_name) ) { $options = get_option($option_name); } if ( isset($options[$name]) ) { return $options[$name]; } else { return $default; } } } /** * Implement the Custom Header feature */ require( get_template_directory() . '/inc/custom-header.php' ); /** Adding dashboard widget to Wordpress **/ add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets'); function my_custom_dashboard_widgets() { global $wp_meta_boxes; wp_add_dashboard_widget('custom_help_widget', 'Blocks Theme Support', 'custom_dashboard_help'); } function custom_dashboard_help() { echo '

    Welcome to Blocks theme! Need help? Read the documentation or contact the developer here. For WordPress Tutorials visit: WPBeginner

    '; echo '

    If you like this theme and want to see more support and features added, then please

    '; }