Example #1
0
/**
 * This function/filter adds new classes to the <body>
 * so that we can use psuedo-variables in our CSS file,
 * which helps us achieve multiple header layouts with minimal code
 *
 * @since 0.2.2
 */
function calibrefx_header_body_classes($classes)
{
    // add header classes to $classes array
    if (!is_active_sidebar('header-right')) {
        $classes[] = 'header-full-width';
    }
    if (current_theme_supports('calibrefx-custom-header') && ('image' == calibrefx_get_option('blog_title') || 'blank' == get_header_textcolor())) {
        $classes[] = 'header-image';
    }
    if (calibrefx_is_responsive_enabled()) {
        $classes[] = 'responsive';
    } else {
        $classes[] = 'non-responsive';
    }
    if (calibrefx_layout_is_fluid()) {
        $classes[] = 'fluid';
    } else {
        $classes[] = 'static';
    }
    $custom_body = calibrefx_get_custom_field('_calibrefx_custom_body_class');
    if (!empty($custom_body)) {
        $classes[] = $custom_body;
    }
    // return filtered $classes
    return $classes;
}
Example #2
0
/**
 * Output All the meta options based on given metabox id
 *
 * @param  Object $settings_obj Screen Object
 * @param  string $metabox_id   Meta box id
 * @return void
 */
function calibrefx_do_post_meta_options($slug)
{
    global $calibrefx_post_meta_options, $calibrefx;
    if (empty($calibrefx_post_meta_options[$slug])) {
        return;
    }
    do_action($slug . '_options');
    $calibrefx->load->library('form');
    foreach ($calibrefx_post_meta_options[$slug] as $options) {
        if (empty($options)) {
            continue;
        }
        ksort($options);
        foreach ($options as $option_priority) {
            foreach ($option_priority as $option_name => $option) {
                //backward compatibility
                if (empty($option['option_attr'])) {
                    $option['option_attr'] = array();
                }
                $attr = '';
                foreach ($option['option_attr'] as $key => $val) {
                    $attr .= ' ' . $key . '="' . $val . '"';
                }
                ?>
            <p <?php 
                echo $attr;
                ?>
 >
                <?php 
                switch ($option['option_type']) {
                    case 'hidden':
                        echo $calibrefx->form->hidden($option_name, calibrefx_get_custom_field($option_name), $option['option_attr']);
                        break;
                    case 'text':
                    case 'textinput':
                    case 'textarea':
                    case 'password':
                        //we need to extract the class from the array
                        $classes = '';
                        if (isset($option['option_attr']['class'])) {
                            $classes = $option['option_attr']['class'];
                            unset($option['option_attr']['class']);
                        }
                        echo '<label for="' . $option_name . '">' . $option['option_label'] . '</label> ';
                        echo $calibrefx->form->{$option['option_type']}($option_name, calibrefx_get_custom_field($option_name), $classes, $option['option_attr']);
                        break;
                    case 'checkbox':
                        $classes = 'calibrefx-settings-checkbox';
                        if (isset($option['option_attr']['class'])) {
                            $classes .= ' ' . $option['option_attr']['class'];
                            unset($option['option_attr']['class']);
                        }
                        $value = calibrefx_get_custom_field($option_name);
                        if (empty($value)) {
                            $value = $option['option_default'];
                        }
                        $attr = array_merge(array('target' => 'cpm-' . $option_name, 'class' => $classes), $option['option_attr']);
                        echo $calibrefx->form->{$option['option_type']}('cpm-checkbox-' . $option_name, $option['option_items'], $value, $option['option_label'], false, $attr);
                        echo $calibrefx->form->hidden($option_name, calibrefx_get_custom_field($option_name), array('id' => 'cpm-' . $option_name));
                        break;
                        /*case 'radio':
                        		case 'select':
                        			echo '<label for="'.$option_name . '">'.$option["option_label"].'</label>';
                        			echo $calibrefx->form->{$option['option_type']}( $option_name, $option['option_items'],calibrefx_get_custom_field( $option_name), '', $option['option_attr']);
                        			break;*/
                    /*case 'radio':
                    		case 'select':
                    			echo '<label for="'.$option_name . '">'.$option["option_label"].'</label>';
                    			echo $calibrefx->form->{$option['option_type']}( $option_name, $option['option_items'],calibrefx_get_custom_field( $option_name), '', $option['option_attr']);
                    			break;*/
                    case 'custom':
                        if (isset($option['option_custom'])) {
                            echo '<label for="' . $option_name . '">' . $option['option_label'] . '</label>';
                            echo $option['option_custom'];
                        }
                        break;
                }
                ?>
            </p>
            <?php 
                if (!empty($option['option_description'])) {
                    ?>
			<p class="description">
				<?php 
                    echo $option['option_description'];
                    ?>
			</p>
            <?php 
                }
            }
        }
    }
}
Example #3
0
/**
 * These functions can be used to easily and efficiently pull data from a
 * post/page custom field. Returns FALSE if field is blank or not set.
 *
 * @param string $field used to indicate the custom field key
 */
function calibrefx_custom_field($field)
{
    echo calibrefx_get_custom_field($field);
}
Example #4
0
/**
 * Show inpost layout box
 */
function calibrefx_inpost_layout_box()
{
    wp_nonce_field('calibrefx_inpost_layout_action', 'calibrefx_inpost_layout_nonce');
    $layout = calibrefx_get_custom_field('site_layout');
    ?>
    <div class="calibrefx-layout-selector">
        <p>
        	<input type="radio" name="_calibrefx_layout" id="default-layout" value="" <?php 
    checked($layout, '');
    ?>
 /> <label class="default" for="default-layout"><?php 
    printf(__('Default Layout set in <a href="%s">Theme Settings</a>', 'calibrefx'), menu_page_url('calibrefx', 0));
    ?>
</label>
        </p>
        <?php 
    calibrefx_layout_selector(array('name' => '_calibrefx_layout', 'selected' => $layout, 'type' => 'site'));
    ?>
    </div>

    <br class="clear" />

    <p><label for="calibrefx_custom_body_class"><b><?php 
    _e('Custom Body Class', 'calibrefx');
    ?>
</b></label></p>
    <p><label for="calibrefx_custom_post_class"><b><?php 
    _e('Custom Post Class', 'calibrefx');
    ?>
</b></label></p>
    <p><input class="large-text" type="text" name="_calibrefx_custom_post_class" id="calibrefx_custom_post_class" value="<?php 
    echo esc_attr(sanitize_html_class(calibrefx_get_custom_field('_calibrefx_custom_post_class')));
    ?>
" /></p>
    <?php 
}
Example #5
0
/**
 * Echo the post meta after the post content. Will not show in page.
 *
 * Use several content shortcode, refered to shortcodes/content.php
 */
function calibrefx_post_meta()
{
    global $post;
    if (is_page($post->ID)) {
        return;
    }
    $post_category = '';
    if (calibrefx_get_option('post_category')) {
        $post_category = '[post_categories]';
    }
    if (is_singular() and calibrefx_get_custom_field('_calibrefx_custom_hide_category')) {
        $post_category = '';
    }
    $post_tags = '';
    if (calibrefx_get_option('post_tags')) {
        $post_tags = '[post_tags]';
    }
    if (is_singular() and calibrefx_get_custom_field('_calibrefx_custom_hide_tags')) {
        $post_tags = '';
    }
    $post_meta = "{$post_category} {$post_tags}";
    printf('<div class="post-meta">%s</div>', apply_filters('calibrefx_post_meta', $post_meta));
}