Example #1
0
/**
 * Initialize Admin-Side Post Format.
 */
function gp_background_admin_init()
{
    $post_id = it_get_post_id();
    if ($post_id) {
        if (it_is_template($post_id, 'template-background.php')) {
            wp_enqueue_script('gp-wp-admin-background', get_template_directory_uri() . '/js/wp-admin/background.js');
            wp_enqueue_style('gp-wp-admin-background', get_template_directory_uri() . '/css/wp-admin/background.css');
            add_action('add_meta_boxes', 'gp_background_add_meta_box');
        }
    }
}
Example #2
0
 function is_item_blog_index($element)
 {
     if ($element->object != 'page') {
         return false;
     }
     return it_is_template($element->object_id, 'template-blog-horizontal.php') || it_is_template($element->object_id, 'template-blog-vertical.php');
 }
Example #3
0
/**
 * Initialize Portfolio Admin
 */
function gp_portfolio_admin_init()
{
    global $pagenow;
    $post_type = isset($_GET['post_type']) ? $_GET['post_type'] : '';
    if ($post_id = it_get_post_id()) {
        $post = get_post($post_id);
        $post_type = $post->post_type;
    }
    if ($post_type == 'gp_portfolio') {
        // Project List Page
        if ('edit.php' == $pagenow) {
            // Set correct order of projects in admin.
            add_filter('pre_get_posts', 'gp_portfolio_admin_project_order');
            // Custom columns in Project List
            add_filter('manage_edit-gp_portfolio_columns', 'gp_portfolio_admin_project_list_columns');
            add_action('manage_posts_custom_column', 'gp_portfolio_project_list_column_data');
        }
        // Post Edit or Post New Page
        if (in_array($pagenow, array('post.php', 'post-new.php', 'admin-ajax.php'))) {
            new PortfolioProjectAdmin($post_id);
        }
    }
    if ($post_id) {
        if (it_is_template($post_id, 'template-portfolio-grid.php')) {
            new GridPortfolioAdmin($post_id);
        }
    }
}
<?php

/**
 * The template for displaying all pages.
 * Texmplate Name: Horizontal with Subnavigation
 *
 * @package gp
 * @since gp 1.0
 */
get_header();
$with_sidebar = !it_is_template(get_the_id(), 'template-full-width.php');
?>


    
<?php 
get_sidebar('subnavigation');
?>
<div id="page_grid" data-pageid="page.php" class="site<?php 
if ($with_sidebar) {
    ?>
 site-with-sidebar<?php 
}
?>
">
    <?php 
if ($with_sidebar) {
    get_sidebar();
    //add_filter( 'the_post', 'remove_h1');
}
?>
Example #5
0
/**
 * The content of Slider tab in media browser.
 */
function gp_slider_media_tab_content()
{
    media_upload_header();
    // add scripts & styles that support the slider admin functionality
    wp_enqueue_style('gp-wp-admin-slider', get_template_directory_uri() . '/css/wp-admin/slider.css');
    wp_enqueue_script('gp-wp-admin-slider', get_template_directory_uri() . '/js/wp-admin/slider.js', array('jquery-ui-sortable'));
    wp_enqueue_script('jquery-ui-sortable');
    if (!isset($_GET['post_id'])) {
        echo 'Post ID is not set.';
        return false;
    }
    $post_id = $_GET['post_id'];
    add_filter('posts_orderby_request', 'gp_portfolio_orderby_filter');
    $portfolio_items = get_posts(array('post_type' => 'gp_portfolio', 'posts_per_page' => -1, 'orderby' => 'menu_order ID', 'post_status' => null, 'order' => 'DESC DESC'));
    remove_filter('posts_orderby_request', 'gp_portfolio_orderby_filter');
    $post = get_post($post_id);
    if (!$post) {
        echo 'Post not found.';
        return false;
    }
    gp_slider_set_order($post_id);
    $slides = gp_slider_get_slides($post_id);
    ?>
    <div id="gp-slider-tab" data-post-id="<?php 
    echo esc_attr($post_id);
    ?>
">

        <div class="slides-container"><?php 
    if (isset($post) && isset($post->post_type) && $post->post_type != 'page') {
        ?>

                <div class="gp-message">
                    <div class="gp-message-contents">
                        <?php 
        _e('Slider only works with pages. Create a page with Full Page Slider template and visit this tab again.', 'gp');
        ?>
                    </div>
                </div><?php 
    } else {
        if (!it_is_template($post_id, 'template-full-page-slider.php')) {
            ?>

                    <div class="gp-message">
                        <div class="gp-message-contents">
                            <?php 
            _e('Current page template is not set to Full Page Slider. To make Full Page Slider visible set the current page\'s template to Full Page Slider.', 'gp');
            ?>
                        </div>
                    </div><?php 
        }
        if (!$slides) {
            ?>

                    <div class="gp-message">
                        <div class="gp-message-contents">
                            <?php 
            _e('No images were uploaded to current page. Please go to Insert Media tab and upload new images to create a Slider.', 'gp');
            ?>
                        </div>
                    </div><?php 
        } else {
            ?>
                    <table class="widefat" cellspacing="0" id="slides">
                        <thead>
                            <tr>
                                <th class="col-media"><?php 
            _e('Media', 'gp');
            ?>
</th>
                                <th class="col-title"><?php 
            _e('Title', 'gp');
            ?>
</th>
                                <th class="col-order"><?php 
            _e('Order', 'gp');
            ?>
</th>
                                <th class="col-actions"><?php 
            _e('Actions', 'gp');
            ?>
</th>
                            </tr>
                        </thead>
                        <tbody><?php 
            foreach ($slides as $slide) {
                $id = $slide->ID;
                $image = wp_get_attachment_image_src($id, 'gp-slider-admin-thumbnail');
                $data = gp_slider_get_slide_data($id);
                ?>
                                <tr>
                                    <td>
                                        <?php 
                echo wp_get_attachment_image($id, 'gp-slider-admin-thumbnail');
                ?>
                                    </td>
                                    <td>
                                        <div class="wrap-slide-title<?php 
                if (empty($data['title'])) {
                    echo ' slide-title-empty';
                }
                ?>
">
                                            <i class="title-empty"><?php 
                _e('Not set', 'gp');
                ?>
</i>
                                            <span class="slide-title"><?php 
                echo $data['title'];
                ?>
</span>
                                        </div>
                                        <div class="wrap-slide-status <?php 
                echo $data['publish'] ? 'slide-published' : 'slide-unpublished';
                ?>
">
                                            <span class="slide-status-published"><?php 
                _e('Published', 'gp');
                ?>
</span>
                                            <span class="slide-status-unpublished"><?php 
                _e('Unpublished', 'gp');
                ?>
</span>
                                        </div>
                                    </td>
                                    <td>
                                        <input type="hidden" value="<?php 
                echo $id;
                ?>
" class="slide-id" />
                                        <a href="#" class="slide-move"></a>
                                    </td>
                                    <td>
                                        <a href="#" class="show-toggle" data-hide="<?php 
                _e('Hide details', 'gp');
                ?>
" data-show="<?php 
                _e('Show details', 'gp');
                ?>
"><?php 
                _e('Show Details', 'gp');
                ?>
</a>
                                        <div class="details" id="slide_<?php 
                echo $id;
                ?>
_details">
                                            <form enctype="multipart/form-data" method="post" action="/">
                                                <input type="hidden" name="security" value="<?php 
                echo wp_create_nonce('gp-slider-form');
                ?>
" />
                                                <input type="hidden" name="action" value="gp_slider_slide_save" />
                                                <input type="hidden" name="slide_id" value="<?php 
                echo $id;
                ?>
" />
                                                <div class="field">
                                                    <label><?php 
                _e('Title', 'gp');
                ?>
</label>
                                                    <input type="text" name="slide_title" value="<?php 
                echo esc_attr($data['title']);
                ?>
" class="input-text" />
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Subtitle', 'gp');
                ?>
</label>
                                                    <input type="text" name="slide_subtitle" value="<?php 
                echo esc_attr($data['subtitle']);
                ?>
" class="input-text" />
                                                    <i><?php 
                _e('eg. featured project', 'gp');
                ?>
</i>
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Description', 'gp');
                ?>
</label>
                                                    <textarea name="slide_description"><?php 
                echo $data['description'];
                ?>
</textarea>
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Custom link', 'gp');
                ?>
</label>
                                                    <input type="text" name="slide_link" value="<?php 
                echo esc_url($data['link']);
                ?>
" class="input-text" />
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Link to portfolio', 'gp');
                ?>
</label><?php 
                $options = array('' => '');
                foreach ($portfolio_items as $item) {
                    $options[$item->ID] = $item->post_title;
                }
                ?>
                                                    <select name="slide_link_portfolio">
                                                        <?php 
                echo it_array_to_select_options($options, $data['link_portfolio']);
                ?>
                                                    </select>
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Link title', 'gp');
                ?>
</label>
                                                    <input type="text" name="slide_link_title" value="<?php 
                echo esc_attr($data['link_title']);
                ?>
" class="input-text" />
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Text color', 'gp');
                ?>
</label>
                                                    <select name="slide_text_color">
                                                        <option value="black"<?php 
                echo $data['info_box_text_color'] == 'black' ? ' selected="selected"' : '';
                ?>
><?php 
                _e('Black', 'gp');
                ?>
</option>
                                                        <option value="white"<?php 
                echo $data['info_box_text_color'] == 'white' ? ' selected="selected"' : '';
                ?>
><?php 
                _e('White', 'gp');
                ?>
</option>
                                                    </select>
                                                    <i><?php 
                _e('Choose according to the picture brightness', 'gp');
                ?>
</i>
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Info box position', 'gp');
                ?>
</label>
                                                    <?php 
                $link = get_permalink($post_id);
                $link = add_query_arg(array('set-infobox-position' => 1, 'slide' => $id), $link);
                $info_box_position = $data['info_box_position'];
                $position_custom_html = '';
                if ($info_box_position == 'custom') {
                    $position_custom_html = ' (' . $data['info_box_left'] . ' ' . $data['info_box_top'] . ')';
                }
                ?>
                                                    <select name="slide_info_box_position">
                                                        <option value="center"<?php 
                echo $info_box_position == 'center' ? ' selected="selected"' : '';
                ?>
><?php 
                _e('Center', 'gp');
                ?>
</option>
                                                        <option value="custom"<?php 
                echo $info_box_position == 'custom' ? ' selected="selected"' : '';
                ?>
 data-custom="<?php 
                echo esc_attr(__('Custom', 'custom'));
                ?>
"><?php 
                _e('Custom', 'custom');
                echo $position_custom_html;
                ?>
</option>
                                                    </select>
                                                    <input type="hidden" value="<?php 
                echo $data['info_box_left'];
                ?>
" name="slide_info_box_left" />
                                                    <input type="hidden" value="<?php 
                echo $data['info_box_top'];
                ?>
" name="slide_info_box_top" />
                                                    <a href="<?php 
                echo $link;
                ?>
" target="_blank" class="set-infobox-position"><?php 
                _e('Set custom position', 'gp');
                ?>
</a>
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Image scaling', 'gp');
                ?>
</label><?php 
                $options = array('top center' => __('Crop Bottom', 'gp'), 'center center' => __('Crop Top and Bottom', 'gp'), 'bottom center' => __('Crop Top', 'gp'), 'fit' => __('Fit Image', 'gp'));
                ?>
                                                    <select name="slide_background_position">
                                                        <?php 
                echo it_array_to_select_options($options, $data['background_position']);
                ?>
                                                    </select>
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Dim Background', 'gp');
                ?>
</label>
                                                    <input type="checkbox" name="slide_dim_background" value="1"<?php 
                echo $data['dim_background'] ? ' checked="checked"' : '';
                ?>
 />
                                                </div>
                                                <div class="field">
                                                    <label><?php 
                _e('Published', 'gp');
                ?>
</label>
                                                    <input type="checkbox" name="slide_published" value="1"<?php 
                echo $data['publish'] ? ' checked="checked"' : '';
                ?>
 />
                                                </div>
                                                <div class="field">
                                                    <label for="">&nbsp;</label>
                                                    <a href="#" class="button gp-save-slide"><?php 
                _e('Save changes', 'gp');
                ?>
</a>
                                                    <span class="saving-status" data-saving="<?php 
                _e('Saving...', 'gp');
                ?>
" data-ok="<?php 
                _e('Saved!', 'gp');
                ?>
" data-failed="<?php 
                _e('Failed', 'gp');
                ?>
"></span>
                                                </div>
                                            </form>
                                        </div>
                                    </td>
                                </tr><?php 
            }
            ?>
                        </tbody>
                    </table><?php 
        }
    }
    ?>
            <form enctype="multipart/form-data" method="post" action="/" id="gp-slider-order-form">
                <input type="hidden" name="security" value="<?php 
    echo wp_create_nonce('gp-slider-order-form');
    ?>
" />
                <input type="hidden" name="action" value="gp_slider_save_order" />
                <input type="hidden" name="order" value="" />
            </form>

        </div>

        <div class="gp-slider-sidebar"><?php 
    $options = gp_slider_get_options($post_id);
    $auto_slideshow = $options['slideshow'] ? ' checked="checked"' : '';
    ?>
            <form enctype="multipart/form-data" method="post" action="/" id="gp-slider-options-form">
                <input type="hidden" name="security" value="<?php 
    echo wp_create_nonce('gp-slider-options-form');
    ?>
" />
                <input type="hidden" name="action" value="gp_slider_save_options" />
                <input type="hidden" name="post_id" value="<?php 
    echo esc_attr($post_id);
    ?>
" />

                <h3><?php 
    _e('Slider Options', 'gp');
    ?>
</h3>

                <div class="gp-slider-settings">

                    <label for="gp_slider_slideshow" class="setting">
                        <span><?php 
    _e('Auto slideshow', 'gp');
    ?>
</span>
                        <input type="checkbox" name="gp_slider_slideshow" id="gp_slider_slideshow" value="1"<?php 
    echo $auto_slideshow;
    ?>
 />
                    </label>

                    <label for="gp_slider_slideshow_interval" class="setting">
                        <span><?php 
    _e('Slide change interval', 'gp');
    ?>
</span>
                        <input type="text" name="gp_slider_slideshow_interval" id="gp_slider_slideshow_interval" value="<?php 
    echo $options['slideshow_interval'];
    ?>
" />
                    </label>

                    <label for="gp_slider_slideshow_animation" class="setting">
                        <span><?php 
    _e('Slideshow animation', 'gp');
    ?>
</span>
                        <?php 
    $animations = array('slide' => 'Slide', 'fade' => 'Fade', 'fadeAndSlide' => 'Fade and Slide');
    ?>
                        <select name="gp_slider_slideshow_animation" id="gp_slider_slideshow_animation">
                            <?php 
    echo it_array_to_select_options($animations, $options['slideshow_animation']);
    ?>
                        </select>
                    </label>

                    <div class="setting setting-controls">
                        <span>&nbsp;</span>
                        <input type="submit" id="button-save-slider-settings" class="button" value="<?php 
    echo esc_attr(__('Save', 'gp'));
    ?>
" />
                        <i class="status-saving"><?php 
    echo esc_attr(__('Saving...', 'gp'));
    ?>
</i>
                        <i class="status-saved"><?php 
    echo esc_attr(__('Saved!', 'gp'));
    ?>
</i>
                        <i class="status-error"><?php 
    echo esc_attr(__('Error!', 'gp'));
    ?>
</i>
                    </div>

                </div>
            </form>

        </div>

    </div><?php 
}
Example #6
0
/**
 * Add Google Maps script, if API key is specified.
 */
function gp_contacts_enqueue_google_maps()
{
    global $post;
    /**
     * If current page has contacts template, then see if we need to enqueue
     * Google Maps script.
     */
    if ($post) {
        if (it_is_template($post->ID, 'template-contacts.php')) {
            if (gp_contacts_has_map($post->ID)) {
                $data = gp_contacts_get_data($post->ID);
                wp_enqueue_script('google-maps-api3', 'https://maps.googleapis.com/maps/api/js?key=' . $data['api'] . '&sensor=false');
                wp_enqueue_script('gp-maps', get_template_directory_uri() . '/js/maps.js', array('google-maps-api3', 'jquery'));
            }
        }
    }
}
Example #7
0
<?php

/**
 * The template used for displaying page content in page.php
 *
 * @package gp
 * @since gp 1.0
 */
$is_full_width = it_is_template(get_the_ID(), 'template-full-width.php');
$is_full_width = $is_full_width ? 'full-width' : '';
?>
<div id="post-<?php 
the_ID();
?>
" <?php 
post_class($is_full_width);
?>
>
	<?php 
if (has_post_thumbnail()) {
    $image_info = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'gp-max');
    $image = $image_info[0];
    ?>
            <article class="entry-header">   
                <div class="post-image">
                    <img src="<?php 
    echo esc_url($image);
    ?>
" width="<?php 
    echo $image_info[1];
    ?>
Example #8
0
 function is_item_portfolio_index($object_id)
 {
     return it_is_template($object_id, 'template-portfolio.php') || it_is_template($object_id, 'template-portfolio-grid.php');
 }