本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: parse_query
/**
* Handles stuff that needs to be done at 'parse_query'
*
* - Ensures that no post is loaded on the creation screen
* - Ensures that an archive template is loaded in /docs/my-groups/
*/
function parse_query($posts_query)
{
// Bail if $posts_query is not the main loop
if (!$posts_query->is_main_query()) {
return;
}
// Bail if filters are suppressed on this query
if (true == $posts_query->get('suppress_filters')) {
return;
}
// Bail if in admin
if (is_admin()) {
return;
}
// Don't query for any posts on /docs/create/
if ($posts_query->get(BP_DOCS_CREATE_SLUG)) {
$posts_query->is_404 = false;
$posts_query->set('p', -1);
}
// Fall back on archive template on /docs/my-groups/
if ($posts_query->get(BP_DOCS_MY_GROUPS_SLUG)) {
$posts_query->is_404 = false;
}
// For single Doc views, allow access to 'deleted' items
// that the current user is the admin of
if ($posts_query->is_single && bp_docs_get_post_type_name() === $posts_query->get('post_type')) {
$doc_slug = $posts_query->get('name');
// Direct query, because barf
global $wpdb;
$author_id = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE post_type = %s AND post_name = %s", bp_docs_get_post_type_name(), $doc_slug));
// Post author or mod can visit it
if ($author_id && ($author_id == get_current_user_id() || current_user_can('bp_moderate'))) {
$posts_query->set('post_status', array('publish', 'trash'));
// Make the 'trash' post status public
add_filter('posts_request', array($this, 'make_trash_public'));
// ... and undo that when we're done
add_filter('the_posts', array($this, 'remove_make_trash_public'));
}
}
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:46,代码来源:bp-docs.php
示例17: bp_docs_upgrade_1_2
function bp_docs_upgrade_1_2($udata = array())
{
global $wpdb;
$url_base = admin_url(add_query_arg(array('post_type' => bp_docs_get_post_type_name(), 'page' => 'bp-docs-upgrade'), 'edit.php'));
if (empty($udata['total'])) {
$udata['total'] = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = %s", bp_docs_get_post_type_name()));
}
if (!isset($udata['done'])) {
$udata['done'] = 0;
}
if (empty($udata['group_terms_migrated'])) {
$tn = bp_docs_get_associated_item_tax_name();
// Get the group parent term
$group_parent_term = term_exists('group', $tn);
// Get all the group terms
if ($group_parent_term) {
// Delete the cached children terms, for good measure
delete_option($tn . '_children');
$group_terms = get_terms($tn, array('parent' => intval($group_parent_term['term_id'])));
foreach ($group_terms as $group_term) {
// Concatenate new term slugs
$new_desc = sprintf(__('Docs associated with the group %s', 'bp-docs'), $group_term->description);
$new_slug = 'bp_docs_associated_group_' . $group_term->name;
$new_name = $group_term->description;
wp_update_term($group_term->term_id, $tn, array('description' => $new_desc, 'slug' => $new_slug, 'name' => $new_name, 'parent' => 0));
}
}
// Store that we're done
$udata['group_terms_migrated'] = 1;
$udata['message'] = __('Group terms migrated. Now migrating Doc access terms....', 'bp-docs');
$udata['refresh_url'] = add_query_arg(array('do_upgrade' => '1', '_wpnonce' => wp_create_nonce('bp-docs-upgrade')), $url_base);
$udata['total'] = 0;
} else {
if (intval($udata['done']) < intval($udata['total'])) {
$counter = 0;
while ($counter < 5) {
$next_doc_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND ID > %d LIMIT 1", bp_docs_get_post_type_name(), intval($udata['last'])));
if (!$next_doc_id) {
$udata['done'] = $udata['total'];
$all_done = true;
break;
}
// Set the 'read' setting to a taxonomy
$doc_settings = get_post_meta($next_doc_id, 'bp_docs_settings', true);
if (isset($doc_settings['read'])) {
$read_setting = $doc_settings['read'];
} else {
$group = groups_get_group('group_id=' . bp_docs_get_associated_group_id($next_doc_id));
if (!empty($group->status) && 'public' != $group->status) {
$read_setting = 'group-members';
// Sanitize settings as well
foreach ($doc_settings as $doc_settings_key => $doc_settings_value) {
if (in_array($doc_settings_value, array('anyone', 'loggedin'))) {
$doc_settings[$doc_settings_key] = 'group-members';
}
}
$doc_settings['read'] = 'group-members';
update_post_meta($next_doc_id, 'bp_docs_settings', $doc_settings);
} else {
$read_setting = 'anyone';
}
}
bp_docs_update_doc_access($next_doc_id, $read_setting);
// Count the total number of edits
$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'revision' AND post_status = 'inherit' AND post_parent = %d", $next_doc_id));
update_post_meta($next_doc_id, 'bp_docs_revision_count', $count + 1);
$counter++;
$udata['done']++;
$udata['last'] = $next_doc_id;
$udata['message'] = sprintf(__('Migrated %s of %s Docs. Migrating....', 'bp-docs'), $udata['done'], $udata['total']);
$udata['refresh_url'] = add_query_arg(array('do_upgrade' => '1', '_wpnonce' => wp_create_nonce('bp-docs-upgrade')), $url_base);
}
} else {
$all_done = true;
$udata['refresh_url'] = add_query_arg(array('bp_docs_upgraded' => 1), admin_url());
}
}
if (isset($all_done)) {
bp_update_option('_bp_docs_done_upgrade_1_2', 1);
}
return $udata;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:82,代码来源:upgrade.php
示例18: create_dummy_post
/**
* Update the global $post with dummy data regarding doc creation
*
* @since 1.3
*/
public function create_dummy_post()
{
bp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Create a Doc', 'bp-docs'), 'post_author' => get_current_user_id(), 'post_date' => 0, 'post_content' => '', 'post_type' => bp_docs_get_post_type_name(), 'post_status' => 'publish', 'is_archive' => true, 'comment_status' => 'closed'));
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:9,代码来源:theme-bridge.php
示例19: bp_docs_get_doc_ids_accessible_to_current_user
function bp_docs_get_doc_ids_accessible_to_current_user()
{
global $wpdb;
// Direct query for speeeeeeed
$exclude = bp_docs_access_query()->get_doc_ids();
if (empty($exclude)) {
$exclude = array(0);
}
$exclude_sql = '(' . implode(',', $exclude) . ')';
$items_sql = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND ID NOT IN {$exclude_sql}", bp_docs_get_post_type_name());
return $wpdb->get_col($items_sql);
}
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:12,代码来源:functions.php
示例20: bp_docs_add_edit_lock_cb
/**
* AJAX handler for setting edit lock.
*
* Called when a user enters an Edit page.
*
* @since 1.6.0
*/
function bp_docs_add_edit_lock_cb()
{
$doc_id = isset($_POST['doc_id']) ? (int) $_POST['doc_id'] : false;
if (!$doc_id) {
return;
}
$doc = get_post($doc_id);
if (!$doc || is_wp_error($doc)) {
return;
}
if (bp_docs_get_post_type_name() !== $doc->post_type) {
return;
}
if (!is_user_logged_in()) {
return;
}
// Is this post already locked?
$lock = bp_docs_check_post_lock($doc_id);
if (!empty($lock) && $lock != bp_loggedin_user_id()) {
die;
}
$now = time();
$user_id = bp_loggedin_user_id();
$lock = "{$now}:{$user_id}";
update_post_meta($doc_id, '_bp_docs_last_pinged', $lock);
die(json_encode('1'));
}
开发者ID:Apatrid,项目名称:buddypress-docs,代码行数:34,代码来源:edit-lock.php
注:本文中的bp_docs_get_post_type_name函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论