__( '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' );
// 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', 360 ) );
// 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( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT/2, true );
// 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' )
)
));
//Choose which sidebars the user can add widgets to
if ( function_exists('register_sidebar') ){
//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' => '',
));
}
//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() {
?>
' . __( '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"
);
//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=''){
// 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;}
}
//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
*/
function ctx_attribution() {
?>
$comment
* @param $args
* @param $depth
*/
function ctx_aj_get_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
id="comment-">
comment_approved == '0') _e("\t\t\t\t\tYour comment is awaiting moderation.\n", 'sandbox') ?>
',$sidebar_html);
$generic_sidebar = (!function_exists('dynamic_sidebar') || !dynamic_sidebar($sidebar_name) ) ? true : false;
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', 'Layout', 'administrator', 'theme-options', 'ctx_aj_options_appearance_layout');
}
/**
* Shows "choose layout" page in Appearance Meny
*/
function ctx_aj_options_appearance_layout() {
require_once 'admin/appearance-layout.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', 'adventuretheme' ),
'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', 'adventuretheme' ), 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.') );
}
?>