本文整理汇总了PHP中presscore_get_attachment_post_data函数的典型用法代码示例。如果您正苦于以下问题:PHP presscore_get_attachment_post_data函数的具体用法?PHP presscore_get_attachment_post_data怎么用?PHP presscore_get_attachment_post_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了presscore_get_attachment_post_data函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shortcode
public function shortcode($atts, $content = null)
{
$attributes = $this->sanitize_attributes($atts);
if (presscore_vc_is_inline()) {
$terms_list = presscore_get_terms_list_by_slug(array('slugs' => $attributes['category'], 'taxonomy' => $this->taxonomy));
$dummy = '
<div class="dt_vc-shortcode_dummy dt_vc-photos_scroller" style="height: ' . $slider_args['height'] . 'px;">
<h5>Photos scroller</h5>
<p class="text-small"><strong>Display categories:</strong> ' . $terms_list . '</p>
</div>
';
return $dummy;
}
$attachments_ids = array();
// get albums
$dt_query = $this->get_posts_by_terms(array_merge($attributes, array('number' => -1)));
if ($dt_query->have_posts()) {
// take albums id
foreach ($dt_query->posts as $dt_post) {
$album_attachments = get_post_meta($dt_post->ID, '_dt_album_media_items', true);
if ($album_attachments) {
$attachments_ids = array_merge($attachments_ids, $album_attachments);
}
}
}
if ('rand' == $attributes['orderby']) {
shuffle($attachments_ids);
}
// new query to take attachments
$attachments_data = presscore_get_attachment_post_data($attachments_ids, 'post__in', 'DESC', $attributes['number']);
$config = Presscore_Config::get_instance();
$slider_class = array('shortcode-instagram');
if ('disabled' == $config->get('sidebar_position')) {
$slider_class[] = 'full';
}
$slider_style = array();
if ($attributes['margin_bottom']) {
$slider_style[] = 'margin-bottom: ' . $attributes['margin_bottom'];
}
if ($attributes['margin_top']) {
$slider_style[] = 'margin-top: ' . $attributes['margin_top'];
}
$slider_fields = array();
/*if ( $attributes['arrows'] ) {
$slider_fields[] = 'arrows';
}*/
$sharebuttons = presscore_get_share_buttons_for_prettyphoto('photo');
$slider_args = array('fields' => $slider_fields, 'class' => $slider_class, 'style' => implode(';', $slider_style), 'link' => $attributes['lightbox'] ? 'file' : 'none', 'popup' => $attributes['lightbox'] ? 'gallery' : 'none', 'container_attr' => $sharebuttons);
/*if ( $attributes['slider_title'] ) {
$slider_args['title'] = $attributes['slider_title'];
}*/
if ($attributes['height']) {
$slider_args['height'] = $attributes['height'];
}
if ($attributes['width']) {
$slider_args['img_width'] = $attributes['width'];
}
$output = presscore_get_fullwidth_slider_two($attachments_data, $slider_args);
return $output;
}
示例2: shortcode
public function shortcode($atts, $content = null)
{
extract(shortcode_atts(array('posts' => '', 'width' => '800', 'height' => '450', 'autoplay' => 'false', 'interval' => '5000'), $atts));
// sanitize attributes
$width = absint($width);
$height = absint($height);
$interval = absint($interval);
$autoplay = apply_filters('dt_sanitize_flag', $autoplay);
$posts = array_map('trim', explode(',', $posts));
$attachments_id = array();
$selected_posts_titles = array();
if ($posts) {
// get posts by slug
foreach ($posts as $post_slug) {
$args = array('no_found_rows' => 1, 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'post_type' => 'dt_slideshow', 'post_status' => 'publish', 'name' => $post_slug);
$dt_query = new WP_Query($args);
if ($dt_query->have_posts()) {
$dt_post = $dt_query->posts[0];
$selected_posts_titles[] = get_the_title($dt_post);
$slides_id = get_post_meta($dt_post->ID, '_dt_slider_media_items', true);
if ($slides_id) {
$attachments_id = array_merge($attachments_id, $slides_id);
}
}
}
// get fresh one
} else {
$args = array('no_found_rows' => 1, 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'post_type' => 'dt_slideshow', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC');
$dt_query = new WP_Query($args);
if ($dt_query->have_posts()) {
$dt_post = $dt_query->posts[0];
$selected_posts_titles[] = get_the_title($dt_post);
$slides_id = get_post_meta($dt_post->ID, '_dt_slider_media_items', true);
if ($slides_id) {
$attachments_id = array_merge($attachments_id, $slides_id);
}
}
}
if (function_exists('vc_is_inline') && vc_is_inline()) {
if (empty($selected_posts_titles)) {
$dummy_posts_titles = __('No posts selected', 'the7mk2');
} else {
$dummy_posts_titles = esc_html(join(', ', $selected_posts_titles));
}
$output = '
<div class="dt_vc-shortcode_dummy dt_vc-royal_slider" style="height: 250px;">
<h5>Royal slider</h4>
<p class="text-small"><strong>Display slider(s):</strong> ' . $dummy_posts_titles . '</p>
</div>
';
} else {
$attachments_data = presscore_get_attachment_post_data($attachments_id);
$output = presscore_get_royal_slider($attachments_data, array('width' => $width, 'height' => $height, 'autoplay' => $autoplay, 'interval' => $interval, 'class' => array('slider-simple', 'shortcode-royal-slider'), 'style' => ' style="width: 100%"'));
}
return $output;
}
示例3: presscore_get_project_media_slider
/**
* Portfolio media slider.
*
* Based on royal slider. Properly works only in the loop.
*
* @param array $class
* @return string
*/
function presscore_get_project_media_slider($class = array())
{
global $post;
// slideshow dimensions
$slider_proportions = get_post_meta($post->ID, '_dt_project_options_slider_proportions', true);
$slider_proportions = wp_parse_args($slider_proportions, array('width' => '', 'height' => ''));
$width = $slider_proportions['width'];
$height = $slider_proportions['height'];
// get slideshow
$media_items = get_post_meta($post->ID, '_dt_project_media_items', true);
$slideshow = '';
if (!$media_items) {
$media_items = array();
}
// if we have post thumbnail and it's not hidden
if (has_post_thumbnail()) {
if (is_single()) {
if (!get_post_meta($post->ID, '_dt_project_options_hide_thumbnail', true)) {
array_unshift($media_items, get_post_thumbnail_id());
}
} else {
array_unshift($media_items, get_post_thumbnail_id());
}
}
$attachments_data = presscore_get_attachment_post_data($media_items);
// TODO: make it clean and simple
if (count($attachments_data) > 1) {
$slideshow = presscore_get_royal_slider($attachments_data, array('width' => $width, 'height' => $height, 'class' => $class, 'style' => ' style="width: 100%"'));
} elseif (!empty($attachments_data)) {
$image = current($attachments_data);
$thumb_id = $image['ID'];
$thumb_meta = array($image['full'], $image['width'], $image['height']);
$video_url = esc_url(get_post_meta($thumb_id, 'dt-video-url', true));
$thumb_args = array('img_meta' => $thumb_meta, 'img_id' => $thumb_id, 'img_class' => 'preload-me', 'class' => 'alignnone rollover', 'href' => get_permalink($post->ID), 'wrap' => '<a %CLASS% %HREF% %TITLE% %CUSTOM%><img %IMG_CLASS% %SRC% %ALT% %SIZE% /></a>', 'echo' => false);
if ($video_url) {
$thumb_args['class'] = 'alignnone rollover-video';
}
$thumb_args = apply_filters('dt_portfolio_thumbnail_args', $thumb_args);
$slideshow = dt_get_thumb_img($thumb_args);
}
return $slideshow;
}
示例4: shortcode
public function shortcode($atts, $content = null)
{
extract(shortcode_atts(array('posts' => '', 'width' => '1200', 'height' => '500'), $atts));
// sanitize attributes
$width = absint($width);
$height = absint($height);
$posts = array_map('trim', explode(',', $posts));
$attachments_id = array();
if ($posts) {
// get posts by slug
foreach ($posts as $post_slug) {
$args = array('no_found_rows' => 1, 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'post_type' => 'dt_slideshow', 'post_status' => 'publish', 'name' => $post_slug);
$dt_query = new WP_Query($args);
if ($dt_query->have_posts()) {
$dt_post = $dt_query->posts[0];
$slides_id = get_post_meta($dt_post->ID, '_dt_slider_media_items', true);
if ($slides_id) {
$attachments_id = array_merge($attachments_id, $slides_id);
}
}
}
// get fresh one
} else {
$args = array('no_found_rows' => 1, 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'post_type' => 'dt_slideshow', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC');
$dt_query = new WP_Query($args);
if ($dt_query->have_posts()) {
$dt_post = $dt_query->posts[0];
$slides_id = get_post_meta($dt_post->ID, '_dt_slider_media_items', true);
if ($slides_id) {
$attachments_id = array_merge($attachments_id, $slides_id);
}
}
}
$attachments_data = presscore_get_attachment_post_data($attachments_id);
$output = presscore_get_royal_slider($attachments_data, array('width' => $width, 'height' => $height, 'class' => array('slider-simple'), 'style' => ' style="width: 100%"'));
return $output;
}
示例5: get_post_meta
* Arhive content.
*
*/
// File Security Check
if (!defined('ABSPATH')) {
exit;
}
global $post;
$config = Presscore_Config::get_instance();
$media_items = get_post_meta($post->ID, '_dt_album_media_items', true);
$exclude_cover = get_post_meta($post->ID, '_dt_album_options_exclude_featured_image', true);
// if we have post thumbnail and it's not hidden
if (has_post_thumbnail()) {
array_unshift($media_items, get_post_thumbnail_id());
}
$attachments_data = presscore_get_attachment_post_data($media_items);
// if there are one image in gallery
if (count($attachments_data) == 1) {
$class[] = 'rollover-zoom';
$exclude_cover = false;
}
$style = ' style="width: 270px;"';
$rell = '';
?>
<?php
do_action('presscore_before_post');
?>
<article id="post-<?php
the_ID();
示例6: presscore_mod_albums_get_preview_gallery
/**
* @param string $class
* @return string
*/
function presscore_mod_albums_get_preview_gallery($class = '')
{
$config = presscore_config();
// get gallery items
$media_items = $config->get('post.media.library');
if (!$media_items) {
$media_items = array();
}
$open_post = 'post' == $config->get('post.open_as');
$exclude_cover = !$config->get('post.media.featured_image.enabled') && has_post_thumbnail();
// get gallery cover
if (has_post_thumbnail()) {
$gallery_cover = presscore_get_attachment_post_data(array(get_post_thumbnail_id()));
// if ! exlude cover - prepend cover
if (!$exclude_cover) {
array_unshift($media_items, get_post_thumbnail_id());
}
} else {
if ($media_items) {
$gallery_cover = presscore_get_attachment_post_data(array($media_items[0]));
} else {
$gallery_cover = array();
}
}
$gallery_cover = current($gallery_cover);
if (post_password_required() || $open_post) {
$media_items = array();
}
$class .= ' rollover-click-target';
// If album lead to single post we need to display only one image
if ($open_post) {
$class .= ' go-to';
}
// get attachments data
$attachments_data = presscore_get_attachment_post_data($media_items);
$gallery_args = array('class' => $class, 'exclude_cover' => $exclude_cover, 'title_img_options' => presscore_set_image_dimesions(), 'share_buttons' => true, 'attachments_count' => false, 'video_icon' => false, 'show_preview_on_hover' => false);
// open album post instead lightbox gallery
if ($open_post) {
$gallery_args['title_image_args'] = array('href' => get_permalink(), 'class' => $class);
}
return presscore_get_images_gallery_hoovered($gallery_cover, $attachments_data, $gallery_args);
}
示例7: presscore_render_3d_slider_data
/**
* Render 3D slider.
*
*/
function presscore_render_3d_slider_data()
{
global $post;
$config = Presscore_Config::get_instance();
$slider_id = $config->get('slideshow_sliders');
$slideshows = Presscore_Inc_Slideshow_Post_Type::get_by_id($slider_id);
if (!$slideshows || !$slideshows->have_posts()) {
return;
}
$slides = array();
foreach ($slideshows->posts as $slideshow) {
$media_items = get_post_meta($slideshow->ID, '_dt_slider_media_items', true);
if (empty($media_items)) {
continue;
}
$slides = array_merge($slides, $media_items);
}
$attachments_data = presscore_get_attachment_post_data($slides);
$count = count($attachments_data);
if ($count < 10) {
$chunks = array($attachments_data, array(), array());
} else {
$length = ceil($count / 3);
$chunks = array_chunk($attachments_data, $length);
}
$chunks = array_reverse($chunks);
foreach ($chunks as $layer => $images) {
printf('<div id="level%d" class="plane">' . "\n", $layer + 1);
foreach ($images as $img) {
printf('<img src="%s" alt="%s" />' . "\n", esc_url($img['full']), esc_attr($img['description']));
}
echo "</div>\n";
}
}
示例8: shortcode
public function shortcode($atts, $content = null)
{
$attributes = shortcode_atts(array('category' => '', 'number' => '6', 'orderby' => 'recent', 'height' => '270', 'margin_top' => '', 'margin_bottom' => '', 'width' => '', 'lightbox' => ''), $atts);
// sanitize attributes
$attributes['number'] = apply_filters('dt_sanitize_posts_per_page', $attributes['number']);
$attributes['orderby'] = in_array($attributes['orderby'], array('recent', 'random')) ? $attributes['orderby'] : 'recent';
$attributes['height'] = absint($attributes['height']);
$attributes['width'] = absint($attributes['width']);
$attributes['margin_top'] = $attributes['margin_top'] ? intval($attributes['margin_top']) . 'px' : '';
$attributes['margin_bottom'] = $attributes['margin_bottom'] ? intval($attributes['margin_bottom']) . 'px' : '';
// $attributes['arrows'] = apply_filters('dt_sanitize_flag', $attributes['arrows']);
$attributes['lightbox'] = apply_filters('dt_sanitize_flag', $attributes['lightbox']);
// $attributes['slider_title'] = wp_kses($content, array());
if ('recent' == $attributes['orderby']) {
$attributes['orderby'] = 'date';
} elseif ('random' == $attributes['orderby']) {
$attributes['orderby'] = 'rand';
}
if ($attributes['category']) {
$attributes['category'] = explode(',', $attributes['category']);
$attributes['category'] = array_map('trim', $attributes['category']);
$attributes['select'] = 'only';
} else {
$attributes['select'] = 'all';
}
$attachments_ids = array();
// get albums
$dt_query = $this->get_posts_by_terms(array_merge($attributes, array('number' => -1)));
if ($dt_query->have_posts()) {
// take albums id
foreach ($dt_query->posts as $dt_post) {
$album_attachments = get_post_meta($dt_post->ID, '_dt_album_media_items', true);
if ($album_attachments) {
$attachments_ids = array_merge($attachments_ids, $album_attachments);
}
}
}
if ('rand' == $attributes['orderby']) {
shuffle($attachments_ids);
}
// new query to take attachments
$attachments_data = presscore_get_attachment_post_data($attachments_ids, 'post__in', 'DESC', $attributes['number']);
$config = Presscore_Config::get_instance();
$slider_class = array('shortcode-instagram');
$slider_style = array();
if ($attributes['margin_bottom']) {
$slider_style[] = 'margin-bottom: ' . $attributes['margin_bottom'];
}
if ($attributes['margin_top']) {
$slider_style[] = 'margin-top: ' . $attributes['margin_top'];
}
$slider_fields = array();
/*if ( $attributes['arrows'] ) {
$slider_fields[] = 'arrows';
}*/
$sharebuttons = presscore_get_share_buttons_for_prettyphoto('photo');
$slider_args = array('fields' => $slider_fields, 'class' => $slider_class, 'style' => implode(';', $slider_style), 'link' => $attributes['lightbox'] ? 'file' : 'none', 'popup' => $attributes['lightbox'] ? 'gallery' : 'none', 'container_attr' => $sharebuttons);
/*if ( $attributes['slider_title'] ) {
$slider_args['title'] = $attributes['slider_title'];
}*/
if ($attributes['height']) {
$slider_args['height'] = $attributes['height'];
}
if ($attributes['width']) {
$slider_args['img_width'] = $attributes['width'];
}
$output = presscore_get_fullwidth_slider_two($attachments_data, $slider_args);
if (function_exists('vc_is_inline') && vc_is_inline()) {
$terms_list = presscore_get_terms_list_by_slug(array('slugs' => $attributes['category'], 'taxonomy' => 'dt_gallery_category'));
$output = '
<div class="dt_vc-shortcode_dummy dt_vc-photos_scroller" style="height: ' . $slider_args['height'] . 'px;">
<h5>Photos scroller</h5>
<p class="text-small"><strong>Display categories:</strong> ' . $terms_list . '</p>
</div>
';
}
return $output;
}
示例9: presscore_get_related_posts
/**
* Get related posts attachments data slightly modified.
*
* @return array Attachments data.
*/
function presscore_get_related_posts($options = array())
{
$default_options = array('select' => 'only', 'exclude_current' => true, 'args' => array());
$options = wp_parse_args($options, $default_options);
// exclude current post if in the loop
if (in_the_loop() && $options['exclude_current']) {
$options['args'] = array_merge($options['args'], array('post__not_in' => array(get_the_ID())));
}
$posts = presscore_get_posts_in_categories($options);
$attachments_ids = array();
$attachments_data_override = array();
$posts_data = array();
// get posts attachments id
if ($posts->have_posts()) {
while ($posts->have_posts()) {
$posts->the_post();
// thumbnail or first attachment id
if (has_post_thumbnail()) {
$attachments_ids[] = get_post_thumbnail_id();
} else {
if ($attachment = presscore_get_first_image()) {
$attachments_ids[] = $attachment->ID;
} else {
$attachments_ids[] = 0;
}
}
switch (get_post_type()) {
case 'post':
$post_meta = presscore_new_posted_on('post');
break;
case 'dt_portfolio':
$post_meta = presscore_new_posted_on('dt_portfolio');
break;
default:
$post_meta = presscore_new_posted_on();
}
$attachments_data_override[] = array('permalink' => get_permalink(), 'link' => presscore_get_project_link('project-link'), 'title' => get_the_title(), 'description' => get_the_excerpt(), 'alt' => get_the_title(), 'parent_id' => get_the_ID(), 'meta' => $post_meta);
}
wp_reset_postdata();
}
if ($attachments_ids) {
// what we want
$attachments_data = presscore_get_attachment_post_data($attachments_ids);
// what we get
$attachments_data_ids = array();
if ($attachments_data) {
$attachments_data_ids = wp_list_pluck($attachments_data, 'ID');
}
$default_image = presscore_get_default_image();
foreach ($attachments_ids as $key => $id) {
$attachments_data_key = array_search($id, $attachments_data_ids);
// if there are image - add it to array
if (false !== $attachments_data_key) {
$posts_data[$key] = $attachments_data[$attachments_data_key];
// or add noimage
} else {
$posts_data[$key] = array('full' => $default_image[0], 'width' => $default_image[1], 'height' => $default_image[2]);
}
if (isset($attachments_data_override[$key])) {
$posts_data[$key] = array_merge($posts_data[$key], $attachments_data_override[$key]);
}
}
}
return $posts_data;
}