当前位置: 首页>>代码示例>>PHP>>正文


PHP get_taxonomies_for_attachments函数代码示例

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


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

示例1: clea_patrice_show_img_cat

function clea_patrice_show_img_cat()
{
    // see https://wordpress.org/support/topic/product-category-in-the-library-dashboard
    global $wp_taxonomies;
    foreach (get_taxonomies_for_attachments('object') as $taxonomy => $params) {
        if (in_array('attachment', $params->object_type) && in_array('product', $params->object_type)) {
            // turns on taxonomy columns
            $wp_taxonomies[$taxonomy]->show_admin_column = 1;
        }
    }
}
开发者ID:aldelpech,项目名称:clea-patrice,代码行数:11,代码来源:clea-patrice-functions.php

示例2: wpuxss_eml_shortcode_atts

 function wpuxss_eml_shortcode_atts($out, $pairs, $atts)
 {
     $is_filter_based = false;
     $id = isset($atts['id']) ? intval($atts['id']) : 0;
     // enforce order defaults
     $pairs['order'] = 'ASC';
     $pairs['orderby'] = 'menu_order ID';
     foreach ($pairs as $name => $default) {
         if (array_key_exists($name, $atts)) {
             $out[$name] = $atts[$name];
         } else {
             $out[$name] = $default;
         }
     }
     if (isset($atts['monthnum']) && isset($atts['year'])) {
         $is_filter_based = true;
     }
     $tax_query = array();
     foreach (get_taxonomies_for_attachments('names') as $taxonomy) {
         if (isset($atts[$taxonomy])) {
             $terms = explode(',', $atts[$taxonomy]);
             $tax_query[] = array('taxonomy' => $taxonomy, 'field' => 'term_id', 'terms' => $terms, 'operator' => 'IN');
             $is_filter_based = true;
         }
     }
     if (!$is_filter_based) {
         return $out;
     }
     $ids = array();
     $mime_type = isset($out['type']) && ('audio' === $out['type'] || 'video' === $out['type']) ? $out['type'] : 'image';
     $query = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => $mime_type, 'order' => $out['order'], 'orderby' => $out['orderby'], 'posts_per_page' => isset($atts['limit']) ? intval($atts['limit']) : -1, 'fields' => 'ids');
     if (isset($atts['monthnum']) && isset($atts['year'])) {
         $query['monthnum'] = $atts['monthnum'];
         $query['year'] = $atts['year'];
     }
     if ('post__in' === $out['orderby']) {
         $query['orderby'] = 'menu_order ID';
     }
     if (!empty($tax_query)) {
         $tax_query['relation'] = 'AND';
         $query['tax_query'] = $tax_query;
     }
     if ($id) {
         $query['post_parent'] = $id;
     }
     $ids = get_posts($query);
     if (!empty($ids)) {
         $out['ids'] = $out['include'] = implode(',', $ids);
     }
     return $out;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:51,代码来源:medialist.php

示例3: wp_ajax_query_attachments

/**
 * Ajax handler for querying attachments.
 *
 * @since 3.5.0
 */
function wp_ajax_query_attachments()
{
    if (!current_user_can('upload_files')) {
        wp_send_json_error();
    }
    $query = isset($_REQUEST['query']) ? (array) $_REQUEST['query'] : array();
    $keys = array('s', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', 'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum');
    foreach (get_taxonomies_for_attachments('objects') as $t) {
        if ($t->query_var && isset($query[$t->query_var])) {
            $keys[] = $t->query_var;
        }
    }
    $query = array_intersect_key($query, array_flip($keys));
    $query['post_type'] = 'attachment';
    if (MEDIA_TRASH && !empty($_REQUEST['query']['post_status']) && 'trash' === $_REQUEST['query']['post_status']) {
        $query['post_status'] = 'trash';
    } else {
        $query['post_status'] = 'inherit';
    }
    if (current_user_can(get_post_type_object('attachment')->cap->read_private_posts)) {
        $query['post_status'] .= ',private';
    }
    /**
     * Filter the arguments passed to WP_Query during an AJAX
     * call for querying attachments.
     *
     * @since 3.7.0
     *
     * @see WP_Query::parse_query()
     *
     * @param array $query An array of query variables.
     */
    $query = apply_filters('ajax_query_attachments_args', $query);
    $query = new WP_Query($query);
    $posts = array_map('wp_prepare_attachment_for_js', $query->posts);
    $posts = array_filter($posts);
    wp_send_json_success($posts);
}
开发者ID:hughnet,项目名称:WordPress,代码行数:43,代码来源:ajax-actions.php

示例4: get_posts


//.........这里部分代码省略.........
         if ('page' != get_option('show_on_front') || $q['page_id'] != get_option('page_for_posts')) {
             $q['p'] = $q['page_id'];
             $where = " AND {$this->db->posts}.ID = " . $q['page_id'];
         }
     }
     // If a search pattern is specified, load the posts that match.
     if (strlen($q['s'])) {
         $search = $this->parse_search($q);
     }
     if (!$q['suppress_filters']) {
         /**
          * Filters the search SQL that is used in the WHERE clause of WP_Query.
          *
          * @since 3.0.0
          *
          * @param string   $search Search SQL for WHERE clause.
          * @param WP_Query $this   The current WP_Query object.
          */
         $search = apply_filters_ref_array('posts_search', array($search, &$this));
     }
     // Taxonomies
     if (!$this->is_singular) {
         $this->parse_tax_query($q);
         $clauses = $this->tax_query->get_sql($this->db->posts, 'ID');
         $join .= $clauses['join'];
         $where .= $clauses['where'];
     }
     if ($this->is_tax) {
         if (empty($post_type)) {
             // Do a fully inclusive search for currently registered post types of queried taxonomies
             $post_type = array();
             $taxonomies = array_keys($this->tax_query->queried_terms);
             foreach (get_post_types(array('exclude_from_search' => false)) as $pt) {
                 $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
                 if (array_intersect($taxonomies, $object_taxonomies)) {
                     $post_type[] = $pt;
                 }
             }
             if (!$post_type) {
                 $post_type = 'any';
             } elseif (count($post_type) == 1) {
                 $post_type = $post_type[0];
             }
             $post_status_join = true;
         } elseif (in_array('attachment', (array) $post_type)) {
             $post_status_join = true;
         }
     }
     /*
      * Ensure that 'taxonomy', 'term', 'term_id', 'cat', and
      * 'category_name' vars are set for backward compatibility.
      */
     if (!empty($this->tax_query->queried_terms)) {
         /*
          * Set 'taxonomy', 'term', and 'term_id' to the
          * first taxonomy other than 'post_tag' or 'category'.
          */
         if (!isset($q['taxonomy'])) {
             foreach ($this->tax_query->queried_terms as $queried_taxonomy => $queried_items) {
                 if (empty($queried_items['terms'][0])) {
                     continue;
                 }
                 if (!in_array($queried_taxonomy, array('category', 'post_tag'))) {
                     $q['taxonomy'] = $queried_taxonomy;
                     if ('slug' === $queried_items['field']) {
                         $q['term'] = $queried_items['terms'][0];
开发者ID:inpsyde,项目名称:wordpress-dev,代码行数:67,代码来源:class-wp-query.php

示例5: get_columns

 public function get_columns()
 {
     $posts_columns = array();
     $posts_columns['cb'] = '<input type="checkbox" />';
     $posts_columns['icon'] = '';
     /* translators: column name */
     $posts_columns['title'] = _x('File', 'column name');
     $posts_columns['author'] = __('Author');
     $taxonomies = get_taxonomies_for_attachments('objects');
     $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name');
     /**
      * Filter the taxonomy columns for attachments in the Media list table.
      *
      * @since 3.5.0
      *
      * @param array $taxonomies An array of registered taxonomies to show for attachments.
      * @param string $post_type The post type. Default 'attachment'.
      */
     $taxonomies = apply_filters('manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment');
     $taxonomies = array_filter($taxonomies, 'taxonomy_exists');
     foreach ($taxonomies as $taxonomy) {
         if ('category' == $taxonomy) {
             $column_key = 'categories';
         } elseif ('post_tag' == $taxonomy) {
             $column_key = 'tags';
         } else {
             $column_key = 'taxonomy-' . $taxonomy;
         }
         $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name;
     }
     /* translators: column name */
     if (!$this->detached) {
         $posts_columns['parent'] = _x('Uploaded to', 'column name');
         if (post_type_supports('attachment', 'comments')) {
             $posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__('Comments') . '" class="comment-grey-bubble"></span></span>';
         }
     }
     /* translators: column name */
     $posts_columns['date'] = _x('Date', 'column name');
     /**
      * Filter the Media list table columns.
      *
      * @since 2.5.0
      *
      * @param array $posts_columns An array of columns displayed in the Media list table.
      * @param bool $detached Whether the list table contains media not attached
      *                             to any posts. Default true.
      */
     $posts_columns = apply_filters('manage_media_columns', $posts_columns, $this->detached);
     return $posts_columns;
 }
开发者ID:ajspencer,项目名称:NCSSM-SG-WordPress,代码行数:51,代码来源:class-wp-media-list-table.php

示例6: array

	$submenu['edit.php'][10]  = array( _x('Add New', 'post'), get_post_type_object( 'post' )->cap->create_posts, 'post-new.php' );

	$i = 15;
	foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
		if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
			continue;

		$submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
	}
	unset($tax);

$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'none' );
	$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
	/* translators: add new file */
	$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
	foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) {
		if ( ! $tax->show_ui )
			continue;

		$submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&amp;post_type=attachment' );
	}
	unset($tax);

$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'none' );
	$submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
	/* translators: add new links */
	$submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' );
	$submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );

$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'none' );
	$submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' );
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:31,代码来源:MENU.PHP

示例7: query_get_post_types

 function query_get_post_types($query, $_if_empty_set_post_types = FALSE)
 {
     $query_post_types = isset($query->query_vars['post_type']) ? $query->query_vars['post_type'] : array();
     if (!empty($query_post_types) && !is_array($query_post_types)) {
         $query_post_types = (array) $query_post_types;
     }
     if (empty($query_post_types) && !is_array($query_post_types)) {
         $query_post_types = array();
     }
     /**
      * 
      *   If empty post type query field AND use default category taxonomy, use post
      *   To check further
      * 
      */
     if (empty($query_post_types) && $_if_empty_set_post_types === FALSE) {
         $taxonomies = array();
         if (isset($query->tax_query) && isset($query->tax_query->queries)) {
             $taxonomies = APTO_query_utils::get_query_taxonomies($query->tax_query->queries);
         }
         if (count($taxonomies) > 0 && count($taxonomies) < 2) {
             reset($taxonomies);
             $query_taxonomy = current($taxonomies);
             if ($query_taxonomy == 'category') {
                 $query_post_types[] = 'post';
             }
         }
     }
     if (empty($query_post_types) && $_if_empty_set_post_types === TRUE) {
         $taxonomies = array();
         if (isset($query->tax_query) && isset($query->tax_query->queries)) {
             $taxonomies = APTO_query_utils::get_query_taxonomies($query->tax_query->queries);
         }
         $ignore = array('revision', 'nav_menu_item');
         foreach ($this->get_post_types($ignore) as $pt) {
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
             if (array_intersect($taxonomies, $object_taxonomies)) {
                 $query_post_types[] = $pt;
             }
         }
         //v3.0  ??????chose the first
         /*
         if(count($query_post_types) > 1)
             $query_post_types  =   array_slice($query_post_types, 0, 1);
         */
         if (count($query_post_types) < 1) {
             $query_post_types[] = 'post';
         }
     }
     return $query_post_types;
 }
开发者ID:b0123498765,项目名称:template-wordpress,代码行数:51,代码来源:apto_functions-class.php

示例8: eventorganiser_is_event_query

/**
 * Checks whether a given query is for events
 * @package event-query-functions
 * @param WP_Query $query The query to test
 * @param bool $exclusive Whether to test if the query is *exclusively* for events, or can include other post types
 * @return bool True if the query is an event query. False otherwise.
 */
function eventorganiser_is_event_query($query, $exclusive = false)
{
    $post_types = $query->get('post_type');
    if ('any' == $post_types) {
        $post_types = get_post_types(array('exclude_from_search' => false));
    }
    if ($post_types == 'event' || array('event') == $post_types) {
        $bool = true;
    } elseif ($query && $query->is_feed('eo-events') || is_feed('eo-events')) {
        $bool = true;
    } elseif (empty($post_types) && eo_is_event_taxonomy($query)) {
        //Querying by taxonomy - check if 'event' is the only post type
        $post_types = array();
        $taxonomies = wp_list_pluck($query->tax_query->queries, 'taxonomy');
        foreach (get_post_types() as $pt) {
            if (version_compare('3.4', get_bloginfo('version')) <= 0) {
                $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
            } else {
                //Backwards compat for 3.3
                $object_taxonomies = $pt === 'attachment' ? array() : get_object_taxonomies($pt);
            }
            if (array_intersect($taxonomies, $object_taxonomies)) {
                $post_types[] = $pt;
            }
        }
        if (in_array('event', $post_types)) {
            if ($exclusive && 1 == count($post_types)) {
                $query->set('post_type', 'event');
                $bool = true;
            } elseif (!$exclusive) {
                $bool = true;
            } else {
                $bool = false;
            }
        } else {
            $bool = false;
        }
    } elseif ($exclusive) {
        $bool = false;
    } elseif (is_array($post_types) && in_array('event', $post_types)) {
        $bool = true;
    } else {
        $bool = false;
    }
    return apply_filters('eventorganiser_is_event_query', $bool, $query, $exclusive);
}
开发者ID:windyjonas,项目名称:fredrika,代码行数:53,代码来源:event-organiser-archives.php

示例9: get_posts


//.........这里部分代码省略.........
         } else {
             preg_match_all('/".*?("|$)|((?<=[\\r\\n\\t ",+])|^)[^\\r\\n\\t ",+]+/', $q['s'], $matches);
             $q['search_terms'] = array_map('_search_terms_tidy', $matches[0]);
         }
         $n = !empty($q['exact']) ? '' : '%';
         $searchand = '';
         foreach ((array) $q['search_terms'] as $term) {
             $term = esc_sql(like_escape($term));
             $search .= "{$searchand}(({$wpdb->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$wpdb->posts}.post_content LIKE '{$n}{$term}{$n}'))";
             $searchand = ' AND ';
         }
         if (!empty($search)) {
             $search = " AND ({$search}) ";
             if (!is_user_logged_in()) {
                 $search .= " AND ({$wpdb->posts}.post_password = '') ";
             }
         }
     }
     // Allow plugins to contextually add/remove/modify the search section of the database query
     $search = apply_filters_ref_array('posts_search', array($search, &$this));
     // Taxonomies
     if (!$this->is_singular) {
         $this->parse_tax_query($q);
         $clauses = $this->tax_query->get_sql($wpdb->posts, 'ID');
         $join .= $clauses['join'];
         $where .= $clauses['where'];
     }
     if ($this->is_tax) {
         if (empty($post_type)) {
             // Do a fully inclusive search for currently registered post types of queried taxonomies
             $post_type = array();
             $taxonomies = wp_list_pluck($this->tax_query->queries, 'taxonomy');
             foreach (get_post_types(array('exclude_from_search' => false)) as $pt) {
                 $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
                 if (array_intersect($taxonomies, $object_taxonomies)) {
                     $post_type[] = $pt;
                 }
             }
             if (!$post_type) {
                 $post_type = 'any';
             }
             $post_status_join = true;
         } elseif (in_array('attachment', (array) $post_type)) {
             $post_status_join = true;
         }
     }
     // Back-compat
     if (!empty($this->tax_query->queries)) {
         $tax_query_in_and = wp_list_filter($this->tax_query->queries, array('operator' => 'NOT IN'), 'NOT');
         if (!empty($tax_query_in_and)) {
             if (!isset($q['taxonomy'])) {
                 foreach ($tax_query_in_and as $a_tax_query) {
                     if (!in_array($a_tax_query['taxonomy'], array('category', 'post_tag'))) {
                         $q['taxonomy'] = $a_tax_query['taxonomy'];
                         if ('slug' == $a_tax_query['field']) {
                             $q['term'] = $a_tax_query['terms'][0];
                         } else {
                             $q['term_id'] = $a_tax_query['terms'][0];
                         }
                         break;
                     }
                 }
             }
             $cat_query = wp_list_filter($tax_query_in_and, array('taxonomy' => 'category'));
             if (!empty($cat_query)) {
                 $cat_query = reset($cat_query);
开发者ID:snagga,项目名称:urbantac,代码行数:67,代码来源:query.php

示例10: geodir_get_taxonomy_posttype

/**
 * Get a taxonomy post type.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wp_query WordPress Query object.
 * @param string $taxonomy The WordPress taxonomy string.
 * @return bool|string Post type on success. false on failure.
 */
function geodir_get_taxonomy_posttype($taxonomy = '')
{
    global $wp_query;
    $post_type = array();
    $taxonomies = array();
    if (!empty($taxonomy)) {
        $taxonomies[] = $taxonomy;
    } elseif (isset($wp_query->tax_query->queries)) {
        $tax_arr = $wp_query->tax_query->queries;
        //if tax query has 'relation' set then it will break wp_list_pluck so we remove it
        if (isset($tax_arr['relation'])) {
            unset($tax_arr['relation']);
        }
        $taxonomies = wp_list_pluck($tax_arr, 'taxonomy');
    }
    if (!empty($taxonomies)) {
        foreach (geodir_get_posttypes() as $pt) {
            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
            if (array_intersect($taxonomies, $object_taxonomies)) {
                $post_type[] = $pt;
            }
        }
    }
    if (!empty($post_type)) {
        return $post_type[0];
    } else {
        return false;
    }
}
开发者ID:kkoppenhaver,项目名称:geodirectory,代码行数:38,代码来源:taxonomy_functions.php

示例11: get_posts


//.........这里部分代码省略.........
         $search = $this->parse_search($q);
     }
     /**
      * Filter the search query.
      *
      * @param string      $search Search filter for ES query.
      * @param ES_WP_Query $this   The current ES_WP_Query object.
      */
     if (!empty($search)) {
         $query['must'] = apply_filters_ref_array('es_posts_search', array($search, &$this));
         if (!is_user_logged_in()) {
             $filter[] = array('or' => array($this->dsl_terms($this->es_map('post_password'), ''), $this->dsl_missing($this->es_map('post_password'))));
         }
     }
     // Taxonomies
     if (!$this->is_singular) {
         $this->parse_tax_query($q);
         $this->tax_query = new ES_WP_Tax_Query($this->tax_query);
         $tax_filter = $this->tax_query->get_dsl($this);
         if (false === $tax_filter) {
             return $this->no_results();
         }
         if (!empty($tax_filter)) {
             $filter[] = $tax_filter;
         }
         unset($tax_filter);
     }
     if ($this->is_tax) {
         if (empty($post_type)) {
             // Do a fully inclusive search for currently registered post types of queried taxonomies
             $post_type = array();
             $taxonomies = wp_list_pluck($this->tax_query->queries, 'taxonomy');
             foreach (get_post_types(array('exclude_from_search' => false)) as $pt) {
                 $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
                 if (array_intersect($taxonomies, $object_taxonomies)) {
                     $post_type[] = $pt;
                 }
             }
             if (!$post_type) {
                 $post_type = 'any';
             } elseif (count($post_type) == 1) {
                 $post_type = $post_type[0];
             }
             // @todo: no good way to do this in ES; workarounds?
             $post_status_join = true;
         } elseif (in_array('attachment', (array) $post_type)) {
             // @todo: no good way to do this in ES; workarounds?
             $post_status_join = true;
         }
     }
     // Back-compat
     if (!empty($this->tax_query->queries)) {
         $tax_query_in_and = wp_list_filter($this->tax_query->queries, array('operator' => 'NOT IN'), 'NOT');
         if (!empty($tax_query_in_and)) {
             if (!isset($q['taxonomy'])) {
                 foreach ($tax_query_in_and as $a_tax_query) {
                     if (!in_array($a_tax_query['taxonomy'], array('category', 'post_tag'))) {
                         $q['taxonomy'] = $a_tax_query['taxonomy'];
                         if ('slug' == $a_tax_query['field']) {
                             $q['term'] = $a_tax_query['terms'][0];
                         } else {
                             $q['term_id'] = $a_tax_query['terms'][0];
                         }
                         break;
                     }
                 }
开发者ID:GiantRobX,项目名称:wordpress-vip-plugins,代码行数:67,代码来源:class-es-wp-query-wrapper.php

示例12: get_columns

 function get_columns()
 {
     $posts_columns = array();
     $posts_columns['cb'] = '<input type="checkbox" />';
     $posts_columns['icon'] = '';
     /* translators: column name */
     $posts_columns['title'] = _x('File', 'column name');
     $posts_columns['author'] = __('Author');
     $taxonomies = array();
     $taxonomies = get_taxonomies_for_attachments('objects');
     $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name');
     $taxonomies = apply_filters('manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment');
     $taxonomies = array_filter($taxonomies, 'taxonomy_exists');
     foreach ($taxonomies as $taxonomy) {
         if ('category' == $taxonomy) {
             $column_key = 'categories';
         } elseif ('post_tag' == $taxonomy) {
             $column_key = 'tags';
         } else {
             $column_key = 'taxonomy-' . $taxonomy;
         }
         $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name;
     }
     /* translators: column name */
     if (!$this->detached) {
         $posts_columns['parent'] = _x('Uploaded to', 'column name');
         if (post_type_supports('attachment', 'comments')) {
             $posts_columns['comments'] = '<span class="vers"><div title="' . esc_attr__('Comments') . '" class="comment-grey-bubble"></div></span>';
         }
     }
     /* translators: column name */
     $posts_columns['date'] = _x('Date', 'column name');
     $posts_columns = apply_filters('manage_media_columns', $posts_columns, $this->detached);
     return $posts_columns;
 }
开发者ID:grff-alpha,项目名称:grff-alpha-web,代码行数:35,代码来源:class-wp-media-list-table.php

示例13: eventorganiser_is_event_query

/**
 * Checks whether a given query is for events
 * @package event-query-functions
 * @param WP_Query $query The query to test
 * @param bool $exclusive Whether to test if the query is *exclusively* for events, or can include other post types
 * @return bool True if the query is an event query. False otherwise.
 */
function eventorganiser_is_event_query($query, $exclusive = false)
{
    $post_types = $query->get('post_type');
    if ('any' == $post_types) {
        $post_types = get_post_types(array('exclude_from_search' => false));
    }
    if ($post_types == 'event' || array('event') == $post_types) {
        $bool = true;
    } elseif ($query && $query->is_feed('eo-events') || is_feed('eo-events')) {
        $bool = true;
    } elseif (empty($post_types) && eo_is_event_taxonomy($query)) {
        //Querying by taxonomy - check if 'event' is the only post type
        $post_types = array();
        $taxonomies = wp_list_pluck($query->tax_query->queries, 'taxonomy');
        foreach (get_post_types() as $pt) {
            if (version_compare('3.4', get_bloginfo('version')) <= 0) {
                $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
            } else {
                //Backwards compat for 3.3
                $object_taxonomies = $pt === 'attachment' ? array() : get_object_taxonomies($pt);
            }
            if (array_intersect($taxonomies, $object_taxonomies)) {
                $post_types[] = $pt;
            }
        }
        if (in_array('event', $post_types)) {
            if ($exclusive && 1 == count($post_types)) {
                $query->set('post_type', 'event');
                $bool = true;
            } elseif (!$exclusive) {
                $bool = true;
            } else {
                $bool = false;
            }
        } else {
            $bool = false;
        }
    } elseif ($exclusive) {
        $bool = false;
    } elseif (is_array($post_types) && in_array('event', $post_types)) {
        $bool = true;
    } else {
        $bool = false;
    }
    /**
     * Filters whether the query is an event query.
     * 
     * This should be `true` if the query is for events, `false` otherwise. The 
     * third parameter, `$exclusive` qualifies if this means 'query exclusively 
     * for events' or not. If `true` then this filter should return `true` only 
     * if the query is exclusively for events.
     * 
     * @param bool     $bool      Whether the query is an event query.
     * @param WP_Query $query     The WP_Query instance to check.
     * @param bool     $exclusive Whether the check if for queries exclusively for events. 
     */
    return apply_filters('eventorganiser_is_event_query', $bool, $query, $exclusive);
}
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:65,代码来源:event-organiser-archives.php

示例14: _bq_filter_post_status

 /**
  * Builds the query param for the post status filter
  * @param array $params
  * @param Lift_WP_Query $lift_query
  * @return array
  */
 public static function _bq_filter_post_status($params, $lift_query)
 {
     $wp_query = $lift_query->wp_query;
     $q = $wp_query->query_vars;
     $user_ID = get_current_user_id();
     //mimic wp_query logic around post_type since it isn't performed on an accessible copy
     $post_type = $q['post_type'];
     if ($wp_query->is_tax && empty($post_type)) {
         $post_type = array();
         $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
         foreach (get_post_types(array('exclude_from_search' => false)) as $pt) {
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
             if (array_intersect($taxonomies, $object_taxonomies)) {
                 $post_type[] = $pt;
             }
         }
         if (!$post_type) {
             $post_type = 'any';
         }
     }
     //direct copy from wp_query 3.5
     if (is_array($post_type)) {
         $post_type_cap = 'multiple_post_type';
     } else {
         $post_type_object = get_post_type_object($post_type);
         if (empty($post_type_object)) {
             $post_type_cap = $post_type;
         }
     }
     //direct copy from wp_query 3.5
     if ('any' == $post_type) {
         //unused code
     } elseif (!empty($post_type) && is_array($post_type)) {
         //unused code
     } elseif (!empty($post_type)) {
         $post_type_object = get_post_type_object($post_type);
     } elseif ($wp_query->is_attachment) {
         $post_type_object = get_post_type_object('attachment');
     } elseif ($wp_query->is_page) {
         $post_type_object = get_post_type_object('page');
     } else {
         $post_type_object = get_post_type_object('post');
     }
     //direct copy from wp_query 3.5
     if (!empty($post_type_object)) {
         $edit_cap = $post_type_object->cap->edit_post;
         $read_cap = $post_type_object->cap->read_post;
         $edit_others_cap = $post_type_object->cap->edit_others_posts;
         $read_private_cap = $post_type_object->cap->read_private_posts;
     } else {
         $edit_cap = 'edit_' . $post_type_cap;
         $read_cap = 'read_' . $post_type_cap;
         $edit_others_cap = 'edit_others_' . $post_type_cap . 's';
         $read_private_cap = 'read_private_' . $post_type_cap . 's';
     }
     if (!empty($q['post_status'])) {
         $q_status = $q['post_status'];
         $stati_expression = new Lift_Expression_Set('and');
         if (!is_array($q_status)) {
             $q_status = explode(',', $q_status);
         }
         $r_stati_expression = new Lift_Expression_Set();
         $p_stati_expression = new Lift_Expression_Set();
         $e_stati_expression = new Lift_Expression_Set('and');
         if (in_array('any', $q_status)) {
             foreach (get_post_stati(array('exclude_from_search' => true)) as $status) {
                 $e_stati_expression->addExpression(new Lift_Expression_Field('post_status', '-' . $status));
             }
         } else {
             foreach (get_post_stati() as $status) {
                 if (in_array($status, $q_status)) {
                     if ('private' == $status) {
                         $p_stati_expression->addExpression(new Lift_Expression_Field('post_status', $status));
                     } else {
                         $r_stati_expression->addExpression(new Lift_Expression_Field('post_status', $status));
                     }
                 }
             }
         }
         if (empty($q['perm']) || 'readable' != $q['perm']) {
             foreach ($p_stati_expression->sub_expressions as $expression) {
                 $r_stati_expression->addExpression($expression);
             }
             unset($p_stati_expression);
         }
         if (isset($r_stati_expression) && count($r_stati_expression)) {
             if (!empty($q['perm']) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap)) {
                 $tmp_expression = new Lift_Expression_Set('and', array(new Lift_Expression_Field('post_author', $user_ID, false), $r_stati_expression));
                 $stati_expression->addExpression($tmp_expression);
             } else {
                 $stati_expression->addExpression($r_stati_expression);
             }
         }
         if (!empty($p_stati_expression)) {
//.........这里部分代码省略.........
开发者ID:voceconnect,项目名称:lift-search,代码行数:101,代码来源:lift-wp-search.php

示例15: geodir_get_taxonomy_posttype

/**
 * Get a taxonomy post type.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wp_query WordPress Query object.
 * @param string $taxonomy The WordPress taxonomy string.
 * @return bool|string Post type on success. false on failure.
 */
function geodir_get_taxonomy_posttype($taxonomy = '')
{
    global $wp_query;
    $post_type = array();
    $taxonomies = array();
    if (!empty($taxonomy)) {
        $taxonomies[] = $taxonomy;
    } elseif ($wp_query->tax_query->queries) {
        $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy');
    }
    if (!empty($taxonomies)) {
        foreach (geodir_get_posttypes() as $pt) {
            $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
            if (array_intersect($taxonomies, $object_taxonomies)) {
                $post_type[] = $pt;
            }
        }
    }
    if (!empty($post_type)) {
        return $post_type[0];
    } else {
        return false;
    }
}
开发者ID:jefferose,项目名称:geodirectory,代码行数:33,代码来源:taxonomy_functions.php


注:本文中的get_taxonomies_for_attachments函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。