コード例 #1
0
ファイル: layouts.php プロジェクト: WPDevHQ/nevertheless
/**
 * Default Layout
 */
function tamatebako_layout_default($return = 'slug')
{
    /* Vars */
    $layouts = array_keys(tamatebako_layouts());
    $args = tamatebako_layouts_args();
    /* Validate Layout */
    if (in_array($args['default'], $layouts)) {
        if ('slug' == $return) {
            return $args['default'];
        }
        if ('name' == $return) {
            return tamatebako_layout_name($args['default']);
        }
    }
    return '';
}
コード例 #2
0
/**
 * Layout Meta Box Callback Function
 */
function tamatebako_layouts_post_meta_box($post, $box)
{
    /* Vars */
    $layouts_args = tamatebako_layouts_args();
    $layouts = tamatebako_layouts();
    /* Add Default/Global */
    $layout_default = array();
    if (true === $layouts_args['customize']) {
        $layout_default['default'] = array('name' => tamatebako_layouts_string('global_layout'));
    } else {
        $layout_default['default'] = array('name' => tamatebako_layouts_string('default'));
    }
    if (tamatebako_current_layout()) {
        $layout_default['default']['name'] = $layout_default['default']['name'] . ' (' . tamatebako_layout_name(tamatebako_current_layout()) . ')';
    }
    $layouts = array_merge($layout_default, $layouts);
    /* Get current post/entry layout */
    $post_layout = tamatebako_get_post_layout($post->ID);
    $div_class = 'post-layout';
    if (true == $layouts_args['thumbnail']) {
        $div_class .= ' theme-layouts-thumbnail-wrap';
    }
    if (!empty($post_layout)) {
        $div_class .= ' post-layout-selected';
    }
    ?>

	<div id="post-layout" class="<?php 
    echo esc_attr($div_class);
    ?>
">

		<?php 
    wp_nonce_field(basename(__FILE__), 'theme-layouts-nonce');
    ?>

		<div class="post-layout-wrap">
			
				<?php 
    foreach ($layouts as $layout => $layout_data) {
        /* Set empty value for Layout Global/Default */
        $layout_value = $layout;
        if ('default' == $layout) {
            $layout_value = '';
        }
        /* Label class */
        $label_class = "theme-layout-label";
        if ('default' == $layout) {
            $label_class .= " layout-default";
            // hide it!
        }
        if ($post_layout == $layout) {
            $label_class .= " layout-selected";
        }
        /* Label */
        if (true === $layouts_args['customize']) {
            $layout_info = tamatebako_layouts_string('global_layout');
        } else {
            $layout_info = tamatebako_layouts_string('default');
        }
        if (tamatebako_current_layout() == $layout) {
            $layout_data['name'] = $layout_data['name'] . ' (' . $layout_info . ')';
            $label_class .= " layout-global";
        }
        $layout_label = $layout_data['name'];
        /* If theme using layout thumbnail, label using image. */
        if (true == $layouts_args['thumbnail'] && isset($layout_data['thumbnail'])) {
            $layout_label = '<img src="' . esc_url($layout_data['thumbnail']) . '" class="layout-thumbnail" title="' . esc_attr($layout_data['name']) . '">' . '<span class="layout-name">' . $layout_data['name'] . '</span>';
        }
        ?>

						<label style="display:block;" class="<?php 
        echo esc_attr($label_class);
        ?>
">
							<input type="radio" name="post-layout" class="theme-layout-input" value="<?php 
        echo esc_attr($layout_value);
        ?>
" <?php 
        checked($post_layout, $layout_value);
        ?>
 />
							<?php 
        echo $layout_label;
        ?>
						</label>

				<?php 
    }
    // end foreach
    ?>
			
		</div>
	</div><?php 
}