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


PHP bp_docs_get_post_type_name函数代码示例

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


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

示例1: bp_docs_create_dummy_doc

/**
 * Ajax handler to create dummy doc on creation
 *
 * @since 1.4
 */
function bp_docs_create_dummy_doc()
{
    add_filter('wp_insert_post_empty_content', '__return_false');
    $doc_id = wp_insert_post(array('post_type' => bp_docs_get_post_type_name(), 'post_status' => 'auto-draft'));
    remove_filter('wp_insert_post_empty_content', '__return_false');
    wp_send_json_success(array('doc_id' => $doc_id));
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:12,代码来源:attachments-ajax.php

示例2: process_bracket_content

 /**
  * Callback function for replacing bracketed links with the proper links
  *
  * If a page is found, a link to the page is produced. Otherwise a link to the create page
  * is produced, with the create_title flag.
  *
  * @since 1.2
  *
  * @param array $match A single match passed from preg_replace_callback()
  * @return str A formatted link
  */
 function process_bracket_content($match)
 {
     global $bp, $wpdb;
     // Check for a pipe
     if ($pipe_pos = strpos($match[1], '|')) {
         // If one is found, then the link text will be different from
         // the page name
         $link_text = substr($match[1], $pipe_pos + 1);
         $link_page = substr($match[1], 0, $pipe_pos);
     } else {
         // If no pipe is found, set the link text and link page the same
         $link_text = $link_page = $match[1];
     }
     // Look for a page with this title. WP_Query does not allow this for some reason
     $docs = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_title = %s AND post_type = %s {$in_clause}", $link_page, bp_docs_get_post_type_name()));
     // If none were found, do the same query with page slugs
     if (empty($docs)) {
         $docs = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s {$in_clause}", sanitize_title_with_dashes($link_page), bp_docs_get_post_type_name()));
     }
     // Filter the docs. This will be used to exclude docs that do not belong to a group
     $docs = apply_filters('bp_docs_bracket_matches', $docs);
     if (!empty($docs)) {
         // If we have a result, create a link to that page
         // There might be more than one result. I guess we take the first one
         $doc = $docs[0];
         $permalink = get_permalink($doc);
         $class = 'existing-doc';
     } else {
         // If no result is found, create a link to the edit page
         $permalink = add_query_arg('create_title', urlencode($link_page), bp_docs_get_create_link());
         $class = 'nonexistent-doc';
     }
     return apply_filters('bp_docs_bracket_link', '<a href="' . $permalink . '" class="' . $class . '">' . $link_text . '</a>');
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:45,代码来源:addon-wikitext.php

示例3: register_with_post_type

 /**
  * Registers the post taxonomies with the bp_docs post type
  *
  * @since 1.0-beta
  *
  * @param array The $bp_docs_post_type_args array created in BP_Docs::register_post_type()
  * @return array $args The modified parameters
  */
 function register_with_post_type()
 {
     $this->taxonomies = array($this->docs_tag_tax_name);
     foreach ($this->taxonomies as $tax) {
         register_taxonomy_for_object_type($tax, bp_docs_get_post_type_name());
     }
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:15,代码来源:addon-taxonomy.php

示例4: bp_docs_template_include

/**
 * Possibly intercept the template being loaded
 *
 * Listens to the 'template_include' filter and waits for a BP Docs post_type
 * to appear. When one is found, we look to see whether the current theme provides
 * its own version of the template; otherwise we fall back on the template shipped
 * with BuddyPress Docs.
 *
 * @since 1.2
 *
 * @param string $template
 *
 * @return string The path to the template file that is being used
 */
function bp_docs_template_include($template = '')
{
    if (bp_docs_is_single_doc() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
    } elseif (bp_docs_is_doc_create() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
    } elseif (is_post_type_archive(bp_docs_get_post_type_name()) && ($new_template = bp_docs_locate_template('archive-bp_doc.php'))) {
    }
    // Custom template file exists
    $template = !empty($new_template) ? $new_template : $template;
    return apply_filters('bp_docs_template_include', $template);
}
开发者ID:hscale,项目名称:webento,代码行数:24,代码来源:theme-bridge.php

示例5: process_bracket_content

 /**
  * Callback function for replacing bracketed links with the proper links
  *
  * If a page is found, a link to the page is produced. Otherwise a link to the create page
  * is produced, with the create_title flag.
  *
  * @package BuddyPress Docs
  * @since 1.2
  *
  * @param array $match A single match passed from preg_replace_callback()
  * @return str A formatted link
  */
 function process_bracket_content($match)
 {
     global $bp, $wpdb;
     // Check for a pipe
     if ($pipe_pos = strpos($match[1], '|')) {
         // If one is found, then the link text will be different from
         // the page name
         $link_text = substr($match[1], $pipe_pos + 1);
         $link_page = substr($match[1], 0, $pipe_pos);
     } else {
         // If no pipe is found, set the link text and link page the same
         $link_text = $link_page = $match[1];
     }
     // Exclude docs from other groups. Todo: move this out
     // Query for all the current group's docs
     if (isset($bp->groups->current_group->id)) {
         $query_args = array('tax_query' => array(array('taxonomy' => $bp->bp_docs->associated_item_tax_name, 'terms' => array($bp->groups->current_group->id), 'field' => 'name', 'operator' => 'IN', 'include_children' => false)), 'post_type' => $bp->bp_docs->post_type_name, 'showposts' => '-1');
     }
     $this_group_docs = new WP_Query($query_args);
     $this_group_doc_ids = array();
     foreach ($this_group_docs->posts as $gpost) {
         $this_group_doc_ids[] = $gpost->ID;
     }
     if (!empty($this_group_doc_ids)) {
         $in_clause = " AND {$wpdb->posts}.ID IN (" . implode(',', $this_group_doc_ids) . ")";
     } else {
         $in_clause = '';
     }
     // Look for a page with this title. WP_Query does not allow this for some reason
     $docs = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_title = %s AND post_type = %s {$in_clause}", $link_page, bp_docs_get_post_type_name()));
     // If none were found, do the same query with page slugs
     if (empty($docs)) {
         $docs = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s {$in_clause}", sanitize_title_with_dashes($link_page), bp_docs_get_post_type_name()));
     }
     // Filter the docs. This will be used to exclude docs that do not belong to a group
     $docs = apply_filters('bp_docs_bracket_matches', $docs);
     if (!empty($docs)) {
         // If we have a result, create a link to that page
         // There might be more than one result. I guess we take the first one
         $doc = $docs[0];
         $permalink = get_permalink($doc);
         $class = 'existing-doc';
     } else {
         // If no result is found, create a link to the edit page
         $permalink = add_query_arg('create_title', urlencode($link_page), bp_docs_get_item_docs_link() . BP_DOCS_CREATE_SLUG);
         $class = 'nonexistent-doc';
     }
     return apply_filters('bp_docs_bracket_link', '<a href="' . $permalink . '" class="' . $class . '">' . $link_text . '</a>');
 }
开发者ID:hscale,项目名称:webento,代码行数:61,代码来源:addon-wikitext.php

示例6: bp_docs_template_include

/**
 * Possibly intercept the template being loaded
 *
 * This function does two different things, depending on whether you're using BP
 * 1.7's theme compatibility feature.
 *  - If so, the function runs the 'bp_setup_theme_compat' hook, which tells BP
 *    to run the theme compat layer
 *  - If not, the function checks to see which page you intend to be looking at
 *    and loads the correct top-level bp-docs template
 *
 * The theme compatibility feature kicks in automatically for users running BP
 * 1.7+. If you are running 1.7+, but you do not want theme compat running for
 * a given Docs template type (archive, single, create), you can filter
 * 'bp_docs_do_theme_compat' and return false. This should only be done in the
 * case of legacy templates; if you're customizing new top-level templates for
 * Docs, you may put a file called plugin-buddypress-docs.php into the root of
 * your theme.
 *
 * @since 1.2
 *
 * @param string $template
 *
 * @return string The path to the template file that is being used
 */
function bp_docs_template_include($template = '')
{
    if (!bp_docs_is_docs_component()) {
        return $template;
    }
    $do_theme_compat = class_exists('BP_Theme_Compat') && apply_filters('bp_docs_do_theme_compat', true, $template);
    if ($do_theme_compat) {
        do_action('bp_setup_theme_compat');
    } else {
        if (bp_docs_is_single_doc() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
        } elseif (bp_docs_is_doc_create() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
        } elseif (is_post_type_archive(bp_docs_get_post_type_name()) && ($new_template = bp_docs_locate_template('archive-bp_doc.php'))) {
        }
        $template = !empty($new_template) ? $new_template : $template;
    }
    return apply_filters('bp_docs_template_include', $template);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:41,代码来源:theme-bridge.php

示例7: get_user_terms

 /**
  * Gets the list of terms used by a user's docs
  *
  * At the moment, this method (and the next one) assumes that you want the terms of the
  * displayed user. At some point, that should be abstracted a bit.
  *
  * @package BuddyPress_Docs
  * @subpackage Users
  * @since 1.2
  *
  * @return array $terms
  */
 function get_user_terms($terms = array())
 {
     global $wpdb;
     if (!bp_is_user()) {
         return $terms;
     }
     $query_args = array('post_type' => bp_docs_get_post_type_name(), 'update_meta_cache' => false, 'update_term_cache' => true, 'showposts' => '-1', 'posts_per_page' => '-1');
     if (bp_docs_is_edited_by()) {
         $query_args['post__in'] = BP_Docs_Query::get_edited_by_post_ids_for_user(bp_displayed_user_id());
         $query_args['post_status'] = array('publish');
     } else {
         if (bp_docs_is_started_by()) {
             $query_args['author'] = bp_displayed_user_id();
             $query_args['post_status'] = array('publish', 'trash');
         } else {
             // Just in case
             $query_args['post__in'] = array(0);
         }
     }
     $user_doc_query = new WP_Query($query_args);
     $terms = array();
     foreach ($user_doc_query->posts as $p) {
         $p_terms = wp_get_post_terms($p->ID, buddypress()->bp_docs->docs_tag_tax_name);
         foreach ($p_terms as $p_term) {
             if (!isset($terms[$p_term->slug])) {
                 $terms[$p_term->slug] = array('name' => $p_term->name, 'posts' => array());
             }
             if (!in_array($p->ID, $terms[$p_term->slug]['posts'])) {
                 $terms[$p_term->slug]['posts'][] = $p->ID;
             }
         }
     }
     foreach ($terms as &$t) {
         $t['count'] = count($t['posts']);
     }
     if (empty($terms)) {
         $terms = array();
     }
     return apply_filters('bp_docs_taxonomy_get_user_terms', $terms);
 }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:52,代码来源:integration-users.php

示例8: filter_permalinks

 /**
  * Display the proper permalink for Docs
  *
  * This function filters 'post_type_link', which in turn powers get_permalink() and related
  * functions.
  *
  * BuddyPress Docs has a completely flat architecture for URLs, where
  * parent slugs never appear in the URL (as they do in the case of WP
  * pages). So we reconstruct the link completely.
  *
  * @package BuddyPress Docs
  * @since 1.1.8
  *
  * @param str $link The permalink
  * @param obj $post The post object
  * @param bool $leavename
  * @param bool $sample See get_post_permalink() for an explanation of these two params
  * @return str $link The filtered permalink
  */
 function filter_permalinks($link, $post, $leavename, $sample)
 {
     if (bp_docs_get_post_type_name() == $post->post_type) {
         $link = trailingslashit(bp_docs_get_archive_link() . $post->post_name);
     }
     return html_entity_decode($link);
 }
开发者ID:pausaura,项目名称:agora_nodes,代码行数:26,代码来源:component.php

示例9: get_edited_by_post_ids_for_user

 /**
  *
  */
 public static function get_edited_by_post_ids_for_user($editor_ids)
 {
     $editor_ids = wp_parse_id_list($editor_ids);
     $post_ids = array();
     foreach ($editor_ids as $editor_id) {
         // @todo - Not sure how this will scale
         $posts = get_posts(array('author' => $editor_id, 'post_status' => array('inherit', 'publish'), 'post_type' => array('revision', bp_docs_get_post_type_name()), 'posts_per_page' => -1, 'update_post_meta_cache' => false, 'update_post_term_cache' => false));
         $this_author_post_ids = array();
         foreach ($posts as $post) {
             if ('revision' === $post->post_type) {
                 $this_author_post_ids[] = $post->post_parent;
             } else {
                 $this_author_post_ids[] = $post->ID;
             }
         }
         $post_ids = array_merge($post_ids, $this_author_post_ids);
     }
     // If the list is empty (the users haven't edited any Docs yet)
     // force 0 so that no items are shown
     if (empty($post_ids)) {
         $post_ids = array(0);
     }
     // @todo Might be faster to let the dupes through and let MySQL optimize
     return array_unique($post_ids);
 }
开发者ID:projectestac,项目名称:wordpress-buddypress-docs,代码行数:28,代码来源:query-builder.php

示例10: bp_docs_get_doc_for_caps

/**
 * Load up the doc to check against for meta cap mapping
 *
 * @since 1.2
 *
 * @param array $args The $args argument passed by the map_meta_cap filter. May be empty
 * @return obj $doc
 */
function bp_docs_get_doc_for_caps($args = array())
{
    global $post;
    $doc_id = 0;
    $doc = NULL;
    if (isset($args[0])) {
        $doc_id = $args[0];
        $doc = get_post($doc_id);
    } else {
        if (isset($post->ID)) {
            $doc = $post;
        }
    }
    if (!is_a($doc, 'WP_Post') || bp_docs_get_post_type_name() !== $doc->post_type) {
        $doc = null;
    }
    return apply_filters('bp_docs_get_doc_for_caps', $doc, $args);
}
开发者ID:ExpectancyLearning,项目名称:buddypress-docs,代码行数:26,代码来源:caps.php

示例11: bp_docs_delete_doc_activity

/**
 * Delete activity associated with a Doc
 *
 * Run on transition_post_status, to catch deletes from all locations
 *
 * @since 1.3
 *
 * @param string $new_status
 * @param string $old_status
 * @param obj WP_Post object
 */
function bp_docs_delete_doc_activity($new_status, $old_status, $post)
{
    if (!bp_is_active('activity')) {
        return;
    }
    if (bp_docs_get_post_type_name() != $post->post_type) {
        return;
    }
    if ('trash' != $new_status) {
        return;
    }
    $activities = bp_activity_get(array('filter' => array('secondary_id' => $post->ID, 'component' => 'docs')));
    foreach ((array) $activities['activities'] as $activity) {
        bp_activity_delete(array('id' => $activity->id));
    }
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:27,代码来源:activity.php

示例12: filter_permalinks

 /**
  * Display the proper permalink for Docs
  *
  * This function filters 'post_type_link', which in turn powers get_permalink() and related
  * functions.
  *
  * As of 1.2, the only role of this function is to ensure that child
  * Doc permalinks are returned correctly (without the parent slug)
  *
  * @package BuddyPress Docs
  * @since 1.1.8
  *
  * @param str $link The permalink
  * @param obj $post The post object
  * @param bool $leavename
  * @param bool $sample See get_post_permalink() for an explanation of these two params
  * @return str $link The filtered permalink
  */
 function filter_permalinks($link, $post, $leavename, $sample)
 {
     if (bp_docs_get_post_type_name() == $post->post_type && !empty($post->post_parent)) {
         $link = $post->guid;
     }
     return html_entity_decode($link);
 }
开发者ID:hscale,项目名称:webento,代码行数:25,代码来源:component.php

示例13: get_doc_ids

 /**
  * Fetch a list of Doc IDs that are forbidden for the user
  *
  * @since 1.2.8
  */
 public function get_doc_ids()
 {
     remove_action('pre_get_posts', 'bp_docs_general_access_protection');
     $tax_query = $this->get_tax_query();
     foreach ($tax_query as &$tq) {
         $tq['operator'] = "NOT IN";
     }
     $forbidden_fruit = get_posts(array('post_type' => bp_docs_get_post_type_name(), 'posts_per_page' => -1, 'nopaging' => true, 'tax_query' => $tax_query, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'no_found_rows' => 1));
     add_action('pre_get_posts', 'bp_docs_general_access_protection');
     return wp_list_pluck($forbidden_fruit, 'ID');
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:16,代码来源:access-query.php

示例14: bp_docs_is_mygroups_directory

/**
 * Is this the My Groups directory?
 *
 * @since 1.5
 * @return bool
 */
function bp_docs_is_mygroups_directory()
{
    $is_mygroups_directory = false;
    if (is_post_type_archive(bp_docs_get_post_type_name()) && get_query_var(BP_DOCS_MY_GROUPS_SLUG) && !get_query_var(BP_DOCS_CREATE_SLUG)) {
        $is_mygroups_directory = true;
    }
    return apply_filters('bp_docs_is_mygroups_directory', $is_mygroups_directory);
}
开发者ID:ExpectancyLearning,项目名称:buddypress-docs,代码行数:14,代码来源:templatetags.php

示例15: map_meta_cap

 /**
  * Give users the 'edit_post' and 'upload_files' cap, when appropriate
  *
  * @since 1.4
  *
  * @param array $caps The mapped caps
  * @param string $cap The cap being mapped
  * @param int $user_id The user id in question
  * @param $args
  * @return array $caps
  */
 public static function map_meta_cap($caps, $cap, $user_id, $args)
 {
     if ('upload_files' !== $cap && 'edit_post' !== $cap) {
         return $caps;
     }
     $maybe_user = new WP_User($user_id);
     if (!is_a($maybe_user, 'WP_User') || empty($maybe_user->ID)) {
         return $caps;
     }
     $is_doc = false;
     // DOING_AJAX is not set yet, so we cheat
     $is_ajax = isset($_SERVER['REQUEST_METHOD']) && 'POST' === $_SERVER['REQUEST_METHOD'] && 'async-upload.php' === substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '/') + 1);
     if ($is_ajax) {
         // WordPress sends the 'media-form' nonce, which we use
         // as an initial screen
         $nonce = isset($_REQUEST['_wpnonce']) ? stripslashes($_REQUEST['_wpnonce']) : '';
         $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : '';
         if (wp_verify_nonce($nonce, 'media-form') && $post_id) {
             $post = get_post($post_id);
             // The dummy Doc created during the Create
             // process should pass this test, in addition to
             // existing Docs
             $is_doc = isset($post->post_type) && bp_docs_get_post_type_name() === $post->post_type;
         }
     } else {
         $is_doc = bp_docs_is_existing_doc() || bp_docs_is_doc_create();
     }
     if ($is_doc) {
         $caps = array('exist');
         // Since we've already done the permissions check,
         // we can filter future current_user_can() checks on
         // this pageload
         add_filter('map_meta_cap', array(__CLASS__, 'map_meta_cap_supp'), 10, 4);
     }
     return $caps;
 }
开发者ID:projectestac,项目名称:wordpress-buddypress-docs,代码行数:47,代码来源:attachments.php


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