• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_post_mime_type_where函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_post_mime_type_where函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_post_mime_type_where函数的具体用法?PHP wp_post_mime_type_where怎么用?PHP wp_post_mime_type_where使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_post_mime_type_where函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: clearbase_count_attachments

/**
 * Count number of attachments for a clearbase post.
 *
 * If you set the optional mime_type parameter, then an array will still be
 * returned, but will only have the item you are looking for. It does not give
 * you the number of attachments that are children of a post. You can get that
 * by counting the number of children that post has.
 *
 * @since 2.5.0
 *
 * @global wpdb $wpdb
 *
 * @param int $post_id.  The ID of parent post
 *  
 * @param string|array $mime_type Optional. Array or comma-separated list of
 *                                MIME patterns. Default empty.
 * @return object An object containing the attachment counts by mime type.
 */
function clearbase_count_attachments($post = null, $mime_type = '')
{
    global $wpdb;
    if (!($post = get_post($post))) {
        throw new WP_Error('invalid_post', 'You must specify a valid post!');
    }
    $and = wp_post_mime_type_where($mime_type);
    $count = $wpdb->get_results($wpdb->prepare("SELECT post_mime_type, COUNT( * ) AS num_posts FROM {$wpdb->posts} \n        WHERE post_type = 'attachment' AND post_parent = %d \n        AND post_status != 'trash' {$and} GROUP BY post_mime_type", $post->ID), ARRAY_A);
    $counts = array();
    foreach ((array) $count as $row) {
        $counts[$row['post_mime_type']] = $row['num_posts'];
    }
    $counts['trash'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'attachment' \n        AND post_parent = %d AND post_status = 'trash' {$and}", $post->ID));
    /**
     * Modify returned attachment counts by mime type.
     *
     * @since 3.7.0
     *
     * @param object  $counts    An object containing the attachment counts by
     *                          mime type.
     * @param WP_POST $post     The parent post of the attachments.
     * @param string $mime_type The mime type pattern used to filter the attachments
     *                          counted.
     */
    return apply_filters('clearbase_count_attachments', (object) $counts, $post, $mime_type);
}
开发者ID:unity3software,项目名称:clearbase,代码行数:44,代码来源:attachment.php


示例2: base_select

 /**
  * Construct a base SQL statement
  *
  * @since 1.0.36
  * @param array $what What columns to SELECT from the DB
  */
 private function base_select($what = array('*'))
 {
     global $wpdb;
     foreach ($what as $what_k => $what_v) {
         if ($what_v != '*') {
             $what[$what_k] = '`' . $what_v . '`';
         }
     }
     $what = implode(',', $what);
     return "SELECT {$what} FROM `{$wpdb->posts}` WHERE `post_status` = 'inherit' AND `post_type` = 'attachment' " . wp_post_mime_type_where('image') . " ";
 }
开发者ID:zhengxiexie,项目名称:wordpress,代码行数:17,代码来源:Images.php


示例3: do_action_ref_array


//.........这里部分代码省略.........
         } else {
             $eq = '=';
             $andor = 'OR';
         }
         $author_array = preg_split('/[,\\s]+/', $q['author']);
         $_author_array = array();
         foreach ($author_array as $key => $_author) {
             $_author_array[] = "{$wpdb->posts}.post_author " . $eq . ' ' . absint($_author);
         }
         $whichauthor .= ' AND (' . implode(" {$andor} ", $_author_array) . ')';
         unset($author_array, $_author_array);
     }
     // Author stuff for nice URLs
     if ('' != $q['author_name']) {
         if (strpos($q['author_name'], '/') !== false) {
             $q['author_name'] = explode('/', $q['author_name']);
             if ($q['author_name'][count($q['author_name']) - 1]) {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 1];
                 // no trailing slash
             } else {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 2];
                 // there was a trailing slash
             }
         }
         $q['author_name'] = sanitize_title_for_query($q['author_name']);
         $q['author'] = get_user_by('slug', $q['author_name']);
         if ($q['author']) {
             $q['author'] = $q['author']->ID;
         }
         $whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')';
     }
     // MIME-Type stuff for attachment browsing
     if (isset($q['post_mime_type']) && '' != $q['post_mime_type']) {
         $whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $wpdb->posts);
     }
     $where .= $search . $whichauthor . $whichmimetype;
     if (empty($q['order']) || strtoupper($q['order']) != 'ASC' && strtoupper($q['order']) != 'DESC') {
         $q['order'] = 'DESC';
     }
     // Order by
     if (empty($q['orderby'])) {
         $orderby = "{$wpdb->posts}.post_date " . $q['order'];
     } elseif ('none' == $q['orderby']) {
         $orderby = '';
     } else {
         // Used to filter values
         $allowed_keys = array('name', 'author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 'comment_count');
         if (!empty($q['meta_key'])) {
             $allowed_keys[] = $q['meta_key'];
             $allowed_keys[] = 'meta_value';
             $allowed_keys[] = 'meta_value_num';
         }
         $q['orderby'] = urldecode($q['orderby']);
         $q['orderby'] = addslashes_gpc($q['orderby']);
         $orderby_array = array();
         foreach (explode(' ', $q['orderby']) as $i => $orderby) {
             // Only allow certain values for safety
             if (!in_array($orderby, $allowed_keys)) {
                 continue;
             }
             switch ($orderby) {
                 case 'menu_order':
                     break;
                 case 'ID':
                     $orderby = "{$wpdb->posts}.ID";
                     break;
开发者ID:nunomorgadinho,项目名称:WordPress,代码行数:67,代码来源:query.php


示例4: do_action_ref_array


//.........这里部分代码省略.........
             $eq = '=';
             $andor = 'OR';
         }
         $author_array = preg_split('/[,\\s]+/', $q['author']);
         $_author_array = array();
         foreach ($author_array as $key => $_author) {
             $_author_array[] = "{$wpdb->posts}.post_author " . $eq . ' ' . absint($_author);
         }
         $whichauthor .= ' AND (' . implode(" {$andor} ", $_author_array) . ')';
         unset($author_array, $_author_array);
     }
     // Author stuff for nice URLs
     if ('' != $q['author_name']) {
         if (strpos($q['author_name'], '/') !== false) {
             $q['author_name'] = explode('/', $q['author_name']);
             if ($q['author_name'][count($q['author_name']) - 1]) {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 1];
                 // no trailing slash
             } else {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 2];
                 // there was a trailling slash
             }
         }
         $q['author_name'] = sanitize_title($q['author_name']);
         $q['author'] = get_user_by('slug', $q['author_name']);
         if ($q['author']) {
             $q['author'] = $q['author']->ID;
         }
         $whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')';
     }
     // MIME-Type stuff for attachment browsing
     if (isset($q['post_mime_type']) && '' != $q['post_mime_type']) {
         $table_alias = $post_status_join ? $wpdb->posts : '';
         $whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $table_alias);
     }
     $where .= $search . $whichcat . $whichauthor . $whichmimetype;
     if (empty($q['order']) || strtoupper($q['order']) != 'ASC' && strtoupper($q['order']) != 'DESC') {
         $q['order'] = 'DESC';
     }
     // Order by
     if (empty($q['orderby'])) {
         $q['orderby'] = "{$wpdb->posts}.post_date " . $q['order'];
     } elseif ('none' == $q['orderby']) {
         $q['orderby'] = '';
     } else {
         // Used to filter values
         $allowed_keys = array('author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 'comment_count');
         if (!empty($q['meta_key'])) {
             $allowed_keys[] = $q['meta_key'];
             $allowed_keys[] = 'meta_value';
             $allowed_keys[] = 'meta_value_num';
         }
         $q['orderby'] = urldecode($q['orderby']);
         $q['orderby'] = addslashes_gpc($q['orderby']);
         $orderby_array = explode(' ', $q['orderby']);
         $q['orderby'] = '';
         foreach ($orderby_array as $i => $orderby) {
             // Only allow certain values for safety
             if (!in_array($orderby, $allowed_keys)) {
                 continue;
             }
             switch ($orderby) {
                 case 'menu_order':
                     break;
                 case 'ID':
                     $orderby = "{$wpdb->posts}.ID";
开发者ID:owaismeo,项目名称:wordpress-10,代码行数:67,代码来源:query.php


示例5: language_filter_upload_page

 function language_filter_upload_page()
 {
     global $sitepress, $wpdb;
     //save query arguments for building language-specific links
     $href_args = array();
     foreach ($_GET as $key => $value) {
         $href_args[$key] = urlencode(stripslashes($value));
     }
     //get language code
     if (isset($_GET['lang'])) {
         $lang_code = $_GET['lang'];
     } else {
         if (method_exists($sitepress, 'get_admin_language_cookie')) {
             $lang_code = $sitepress->get_admin_language_cookie();
         }
         if (empty($lang_code)) {
             $lang_code = $sitepress->get_default_language();
         }
     }
     $active_languages = $sitepress->get_active_languages();
     $active_languages[] = array('code' => 'all', 'display_name' => __('All languages', 'sitepress'));
     $langc['all'] = 0;
     $language_items = array();
     foreach ($active_languages as $lang) {
         //count language-specific attachments
         if ($lang['code'] != 'all') {
             //select all attachments
             $sql = $wpdb->prepare("\n\t\t\t\tSELECT COUNT(p.id)\n\t\t\t\tFROM {$wpdb->posts} AS p\n\t\t\t\tINNER JOIN {$wpdb->prefix}icl_translations AS t\n\t\t\t\t\tON t.element_id = p.id\n\t\t\t\tWHERE p.post_type = 'attachment'\n\t\t\t\tAND t.element_type ='post_attachment'\n\t\t\t\tAND t.language_code=%s\n\t\t\t", $lang['code']);
             //handle trash setting
             if (isset($_GET['status'])) {
                 $sql .= " AND p.post_status = 'trash' ";
             } else {
                 $sql .= " AND p.post_status != 'trash' ";
             }
             //select detached attachments
             if (isset($_GET['detached'])) {
                 $sql .= " AND p.post_parent = 0 ";
             }
             //select mime type(image,etc) attachments
             if (isset($_GET['post_mime_type'])) {
                 $sql .= wp_post_mime_type_where($_GET['post_mime_type'], 'p');
             }
             $sql = apply_filters('wpml-media_view-upload-page-sql', $sql, $lang);
             $res = apply_filters('wpml-media_view-upload-page-count', NULL, $lang);
             if (NULL === $res) {
                 $res = $wpdb->get_col($sql);
             }
             $langc[$lang['code']] = $res[0];
             $langc['all'] += $res[0];
         }
         //generation language block
         if ($lang['code'] == $lang_code) {
             $px = '<strong>';
             $sx = ' <span class="count">(' . $langc[$lang['code']] . ')</span></strong>';
         } else {
             $href_args['lang'] = $lang['code'];
             $px = '<a href="' . esc_url(add_query_arg($href_args, '')) . '">';
             $sx = '</a> <span class="count">(' . $langc[$lang['code']] . ')</span>';
         }
         $language_items[] = $px . $lang['display_name'] . $sx;
     }
     wp_enqueue_script('wpml-media-language-options', WPML_MEDIA_URL . '/res/js/language_options.js', array(), WPML_MEDIA_VERSION, true);
     wp_localize_script('wpml-media-language-options', 'language_items', $language_items);
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:64,代码来源:wpml-media.class.php


示例6: mla_paginated_term_gallery

/**
 * Generate a taxonomy- and term-specific [mla_gallery], limited by current_page and posts_per_page
 *
 * This function uses $wpdb functions for efficiency.
 *
 * @param array Attributes of the function: page, taxonomy, term, post_mime_type, posts_per_page, current_page
 *
 * @return integer number of posts matching taxonomy & term, before LIMIT. echoes HTML <h3>, <p> and <a> tags
 */
function mla_paginated_term_gallery($attr = NULL)
{
    global $wpdb;
    /*
     * Make sure $attr is an array, even if it's empty
     */
    if (empty($attr)) {
        $attr = array();
    } elseif (is_string($attr)) {
        $attr = shortcode_parse_atts($attr);
    }
    /*
     * Create the PHP variables we need
     */
    extract(shortcode_atts(array('page' => NULL, 'taxonomy' => 'attachment_tag', 'term' => '', 'post_mime_type' => 'all', 'posts_per_page' => 10, 'current_page' => 1), $attr));
    /*
     * Convert to objects for validation and labels
     */
    $taxonomy = get_taxonomy($taxonomy);
    $term = get_term_by('slug', $term, $taxonomy->name);
    if (empty($taxonomy)) {
        echo __('Taxonomy does not exist.', 'mla-child-theme');
        return;
    } elseif (empty($term)) {
        echo __('Term does not exist.', 'mla-child-theme');
        return;
    }
    $offset = absint($current_page - 1) * $posts_per_page;
    if ('all' == strtolower($post_mime_type)) {
        $count = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->term_relationships . ' WHERE ( term_taxonomy_id = ' . $term->term_taxonomy_id . ' )');
        $posts = implode(',', $wpdb->get_col('SELECT object_id FROM ' . $wpdb->term_relationships . ' WHERE ( term_taxonomy_id = ' . $term->term_taxonomy_id . ' ) LIMIT ' . $offset . ', ' . $posts_per_page));
    } else {
        /*
         * $posts contains all post types, so we further limit the results to select attachments of the
         * desired MIME type, then apply the limit criteria.
         */
        $mime_where = wp_post_mime_type_where($post_mime_type, 'p');
        $posts = implode(',', $wpdb->get_col('SELECT object_id FROM ' . $wpdb->term_relationships . ' WHERE ( term_taxonomy_id = ' . $term->term_taxonomy_id . ' )'));
        $count = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->posts . ' AS p WHERE ( p.ID IN ( ' . $posts . ' )' . $mime_where . ')');
        $posts = implode(',', $wpdb->get_col('SELECT p.ID FROM ' . $wpdb->posts . ' as p WHERE ( p.ID IN ( ' . $posts . ' )' . $mime_where . ') LIMIT ' . $offset . ', ' . $posts_per_page));
    }
    $href = empty($page) ? '{+link_url+}' : "{+site_url+}{$page}";
    /* translators: 1: term name, 2: taxonomy label */
    $output = '<h3>' . sprintf(__('Gallery for term "%1$s" in taxonomy "%2$s"', 'mla-child-theme'), $term->name, $taxonomy->labels->name) . '</h3>';
    $output .= '<p>' . do_shortcode(sprintf('[mla_gallery ids="%1$s" post_mime_type="%2$s" mla_paginate_current=1 mla_nolink_text="No items found" update_post_term_cache="false" mla_link_href="%3$s?post_id={+attachment_ID+}"]', $posts, $post_mime_type, $href) . "</p>\r\n");
    echo $output;
    return $count;
}
开发者ID:Bakerpedia,项目名称:Development_Site5,代码行数:57,代码来源:functions.php


示例7: do_action_ref_array


//.........这里部分代码省略.........
             $eq = '!=';
             $andor = 'AND';
             $q['author'] = explode('-', $q['author']);
             $q['author'] = '' . absint($q['author'][1]);
         } else {
             $eq = '=';
             $andor = 'OR';
         }
         $author_array = preg_split('/[,\\s]+/', $q['author']);
         $whichauthor .= " AND ({$wpdb->posts}.post_author " . $eq . ' ' . absint($author_array[0]);
         for ($i = 1; $i < count($author_array); $i = $i + 1) {
             $whichauthor .= ' ' . $andor . " {$wpdb->posts}.post_author " . $eq . ' ' . absint($author_array[$i]);
         }
         $whichauthor .= ')';
     }
     // Author stuff for nice URLs
     if ('' != $q['author_name']) {
         if (strpos($q['author_name'], '/') !== false) {
             $q['author_name'] = explode('/', $q['author_name']);
             if ($q['author_name'][count($q['author_name']) - 1]) {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 1];
                 #no trailing slash
             } else {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 2];
                 #there was a trailling slash
             }
         }
         $q['author_name'] = sanitize_title($q['author_name']);
         $q['author'] = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE user_nicename='" . $q['author_name'] . "'");
         $whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')';
     }
     // MIME-Type stuff for attachment browsing
     if (isset($q['post_mime_type']) && '' != $q['post_mime_type']) {
         $whichmimetype = wp_post_mime_type_where($q['post_mime_type']);
     }
     $where .= $search . $whichcat . $whichauthor . $whichmimetype;
     if (empty($q['order']) || strtoupper($q['order']) != 'ASC' && strtoupper($q['order']) != 'DESC') {
         $q['order'] = 'DESC';
     }
     // Order by
     if (empty($q['orderby'])) {
         $q['orderby'] = "{$wpdb->posts}.post_date " . $q['order'];
     } else {
         // Used to filter values
         $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand');
         if (!empty($q['meta_key'])) {
             $allowed_keys[] = $q['meta_key'];
             $allowed_keys[] = 'meta_value';
         }
         $q['orderby'] = urldecode($q['orderby']);
         $q['orderby'] = addslashes_gpc($q['orderby']);
         $orderby_array = explode(' ', $q['orderby']);
         if (empty($orderby_array)) {
             $orderby_array[] = $q['orderby'];
         }
         $q['orderby'] = '';
         for ($i = 0; $i < count($orderby_array); $i++) {
             // Only allow certain values for safety
             $orderby = $orderby_array[$i];
             switch ($orderby) {
                 case 'menu_order':
                     break;
                 case 'ID':
                     $orderby = "{$wpdb->posts}.ID";
                     break;
                 case 'rand':
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:67,代码来源:query.php


示例8: recount_attachments

 /**
  * Count of items in media library
  *
  * @access public
  * @param $counts_in
  * @return int
  */
 public static function recount_attachments($counts_in)
 {
     global $wpdb;
     global $current_user;
     $and = wp_post_mime_type_where('');
     $count = $wpdb->get_results("SELECT post_mime_type, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_status != 'trash' AND post_author = {$current_user->ID} {$and} GROUP BY post_mime_type", ARRAY_A);
     $counts = array();
     foreach ((array) $count as $row) {
         $counts[$row['post_mime_type']] = $row['num_posts'];
     }
     $counts['trash'] = $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_author = {$current_user->ID} AND post_status = 'trash' {$and}");
     return $counts;
 }
开发者ID:jhonrsalcedo,项目名称:sitio,代码行数:20,代码来源:class-realia-post-type-user.php


示例9: ajaxThumbnailRebuildAjax

 /**
  * Rebuild the image
  * 
  * @access public
  * @return void
  * @author Nicolas Juen
  */
 public function ajaxThumbnailRebuildAjax()
 {
     global $wpdb;
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     // Time a the begining
     $start_time = microtime(true);
     // Get the action
     $action = $_POST["do"];
     // Get the thumbnails
     $thumbnails = isset($_POST['thumbnails']) ? $_POST['thumbnails'] : NULL;
     if ($action == "getlist") {
         // Check the nonce
         if (!wp_verify_nonce($nonce, 'getList')) {
             echo json_encode(array());
             die;
         }
         if (isset($_POST['post_types']) && !empty($_POST['post_types'])) {
             // Get image medias
             $whichmimetype = wp_post_mime_type_where('image', $wpdb->posts);
             // Get all parent from post type
             $attachments = $wpdb->get_results("SELECT *\r\n\t\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\t\tWHERE 1 = 1\r\n\t\t\t\t\tAND post_type = 'attachment'\r\n\t\t\t\t\t{$whichmimetype}\r\n\t\t\t\t\tAND post_parent IN (\r\n\t\t\t\t\t\tSELECT DISTINCT ID \r\n\t\t\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\t\t\tWHERE post_type IN ('" . implode("', '", $_POST['post_types']) . "')\r\n\t\t\t\t\t)");
         } else {
             $attachments =& get_children(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, 'output' => 'object'));
         }
         // Get the attachments
         foreach ($attachments as $attachment) {
             $res[] = array('id' => $attachment->ID, 'title' => $attachment->post_title);
         }
         // Return the Id's and Title of medias
         die(json_encode($res));
     } else {
         if ($action == "regen") {
             // Check the nonce
             if (!wp_verify_nonce($nonce, 'regen')) {
                 echo json_encode(array('error' => _e('Trying to cheat ?', 'sis')));
                 die;
             }
             // Get the id
             $id = $_POST["id"];
             // Check Id
             if ((int) $id == 0) {
                 die(json_encode(array('time' => round(microtime(true) - $start_time, 4), 'error' => __('No id given in POST datas.', 'sis'))));
             }
             // Get the path
             $fullsizepath = get_attached_file($id);
             // Regen the attachment
             if (FALSE !== $fullsizepath && @file_exists($fullsizepath)) {
                 set_time_limit(30);
                 if (wp_update_attachment_metadata($id, $this->wp_generate_attachment_metadata_custom($id, $fullsizepath, $thumbnails)) == false) {
                     die(json_encode(array('src' => wp_get_attachment_thumb_url($id), 'time' => round(microtime(true) - $start_time, 4), 'message' => sprintf(__('This file already exists in this size and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'sis'), get_edit_post_link($id), get_the_title($id)))));
                 }
             } else {
                 die(json_encode(array('src' => wp_get_attachment_thumb_url($id), 'time' => round(microtime(true) - $start_time, 4), 'error' => sprintf(__('This file does not exists and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'sis'), get_edit_post_link($id), get_the_title($id)))));
             }
             // Display the attachment url for feedback
             die(json_encode(array('time' => round(microtime(true) - $start_time, 4), 'src' => wp_get_attachment_thumb_url($id), 'title' => get_the_title($id))));
         }
     }
 }
开发者ID:sriram911,项目名称:pls,代码行数:67,代码来源:class.admin.php


示例10: mla_get_terms


//.........这里部分代码省略.........
                         $includes[$term->term_id] = $term->term_id;
                     }
                     // terms
                 }
             }
             // taxonomies
         }
         // ids
         /*
          * If there are no terms we want an empty cloud
          */
         if (empty($includes)) {
             $arguments['include'] = (string) 0x7fffffff;
         } else {
             ksort($includes);
             $arguments['include'] = implode(',', $includes);
         }
     }
     /*
      * Add include/exclude and parent constraints to WHERE cluse
      */
     if (!empty($arguments['include'])) {
         $placeholders = implode("','", wp_parse_id_list($arguments['include']));
         $clause[] = "AND t.term_id IN ( '{$placeholders}' )";
     } elseif (!empty($arguments['exclude'])) {
         $placeholders = implode("','", wp_parse_id_list($arguments['exclude']));
         $clause[] = "AND t.term_id NOT IN ( '{$placeholders}' )";
     }
     if ('' !== $arguments['parent']) {
         $parent = (int) $arguments['parent'];
         $clause[] = "AND tt.parent = '{$parent}'";
     }
     if ('all' !== strtolower($arguments['post_mime_type'])) {
         $where = str_replace('%', '%%', wp_post_mime_type_where($arguments['post_mime_type'], 'p'));
         if (0 == absint($arguments['minimum'])) {
             $clause[] = ' AND ( p.post_mime_type IS NULL OR ' . substr($where, 6);
         } else {
             $clause[] = $where;
         }
     }
     $clause = join(' ', $clause);
     $clauses['where'] = $wpdb->prepare($clause, $clause_parameters);
     /*
      * For the inner/initial query, always select the most popular terms
      */
     if ($arguments['no_orderby']) {
         $arguments['orderby'] = 'count';
         $arguments['order'] = 'DESC';
     }
     /*
      * Add sort order
      */
     $orderby = strtolower($arguments['orderby']);
     $order = strtoupper($arguments['order']);
     if ('DESC' != $order) {
         $order = 'ASC';
     }
     $clauses['order'] = $order;
     $clauses['orderby'] = "ORDER BY {$orderby}";
     /*
      * Count, Descending, is the default order so no further work
      * is needed unless a different order is specified
      */
     if ('count' != $orderby || 'DESC' != $order) {
         if ('true' == strtolower($arguments['preserve_case'])) {
             $binary_keys = array('name', 'slug');
开发者ID:Bakerpedia,项目名称:Development_Site5,代码行数:67,代码来源:class-mla-shortcodes.php


示例11: wp_count_attachments

/**
 * wp_count_attachments() - Count number of attachments
 *
 * {@internal Missing Long Description}}
 *
 * @package WordPress
 * @subpackage Post
 * @since 2.5
 *
 * @param string|array $post_mime_type Array or comma-separated list of MIME patterns
 * @return array Number of posts for each post_mime_type
 */

function wp_count_attachments( $mime_type = '' ) {
	global $wpdb;

	$and = wp_post_mime_type_where( $mime_type );
	$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' $and GROUP BY post_mime_type", ARRAY_A );

	$stats = array( );
	foreach( (array) $count as $row ) {
		$stats[$row['post_mime_type']] = $row['num_posts'];
	}

	return (object) $stats;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:26,代码来源:post.php


示例12: a_thumbnails_rebuild

 /**
  * Regenerate the thumbnails ajax action
  *
  * @return array
  * @param void
  * @author Nicolas Juen
  */
 public static function a_thumbnails_rebuild()
 {
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     $offset = isset($_POST['offset']) ? absint($_POST['offset']) : 0;
     $post_types = isset($_POST['post_types']) ? $_POST['post_types'] : 'any';
     $thumbnails = isset($_POST['thumbnails']) ? $_POST['thumbnails'] : NULL;
     // Check the nonce
     if (!wp_verify_nonce($nonce, 'regen')) {
         SIS_Admin_Main::displayJson(array('error' => __('Trying to cheat ?', 'simple-image-sizes')));
     }
     if ($post_types !== 'any') {
         foreach ($_POST['post_types'] as $key => $type) {
             if (!post_type_exists($type)) {
                 unset($_POST['post_types'][$key]);
             }
         }
         if (empty($_POST['post_types'])) {
             SIS_Admin_Main::displayJson();
         }
         // Get image medias
         $whichmimetype = wp_post_mime_type_where('image', $wpdb->posts);
         // Get all parent from post type
         $attachment = $wpdb->get_var($wpdb->prepare("SELECT ID\r\n\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\tWHERE 1 = 1\r\n\t\t\t\tAND post_type = 'attachment'\r\n\t\t\t\t{$whichmimetype}\r\n\t\t\t\tAND post_parent IN (\r\n\t\t\t\t\tSELECT DISTINCT ID \r\n\t\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\t\tWHERE post_type IN ('" . implode("', '", $_POST['post_types']) . "')\r\n\t\t\t\t)\r\n\t\t\t\tLIMIT %d,1 \r\n\t\t\t", $offset));
     } else {
         $attachment = get_posts(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1, 'post_status' => 'any', 'output' => 'object', 'offset' => $offset));
         $attachment = !empty($attachment) ? $attachment[0]->ID : 0;
     }
     if (empty($attachment)) {
         return array('message' => __('Regeneration ended', 'simple-image-sizes'));
     }
     SIS_Admin_Main::displayJson(SIS_Admin_Main::thumbnail_rebuild($attachment, $thumbnails));
 }
开发者ID:Allan019,项目名称:grupometa,代码行数:40,代码来源:media.php


示例13: _media_view_settings

 public function _media_view_settings($settings = array(), $post = null)
 {
     $media_filter = clearbase_get_value('media_filter', '', clearbase_get_folder_settings($cb_post_id));
     if (!empty($media_filter)) {
         $post_mime_types = get_post_mime_types();
         $matches = wp_match_mime_types($media_filter, array_keys($post_mime_types));
         $settings['mimeTypes'] = wp_list_pluck(array_intersect_key($post_mime_types, $matches), 0);
         global $wpdb, $wp_locale;
         $post_parent = absint($post->ID);
         $and_where_mime = wp_post_mime_type_where($media_filter);
         $months = $wpdb->get_results("\n              SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n              FROM {$wpdb->posts}\n              WHERE post_parent = {$post_parent} AND post_type = 'attachment' {$and_where_mime}\n              ORDER BY post_date DESC");
         foreach ($months as $month_year) {
             $month_year->text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($month_year->month), $month_year->year);
         }
         $settings['months'] = $months;
     }
     return $settings;
 }
开发者ID:unity3software,项目名称:clearbase,代码行数:18,代码来源:class-view-folder.php


示例14: custom_uploader_tabs

 /**
  * Remove as abas desnecessárias e filtra o contador da galeria
  * 
  * @uses $wpdb
  * @uses self::get_custom_uploader_allowed_types
  * @uses wp_post_mime_type_where() Cria o SQL para os mime types
  *
  * @param array $default_tabs As abas default
  * @see http://shibashake.com/wordpress-theme/how-to-hook-into-the-media-upload-popup-interface Hack para o media uploader
  */
 function custom_uploader_tabs($default_tabs)
 {
     global $wpdb;
     $post_id = intval($_REQUEST['post_id']);
     // Hack para o count apenas mostrar os tipos permitidos de arquivo
     $allowed_mime_types = $this->get_custom_uploader_allowed_types();
     $gallery_query = "SELECT count(*)\n            \tFROM {$wpdb->posts}\n            \tWHERE post_type = 'attachment'\n            \tAND post_status != 'trash'\n            \tAND post_parent = %d";
     $gallery_query .= wp_post_mime_type_where($allowed_mime_types);
     if ($post_id) {
         $attachments = intval($wpdb->get_var($wpdb->prepare($gallery_query, $post_id)));
     }
     if (!empty($attachments)) {
         $default_tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>{$attachments}</span>");
     }
     // Remove as tabs desnecessárias (opções: 'type', 'type_url', 'gallery', 'library')
     unset($default_tabs['type_url']);
     return $default_tabs;
 }
开发者ID:aspto,项目名称:wordpress-themes,代码行数:28,代码来源:custom-uploader.php


示例15: get_posts


//.........这里部分代码省略.........
			}
			$q['author'] = implode( ',', $authors );
		}

		if ( ! empty( $q['author__not_in'] ) ) {
			$author__not_in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__not_in'] ) ) );
			$where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
		} elseif ( ! empty( $q['author__in'] ) ) {
			$author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
			$where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
		}

		// Author stuff for nice URLs

		if ( '' != $q['author_name'] ) {
			if ( strpos($q['author_name'], '/') !== false ) {
				$q['author_name'] = explode('/', $q['author_name']);
				if ( $q['author_name'][ count($q['author_name'])-1 ] ) {
					$q['author_name'] = $q['author_name'][count($q['author_name'])-1]; // no trailing slash
				} else {
					$q['author_name'] = $q['author_name'][count($q['author_name'])-2]; // there was a trailing slash
				}
			}
			$q['author_name'] = sanitize_title_for_query( $q['author_name'] );
			$q['author'] = get_user_by('slug', $q['author_name']);
			if ( $q['author'] )
				$q['author'] = $q['author']->ID;
			$whichauthor .= " AND ($wpdb->posts.post_author = " . absint($q['author']) . ')';
		}

		// MIME-Type stuff for attachment browsing

		if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] )
			$whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts );

		$where .= $search . $whichauthor . $whichmimetype;

		if ( empty($q['order']) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC')) )
			$q['order'] = 'DESC';

		// Order by
		if ( empty($q['orderby']) ) {
			$orderby = "$wpdb->posts.post_date " . $q['order'];
		} elseif ( 'none' == $q['orderby'] ) {
			$orderby = '';
		} elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) {
			$orderby = "FIELD( {$wpdb->posts}.ID, $post__in )";
		} elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) {
			$orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in )";
		} else {
			// Used to filter values
			$allowed_keys = array('name', 'author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 'comment_count');
			if ( !empty($q['meta_key']) ) {
				$allowed_keys[] = $q['meta_key'];
				$allowed_keys[] = 'meta_value';
				$allowed_keys[] = 'meta_value_num';
			}
			$q['orderby'] = urldecode($q['orderby']);
			$q['orderby'] = addslashes_gpc($q['orderby']);

			$orderby_array = array();
			foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) {
				// Only allow certain values for safety
				if ( ! in_array($orderby, $allowed_keys) )
					continue;
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:66,代码来源:query.php


示例16: get_posts


//.........这里部分代码省略.........
             $key = $author > 0 ? 'author__in' : 'author__not_in';
             $q[$key][] = abs($author);
         }
         $q['author'] = implode(',', $authors);
     }
     if (!empty($q['author__not_in'])) {
         $author__not_in = implode(',', array_map('absint', array_unique((array) $q['author__not_in'])));
         $where .= " AND {$this->db->posts}.post_author NOT IN ({$author__not_in}) ";
     } elseif (!empty($q['author__in'])) {
         $author__in = implode(',', array_map('absint', array_unique((array) $q['author__in'])));
         $where .= " AND {$this->db->posts}.post_author IN ({$author__in}) ";
     }
     // Author stuff for nice URLs
     if ('' != $q['author_name']) {
         if (strpos($q['author_name'], '/') !== false) {
             $q['author_name'] = explode('/', $q['author_name']);
             if ($q['author_name'][count($q['author_name']) - 1]) {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 1];
                 // no trailing slash
             } else {
                 $q['author_name'] = $q['author_name'][count($q['author_name']) - 2];
                 // there was a trailing slash
             }
         }
         $q['author_name'] = sanitize_title_for_query($q['author_name']);
         $q['author'] = get_user_by('slug', $q['author_name']);
         if ($q['author']) {
             $q['author'] = $q['author']->ID;
         }
         $whichauthor .= " AND ({$this->db->posts}.post_author = " . absint($q['author']) . ')';
     }
     // MIME-Type stuff for attachment browsing
     if (isset($q['post_mime_type']) && '' != $q['post_mime_type']) {
         $whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $this->db->posts);
     }
     $where .= $search . $whichauthor . $whichmimetype;
     if (!empty($this->meta_query->queries)) {
         $clauses = $this->meta_query->get_sql('post', $this->db->posts, 'ID', $this);
         $join .= $clauses['join'];
         $where .= $clauses['where'];
     }
     $rand = isset($q['orderby']) && 'rand' === $q['orderby'];
     if (!isset($q['order'])) {
         $q['order'] = $rand ? '' : 'DESC';
     } else {
         $q['order'] = $rand ? '' : $this->parse_order($q['order']);
     }
     // Order by.
     if (empty($q['orderby'])) {
         /*
          * Boolean false or empty array blanks out ORDER BY,
          * while leaving the value unset or otherwise empty sets the default.
          */
         if (isset($q['orderby']) && (is_array($q['orderby']) || false === $q['orderby'])) {
             $orderby = '';
         } else {
             $orderby = "{$this->db->posts}.post_date " . $q['order'];
         }
     } elseif ('none' == $q['orderby']) {
         $orderby = '';
     } elseif ($q['orderby'] == 'post__in' && !empty($post__in)) {
         $orderby = "FIELD( {$this->db->posts}.ID, {$post__in} )";
     } elseif ($q['orderby'] == 'post_parent__in' && !empty($post_parent__in)) {
         $orderby = "FIELD( {$this->db->posts}.post_parent, {$post_parent__in} )";
     } elseif ($q['orderby'] == 'post_name__in' && !empty($post_name__in)) {
         $orderby = "FIELD( {$this->db->posts}.post_name, {$post_name__in} )";
开发者ID:inpsyde,项目名称:wordpress-dev,代码行数:67,代码来源:class-wp-query.php


示例17: wp_count_attachments

/**
 * Count number of attachments for the mime type(s).
 *
 * If you set the optional mime_type parameter, then an array will still be
 * returned, but will only have the item you are looking for. It does not give
 * you the number of attachments that are children of a post. You can get that
 * by counting the number of children that post has.
 *
 * @since 2.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string|array $mime_type Optional. Array or comma-separated list of
 *                                MIME patterns. Default empty.
 * @return object An object containing the attachment counts by mime type.
 */
function wp_count_attachments($mime_type = '')
{
    global $wpdb;
    $and = wp_post_mime_type_where($mime_type);
    $count = $wpdb->get_results("SELECT post_mime_type, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_status != 'trash' {$and} GROUP BY post_mime_type", ARRAY_A);
    $counts = array();
    foreach ((array) $count as $row) {
        $counts[$row['post_mime_type']] = $row['num_posts'];
    }
    $counts['trash'] = $wpdb->get_var("SELECT COUNT( * ) FROM {$wpdb->posts} WHERE post_type = 'attachment' AND post_status = 'trash' {$and}");
    /**
     * Modify returned attachment counts by mime type.
     *
     * @since 3.7.0
     *
     * @param object $counts    An object containing the attachment counts by
     *                          mime type.
     * @param string $mime_type The mime type pattern used to filter the attachments
     *                          counted.
     */
    return apply_filters('wp_count_attachments', (object) $counts, $mime_type);
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:38,代码来源:post.php


示例18: file_gallery_shortcode


//.........这里部分代码省略.........
    } else {
        $output_params = true;
    }
    if ('false' === $paginate || is_numeric( 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_post_revision_title函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_popular_terms_checklist函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap