Example #1
0
/**
 * Meta box contents.
 */
function gp_background_meta_box_contents()
{
    global $post;
    if (!$post) {
        return;
    }
    $data = gp_background_get_data($post->ID);
    extract($data);
    ?>
    <div class="gp-meta-field">
        <label for="gp_background_background_position"><?php 
    _e('Background position', 'gp');
    ?>
</label>
        <div class="field"><?php 
    $options = array('top center' => __('Top', 'gp'), 'center center' => __('Center', 'gp'), 'bottom center' => __('Bottom', 'gp'));
    ?>
            <select name="gp_background_background_position"><?php 
    echo it_array_to_select_options($options, $background_position);
    ?>
            </select>
        </div>
    </div>
    <div class="gp-meta-field">
        <label for="gp_background_text_color"><?php 
    _e('Text color', 'gp');
    ?>
</label>
        <div class="field">
            <select name="gp_background_text_color">
                <option<?php 
    if ($text_color == 'black') {
        echo ' selected="selected"';
    }
    ?>
 value="black"><?php 
    _e('Black', 'gp');
    ?>
</option>
                <option<?php 
    if ($text_color == 'white') {
        echo ' selected="selected"';
    }
    ?>
 value="white"><?php 
    _e('White', 'gp');
    ?>
</option>
            </select>
        </div>
    </div>
    <div class="gp-meta-field">
        <label for="gp_background_dim_background"><?php 
    _e('Dim background', 'gp');
    ?>
</label>
        <div class="field"><?php 
    $checked = $dim_background == '1' ? ' checked="checked"' : '';
    ?>
            <input type="checkbox" name="gp_background_dim_background" value="1"<?php 
    echo $checked;
    ?>
 />
        </div>
    </div>
    <div class="gp-meta-field">
        <label for="gp_background_content_position"><?php 
    _e('Content position', 'gp');
    ?>
</label>
        <div class="field">
            <select name="gp_background_content_position">
                <option<?php 
    if ($content_position == 'center') {
        echo ' selected="selected"';
    }
    ?>
 value="center"><?php 
    _e('Center', 'gp');
    ?>
</option>
                <option<?php 
    if ($content_position == 'custom') {
        echo ' selected="selected"';
    }
    ?>
 value="custom"><?php 
    _e('Custom', 'gp');
    ?>
</option>
            </select>
        </div>
    </div>
    <div class="gp-meta-field">
        <label for=""><?php 
    _e('Custom position', 'gp');
    ?>
</label>
        <div class="field">
            <?php 
    $post_url = get_permalink($post->ID);
    $post_url = add_query_arg('set-position', 1, $post_url);
    ?>
            <input type="hidden" name="gp_box_position_top" value="<?php 
    echo esc_attr($top);
    ?>
" />
            <input type="hidden" name="gp_box_position_left" value="<?php 
    echo esc_attr($left);
    ?>
" />
            <div id="gp-content-position">
                <?php 
    $top_html = !empty($top) ? $top : __('not set', 'gp');
    $left_html = !empty($left) ? $left : __('not set', 'gp');
    ?>
                <div>Top: <b class="top"><?php 
    echo $top_html;
    ?>
</b></div>
                <div>Left: <b class="left"><?php 
    echo $left_html;
    ?>
</b></div>
            </div>
            <a href="<?php 
    echo esc_url($post_url);
    ?>
" class="button-secondary" id="gp-set-content-position"><?php 
    _e('Set custom position', 'gp');
    ?>
</a>
        </div>
    </div>

    <?php 
}
<?php

/*
T-MMM-emplate Name: Page with Background
*/
gp_add_html_class('horizontal-page no-scroll');
get_header();
if (have_posts()) {
    the_post();
    $data = gp_background_get_data(get_the_ID());
    $slide_attr = array('class' => array('slide'), 'id' => 'slide-' . get_the_ID(), 'data-image' => has_post_thumbnail() ? it_get_post_thumbnail(get_the_ID(), 'gp-max') : '', 'style' => array('background-position: ' . $data['background_position']));
    $slide_info_attr = array('class' => array('info', $data['text_color'], 'no-fade', 'style-page-with-background'), 'style' => array(), 'data-position' => $data['content_position'], 'data-top' => $data['top'], 'data-left' => $data['left']);
    if ($data['dim_background'] == '1') {
        $slide_info_attr['class'][] = 'dim-background';
    }
    ?>
    <div id="main" class="site">
        <div class="slider">
            <div<?php 
    echo it_array_to_attributes($slide_attr);
    ?>
>
                <article<?php 
    echo it_array_to_attributes($slide_info_attr);
    ?>
>
                    <div class="viewport">
                        <h1 class="entry-title"><?php 
    the_title();
    ?>
</h1>