Skip to content
This repository
tree: c33b812e12
Fetching contributors…

Cannot retrieve contributors at this time

file 87 lines (73 sloc) 3.87 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
<?php
/**
* Functions for dealing with theme settings on both the front end of the site and the admin. This allows us
* to set some default settings and make it easy for theme developers to quickly grab theme settings from
* the database. This file is only loaded if the theme adds support for the 'hybrid-core-theme-settings'
* feature.
*
* @package HybridCore
* @subpackage Functions
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2008 - 2012, Justin Tadlock
* @link http://themehybrid.com/hybrid-core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/

/**
* Loads the Hybrid theme settings once and allows the input of the specific field the user would
* like to show. Hybrid theme settings are added with 'autoload' set to 'yes', so the settings are
* only loaded once on each page load.
*
* @since 0.7.0
* @access public
* @uses get_option() Gets an option from the database.
* @uses hybrid_get_prefix() Gets the prefix of the theme.
* @global object $hybrid The global Hybrid object.
* @param string $option The specific theme setting the user wants.
* @return mixed $settings[$option] Specific setting asked for.
*/
function hybrid_get_setting( $option = '' ) {
global $hybrid;

/* If no specific option was requested, return false. */
if ( !$option )
return false;

/* If the settings array hasn't been set, call get_option() to get an array of theme settings. */
if ( !isset( $hybrid->settings ) )
$hybrid->settings = get_option( hybrid_get_prefix() . '_theme_settings', hybrid_get_default_theme_settings() );

/* If the settings isn't an array or the specific option isn't in the array, return false. */
if ( !is_array( $hybrid->settings ) || empty( $hybrid->settings[$option] ) )
return false;

/* If the specific option is an array, return it. */
if ( is_array( $hybrid->settings[$option] ) )
return $hybrid->settings[$option];

/* Strip slashes from the setting and return. */
else
return wp_kses_stripslashes( $hybrid->settings[$option] );
}

/**
* Sets up a default array of theme settings for use with the theme. Theme developers should filter the
* "{$prefix}_default_theme_settings" hook to define any default theme settings. WordPress does not
* provide a hook for default settings at this time.
*
* @since 1.0.0
* @access public
* @return array $settings The default theme settings.
*/
function hybrid_get_default_theme_settings() {

/* Set up some default variables. */
$settings = array();
$prefix = hybrid_get_prefix();

/* Get theme-supported meta boxes for the settings page. */
$supports = get_theme_support( 'hybrid-core-theme-settings' );

/* If the current theme supports the footer meta box and shortcodes, add default footer settings. */
if ( is_array( $supports[0] ) && in_array( 'footer', $supports[0] ) && current_theme_supports( 'hybrid-core-shortcodes' ) ) {

/* If there is a child theme active, add the [child-link] shortcode to the $footer_insert. */
if ( is_child_theme() )
$settings['footer_insert'] = '<p class="copyright">' . __( 'Copyright &#169; [the-year] [site-link].', 'hybrid-core' ) . '</p>' . "\n\n" . '<p class="credit">' . __( 'Powered by [wp-link], [theme-link], and [child-link].', 'hybrid-core' ) . '</p>';

/* If no child theme is active, leave out the [child-link] shortcode. */
else
$settings['footer_insert'] = '<p class="copyright">' . __( 'Copyright &#169; [the-year] [site-link].', 'hybrid-core' ) . '</p>' . "\n\n" . '<p class="credit">' . __( 'Powered by [wp-link] and [theme-link].', 'hybrid-core' ) . '</p>';
}

/* Return the $settings array and provide a hook for overwriting the default settings. */
return apply_filters( "{$prefix}_default_theme_settings", $settings );
}

?>
Something went wrong with that request. Please try again.