Example #1
0
<?php

/**
 * The template for displaying 404 pages (Not Found).
 *
 * @package gp
 * @since gp 1.0
 */
gp_add_html_class('horizontal-page no-scroll');
get_header();
/**
 * Find pages that have full page slider template. Search those pages for big images.
 */
$slider_pages = it_find_page_by_template('template-full-page-slider.php', 'post_status=publish');
$image = false;
foreach ($slider_pages as $slider_page) {
    $slides = gp_slider_get_published_slides($slider_page->ID);
    if ($slides && is_array($slides)) {
        shuffle($slides);
        foreach ($slides as $slide) {
            $image = wp_get_attachment_image_src($slide->ID, 'gp-max');
            // We found our first image!
            if ($image) {
                $image = $image[0];
                $data = gp_slider_get_slide_data($slide->ID);
                break;
            }
        }
    }
    // Stop as soon as we find first image.
    if ($image) {
Example #2
0
/**
 * Return template-portfolio.php or template-portfolio-grid.php slug to be used
 * in portfolio project URL.
 */
function gp_portfolio_base_slug()
{
    $portfolio_page = it_find_page_by_template('template-portfolio.php');
    if ($portfolio_page) {
        return $portfolio_page[0]->post_name;
    } else {
        return 'portfolio';
    }
}
Example #3
0
function gp_project_type_layout($project_type_id)
{
    $options = new gpProjectTypeOptions($project_type_id);
    $template = $options->layout;
    if (!$template) {
        $project_type = get_term_by('id', $project_type_id, 'gp-project-type');
        if ($project_type->parent) {
            for ($i = 0; $i <= 10; $i++) {
                $parent = get_term_by('id', $project_type->parent, 'gp-project-type');
                $parent_options = new gpProjectTypeOptions($parent->term_id);
                $template = $parent_options->layout;
                if ($template || $parent->parent == 0) {
                    break;
                }
            }
        }
    }
    switch ($template) {
        case 'grid':
            $template = 'template-portfolio-grid.php';
            break;
        case 'horizontal':
            $template = 'template-portfolio.php';
            break;
        default:
            /*
             * Template is not set using Project Type options, so let's determinate it by ourselves
             * using following logic:
             *   1. If page with horizontal portfolio template is found, then use horizontal.
             *   2. If page with grid portfolio template is found, then use grid.
             *   3. If no page is found, then use horizontal.
             */
            $template = 'template-portfolio.php';
            $horizontal_portfolio = it_find_page_by_template('template-portfolio.php', array('post_status' => 'publish'));
            if ($horizontal_portfolio) {
                $template = 'template-portfolio.php';
            } else {
                $grid_portfolio = it_find_page_by_template('template-portfolio-grid.php', array('post_status' => 'publish'));
                if ($grid_portfolio) {
                    $template = 'template-portfolio-grid.php';
                }
            }
    }
    return $template;
}