* add_action( 'after_setup_theme', 'my_child_theme_setup' );
* function my_child_theme_setup() {
* // We are providing our own filter for excerpt_length (or using the unfiltered value)
* remove_filter( 'excerpt_length', 'catchbox_excerpt_length' );
* ...
* }
*
*
* For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
*
* @package Catch Themes
* @subpackage Catch_Box
* @since Catch Box 1.0
*/
/**
* Tell WordPress to run catchbox_setup() when the 'after_setup_theme' hook is run.
*/
add_action( 'after_setup_theme', 'catchbox_setup' );
if ( ! function_exists( 'catchbox_setup' ) ):
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* To override catchbox_setup() in a child theme, add your own catchbox_setup to your child theme's
* functions.php file.
*
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_editor_style() To style the visual editor.
* @uses add_theme_support() To add support for post thumbnails, automatic feed links,custom headers and backgrounds.
* @uses register_nav_menus() To add support for navigation menus.
* @uses register_default_headers() To register the default custom header images provided with the theme.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
* @since Catch Box 1.0
*/
function catchbox_setup() {
/**
* Global content width.
*
* Set the content width based on the theme's design and stylesheet.
* making it large as we have template without sidebar which is large
*/
if ( ! isset( $content_width ) )
$content_width = 818;
/* Catch Box is now available for translation.
* Add your files into /languages/ directory.
* @see http://codex.wordpress.org/Function_Reference/load_theme_textdomain
*/
load_theme_textdomain( 'catchbox', get_template_directory() . '/languages' );
$locale = get_locale();
$locale_file = get_template_directory().'/languages/$locale.php';
if (is_readable( $locale_file))
require_once( $locale_file);
/**
* Add callback for custom TinyMCE editor stylesheets. (editor-style.css)
* @see http://codex.wordpress.org/Function_Reference/add_editor_style
*/
add_editor_style();
// Load up our theme options page and related code.
require( get_template_directory() . '/inc/theme-options.php' );
// Grab Catch Box's Adspace Widget.
require( get_template_directory() . '/inc/widgets.php' );
// Add default posts and comments RSS feed links to
.
add_theme_support( 'automatic-feed-links' );
/**
* This feature enables custom-menus support for a theme.
* @see http://codex.wordpress.org/Function_Reference/register_nav_menus
*/
register_nav_menus(array(
'primary' => __( 'Primary Menu', 'catchbox' ),
'secondary' => __( 'Secondary Menu', 'catchbox' ),
'footer' => __( 'Footer Menu', 'catchbox' )
) );
// Add support for custom backgrounds
// WordPress 3.4+
if ( function_exists( 'get_custom_header') ) {
add_theme_support( 'custom-background' );
} else {
// Backward Compatibility for WordPress Version 3.3
add_custom_background();
}
/**
* This feature enables post-thumbnail support for a theme.
* @see http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
// The next four constants set how Catch Boxsupports custom headers.
// The default header text color
define( 'HEADER_TEXTCOLOR', '000' );
// By leaving empty, we allow for random image rotation.
define( 'HEADER_IMAGE', '' );
// The height and width of your custom header used for site logo.
// Add a filter to catchbox_header_image_width and catchbox_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'catchbox_header_image_width', 300 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'catchbox_header_image_height', 125 ) );
// We'll be using post thumbnails for custom header images for logos.
// We want them to be the size of the header image that we just defined
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
// Add Catch Box's custom image sizes
add_image_size( 'featured-header', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for logo (header) images
//disable old image size for featued posts add_image_size( 'featured-slider', 560, 270, true );
add_image_size( 'featured-slider', 644, 320, true ); // Used for featured posts if a large-feature doesn't exist
// Add support for custom backgrounds
// WordPress 3.4+
if ( function_exists( 'get_custom_header') ) {
add_theme_support( 'custom-header', array(
// Header image random rotation default
'random-default' => false,
// Header image flex width
'flex-width' => true,
// Header image flex height
'flex-height' => true,
// Template header style callback
'wp-head-callback' => 'catchbox_header_style',
// Admin header style callback
'admin-head-callback' => 'catchbox_admin_header_style',
// Admin preview style callback
'admin-preview-callback' => 'catchbox_admin_header_image'
) );
} else {
// Backward Compatibility for WordPress Version 3.3
// Add a way for the custom header to be styled in the admin panel that controls
// custom headers. See catchbox_admin_header_style(), below.
add_custom_image_header( 'catchbox_header_style', 'catchbox_admin_header_style', 'catchbox_admin_header_image' );
}
// ... and thus ends the changeable header business.
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'wheel' => array(
'url' => '%s/images/headers/garden.jpg',
'thumbnail_url' => '%s/images/headers/garden-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Garden', 'catchbox' )
),
'shore' => array(
'url' => '%s/images/headers/flower.jpg',
'thumbnail_url' => '%s/images/headers/flower-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Flower', 'catchbox' )
),
'trolley' => array(
'url' => '%s/images/headers/mountain.jpg',
'thumbnail_url' => '%s/images/headers/mountain-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Mountain', 'catchbox' )
),
) );
}
endif; // catchbox_setup
if ( ! function_exists( 'catchbox_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog
*
* @since Catch Box 1.0
*/
function catchbox_header_style() {
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail.
if ( $text_color == HEADER_TEXTCOLOR )
return;
// If we get this far, we have custom styles. Let's do this.
?>
Header admin panel.
*
* @since Catch Box 1.0
*/
function catchbox_admin_header_style() {
?>
Header admin panel.
*
* @since Catch Box 1.0
*/
function catchbox_admin_header_image() { ?>
= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'catchbox' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'catchbox_filter_wp_title', 10, 2 );
/**
* Sets the post excerpt length.
*
* To override this length in a child theme, remove the filter and add your own
* function tied to the excerpt_length filter hook.
*/
function catchbox_excerpt_length( $length ) {
$options = catchbox_get_theme_options();
if( empty( $options['excerpt_length'] ) )
$options = catchbox_get_default_theme_options();
$length = $options['excerpt_length'];
return $length;
}
add_filter( 'excerpt_length', 'catchbox_excerpt_length' );
/**
* Returns a "Continue Reading" link for excerpts
*/
function catchbox_continue_reading_link() {
return ' ' . __( 'Continue reading →', 'catchbox' ) . '';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and catchbox_continue_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*/
function catchbox_auto_excerpt_more( $more ) {
return catchbox_continue_reading_link();
}
add_filter( 'excerpt_more', 'catchbox_auto_excerpt_more' );
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*
* To override this link in a child theme, remove the filter and add your own
* function tied to the get_the_excerpt filter hook.
*/
function catchbox_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= catchbox_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'catchbox_custom_excerpt_more' );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*/
function catchbox_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'catchbox_page_menu_args' );
/**
* Register our sidebars and widgetized areas. Also register the default Epherma widget.
*
* @since Catch Box 1.0
*/
function catchbox_widgets_init() {
register_widget( 'catchbox_adwidget' );
register_sidebar( array(
'name' => __( 'Main Sidebar', 'catchbox' ),
'id' => 'sidebar-1',
'before_widget' => '",
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Area One', 'catchbox' ),
'id' => 'sidebar-2',
'description' => __( 'An optional widget area for your site footer', 'catchbox' ),
'before_widget' => '",
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Area Two', 'catchbox' ),
'id' => 'sidebar-3',
'description' => __( 'An optional widget area for your site footer', 'catchbox' ),
'before_widget' => '",
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer Area Three', 'catchbox' ),
'id' => 'sidebar-4',
'description' => __( 'An optional widget area for your site footer', 'catchbox' ),
'before_widget' => '",
'before_title' => '
',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'catchbox_widgets_init' );
if ( ! function_exists( 'catchbox_content_nav' ) ) :
/**
* Display navigation to next/previous pages when applicable
*/
function catchbox_content_nav( $nav_id ) {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) { ?>
]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
return false;
return esc_url_raw( $matches[1] );
}
/**
* Count the number of footer sidebars to enable dynamic classes for the footer
*/
function catchbox_footer_sidebar_class() {
$count = 0;
if ( is_active_sidebar( 'sidebar-2' ) )
$count++;
if ( is_active_sidebar( 'sidebar-3' ) )
$count++;
if ( is_active_sidebar( 'sidebar-4' ) )
$count++;
$class = '';
switch ( $count ) {
case '1':
$class = 'one';
break;
case '2':
$class = 'two';
break;
case '3':
$class = 'three';
break;
}
if ( $class )
echo 'class="' . $class . '"';
}
if ( ! function_exists( 'catchbox_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own catchbox_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Catch Box 1.0
*/
function catchbox_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>