本文整理汇总了PHP中get_children函数的典型用法代码示例。如果您正苦于以下问题:PHP get_children函数的具体用法?PHP get_children怎么用?PHP get_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_children函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setup
public static function setup($output, $attr)
{
global $post;
$html5 = current_theme_supports('html5');
$atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'itemtag' => $html5 ? 'figure' : 'dl', 'icontag' => $html5 ? 'div' : 'dt', 'captiontag' => $html5 ? 'figcaption' : 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'link' => ''), $attr, 'gallery');
$id = intval($atts['id']);
if (!empty($atts['include'])) {
$posts = get_posts(array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
$attachments = array();
foreach ($posts as $key => $val) {
$attachments[$val->ID] = $posts[$key];
}
} elseif (!empty($atts['exclude'])) {
$attachments = get_children(array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
} else {
$attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']));
}
if (count($attachments)) {
foreach ($attachments as &$attachment) {
$attachment = new \TimberImage($attachment);
}
// add a static incrementer for the gallery HTML ID to allow more than one per page.
static $gallery_inc = 0;
$gallery_inc++;
$data['id'] = sprintf("gallery-%s", $gallery_inc);
$data['thumbnails'] = $attachments;
return \Timber::compile('gallery.twig', $data);
}
}
开发者ID:benedict-w,项目名称:pressgang,代码行数:29,代码来源:gallery.php
示例2: roots_gallery
/**
* Clean up gallery_shortcode()
*
* Re-create the [gallery] shortcode and use thumbnails styling from Bootstrap
*
* @link http://twitter.github.com/bootstrap/components.html#thumbnails
*/
function roots_gallery($attr)
{
$post = get_post();
static $instance = 0;
$instance++;
if (!empty($attr['ids'])) {
if (empty($attr['orderby'])) {
$attr['orderby'] = 'post__in';
}
$attr['include'] = $attr['ids'];
}
$output = apply_filters('post_gallery', '', $attr);
if ($output != '') {
return $output;
}
if (isset($attr['orderby'])) {
$attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
if (!$attr['orderby']) {
unset($attr['orderby']);
}
}
extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => '', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'link' => 'file'), $attr));
$id = intval($id);
if ($order === 'RAND') {
$orderby = 'none';
}
if (!empty($include)) {
$_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
$attachments = array();
foreach ($_attachments as $key => $val) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif (!empty($exclude)) {
$attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
} else {
$attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
}
if (empty($attachments)) {
return '';
}
if (is_feed()) {
$output = "\n";
foreach ($attachments as $att_id => $attachment) {
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
}
return $output;
}
$output = '<ul class="thumbnails gallery">';
$i = 0;
foreach ($attachments as $id => $attachment) {
$image = 'file' == $link ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
$output .= '<li>' . $image;
if (trim($attachment->post_excerpt)) {
$output .= '<div class="caption hidden">' . wptexturize($attachment->post_excerpt) . '</div>';
}
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
开发者ID:NaszvadiG,项目名称:roots,代码行数:67,代码来源:gallery.php
示例3: tclm
function tclm()
{
if (!isset($_POST['fid']) or empty($_POST['fid'])) {
$path = 0;
} else {
$fid = $_POST['fid'];
$a = $this->where('typeid=' . $fid)->field('path,typeid')->find();
if ($a) {
$path = $a['path'] . '-' . $a['typeid'];
} else {
$path = '0';
}
}
//修改时注意将自身的子孙path也修改下
if (isset($_POST['typeid']) && intval($_POST['typeid']) > 0) {
$typeid = intval($_POST['typeid']);
$substr = get_children($typeid, 0);
if ($substr != '') {
$old_path = $this->where('typeid=' . $typeid)->getField('path');
$new_str = 'replace(`path`,\'' . $old_path . '-' . $typeid . '\',\'' . $path . '-' . $typeid . '\')';
$sql = "UPDATE `" . C('DB_PREFIX') . "type` SET `path`=" . $new_str . " WHERE typeid in(" . $substr . ")";
M()->query($sql);
}
}
return $path;
}
开发者ID:babyhuangshiming,项目名称:webserver,代码行数:26,代码来源:TypeModel.class.php
示例4: get_image
/**
* Determine the correct image to use for the post
*/
function get_image()
{
// Get the arguments
$args = $this->args;
$image = array();
extract($args);
// First use the "Featured Image" thumbnail if set
$thumb_id = get_post_thumbnail_id($post_id);
if (!empty($thumb_id)) {
$thumb_id = get_post_thumbnail_id($post_id);
$src = wp_get_attachment_image_src($thumb_id, $size);
$img = $src[0];
// Next try scanning the post for attachments
} else {
$att_args = array('numberposts' => 1, 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image', 'post_status' => null);
$attachments = get_children($att_args);
// If attachments were found, grab the first one which is a valid image
if ($attachments) {
foreach ($attachments as $att) {
$src = wp_get_attachment_image_src($att->ID, $size);
$img = $src[0];
if (!empty($img)) {
break;
}
}
}
// If we still have nothing, grab a default
if (empty($img)) {
$img = THEME_URI . '/images/avatars/foundry-thumb.jpg';
}
}
// Return the image
return $img;
}
开发者ID:tamriel-foundry,项目名称:apoc2,代码行数:37,代码来源:thumbnail.php
示例5: photoline_modified_post_gallery
function photoline_modified_post_gallery($output, $attr)
{
global $post;
static $instance = 0;
$instance++;
//disable all filter
if (empty($attr['type']) || $attr['type'] != 'slider') {
return;
}
if (isset($attr['orderby'])) {
$attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
if (!$attr['orderby']) {
unset($attr['orderby']);
}
}
extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'size' => 'photoline-featured', 'include' => '', 'exclude' => ''), $attr));
$id = intval($id);
if ('RAND' == $order) {
$orderby = 'none';
}
if (!empty($include)) {
$include = preg_replace('/[^0-9,]+/', '', $include);
$_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
$attachments = array();
foreach ($_attachments as $key => $val) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif (!empty($exclude)) {
$exclude = preg_replace('/[^0-9,]+/', '', $exclude);
$attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
} else {
$attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
}
if (empty($attachments)) {
return '';
}
if (is_feed()) {
$output = "\n";
foreach ($attachments as $att_id => $attachment) {
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
}
return $output;
}
$selector = "gallery-{$instance}";
$size_class = sanitize_html_class($size);
$gallery_div = "<div id='{$selector}' class='gallery galleryid-{$id} gallery-size-{$size_class} flexslider'>";
$output = apply_filters('gallery_style', $gallery_div);
$output .= '<ul class="slides">';
$i = 0;
foreach ($attachments as $id => $attachment) {
$caption = !empty($attachment->post_excerpt) ? '<p class="flex-caption wp-caption-text gallery-caption">' . wptexturize($attachment->post_excerpt) . '</p>' : '';
$image = wp_get_attachment_image($id, $size);
$output .= '<li>';
$output .= $image;
$output .= $caption;
$output .= '</li>';
}
$output .= "\r\n </ul><!-- .slides -->\r\n </div>\n";
return $output;
}
开发者ID:AlexanderDolgan,项目名称:ojahuri,代码行数:60,代码来源:gallery-layout.php
示例6: my_custom_columns
function my_custom_columns($column)
{
global $post;
// Bildstorlek
$width = (int) 200;
$height = (int) 125;
if ('ID' == $column) {
echo $post->ID;
} elseif ('thumbnail' == $column) {
// thumbnail of WP 2.9
$thumbnail_id = get_post_meta($post->ID, '_thumbnail_id', true);
// image from gallery
$attachments = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
if ($thumbnail_id) {
$thumb = wp_get_attachment_image($thumbnail_id, array($width, $height), true);
} elseif ($attachments) {
foreach ($attachments as $attachment_id => $attachment) {
$thumb = wp_get_attachment_image($attachment_id, array($width, $height), true);
}
}
if (isset($thumb) && $thumb) {
echo $thumb;
} else {
echo __('None');
}
} elseif ('description' == $column) {
echo $post->post_content;
}
}
开发者ID:Jonatan,项目名称:makthavare,代码行数:29,代码来源:makthavare.php
示例7: prettyfilelist_shortcode
public function prettyfilelist_shortcode($atts, $content = null)
{
//Get attributes from shortcode
extract(shortcode_atts(array("type" => "excel,pdf,doc,zip,ppt", "filesperpage" => "7"), $atts));
$html = '';
//Set paging numbers
$params = array('pageAt' => $filesperpage);
wp_localize_script('prettylistjs', 'prettylistScriptParams', $params);
wp_enqueue_script("jquery");
wp_enqueue_script('prettylistjs');
//Get a string of mime types we want
$mimeTypesToGet = $this->TypeToMime($type);
//Check to see if we want all types
//If all types add filters
//Get all attachments of the right type
//TODO:Add option for 'orderby' => 'title'
$args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => get_the_id(), 'post_mime_type' => $mimeTypesToGet);
$attachments = get_children($args);
if ($attachments) {
$html .= '<div class="prettyFileList">';
foreach ($attachments as $attachment) {
$html .= $this->srf_get_formatted_link($attachment);
}
$html .= '</div>';
}
return $html;
}
开发者ID:MarcSky,项目名称:pretty-file-lister,代码行数:27,代码来源:PrettyFileList.php
示例8: shortcode
public function shortcode($attr)
{
$post = get_post();
if (!empty($attr['ids'])) {
// 'ids' is explicitly ordered, unless you specify otherwise.
if (empty($attr['orderby'])) {
$attr['orderby'] = 'post__in';
}
$attr['include'] = $attr['ids'];
}
$atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'include' => '', 'exclude' => '', 'size' => array($this->args['width'], $this->args['height'])), $attr, 'gallery');
$id = intval($atts['id']);
if (!empty($atts['include'])) {
$attachments = get_posts(array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'fields' => 'ids'));
} elseif (!empty($atts['exclude'])) {
$attachments = get_children(array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'fields' => 'ids'));
} else {
$attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'fields' => 'ids'));
}
if (empty($attachments)) {
return '';
}
$urls = array();
foreach ($attachments as $attachment_id) {
list($url, $width, $height) = wp_get_attachment_image_src($attachment_id, $atts['size'], true);
if (!$url) {
continue;
}
$urls[] = array('url' => $url, 'width' => $width, 'height' => $height);
}
return $this->render(array('images' => $urls));
}
开发者ID:hrkhal,项目名称:amp-wp,代码行数:32,代码来源:class-amp-gallery-embed.php
示例9: check_post_for_images
/**
* Cache images on post's saving
*/
function check_post_for_images($post_ID, $ablog, $item)
{
// Get the post so we can edit it.
$post = get_post($post_ID);
$images = $this->get_remote_images_in_content($post->post_content);
if (!empty($images)) {
// Include the file and media libraries as they have the functions we want to use
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/media.php';
foreach ($images as $image) {
preg_match('/[^\\?]+\\.(jpe?g|jpe|gif|png)\\b/i', $image, $matches);
if (!empty($matches)) {
$this->grab_image_from_url($image, $post_ID);
}
}
// Set the first image as the featured one - from a snippet at http://wpengineer.com/2460/set-wordpress-featured-image-automatically/
$imageargs = array('numberposts' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $post_ID, 'post_status' => NULL, 'post_type' => 'attachment');
$cachedimages = get_children($imageargs);
if (!empty($cachedimages)) {
foreach ($cachedimages as $image_id => $image) {
set_post_thumbnail($post_ID, $image_id);
}
}
}
// Returning the $post_ID even though it's an action and we really don't need to
return $post_ID;
}
开发者ID:hscale,项目名称:webento,代码行数:30,代码来源:cacheandfeatureimages.php
示例10: showImagesList
public function showImagesList($post_id)
{
$attachments = array();
if ($post_id) {
$post = get_post($post_id);
if ($post && $post->post_type == 'attachment') {
$attachments = array($post->ID => $post);
} else {
$attachments = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC'));
}
} else {
if (is_array($GLOBALS['wp_the_query']->posts)) {
foreach ($GLOBALS['wp_the_query']->posts as $attachment) {
$attachments[$attachment->ID] = $attachment;
}
}
}
$output = '';
foreach ((array) $attachments as $id => $attachment) {
if ($attachment->post_status == 'trash') {
continue;
}
if ($item = $this->getMediaItem($id, array('used' => in_array((string) $id, $this->selected_ids), 'errors' => isset($this->errors[$id]) ? $this->errors[$id] : null))) {
$output .= "\n{$item}\n";
}
}
return $output;
}
开发者ID:nilmadhab,项目名称:webtutplus,代码行数:28,代码来源:media_tab.php
示例11: thumb_or_first
function thumb_or_first($post_id = null, $path = true, $nopic = false, $size = 'large', $details = false)
{
global $root;
global $default_img;
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size);
if (!empty($thumb)) {
$thumb = $thumb[0];
} else {
$imgs = array();
$images = get_children(array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $post_id, 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image'));
if (count($images)) {
foreach ($images as $image) {
$attachment = wp_get_attachment_image_src($image->ID, 'large');
if (file_exists($root . str_replace('http://' . $_SERVER['HTTP_HOST'], '', $attachment[0]))) {
$thumb = $attachment[0];
} else {
if ($nopic) {
$thumb = 'http://' . $_SERVER['HTTP_HOST'] . $default_img;
}
}
}
} else {
if ($nopic) {
$thumb = 'http://' . $_SERVER['HTTP_HOST'] . $default_img;
}
}
}
if ($path) {
$thumb = str_replace('http://' . $_SERVER['HTTP_HOST'], '', $thumb);
}
return $thumb;
}
开发者ID:alex-propulse,项目名称:Rion,代码行数:32,代码来源:functions.php
示例12: lists
protected function lists($typeid, $mode, $limit, $param, $order = 'addtime desc')
{
//查询数据库
$article = D('ArticleView');
$type = M('type');
//封装条件
$map['status'] = 1;
//准备工作
//追影 QQ:279197963修改让其支持无限极
$arr = get_children($typeid);
//模式判断
switch ($mode) {
case 0:
$map['article.typeid'] = array('in', $arr);
break;
case 1:
$map['article.typeid'] = $typeid;
break;
case 2:
$map['article.typeid'] = array('in', $arr);
break;
}
$alist = $article->where($map)->order($order)->limit($limit)->select();
$this->assign($param, $alist);
}
开发者ID:babyhuangshiming,项目名称:webserver,代码行数:25,代码来源:BaseAction.class.php
示例13: eventon_create_duplicate_from_event
function eventon_create_duplicate_from_event($post, $parent = 0, $post_status = '')
{
global $wpdb;
$new_post_author = wp_get_current_user();
$new_post_date = current_time('mysql');
$new_post_date_gmt = get_gmt_from_date($new_post_date);
if ($parent > 0) {
$post_parent = $parent;
$post_status = $post_status ? $post_status : 'publish';
$suffix = '';
} else {
$post_parent = $post->post_parent;
$post_status = $post_status ? $post_status : 'draft';
$suffix = ' ' . __('(Copy)', 'eventon');
}
// Insert the new template in the post table
$wpdb->insert($wpdb->posts, array('post_author' => $new_post_author->ID, 'post_date' => $new_post_date, 'post_date_gmt' => $new_post_date_gmt, 'post_content' => $post->post_content, 'post_content_filtered' => $post->post_content_filtered, 'post_title' => $post->post_title . $suffix, 'post_excerpt' => $post->post_excerpt, 'post_status' => $post_status, 'post_type' => $post->post_type, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_password' => $post->post_password, 'to_ping' => $post->to_ping, 'pinged' => $post->pinged, 'post_modified' => $new_post_date, 'post_modified_gmt' => $new_post_date_gmt, 'post_parent' => $post_parent, 'menu_order' => $post->menu_order, 'post_mime_type' => $post->post_mime_type));
$new_post_id = $wpdb->insert_id;
// Copy the taxonomies
eventon_duplicate_post_taxonomies($post->ID, $new_post_id, $post->post_type);
// Copy the meta information
eventon_duplicate_post_meta($post->ID, $new_post_id);
// ONLY for ticket addon event duplication
if ($post->post_type == 'product') {
$exclude = apply_filters('woocommerce_duplicate_product_exclude_children', false);
if (!$exclude && ($children_products = get_children('post_parent=' . $post->ID . '&post_type=product_variation'))) {
foreach ($children_products as $child) {
eventon_create_duplicate_from_event(eventon_get_event_to_duplicate($child->ID), $new_post_id, $child->post_status);
}
}
}
return $new_post_id;
}
开发者ID:pab44,项目名称:pab44,代码行数:33,代码来源:duplicate_event.php
示例14: social_ring_get_first_image
function social_ring_get_first_image()
{
global $post, $posts;
if (function_exists('has_post_thumbnail') && has_post_thumbnail($post->ID)) {
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-thumbnail');
if ($thumbnail) {
$image = $thumbnail[0];
}
// If that's not there, grab the first attached image
} else {
$files = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image'));
if ($files) {
$keys = array_reverse(array_keys($files));
$image = image_downsize($keys[0], 'thumbnail');
$image = $image[0];
}
}
//if there's no attached image, try to grab first image in content
if (empty($image)) {
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
if (!empty($matches[1][0])) {
$image = $matches[1][0];
}
}
return $image;
}
开发者ID:ahsaeldin,项目名称:projects,代码行数:28,代码来源:library.php
示例15: jQuery_gallery
function jQuery_gallery($null, $attr)
{
global $post;
$attachments = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
$lis = array();
foreach ($attachments as $key => $attachment) {
array_push($lis, '<li>' . wp_get_attachment_link($key, 'thumbnail', false, false) . '</li>');
}
$output = '
<div id="gallery" class="ad-gallery">
<div class="ad-image-wrapper"></div>
<div class="ad-controls"></div>
<div class="ad-nav">
<div class="ad-thumbs">
<ul class="ad-thumb-list">
' . implode('', $lis) . '
</ul>
</div>
</div>
</div>
<script type="text/javascript">
$("div.ad-gallery").adGallery({
loader_image: "/i/loader.gif",
slideshow:{enable:false},
callbacks: {
init: function() {
this.preloadAll();
}
}
});
</script>
';
return $output;
}
开发者ID:adambrill,项目名称:Lake-Tomahawk-Bible-Church,代码行数:34,代码来源:jquery-gallery.php
示例16: cleanGallery
public function cleanGallery($output, $attr)
{
static $cleaner_gallery_instance = 0;
$cleaner_gallery_instance++;
if (is_feed()) {
return $output;
}
/* Default gallery settings. */
$defaults = array('order' => 'ASC', 'orderby' => 'ID', 'id' => get_the_ID(), 'link' => '', 'itemtag' => 'figure', 'icontag' => '', 'captiontag' => '', 'columns' => 3, 'size' => 'thumbnail', 'ids' => '', 'include' => '', 'exclude' => '', 'numberposts' => -1, 'offset' => '');
$attr = array_merge($defaults, $attr);
extract($attr);
$id = intval($id);
/* Arguments for get_children(). */
$children = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'exclude' => $exclude, 'include' => $include, 'numberposts' => $numberposts, 'offset' => $offset, 'suppress_filters' => true);
if (empty($include)) {
$attachments = get_children(array_merge(array('post_parent' => $id), $children));
} else {
$attachments = get_posts($children);
}
$attr['link'] = get_option('yopress_gallery_clean_link');
if ($attr['link'] == '' || $attr['link'] == null) {
$attr['link'] = 'big-thumbnail';
update_option('yopress_gallery_clean_link', 'full');
}
$size = get_option('yopress_theme_gallery_def_size');
if ($size == '' || $size == null) {
$size = 'thumbnail';
update_option('yopress_gallery_clean_size', 'thumbnail');
}
if (empty($attachments)) {
return '<!-- No images. -->';
}
$itemtag = tag_escape($itemtag);
$icontag = tag_escape($icontag);
$captiontag = tag_escape($captiontag);
$columns = intval($columns);
$i = 0;
$galleryWidth = floor(100 / $columns);
$style = '<style type="text/css">#gallery-' . $cleaner_gallery_instance . ' .gallery-item { width : ' . $galleryWidth . '%}</style>';
$output = $style;
$output .= '<div id="gallery-' . $cleaner_gallery_instance . '" class="gallery gallery-columns-' . $columns . ' gallery-size-thumbnail">';
$itemInColum = 0;
foreach ($attachments as $attachment) {
$output .= '<dl class="gallery-item"><dt class="gallery-icon">';
$image = isset($attr['link']) && 'full' == $attr['link'] ? wp_get_attachment_link($attachment->ID, $size, false, false) : wp_get_attachment_link($attachment->ID, $size, true, false);
$lightbox = $attr['link'] == 'full' ? 'class="apply-lightbox"' : '';
$output .= "<div " . $lightbox . ">";
$output .= apply_filters('cleaner_gallery_image', $image, $attachment->ID, $attr, $cleaner_gallery_instance);
$output .= '</div>';
$output .= '</dt></dl>';
$itemInColum++;
if ($itemInColum == $columns) {
$itemInColum = 0;
$output .= '<br class="clearfix">';
}
}
$output .= '<br class="clearfix">';
$output .= "</div><!-- .gallery -->";
return $output;
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:60,代码来源:YoPressGalleryClean.php
示例17: attachment_toolbox
function attachment_toolbox($size = thumbnail, $type = 'house', $gallcount = '0', $ulClass = '', $emptyMsg = '')
{
$images = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'));
$count = 0;
$out = '<ul class="' . $ulClass . '">';
foreach ($images as $image) {
$attimg = wp_get_attachment_image_src($image->ID, $size);
$attimgurl = $attimg[0];
$atturl = wp_get_attachment_url($image->ID);
$attlink = get_attachment_link($image->ID);
$postlink = get_permalink($image->post_parent);
$atttitle = apply_filters('the_title', $image->post_title);
$attcontent = $image->post_content;
$attimgtype = get_post_meta($image->ID, "_mySelectBox", true);
$imglink = $image->guid;
if ($attimgtype == $type) {
$count++;
$out .= '<li><a href=' . $imglink . ' rel="prettyPhoto[gallery' . $gallcount . ']"><img class="primary" src="' . $attimgurl . '"/></a></li>';
}
}
$out .= '</ul>';
if ($count > 0) {
echo $out;
} else {
echo $emptyMsg;
}
return $count;
}
开发者ID:jayfresh,项目名称:SweetSpot,代码行数:28,代码来源:functions.php
示例18: create_duplicate
function create_duplicate($project_id)
{
//Get all data post type project, message, task_list, milestone
$prev_pro_data = $this->fatch_projcet_data($project_id);
$new_pro_arg = $this->fill_array($prev_pro_data[$project_id]);
//create duplicate new project
$new_pro_id = $this->insert_duplicate($new_pro_arg, $project_id);
if (!$new_pro_id) {
wp_send_json_error('Unknown Error', 'cpm');
}
//remove project post type from data array
unset($prev_pro_data[$project_id]);
foreach ($prev_pro_data as $prev_post_id => $post_obj) {
if ($post_obj->post_type == 'milestone') {
$args = $this->fill_array($post_obj, $new_pro_id);
//Insert message, task list and milestone
$new_milestone_id[$post_obj->ID] = $this->insert_duplicate($args, $post_obj->ID);
unset($prev_pro_data[$prev_post_id]);
}
}
foreach ($prev_pro_data as $prev_post_id => $post_obj) {
$args = $this->fill_array($post_obj, $new_pro_id);
$new_milestone_id = isset($new_milestone_id) ? $new_milestone_id : array();
//Insert message, task list and milestone
$id = $this->insert_duplicate($args, $post_obj->ID, $new_milestone_id);
//If post type task list then fatch task and insert duplicate
if ($post_obj->post_type == 'task_list') {
$task = array('post_parent' => $post_obj->ID, 'post_type' => 'task', 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'ID');
$task_data = get_children($task);
$this->insert_duplicate_task($task_data, $id);
}
}
return $new_pro_id;
}
开发者ID:javalidigital,项目名称:multipla,代码行数:34,代码来源:duplicate.php
示例19: index_get_cat_id_goods_best_list
/**
* 获得cat_id精品列表。
*
* @access private
* @param integer
* @return array
*/
function index_get_cat_id_goods_best_list($cat_id, $num)
{
$sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, ' . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = 1 AND (" . $cat_id . " OR " . get_extension_goods($cat_id) . ")";
$cats = get_children($cat_id);
$where = !empty($cats) ? "AND ({$cats} OR " . get_extension_goods($cats) . ") " : '';
$sql .= $where . " LIMIT {$num}";
$res = $GLOBALS['db']->getAll($sql);
$goods = array();
foreach ($res as $idx => $row) {
$goods[$idx]['id'] = $row['article_id'];
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb'];
$goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img'];
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $goods;
}
开发者ID:hackjiyi,项目名称:maozishifa,代码行数:32,代码来源:allcate.php
示例20: azeria_post_gallery
/**
* Show featured gallery for gallery post format
*/
function azeria_post_gallery()
{
$post_id = get_the_ID();
// first - try to get images from galleries in post
$post_gallery = get_post_gallery($post_id, false);
if (!empty($post_gallery['ids'])) {
$post_gallery = explode(',', $post_gallery['ids']);
} elseif (!empty($post_gallery['src'])) {
$post_gallery = $post_gallery['src'];
} else {
$post_gallery = false;
}
// if can't try to catch images inserted into post
if (!$post_gallery) {
$post_gallery = azeria_post_images($post_id, 15);
}
// and if not find any images - try to get images attached to post
if (!$post_gallery || empty($post_gallery)) {
$attachments = get_children(array('post_parent' => $post_id, 'posts_per_page' => 3, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image'));
if ($attachments && is_array($attachments)) {
$post_gallery = array_keys($attachments);
}
}
if (!$post_gallery || empty($post_gallery)) {
return false;
}
$output = azeria_get_gallery_html($post_gallery);
echo $output;
}
开发者ID:phdulac,项目名称:wordpress,代码行数:32,代码来源:template-post-formats.php
注:本文中的get_children函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论