function meta_box_options_content_save($post_id)
 {
     if (!it_check_save_action($post_id, 'gp_portfolio')) {
         return $post_id;
     }
     $project = new PortfolioProject($post_id);
     $project->update_from_array($_POST);
     if (it_key_is_array($_POST, 'gp_project_info_title')) {
         $titles = $_POST['gp_project_info_title'];
         $contents = $_POST['gp_project_info_content'];
         $data = array();
         foreach ($titles as $index => $title) {
             if (!empty($title) && !empty($contents[$index])) {
                 $data[] = array('title' => $title, 'content' => $contents[$index]);
             }
         }
         $project->meta_info = $data;
     } else {
         $project->meta_info = array();
     }
     $project->save();
 }
    <div id="content" class="site-content">
        <div class="portfolio-list horizontal-content"><?php 
if (is_page()) {
    /**
     * We are on index page.
     * Let's modify main loop to gp_portfolio post type.
     *
     * If is_page() is false, then we are on taxonomy-gp-project-type.php
     * template, so our loop is already correct.
     */
    gp_query_portfolio();
}
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $project = new PortfolioProject(get_the_ID());
        $featured = $project->get_featured_media();
        if (!$featured) {
            continue;
        }
        // We have no media on this project, nothing to show.
        $attr['class'] = 'horizontal-item project';
        if ($featured->is_image()) {
            $image = $featured->get_image_data('gp-max');
        } else {
            $image = $featured->get_video_thumbnail('gp-max');
        }
        if (!$image) {
            $image = array('src' => get_template_directory_uri() . '/images/no-portfolio-thumbnail.png', 'width' => 1920, 'height' => 1280);
        }
        ?>
}
if (have_posts()) {
    $grid_portfolio = new GridPortfolio(get_the_ID());
    ?>
    <div id="main" class="site">

        <div class="portfolio-grid" data-columns="<?php 
    echo $grid_portfolio->get_grid_column_count();
    ?>
" data-rows="<?php 
    echo $grid_portfolio->get_grid_row_count();
    ?>
"><?php 
    while (have_posts()) {
        the_post();
        $project = new PortfolioProject(get_the_ID());
        $featured = $project->get_featured_media();
        if (!$featured) {
            continue;
        }
        // We have no media on this project, nothing to show.
        if ($featured->is_image()) {
            $image = $featured->get_image_data('gp-thumbnail');
            $image = $image ? $image['src'] : '';
        } else {
            $image = $featured->get_video_thumbnail('gp-thumbnail');
            if (!$image) {
                $image = array('src' => get_template_directory_uri() . '/images/no-portfolio-thumbnail.png');
            }
            $image = $image['src'];
        }
<?php

/**
 * Portfolio single project template.
 */
gp_add_html_class('horizontal-page');
the_post();
$project = new PortfolioProject(get_the_ID());
$project_media = $project->get_media();
$featured = $project->get_featured_media();
$max_upscale_height = of_get_option('gp_allow_image_upscaling') ? apply_filters('gp_max_upscale_height', 3000) : '';
if ($featured) {
    global $gp_theme;
    // Use featured image as page thumbnail.
    $image = '';
    if ($featured->is_image()) {
        $image = $featured->get_image_data('gp-max');
    } else {
        $image = $featured->get_video_thumbnail('gp-max');
    }
    if ($image) {
        $gp_theme->set_image($image['src']);
    }
    // Use project excerpt as page description.
    $excerpt = get_the_excerpt();
    if ($excerpt) {
        $gp_theme->set_description($excerpt);
    }
}
get_header();
?>
<?php

/**
 * Portfolio Single Sidebar.
 *
 * @package gp
 * @since gp 1.0
 */
$project = new PortfolioProject(get_the_ID());
?>
<div class="sidebar sidebar-portfolio-single widget-area">

    <?php 
do_action('before_sidebar');
?>

    <div class="scroll-container">
        <div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>
        <div class="viewport">
            <div class="overview"><?php 
if (!post_password_required()) {
    if ($project->exists()) {
        ?>
                        <hgroup><?php 
        if ($project->meta_subtitle) {
            ?>
                                <h2 class="subtitle"><?php 
            echo $project->meta_subtitle;
            ?>
</h2><?php 
        }
示例#6
0
 function upgrade_v1_to_v1_1()
 {
     /**
      * Upgrade Projects
      */
     $projects = PortfolioProject::all();
     if ($projects) {
         $args = array('post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'any', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
         foreach ($projects as $project) {
             $args['post_parent'] = $project->post->ID;
             $media = $project->get_media();
             if (!$this->clean && count($media)) {
                 break;
                 // Let's not update if we have some media already
             } elseif ($this->clean && count($media)) {
                 // Delete existing assigned media
                 foreach ($media as $m) {
                     $m->delete();
                 }
             }
             /**
              * Make sure featured image is added.
              */
             $featured_id = get_post_thumbnail_id($project->post->ID);
             $featured_image_added = false;
             $attachments = get_children($args);
             if ($attachments) {
                 $max_order = 0;
                 foreach ($attachments as $attachment) {
                     $max_order = $attachment->menu_order > $max_order ? $attachment->menu_order : $max_order;
                 }
                 foreach ($attachments as $attachment) {
                     $media_item = PortfolioMedia::create($project->post->ID);
                     $media_item->meta_type = 'image';
                     $media_item->meta_attachment_id = $attachment->ID;
                     $media_item->post->menu_order = $max_order - $attachment->menu_order;
                     // This is featured image
                     if ($featured_id == $attachment->ID) {
                         $media_item->meta_featured = 1;
                         $featured_image_added = true;
                     }
                     // If there was no featured image, then make the first one featured
                     if (!$featured_id && !$featured_image_added) {
                         $media_item->meta_featured = 1;
                         $featured_image_added = true;
                     }
                     $saved = $media_item->save();
                 }
             }
             /**
              * Featured image was not added, let's add it in the first position.
              */
             if (!$featured_image_added && $featured_id) {
                 $media_item = PortfolioMedia::create($project->post->ID);
                 $media_item->meta_type = 'image';
                 $media_item->meta_attachment_id = $featured_id;
                 $media_item->meta_featured = 1;
                 $media_item->post->menu_order = $max_order + 1;
                 $media_item->save();
             }
         }
     }
 }