* add_action( 'after_setup_theme', 'my_child_theme_setup' ); * function my_child_theme_setup() { * * remove_filter('filter_hook', 'callback_function' ); * ... * } * * * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API. * * @package WordPress * @subpackage Graphene * @since Graphene 1.0 */ /** * Retrieve the theme's user settings and default settings. Individual files can access * these setting via a global variable call, so database query is only * done once. * */ include('admin/options-defaults.php'); $graphene_settings = get_option('graphene_settings'); /** * If there is no theme settings in the database yet (e.g. first install), add the database entry. */ if (!function_exists('graphene_db_init')) : function graphene_db_init(){ global $graphene_settings, $graphene_defaults; /* Run DB updater if $graphene_settings does not exist in db */ if (!$graphene_settings){ // For first install if (get_option('graphene_ga_code') === false) { update_option('graphene_settings', $graphene_defaults); $graphene_settings = $graphene_defaults; } else { // For updates include('admin/db-updater.php'); graphene_update_db(); $graphene_settings = get_option('graphene_settings'); } /* $graphene_settings exists, but new options has been added since previous version */ } elseif (count($graphene_settings) != count($graphene_defaults)) { $initial_settings = array(); // Construct the updated settings foreach ($graphene_defaults as $option => $value) : $updated_settings[$option] = (array_key_exists($option, $graphene_settings)) ? $graphene_settings[$option] : $value; endforeach; // Add the initial settings to the database update_option('graphene_settings', $updated_settings); // Update the global $graphene_settings; $graphene_settings = $updated_settings; } } endif; add_action('init', 'graphene_db_init'); /** * Set the content width based on the theme's design and stylesheet. * * Used to set the width of images and content. Should be equal to the width the theme * is designed for, generally via the style.css stylesheet. */ if (!isset($content_width)){ $column_mode = graphene_column_mode(); if (strpos($graphene_settings['post_date_display'], 'icon') === 0){ if (strpos($column_mode, 'two-col') === 0){ $content_width = apply_filters('graphene_content_width_two_columns', 590); } else if (strpos($column_mode, 'three-col-center') === 0) { $content_width = apply_filters('graphene_content_width_three_columns_center', 360); } else if (strpos($column_mode, 'three-col') === 0){ $content_width = apply_filters('graphene_content_width_three_columns', 375); } else { $content_width = apply_filters('graphene_content_width_one_columns', 875); } } else { if (strpos($column_mode, 'two-col') === 0){ $content_width = apply_filters('graphene_content_width_two_columns_nodate', 645); } else if (strpos($column_mode, 'three-col-center') === 0) { $content_width = apply_filters('graphene_content_width_three_columns_center_nodate', 415); } else if (strpos($column_mode, 'three-col') === 0){ $content_width = apply_filters('graphene_content_width_three_columns_nodate', 430); } else { $content_width = apply_filters('graphene_content_width_one_columns_nodate', 930); } } } /** Tell WordPress to run graphene_setup() when the 'after_setup_theme' hook is run. */ add_action('after_setup_theme', 'graphene_setup' ); if (!function_exists( 'graphene_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 graphene_setup() in a child theme, add your own graphene_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 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 Graphene 1.0 */ function graphene_setup() { global $graphene_settings; // Define the theme's database version define('GRAPHENE_DBVERSION', 1.0); // Add the theme's dbversion in the database if none exist if (!get_option('graphene_dbversion')) {update_option('graphene_dbversion', GRAPHENE_DBVERSION);} // Add custom image sizes $height = ($graphene_settings['slider_height']) ? $graphene_settings['slider_height'] : 240; add_image_size('graphene_slider', apply_filters('graphene_slider_image_width', 660), $height, true); add_image_size('graphene_slider_full', apply_filters('graphene_slider_full_image_width', 930), $height, true); add_image_size('graphene_slider_small', apply_filters('graphene_slider_small_image_width', 445), $height, true); // Add support for editor syling add_editor_style(); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); // Make theme available for translation // Translations can be filed in the /languages/ directory load_theme_textdomain( 'graphene', get_template_directory().'/languages' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'Header Menu' => __('Header Menu', 'graphene'), 'secondary-menu' => __('Secondary Menu', 'graphene'), ) ); // This theme allows users to set a custom background add_custom_background(); // Your changeable header business starts here define('HEADER_TEXTCOLOR', apply_filters('graphene_header_textcolor', '000000')); // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI. define('HEADER_IMAGE', apply_filters('graphene_header_image', '%s/images/headers/flow.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 graphene_header_image_width and graphene_header_image_height to change these values. define('HEADER_IMAGE_WIDTH', apply_filters('graphene_header_image_width', 960)); define('HEADER_IMAGE_HEIGHT', apply_filters('graphene_header_image_height', 198)); // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be 940 pixels wide by 198 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, true); // Don't support text inside the header image. define('NO_HEADER_TEXT', apply_filters('graphene_header_text', false)); // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See graphene_admin_header_style(), below. add_custom_image_header('', 'graphene_admin_header_style'); // ... 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( graphene_get_default_headers() ); do_action('graphene_setup'); } endif; function graphene_get_default_headers() { return array( 'Schematic' => array( 'url' => '%s/images/headers/schematic.jpg', 'thumbnail_url' => '%s/images/headers/schematic-thumb.jpg', /* translators: header image description */ 'description' => __('Header image by Syahir Hakim', 'graphene') ), 'Flow' => array( 'url' => '%s/images/headers/flow.jpg', 'thumbnail_url' => '%s/images/headers/flow-thumb.jpg', /* translators: header image description */ 'description' => __('This is the default Graphene theme header image, cropped from image by Quantin Houyoux at sxc.hu', 'graphene') ), 'Fluid' => array( 'url' => '%s/images/headers/fluid.jpg', 'thumbnail_url' => '%s/images/headers/fluid-thumb.jpg', /* translators: header image description */ 'description' => __('Header image cropped from image by Ilco at sxc.hu', 'graphene') ), 'Techno' => array( 'url' => '%s/images/headers/techno.jpg', 'thumbnail_url' => '%s/images/headers/techno-thumb.jpg', /* translators: header image description */ 'description' => __('Header image cropped from image by Ilco at sxc.hu', 'graphene') ), 'Fireworks' => array( 'url' => '%s/images/headers/fireworks.jpg', 'thumbnail_url' => '%s/images/headers/fireworks-thumb.jpg', /* translators: header image description */ 'description' => __('Header image cropped from image by Ilco at sxc.hu', 'graphene') ), 'Nebula' => array( 'url' => '%s/images/headers/nebula.jpg', 'thumbnail_url' => '%s/images/headers/nebula-thumb.jpg', /* translators: header image description */ 'description' => __('Header image cropped from image by Ilco at sxc.hu', 'graphene') ), 'Sparkle' => array( 'url' => '%s/images/headers/sparkle.jpg', 'thumbnail_url' => '%s/images/headers/sparkle-thumb.jpg', /* translators: header image description */ 'description' => __('Header image cropped from image by Ilco at sxc.hu', 'graphene') ), ); } /** * Register and print the main theme stylesheet */ function graphene_main_stylesheet(){ wp_register_style('graphene-stylesheet', get_stylesheet_uri(), array(), false, 'screen'); wp_enqueue_style('graphene-stylesheet'); } add_action('wp_print_styles', 'graphene_main_stylesheet'); if (!function_exists('graphene_admin_header_style')) : /** * Styles the header image displayed on the Appearance > Header admin panel. * * Referenced via add_custom_image_header() in graphene_setup(). * * @since graphene 1.0 */ function graphene_admin_header_style(){ ?>
'General')){ $links = array(); foreach( $tabs as $tab => $name) : if ( $tab == $current ) : $links[] = "$name"; else : $links[] = "$name"; endif; endforeach; echo '
'.$more_link_text.''; } } endif; /** * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and graphene_continue_reading_link(). * Based on the function from Twenty Ten theme. * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. * * @since Graphene 1.0.8 * @return string An ellipsis */ function graphene_auto_excerpt_more($more) { return apply_filters('graphene_auto_excerpt_more', ' … '.graphene_continue_reading_link()); } add_filter('excerpt_more', 'graphene_auto_excerpt_more' ); /** * Add the Read More link to manual excerpts * * @since Graphene 1.1.3 */ function graphene_manual_except_more($text){ if (has_excerpt()){ $text = explode('
', $text); $text[count($text)-2] .= graphene_auto_excerpt_more(''); $text = implode('', $text); } return $text; } if ($graphene_settings['show_excerpt_more']) { add_filter('the_excerpt', 'graphene_manual_except_more'); } /** * Generates the posts navigation links */ if (!function_exists('graphene_posts_nav')) : function graphene_posts_nav(){ ?> tag of the the slider image. * * It requires the post's ID to be passed in as argument so that the user settings in * individual post / page can be retrieved. */ if (!function_exists('graphene_get_slider_image')) : function graphene_get_slider_image($post_id = NULL, $size = 'thumbnail', $urlonly = false){ global $graphene_settings; // Throw an error message if no post ID supplied if ($post_id == NULL){ echo 'ERROR: Post ID must be passed as an input argument to call the functiongraphene_get_slider_image()
.';
return;
}
// First get the settings
$global_setting = ($graphene_settings['slider_img']) ? $graphene_settings['slider_img'] : 'featured_image';
$local_setting = (get_post_meta($post_id, '_graphene_slider_img', true)) ? get_post_meta($post_id, '_graphene_slider_img', true) : 'global';
// Determine which image should be displayed
$final_setting = ($local_setting == 'global') ? $global_setting : $local_setting;
// Build the html based on the final setting
$html = '';
if ($final_setting == 'disabled'){ // image disabled
return;
} elseif ($final_setting == 'featured_image'){ // Featured Image
if (has_post_thumbnail($post_id)) :
if ($urlonly)
$html = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size);
else
$html .= get_the_post_thumbnail($post_id, $size);
/* Disabling the default image. Seems like it's more trouble than worth it
elseif (!$urlonly) :
$html .= apply_filters('graphene_generic_slider_img', ' elements.
* For development and debugging use
*/
function disect_it($var = NULL, $exit = true, $comment = false){
if ($var !== NULL){
if ($comment) {echo '';}
if ($exit) {exit();}
} else {
echo 'ERROR: You must pass a variable as argument to the disect_it()
function.';
}
}
?>