Пример #1
0
/**
 * Get a Carrington Framework option, load the default otherwise
 *
 * @param string $name Name of the option to retrieve
 * @return mixed Value of the option
 * 
**/
function cfct_get_option($name)
{
    $defaults = array(cfct_option_name('login_link_enabled') => 'yes', cfct_option_name('copyright') => sprintf(__('Copyright © %s  ·  %s', 'carrington'), date('Y'), get_bloginfo('name')), cfct_option_name('credit') => 'yes', cfct_option_name('lightbox') => 'yes', cfct_option_name('header_image') => 0);
    $name = cfct_option_name($name);
    $defaults = apply_filters('cfct_option_defaults', $defaults);
    $value = get_option($name);
    // We want to check for defaults registered using the prefixed and unprefixed versions of the option name.
    if ($value === false) {
        $prefix = cfct_get_option_prefix();
        $basname = substr($name, strlen($prefix) + 1, -1);
        if (isset($defaults[$name])) {
            $value = $defaults[$name];
        } else {
            if (isset($basename) && isset($defaults[$basename])) {
                $value = $defaults[$basename];
            }
        }
    }
    return $value;
}
Пример #2
0
/**
 * Display a form for image header customization
 *
 * @return string Markup displaying the form
 *
**/
function cfct_header_image_form()
{
    global $wpdb;
    $images = $wpdb->get_results("\n\t\tSELECT * FROM {$wpdb->posts}\n\t\tWHERE post_type = 'attachment'\n\t\tAND post_mime_type LIKE 'image%'\n\t\tAND post_parent = 0\n\t\tORDER BY post_date_gmt DESC\n\t\tLIMIT 50\n\t");
    $upload_url = admin_url('media-new.php');
    $header_image = cfct_get_option('header_image');
    if (empty($header_image)) {
        $header_image = 0;
    }
    $output = '
<ul style="width: ' . (count($images) + 1) * 152 . 'px">
	<li style="background: #666;">
		<label for="cfct_header_image_0">
			<input type="radio" name="' . esc_attr(cfct_option_name('header_image')) . '" value="0" id="' . esc_attr(cfct_option_name('header_image_0')) . '" ' . checked($header_image, 0, false) . '/>' . __('No Image', 'carrington-core') . '
		</label>
	</li>
	';
    if (count($images)) {
        foreach ($images as $image) {
            $id = cfct_option_name('header_image_' . $image->ID);
            $thumbnail = wp_get_attachment_image_src($image->ID);
            $output .= '
	<li style="background-image: url(' . $thumbnail[0] . ')">
		<label for="' . $id . '">
			<input type="radio" name="' . esc_attr(cfct_option_name('header_image')) . '" value="' . $image->ID . '" id="' . $id . '"' . checked($header_image, $image->ID, false) . ' />' . esc_html($image->post_title) . '
		</label>
	</li>';
        }
    }
    $output .= '</ul>';
    return '<p>' . sprintf(__('Header Image &mdash; <a href="%s">Upload Images</a>', 'carrington-core'), $upload_url) . '</p><div class="cfct_header_image_carousel">' . $output . '</div>';
}
Пример #3
0
/**
 * Filter for registering defaults of cfcp_options.
 */
function cfcp_option_defaults($defaults)
{
    $defaults[cfct_option_name('social_enabled')] = 'yes';
    $defaults[cfct_option_name('cfcp_header_options')] = array('posts' => array('_1' => null, '_2' => null, '_3' => null), 'type' => 'featured');
    return $defaults;
}