Exemplo n.º 1
0
/**
 * Modifies post data to use new imported ids
 *
 * @return void
 * @author
 **/
function oxy_one_click_before_insert_post($post, $one_click)
{
    if (!class_exists('simple_html_dom')) {
        require_once OXY_THEME_DIR . 'vendor/oxygenna/oxygenna-one-click/inc/simple_html_dom.php';
    }
    // create post object
    $post_object = new stdClass();
    // strip slashes added by json
    $post_object->post_content = stripslashes($post['post_content']);
    $gallery_shortcode = oxy_get_content_shortcode($post_object, 'gallery');
    if ($gallery_shortcode !== null) {
        if (isset($gallery_shortcode[0])) {
            // show gallery
            $gallery_ids = null;
            if (array_key_exists(3, $gallery_shortcode)) {
                if (array_key_exists(0, $gallery_shortcode[3])) {
                    $gallery_attrs = shortcode_parse_atts($gallery_shortcode[3][0]);
                    if (array_key_exists('ids', $gallery_attrs)) {
                        // we have a gallery with ids so lets replace the ids
                        $gallery_ids = explode(',', $gallery_attrs['ids']);
                        $new_gallery_ids = array();
                        foreach ($gallery_ids as $gallery_id) {
                            $new_gallery_ids[] = $one_click->install_package->lookup_map('attachments', $gallery_id);
                        }
                        // replace old ids with new ones
                        $old_string = 'ids="' . implode(',', $gallery_ids) . '"';
                        $new_string = 'ids="' . implode(',', $new_gallery_ids) . '"';
                        $post_object->post_content = str_replace($old_string, $new_string, $post_object->post_content);
                    }
                }
            }
        }
    }
    if (!empty($post_object->post_content)) {
        $html = str_get_html($post_object->post_content);
        $imgs = $html->find('img');
        foreach ($imgs as $img) {
            $replace_image_src = $one_click->install_package->lookup_map('images', $img->src);
            if (false !== $replace_image_src) {
                $img->src = $replace_image_src;
            }
        }
        $post_object->post_content = $html->save();
        $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'vc_single_image', 'image', 'attachments');
        $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'vc_row', 'background_image', 'attachments');
        $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'shapedimage', 'image', 'attachments');
        $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'staff_featured', 'member', 'oxy_staff');
        $post_object->post_content = $one_click->replace_shortcode_attachment_id($post_object->post_content, 'post_featured', 'featured', 'post');
    }
    // replace post content with one from object
    $post['post_content'] = $post_object->post_content;
    return $post;
}
Exemplo n.º 2
0
function oxy_shortcode_appland_gallery($atts, $content = '')
{
    // setup options
    extract(shortcode_atts(array('count' => 3, 'columns' => 3, 'rows' => 2, 'gallery' => ''), $atts));
    $query_options = array('post_type' => 'oxy_gallery_item', 'numberposts' => $count, 'orderby' => 'menu_order', 'order' => 'ASC');
    $filters = get_terms('oxy_gallery_categories', array('hide_empty' => 1));
    if (!empty($gallery)) {
        $galleries = explode(',', $gallery);
        $query_options['tax_query'][] = array('taxonomy' => 'oxy_gallery_categories', 'field' => 'slug', 'terms' => $galleries);
    }
    $span = $columns == 3 ? 'span4' : 'span3';
    // fetch posts
    $attachments = get_posts($query_options);
    $attachments_count = count($attachments);
    $output = '';
    //  ----------------------
    $span_width = $columns > 0 ? floor(12 / $columns) : 12;
    $gallery_id = 'gallery-' . rand(1, 100);
    $output = '<div class="carousel slide thumbs" id="' . $gallery_id . '">';
    $output .= '<div class="carousel-inner">';
    $output .= '<div class="active item">';
    $output .= '<ul class="thumbnails thumbnail-list">';
    $item = 1;
    foreach ($attachments as $attachment) {
        global $post;
        $post = $attachment;
        setup_postdata($post);
        $format = get_post_format($post->ID);
        if (false === $format) {
            $format = 'standard';
        }
        $use_magnific = get_post_meta($post->ID, THEME_SHORT . '_open_magnific', true);
        $link = get_post_meta($post->ID, THEME_SHORT . '_external_link', true);
        if ($link) {
            // overide magnific settings
            $use_magnific = false;
            $popup_class = '';
            $full = $link;
        }
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
        $extra_gallery_images = array();
        $gallery_links = "";
        if ($use_magnific) {
            switch ($format) {
                case 'gallery':
                    $gallery_ids = oxy_get_content_gallery($post);
                    if ($gallery_ids !== null) {
                        if (count($gallery_ids) > 0) {
                            // use the first image as thumbnail for the gallery
                            // $gallery_thumb = wp_get_attachment_image_src( $gallery_ids[0], 'full');
                            // $thumbnail = $gallery_thumb;
                            // remove first gallery image from array
                            // array_shift( $gallery_ids );
                            foreach ($gallery_ids as $gallery_image_id) {
                                $gallery_image = wp_get_attachment_image_src($gallery_image_id, 'full');
                                $extra_gallery_images[] = $gallery_image[0];
                            }
                        }
                        $popup_class = 'popup-gallery';
                        $gallery_links = implode(",", $extra_gallery_images);
                    }
                    break;
                case 'video':
                    $video_shortcode = oxy_get_content_shortcode($post, 'embed');
                    if ($video_shortcode !== null) {
                        if (isset($video_shortcode[5])) {
                            $video_shortcode = $video_shortcode[5];
                            if (isset($video_shortcode[0])) {
                                $popup_class = 'popup-video';
                                $full = $video_shortcode[0];
                            }
                        }
                    }
                    break;
                default:
                case 'standard':
                    $full = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                    $full = $full[0];
                    $popup_class = 'popup-image';
                    break;
            }
        }
        if ($item > $columns * $rows) {
            $output .= '</ul></div><div class="item"><ul class="thumbnails thumbnail-list">';
            $item = 1;
        }
        $output .= '<li class="span' . $span_width . '">';
        $output .= '<figure class="thumbnail-figure">';
        $output .= '<figcaption>';
        $output .= get_the_excerpt();
        $output .= '</figcaption>';
        if ($use_magnific || $link) {
            $output .= '<a class="popup-link ' . $popup_class . '" href="' . $full . '">';
        }
        $output .= '<img src="' . $thumbnail[0] . '"';
        if ($use_magnific || $link) {
            $output .= "" !== $gallery_links ? 'data-links="' . $gallery_links . '"' : "";
            $output .= '><i></i>';
            $output .= '</a>';
        }
        $output .= '</figure></li>';
        $item++;
    }
    $output .= '</ul>';
    $output .= '</div></div>';
    $output .= '<a class="carousel-control left" data-slide="prev" href="#' . $gallery_id . '"><i class="icon-chevron-left"></i></a>';
    $output .= '<a class="carousel-control right" data-slide="next" href="#' . $gallery_id . '"><i class="icon-chevron-right"></i></a>';
    $output .= '</div>';
    wp_reset_postdata();
    return $output;
}
Exemplo n.º 3
0
/**
 * Shows a simple single post
 *
 * @package Omega
 * @subpackage Frontend
 * @since 1.0
 *
 * @copyright (c) 2014 Oxygenna.com
 * @license http://wiki.envato.com/support/legal-terms/licensing-terms/
 * @version 1.7.3
 */
global $wp_embed;
global $post;
$content = get_the_content('', oxy_get_option('blog_stripteaser') === 'on');
$video_shortcode = oxy_get_content_shortcode($post, 'embed');
$extra_post_class = oxy_get_option('blog_post_icons') === 'on' ? 'post-showinfo' : '';
if ($video_shortcode !== null) {
    if (isset($video_shortcode[0])) {
        $video_shortcode = $video_shortcode[0];
        if (isset($video_shortcode[0])) {
            $content = str_replace($video_shortcode[0], '', $content);
        }
    }
}
?>
<article id="post-<?php 
the_ID();
?>
" <?php 
post_class($extra_post_class);
Exemplo n.º 4
0
/**
 * Shows a simple single post
 *
 * @package Omega
 * @subpackage Frontend
 * @since 1.0
 *
 * @copyright (c) 2014 Oxygenna.com
 * @license http://wiki.envato.com/support/legal-terms/licensing-terms/
 * @version 1.7.3
 */
global $oxy_theme_options;
global $post;
$content = get_the_content('', oxy_get_option('blog_stripteaser') === 'on');
$extra_post_class = oxy_get_option('blog_post_icons') === 'on' ? 'post-showinfo' : '';
$gallery_shortcode = oxy_get_content_shortcode($post, 'gallery');
$gallery_ids = null;
if ($gallery_shortcode !== null) {
    if (isset($gallery_shortcode[0])) {
        if (array_key_exists(3, $gallery_shortcode)) {
            if (array_key_exists(0, $gallery_shortcode[3])) {
                $gallery_attrs = shortcode_parse_atts($gallery_shortcode[3][0]);
                if (array_key_exists('ids', $gallery_attrs)) {
                    $gallery_ids = explode(',', $gallery_attrs['ids']);
                }
            }
        }
        // strip shortcode from the content
        $content = str_replace($gallery_shortcode[0], '', $content);
    }
}
Exemplo n.º 5
0
/**
 * Shows a simple single post
 *
 * @package Omega
 * @subpackage Frontend
 * @since 1.0
 *
 * @copyright (c) 2014 Oxygenna.com
 * @license http://wiki.envato.com/support/legal-terms/licensing-terms/
 * @version 1.7.3
 */
global $wp_embed;
global $post;
$content = get_the_content('', oxy_get_option('blog_stripteaser') === 'on');
$extra_post_class = oxy_get_option('blog_post_icons') === 'on' ? 'post-showinfo' : '';
$audio_shortcode = oxy_get_content_shortcode($post, 'audio');
if ($audio_shortcode !== null) {
    $audio_src = null;
    if (array_key_exists(3, $audio_shortcode)) {
        if (array_key_exists(0, $audio_shortcode[3])) {
            $audio_attrs = shortcode_parse_atts($audio_shortcode[3][0]);
            if (array_key_exists('src', $audio_attrs)) {
                $audio_src = $audio_attrs['src'];
            }
        }
        $content = str_replace($audio_shortcode[0][0], '', $content);
    }
}
?>
<article id="post-<?php 
the_ID();
Exemplo n.º 6
0
function oxy_get_portfolio_item_data($item)
{
    // setup post data
    global $post;
    $post = $item;
    setup_postdata($post);
    global $more;
    // Declare global $more (before the loop).
    $more = 0;
    // grab the featured image
    $full_image_id = get_post_thumbnail_id($post->ID);
    $full_image_src = wp_get_attachment_image_src($full_image_id, 'full');
    // create info data structure
    $info = new stdClass();
    $info->title = get_the_title($post->ID);
    if (false !== $full_image_src) {
        $info->full_image_url = $full_image_src[0];
    } else {
        $info->full_image_url = '';
    }
    // set default popup link
    $info->popup_link = $info->full_image_url;
    $info->isGallery = false;
    // post format specific data
    $format = get_post_format($post->ID);
    if (false === $format) {
        $format = 'standard';
    }
    switch ($format) {
        case 'standard':
            $info->icon = 'fa fa-search-plus';
            $info->popup_class = 'magnific';
            break;
        case 'image':
            $info->icon = 'fa fa-picture-o';
            $info->popup_class = 'magnific';
            break;
        case 'video':
            $info->icon = 'fa fa-play';
            $info->popup_class = 'magnific-vimeo';
            $video_shortcode = oxy_get_content_shortcode($post, 'embed');
            if ($video_shortcode !== null) {
                if (isset($video_shortcode[5])) {
                    $video_shortcode = $video_shortcode[5];
                    if (isset($video_shortcode[0])) {
                        $info->popup_link = $video_shortcode[0];
                    }
                }
            }
            break;
        case 'audio':
            $info->icon = 'fa fa-play';
            $info->popup_class = 'magnific-audio';
            $audio_shortcode = oxy_get_content_shortcode($post, 'audio');
            if ($audio_shortcode !== null) {
                $audio_src = null;
                if (array_key_exists(3, $audio_shortcode)) {
                    if (array_key_exists(0, $audio_shortcode[3])) {
                        $audio_attrs = shortcode_parse_atts($audio_shortcode[3][0]);
                        if (array_key_exists('src', $audio_attrs)) {
                            $info->popup_link = $audio_attrs['src'];
                        }
                    }
                }
            }
            break;
        case 'gallery':
            $info->icon = 'fa fa-search-plus';
            $info->popup_class = 'magnific-gallery';
            $info->isGallery = true;
            $gallery_ids = oxy_get_content_gallery($post);
            if ($gallery_ids !== null) {
                if (count($gallery_ids) > 0) {
                    // ok lets create a gallery
                    $gallery_rel = 'rel="gallery' . $post->ID . '"';
                    $gallery_images = array();
                    foreach ($gallery_ids as $gallery_image_id) {
                        $gallery_image = wp_get_attachment_image_src($gallery_image_id, 'full');
                        $gallery_images[] = $gallery_image[0];
                    }
                    $info->gallery_links = implode(",", $gallery_images);
                }
            }
            break;
    }
    $info->item_link = get_permalink($post->ID);
    return $info;
}