add_data( 'style-ie', 'conditional', 'lt IE 9' );
//wp_die(print_r($themeOpts,true));
//If we have a custom override stylesheet, let's use it
if( !empty($themeOpts['css-path']) && file_exists(ABSPATH.$themeOpts['css-path']) ) {
wp_enqueue_style('theme_override', '/'.$themeOpts['css-path'], array('theme'), '');
}
}
//If we don't have a content width specified, assume this as default
if ( ! isset( $content_width ) ){
$content_width = 665;
}
}
/**
* 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 ctx_adventurejournal_setup() in a child theme, add your own ctx_adventurejournal_setup to your child theme's
* functions.php file.
*
* @uses add_theme_support() To add support for post thumbnails and automatic feed links.
* @uses register_nav_menus() To add support for navigation menus.
* @uses add_custom_background() To add support for a custom background.
* @uses add_editor_style() To style the visual editor.
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_custom_image_header() To add support for a custom header.
* @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 Advenure Journal 1.0
*/
function ctx_aj_setup() {
$themeOpts = get_option('ctx-adventurejournal-options');
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
// Make theme available for translation
// Translations can be filed in the /languages/ directory
load_theme_textdomain( 'adventurejournal', TEMPLATEPATH . '/languages' );
$locale = get_locale();
$locale_file = TEMPLATEPATH . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
// This theme uses wp_nav_menu() in 2 locations.
register_nav_menus( array(
'primary-menu' => __( 'Primary Menu', 'adventurejournal' ),
'footer-menu' => __( 'Footer Menu', 'adventurejournal' )
) );
// This theme allows users to set a custom background
add_custom_background();
define( 'HEADER_TEXTCOLOR', '' );
// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
define( 'HEADER_IMAGE', '%s/images/headers/ctx-header-egypt.jpg' );
//Get the theme options
$themeOpts = get_option('ctx-adventurejournal-options');
$theme_header_height = $themeOpts['header-height'];
//Check and see if the custom header size is set, if not use the default value of 360
if(!isset($theme_header_height)){
$theme_header_height = 360;
}
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
// Add a filter to adventurejournal_header_image_width and adventurejournal_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'adventurejournal_header_image_width', 920 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'adventurejournal_header_image_height', $theme_header_height ) );
//Set post thumbnail sizes depending on layout
switch ($themeOpts['layout']) {
case 'col-2-left':
case 'col-2-right':
set_post_thumbnail_size( 665, 130, true );
break;
case 'col-3':
case 'col-3-left':
set_post_thumbnail_size( 485, 94, true );
break;
default:
// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be 920 pixels wide by 180 pixels tall.
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( 920, 180, true );
break;
}
// Don't support text inside the header image.
define( 'NO_HEADER_TEXT', true );
// This theme allows users to set a custom image header
add_custom_image_header('', 'ctx_aj_admin_header_style');
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'egypt' => array(
'url' => '%s/images/headers/ctx-header-egypt.jpg',
'thumbnail_url' => '%s/images/headers/ctx-header-egypt-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Egypt', 'adventurejournal' )
),
'cart' => array(
'url' => '%s/images/headers/ctx-header-cart.jpg',
'thumbnail_url' => '%s/images/headers/ctx-header-cart-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Cart', 'adventurejournal' )
),
'flower' => array(
'url' => '%s/images/headers/ctx-header-flower.jpg',
'thumbnail_url' => '%s/images/headers/ctx-header-flower-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Flower', 'adventurejournal' )
),
'hut' => array(
'url' => '%s/images/headers/ctx-header-hut.jpg',
'thumbnail_url' => '%s/images/headers/ctx-header-hut-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Hut', 'adventurejournal' )
)
));
if ( function_exists('register_sidebar') ){
switch ($themeOpts['layout']) {
case 'col-2-left':
case 'col-2-right':
/** 2 COL LAYOUTS **/
//Page Sidebar
register_sidebar(array(
'name'=>'Page Sidebar',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
//Blog Sidebar
register_sidebar(array(
'name'=>'Blog Sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
break;
case 'col-3':
case 'col-3-left':
/** 3 COL LAYOUT **/
//Blog Sidebar
register_sidebar(array(
'name'=>'Page Sidebar (Left)',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Page Sidebar (Right)',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Blog Sidebar (Left)',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Blog Sidebar (Right)',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '
',
));
break;
default:break;
}
}
//Create the default theme options
ctx_aj_set_options();
}
/**
* Styles the header image displayed on the Appearance > Header admin panel.
*
* Referenced via add_custom_image_header() in ctx_adventurejournal_setup().
*
* @since Adventure Journal 1.0
*/
function ctx_aj_admin_header_style() {
//echo ''; //Warning: This would go at top of screen
}
/**
* Returns a "Continue Reading" link for excerpts
*
* @return string "Continue Reading" link
*/
function ctx_aj_continue_reading_link() {
return ' ' . __( 'Continue reading »', 'adventurejournal' ) . '';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and adventuretheme_continue_reading_link().
*
* @param $more
* @return
*/
function ctx_aj_auto_excerpt_more( $more ) {
return ' &hellip' . ctx_aj_continue_reading_link();
}
/**
* 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.
*
* @return string Excerpt with a pretty "Continue Reading" link
*/
function ctx_aj_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= ctx_aj_continue_reading_link();
}
return $output;
}
/**
* Handles creating or updating the options array for the theme
*
* @param array $array_overrides An associative array containing key=>value pairs to override originals
* @return string
*/
function ctx_aj_set_options($arrayOverrides=false){
//Set defaults
$defaultOpts = array(
'layout'=>'col-2-left',
'custom_css'=>'',
'attrib'=>'true',
'showtitle'=>'true',
'title-type'=>'title-default'
);
//Let's see if the options already exist...
$dbOpts = get_option('ctx-adventurejournal-options');
if(!$dbOpts){
//There's no options! Let's build them...
if($arrayOverrides!=false && is_array($arrayOverrides)){
//If we have some custom settings, use those
$defaultOpts = array_merge($defaultOpts, $arrayOverrides);
}
//Now add them to the db
return add_option('ctx-adventurejournal-options',$defaultOpts);
}else{
//db options exist, so let's merge it with the defaults (just to be sure we have all the latest options
$defaultOpts = array_merge($defaultOpts, $dbOpts);
//Now let's add our custom settings (if appropriate)
if($arrayOverrides!=false && is_array($arrayOverrides)){
//If we have some custom settings, use those
$defaultOpts = array_merge($defaultOpts, $arrayOverrides);
}
return update_option('ctx-adventurejournal-options',$defaultOpts);
}
}
/**
* This snippet creates an ID and a series of classes for the body tag based on the nested URL structure which recreates the
* sites child parent relationships. This allows you to control elements via CSS on a per page and per section basis
*
* @param int $postID The id of the post get relationships for
* @return string Returns a string containing html attributes for the body tag
*/
function ctx_aj_get_relationships($postID='',$extraclass=''){
// Remove any leading and trailing slashes.
$uri_path = trim($_SERVER['REQUEST_URI'], '/');
// Split up the remaining URI into an array, using '/' as delimiter.
$uri_parts = explode('/', $uri_path);
// If this is the homepage, set ID and class accordingly
if ($uri_parts[0] == '') {
$ancestor = 'homepage';
$body_class = 'index';
} else {
// Construct the class name from the first part of the URI only.
$body_class = str_replace('/',' page-', $uri_path);
//Generate an array of this pages parents based on the variable passed in the function
$myAncestors = get_post_ancestors($postID);
//Grab the top most parent's ID out of the array
$ancestor = (count($myAncestors)>0) ? $myAncestors[(count($myAncestors)-1)] : 0;
//If the current page IS a top level parent then grab it's own ID since it would otherwise be blank
if( empty($ancestor) ){$ancestor = $postID;}
}
$body_class = $extraclass.' ';
//Prefix body classes with "page-"
$body_class .= 'page-'.$body_class;
//Generate the ID and Class tags
return 'id="ancestor-'.$ancestor.'" class="'.$body_class.'"';
}
/**
* This snippet echos/displays a link in the wp_footer section with a link back back to the theme's creator and WordPress.
*
* You can remove this from footer.php if you really want to, but we'd REALLY appreciate if you left it in there. ;-)
*
* @return Prints HTML for the footer's attribution.
*/
function ctx_attribution() {
$themeOpts = get_option('ctx-adventurejournal-options');
?>
id="comment-">
comment_approved == '0') _e("\t\t\t\t\tYour comment is awaiting moderation.\n", 'adventurejournal') ?>
',$sidebar_class);
if ( function_exists('dynamic_sidebar') ){
dynamic_sidebar($sidebar_name);
}
echo '
';
}
/**
* Add's "Layout" option to the theme-options/Appearance nav menu
*/
function ctx_aj_theme_add_pages() {
// Add a new submenu under Appearance:
add_theme_page(__('Layout','adventurejournal'), __('Layout','adventurejournal'), 'edit_theme_options', 'theme-layouts', 'ctx_aj_options_appearance_layout');
//add_theme_page(, __('Advanced','adventurejournal'), 'administrator', 'theme-options', 'ctx_aj_options_adventurejournal');
add_theme_page(__('Adventure Journal','adventurejournal'), __('Adventure Journal','adventurejournal'), 'edit_theme_options', 'z-adventurejournal', 'ctx_aj_options_adventurejournal');
}
/**
* Shows "choose layout" page in Appearance Meny
*/
function ctx_aj_options_appearance_layout() {
require_once 'admin/appearance-layout.php';
}
/**
* Shows "choose layout" page in Appearance Meny
*/
function ctx_aj_options_adventurejournal() {
require_once 'admin/options.php';
}
/**
* Prints HTML with meta information for the current post—date/time and author.
*/
function ctx_aj_posted_on() {
printf( __( 'Posted on %2$s by %3$s', 'adventurejournal' ),
'meta-prep meta-prep-author',
sprintf( '%3$s',
get_permalink(),
esc_attr( get_the_time() ),
get_the_date()
),
sprintf( '%3$s',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
sprintf( esc_attr__( 'View all posts by %s', 'adventurejournal' ), get_the_author() ),
get_the_author()
)
);
}
/**
* This adds contextual help to the theme
*/
function ctx_aj_help_theme_options(){
//Add contextual help to this page
add_contextual_help( 'appearance_page_theme-options', __('Adventure Journal supports different page layouts without any additional coding. Simply select the layout you want to use on your site and click Save Changes.') );
}
/**
* Controls the display options for the site title and description. This function lets users turn off the paperclip or use a logo instead.
*/
function ctx_aj_site_title(){
//Get the theme options
$themeOpts = get_option('ctx-adventurejournal-options');
$themeTitle = $themeOpts['title-type'];
//Check if a site title option has been set, if not use the default value
if (!isset($themeTitle)){
$themeTitle = 'title-default';
}
//Check and see if the site title option is set to default or custom logo option
if($themeTitle == 'title-default' || $themeTitle == 'title-logo'){
?>
%s',$sitedescr);
//Display the custom logo
} else {
?>
|