本文整理汇总了PHP中bp_core_get_directory_page_ids函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_get_directory_page_ids函数的具体用法?PHP bp_core_get_directory_page_ids怎么用?PHP bp_core_get_directory_page_ids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_get_directory_page_ids函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_item
/**
* get_item function.
*
* returns data about a BuddyPress site
*
* @access public
* @param mixed $request
* @return void
*/
public function get_item($request)
{
global $bp;
$core = array('version' => $bp->version, 'active_components' => $bp->active_components, 'directory_page_ids' => bp_core_get_directory_page_ids());
$core = apply_filters('core_api_data_filter', $core);
$response = new WP_REST_Response();
$response->set_data($core);
$response = rest_ensure_response($response);
return $response;
}
示例2: fix_registration
/**
* Fixes the ProSites checkout if BuddyPress registration page is set to checkout page
*/
public static function fix_registration()
{
global $psts;
if (function_exists('bp_core_get_directory_page_ids')) {
$bp_directory_page_ids = bp_core_get_directory_page_ids();
if (!empty($bp_directory_page_ids['register'])) {
$register_url = get_permalink($bp_directory_page_ids['register']);
}
if (bp_is_current_component('register') && $register_url == $psts->checkout_url()) {
remove_action('bp_init', 'bp_core_wpsignup_redirect');
remove_action('bp_screens', 'bp_core_screen_signup');
}
}
}
示例3: bp_core_clear_directory_pages_cache_page_edit
/**
* Clear the directory_pages cache when one of the pages is updated.
*
* @since BuddyPress (2.0.0)
*
* @param int $post_id
*/
function bp_core_clear_directory_pages_cache_page_edit($post_id)
{
if (!bp_is_root_blog()) {
return;
}
// Bail if BP is not defined here
if (!buddypress()) {
return;
}
$page_ids = bp_core_get_directory_page_ids('all');
if (!in_array($post_id, (array) $page_ids)) {
return;
}
wp_cache_delete('directory_pages', 'bp');
}
示例4: bps_add_form
function bps_add_form()
{
global $post;
$page = $post->ID;
if ($page == 0) {
$bp_pages = bp_core_get_directory_page_ids();
$page = $bp_pages['members'];
}
$len = strlen((string) $page);
$args = array('post_type' => 'bps_form', 'orderby' => 'ID', 'order' => 'ASC', 'nopaging' => true, 'meta_query' => array(array('key' => 'bps_options', 'value' => 's:9:"directory";s:3:"Yes";', 'compare' => 'LIKE'), array('key' => 'bps_options', 'value' => "s:6:\"action\";s:{$len}:\"{$page}\";", 'compare' => 'LIKE')));
$args = apply_filters('bps_form_order', $args);
$posts = get_posts($args);
foreach ($posts as $post) {
$meta = bps_meta($post->ID);
$template = $meta['template'];
bps_display_form($post->ID, $template, 'directory');
}
}
示例5: add_steps
function add_steps()
{
global $nxt_rewrite;
// Setup wizard steps
$steps = array();
if ('install' == $this->setup_type) {
$steps = array(__('Components', 'buddypress'), __('Pages', 'buddypress'), __('Permalinks', 'buddypress'), __('Theme', 'buddypress'), __('Finish', 'buddypress'));
// Update wizard steps
} else {
if ($this->is_network_activate) {
$steps[] = __('Multisite Update', 'buddypress');
}
if ($this->database_version < (int) $this->new_version) {
$steps[] = __('Database Update', 'buddypress');
}
if ($this->database_version < 1801 || !bp_core_get_directory_page_ids()) {
$steps[] = __('Components', 'buddypress');
$steps[] = __('Pages', 'buddypress');
}
$steps[] = __('Finish', 'buddypress');
}
return $steps;
}
示例6: test_should_return_false_for_invalid_component
public function test_should_return_false_for_invalid_component()
{
$found = bp_core_get_directory_page_id('foo');
$pages = bp_core_get_directory_page_ids();
$this->assertFalse($found);
}
示例7: check_positive_pages
function check_positive_pages($posts)
{
global $wp_query, $M_options;
$component = bp_current_component();
if (count($posts) > 1) {
return $posts;
}
if (!empty($component)) {
// we may be on a restricted post so check the URL and redirect if needed
$redirect = false;
$url = '';
$exclude = array();
if (!empty($M_options['registration_page'])) {
$exclude[] = get_permalink((int) $M_options['registration_page']);
$exclude[] = untrailingslashit(get_permalink((int) $M_options['registration_page']));
}
if (!empty($M_options['account_page'])) {
$exclude[] = get_permalink((int) $M_options['account_page']);
$exclude[] = untrailingslashit(get_permalink((int) $M_options['account_page']));
}
if (!empty($M_options['nocontent_page'])) {
$exclude[] = get_permalink((int) $M_options['nocontent_page']);
$exclude[] = untrailingslashit(get_permalink((int) $M_options['nocontent_page']));
}
if (!empty($wp_query->query_vars['protectedfile']) && !$forceviewing) {
$exclude[] = $host;
$exclude[] = untrailingslashit($host);
}
$existing_pages = bp_core_get_directory_page_ids();
if (!in_array(strtolower(get_permalink($existing_pages[$component])), $exclude)) {
$url = get_permalink($existing_pages[$component]);
}
// Check if we have a url available to check
if (empty($url)) {
return $posts;
}
// we have the current page / url - get the groups selected
$group_id = $this->get_group();
if ($group_id) {
$group = new M_Urlgroup($group_id);
if (!$group->url_matches($url)) {
$redirect = true;
}
}
if ($redirect === true && !empty($M_options['nocontent_page'])) {
// we need to redirect
$this->redirect();
} else {
return $posts;
}
}
return $posts;
}
示例8: bp_core_admin_page_options
/**
* Creates reusable markup for page setup on the Components and Pages dashboard panel.
*
* This markup has been abstracted so that it can be used both during the setup wizard as well as
* when BP has been fully installed.
*
* @package BuddyPress Core
* @since 1.5
*/
function bp_core_admin_page_options()
{
global $bp;
// Get the existing nxt pages
$existing_pages = bp_core_get_directory_page_ids();
// Set up an array of components (along with component names) that have
// directory pages.
$directory_pages = array();
foreach ($bp->loaded_components as $component_slug => $component_id) {
// Only components that need directories should be listed here
if (isset($bp->{$component_id}) && !empty($bp->{$component_id}->has_directory)) {
// component->name was introduced in BP 1.5, so we must provide a fallback
$component_name = !empty($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($component_id);
$directory_pages[$component_id] = $component_name;
}
}
$directory_pages = apply_filters('bp_directory_pages', $directory_pages);
?>
<h3><?php
_e('Directories', 'buddypress');
?>
</h3>
<p><?php
_e('Associate a NXTClass Page with each BuddyPress component directory.', 'buddypress');
?>
</p>
<table class="form-table">
<tbody>
<?php
foreach ($directory_pages as $name => $label) {
?>
<?php
$disabled = !bp_is_active($name) ? ' disabled="disabled"' : '';
?>
<tr valign="top">
<th scope="row">
<label for="bp_pages[<?php
echo esc_attr($name);
?>
]"><?php
echo esc_html($label);
?>
</label>
</th>
<td>
<?php
if (!bp_is_root_blog()) {
switch_to_blog(bp_get_root_blog_id());
}
?>
<?php
echo nxt_dropdown_pages(array('name' => 'bp_pages[' . esc_attr($name) . ']', 'echo' => false, 'show_option_none' => __('- None -', 'buddypress'), 'selected' => !empty($existing_pages[$name]) ? $existing_pages[$name] : false));
?>
<a href="<?php
echo admin_url(add_query_arg(array('post_type' => 'page'), 'post-new.php'));
?>
" class="button-secondary"><?php
_e('New Page');
?>
</a>
<input class="button-primary" type="submit" name="bp-admin-pages-single" value="<?php
_e('Save', 'buddypress');
?>
" />
<?php
if (!empty($existing_pages[$name])) {
?>
<a href="<?php
echo get_permalink($existing_pages[$name]);
?>
" class="button-secondary" target="_bp"><?php
_e('View');
?>
</a>
<?php
}
?>
<?php
if (!bp_is_root_blog()) {
//.........这里部分代码省略.........
示例9: yit_fix_bp_comments_list
function yit_fix_bp_comments_list($comments, $post_id)
{
global $wp_query;
$post = $wp_query->get_queried_object();
if (in_array($post->ID, bp_core_get_directory_page_ids())) {
return array();
}
return $comments;
}
示例10: validate_positive
public function validate_positive($args = null)
{
$component = bp_current_component();
if ($component) {
$pages = bp_core_get_directory_page_ids();
if (!empty($pages[$component])) {
return in_array($pages[$component], $this->data);
}
}
return parent::validate_positive();
}
示例11: add_filter
public function test_bp_core_get_directory_page_ids_should_not_contain_register_and_activet_pages_when_registration_is_closed()
{
// Make sure the pages exist, to verify they're filtered out.
add_filter('bp_get_signup_allowed', '__return_true', 999);
$ac = buddypress()->active_components;
bp_core_add_page_mappings(array_keys($ac));
remove_filter('bp_get_signup_allowed', '__return_true', 999);
// Get page ids
$page_ids = bp_core_get_directory_page_ids();
// Need to delete these pages as previously created.
wp_delete_post($page_ids['register'], true);
wp_delete_post($page_ids['activate'], true);
add_filter('bp_get_signup_allowed', '__return_false', 999);
bp_core_add_page_mappings(array_keys($ac));
$page_ids = bp_core_get_directory_page_ids();
remove_filter('bp_get_signup_allowed', '__return_false', 999);
$page_names = array_keys($page_ids);
$this->assertNotContains('register', $page_names);
$this->assertNotContains('activate', $page_names);
}
示例12: step_pages_save
function step_pages_save()
{
global $wpdb;
if (isset($_POST['submit']) && isset($_POST['bp_pages'])) {
check_admin_referer('bpwizard_pages');
// Make sure that the pages are created on the bp_get_root_blog_id(), no matter which Dashboard the setup is being run on
if (!empty($wpdb->blogid) && $wpdb->blogid != bp_get_root_blog_id() && !defined('BP_ENABLE_MULTIBLOG')) {
switch_to_blog(bp_get_root_blog_id());
}
// Delete any existing pages
$existing_pages = bp_core_get_directory_page_ids();
foreach ((array) $existing_pages as $page_id) {
wp_delete_post($page_id, true);
}
$blog_pages = $this->setup_pages((array) $_POST['bp_pages']);
bp_update_option('bp-pages', $blog_pages);
if (!empty($wpdb->blogid) && $wpdb->blogid != bp_get_root_blog_id() && !defined('BP_ENABLE_MULTIBLOG')) {
restore_current_blog();
}
return true;
}
return false;
}
示例13: buddydrive_deactivation
/**
* Handles plugin deactivation
*
* @uses bp_core_get_directory_page_ids() to get the BuddyPress component page ids
* @uses buddydrive_get_slug() to get BuddyDrive slug
* @uses wp_delete_post() to eventually delete the BuddyDrive page
* @uses bp_core_update_directory_page_ids() to update the BuddyPres component pages ids
*/
function buddydrive_deactivation()
{
// Bail if config does not match what we need
if (buddydrive::bail()) {
return;
}
$directory_pages = bp_core_get_directory_page_ids();
$buddydrive_slug = buddydrive_get_slug();
if (!empty($directory_pages[$buddydrive_slug])) {
// let's remove the page as the plugin is deactivated.
$buddydrive_page_id = $directory_pages[$buddydrive_slug];
wp_delete_post($buddydrive_page_id, true);
unset($directory_pages[$buddydrive_slug]);
bp_core_update_directory_page_ids($directory_pages);
}
do_action('buddydrive_deactivation');
}
示例14: bp_core_create_root_component_page
function bp_core_create_root_component_page()
{
global $bp;
$new_page_ids = array();
foreach ((array) $bp->add_root as $slug) {
$new_page_ids[$slug] = wp_insert_post(array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords($slug), 'post_status' => 'publish', 'post_type' => 'page'));
}
$page_ids = array_merge((array) $new_page_ids, (array) bp_core_get_directory_page_ids());
bp_core_update_directory_page_ids($page_ids);
}
示例15: buildDirectoryPages
/**
* Generates the BP component pages array
*
* @version 1.0
* @since 1.0
* @param array $flat_pages | Flat array of all WordPress pages on the site
* @return obj $pages | Exception on failure. Structured object containing page ID's, Names, and Slugs on success.
*/
function buildDirectoryPages($flat_pages)
{
if (empty($flat_pages)) {
throw new FOX_exception(array('numeric' => 1, 'text' => "Called with empty flat_pages array", 'file' => __FILE__, 'line' => __LINE__, 'method' => __METHOD__, 'child' => null));
}
$page_ids = (array) bp_core_get_directory_page_ids();
if (empty($page_ids)) {
throw new FOX_exception(array('numeric' => 2, 'text' => "BP core directory page ids option is empty", 'file' => __FILE__, 'line' => __LINE__, 'method' => __METHOD__, 'child' => null));
}
$pages = new stdClass();
// Iterate through each entry in the BP pages config option
foreach ($page_ids as $component_id => $bp_page_id) {
// Iterate through each WP site page in the flat pages array
foreach ($flat_pages as $wp_page_id => $data) {
// If the page ids match, add this page to the components array
if ($wp_page_id == $bp_page_id) {
$pages->{$component_id}->name = $data['slug'];
$pages->{$component_id}->id = $wp_page_id;
$pages->{$component_id}->title = $data['title'];
$stem = array();
$stem[] = $data['slug'];
$parent = $data['parent'];
// If the page is not attached to the root node, traverse the page tree backwards to the
// root node generating the reverse walk, then flip it and implode it to a string.
while ($parent != 0) {
$stem[] = $flat_pages[$parent]['slug'];
$parent = $flat_pages[$parent]['parent'];
}
// NOTE: BuddyPress incorrectly calls this a "slug", which is confusing. The correct term
// is a "stem" (in string form) and a "walk" (in array form).
$pages->{$component_id}->slug = implode('/', array_reverse((array) $stem));
}
unset($slug);
}
unset($wp_page_id, $data);
}
unset($component_id, $bp_page_id);
return apply_filters('bp_core_get_directory_pages', $pages);
}