本文整理汇总了PHP中bp_get_requested_url函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_requested_url函数的具体用法?PHP bp_get_requested_url怎么用?PHP bp_get_requested_url使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_get_requested_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_members_admin_bar_my_account_menu
/**
* Add the "My Account" menu and all submenus.
*
* @since 1.6.0
*
* @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support
*/
function bp_members_admin_bar_my_account_menu()
{
global $wp_admin_bar;
// Bail if this is an ajax request
if (defined('DOING_AJAX')) {
return;
}
// Logged in user
if (is_user_logged_in()) {
$bp = buddypress();
// Stored in the global so we can add menus easily later on
$bp->my_account_menu_id = 'my-account-buddypress';
// Create the main 'My Account' menu
$wp_admin_bar->add_menu(array('id' => $bp->my_account_menu_id, 'group' => true, 'title' => __('Edit My Profile', 'buddypress'), 'href' => bp_loggedin_user_domain(), 'meta' => array('class' => 'ab-sub-secondary')));
// Show login and sign-up links
} elseif (!empty($wp_admin_bar)) {
add_filter('show_admin_bar', '__return_true');
// Create the main 'My Account' menu
$wp_admin_bar->add_menu(array('id' => 'bp-login', 'title' => __('Log in', 'buddypress'), 'href' => wp_login_url(bp_get_requested_url())));
// Sign up
if (bp_get_signup_allowed()) {
$wp_admin_bar->add_menu(array('id' => 'bp-register', 'title' => __('Register', 'buddypress'), 'href' => bp_get_signup_page()));
}
}
}
示例2: bp_setup_nav_menu_item
/**
* Add BuddyPress-specific items to the wp_nav_menu.
*
* @since BuddyPress (1.9.0)
*
* @param WP_Post $menu_item The menu item.
* @return obj The modified WP_Post object.
*/
function bp_setup_nav_menu_item( $menu_item ) {
if ( is_admin() ) {
return $menu_item;
}
// We use information stored in the CSS class to determine what kind of
// menu item this is, and how it should be treated
preg_match( '/\sbp-(.*)-nav/', implode( ' ', $menu_item->classes), $matches );
// If this isn't a BP menu item, we can stop here
if ( empty( $matches[1] ) ) {
return $menu_item;
}
switch ( $matches[1] ) {
case 'login' :
if ( is_user_logged_in() ) {
$menu_item->_invalid = true;
} else {
$menu_item->url = wp_login_url( bp_get_requested_url() );
}
break;
case 'logout' :
if ( ! is_user_logged_in() ) {
$menu_item->_invalid = true;
} else {
$menu_item->url = wp_logout_url( bp_get_requested_url() );
}
break;
// Don't show the Register link to logged-in users
case 'register' :
if ( is_user_logged_in() ) {
$menu_item->_invalid = true;
}
break;
// All other BP nav items are specific to the logged-in user,
// and so are not relevant to logged-out users
default:
if ( is_user_logged_in() ) {
$menu_item->url = bp_nav_menu_get_item_url( $matches[1] );
} else {
$menu_item->_invalid = true;
}
break;
}
// If component is deactivated, make sure menu item doesn't render
if ( empty( $menu_item->url ) ) {
$menu_item->_invalid = true;
// Highlight the current page
} else {
$current = bp_get_requested_url();
if ( strpos( $current, $menu_item->url ) !== false ) {
$menu_item->classes[] = 'current_page_item';
}
}
return $menu_item;
}
示例3: bp_get_title_parts
/**
* Get the title parts of the BuddyPress displayed page
*
* @since 2.4.3
*
* @param string $seplocation Location for the separator.
* @return array the title parts
*/
function bp_get_title_parts($seplocation = 'right')
{
$bp = buddypress();
// Defaults to an empty array.
$bp_title_parts = array();
// If this is not a BP page, return the empty array.
if (bp_is_blog_page()) {
return $bp_title_parts;
}
// If this is a 404, return the empty array.
if (is_404()) {
return $bp_title_parts;
}
// If this is the front page of the site, return the empty array.
if (is_front_page() || is_home()) {
return $bp_title_parts;
}
// Return the empty array if not a BuddyPress page.
if (!is_buddypress()) {
return $bp_title_parts;
}
// Now we can build the BP Title Parts
// Is there a displayed user, and do they have a name?
$displayed_user_name = bp_get_displayed_user_fullname();
// Displayed user.
if (!empty($displayed_user_name) && !is_404()) {
// Get the component's ID to try and get its name.
$component_id = $component_name = bp_current_component();
// Set empty subnav name.
$component_subnav_name = '';
if (!empty($bp->members->nav)) {
$primary_nav_item = $bp->members->nav->get_primary(array('slug' => $component_id), false);
$primary_nav_item = reset($primary_nav_item);
}
// Use the component nav name.
if (!empty($primary_nav_item->name)) {
$component_name = _bp_strip_spans_from_title($primary_nav_item->name);
// Fall back on the component ID.
} elseif (!empty($bp->{$component_id}->id)) {
$component_name = ucwords($bp->{$component_id}->id);
}
if (!empty($bp->members->nav)) {
$secondary_nav_item = $bp->members->nav->get_secondary(array('parent_slug' => $component_id, 'slug' => bp_current_action()), false);
if ($secondary_nav_item) {
$secondary_nav_item = reset($secondary_nav_item);
}
}
// Append action name if we're on a member component sub-page.
if (!empty($secondary_nav_item->name) && !empty($bp->canonical_stack['action'])) {
$component_subnav_name = $secondary_nav_item->name;
}
// If on the user profile's landing page, just use the fullname.
if (bp_is_current_component($bp->default_component) && bp_get_requested_url() === bp_displayed_user_domain()) {
$bp_title_parts[] = $displayed_user_name;
// Use component name on member pages.
} else {
$bp_title_parts = array_merge($bp_title_parts, array_map('strip_tags', array($displayed_user_name, $component_name)));
// If we have a subnav name, add it separately for localization.
if (!empty($component_subnav_name)) {
$bp_title_parts[] = strip_tags($component_subnav_name);
}
}
// A single item from a component other than Members.
} elseif (bp_is_single_item()) {
$component_id = bp_current_component();
if (!empty($bp->{$component_id}->nav)) {
$secondary_nav_item = $bp->{$component_id}->nav->get_secondary(array('parent_slug' => bp_current_item(), 'slug' => bp_current_action()), false);
if ($secondary_nav_item) {
$secondary_nav_item = reset($secondary_nav_item);
}
}
$single_item_subnav = '';
if (!empty($secondary_nav_item->name)) {
$single_item_subnav = $secondary_nav_item->name;
}
$bp_title_parts = array($bp->bp_options_title, $single_item_subnav);
// An index or directory.
} elseif (bp_is_directory()) {
$current_component = bp_current_component();
// No current component (when does this happen?).
$bp_title_parts = array(_x('Directory', 'component directory title', 'buddypress'));
if (!empty($current_component)) {
$bp_title_parts = array(bp_get_directory_title($current_component));
}
// Sign up page.
} elseif (bp_is_register_page()) {
$bp_title_parts = array(__('Create an Account', 'buddypress'));
// Activation page.
} elseif (bp_is_activation_page()) {
$bp_title_parts = array(__('Activate Your Account', 'buddypress'));
// Group creation page.
} elseif (bp_is_group_create()) {
//.........这里部分代码省略.........
示例4: bp_verify_nonce_request
/**
* Makes sure the user requested an action from another page on this site.
*
* To avoid security exploits within the theme.
*
* @since BuddyPress (1.6)
*
* @uses do_action() Calls 'bp_verify_nonce_request' on $action.
* @param string $action Action nonce
* @param string $query_arg where to look for nonce in $_REQUEST
*/
function bp_verify_nonce_request($action = '', $query_arg = '_wpnonce')
{
// Get the home URL
$home_url = strtolower(home_url());
$requested_url = bp_get_requested_url();
// Check the nonce
$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
// Nonce check failed
if (empty($result) || empty($action) || strpos($requested_url, $home_url) !== 0) {
$result = false;
}
// Do extra things
do_action('bp_verify_nonce_request', $action, $result);
return $result;
}
示例5: _e
?>
</p>
<p>
<input type="checkbox" value="1" name="delete-confirm" /> <?php
_e('I understand the consequences and wish to continue deleting this folder.', 'bp-docs');
?>
</p>
<p>
<input type="submit" name="bp-docs-delete-folder-submit" class="button-primary" value="<?php
_e('Delete', 'bp-docs');
?>
" />
<a href="<?php
echo remove_query_arg('delete-folder', bp_get_requested_url());
?>
"><?php
_e('Cancel', 'bp-docs');
?>
</a>
<?php
wp_nonce_field('bp-docs-delete-folder-' . $folder_to_delete->ID);
?>
</p>
</form>
<?php
}
?>
示例6: widget
/**
* Display the login widget.
*
* @see WP_Widget::widget() for description of parameters.
*
* @param array $args Widget arguments.
* @param array $instance Widget settings, as saved by the user.
*/
public function widget($args, $instance)
{
$title = isset($instance['title']) ? $instance['title'] : '';
$title = apply_filters('widget_title', $title);
echo $args['before_widget'];
echo $args['before_title'] . esc_html($title) . $args['after_title'];
?>
<?php
if (is_user_logged_in()) {
?>
<?php
do_action('bp_before_login_widget_loggedin');
?>
<div class="bp-login-widget-user-avatar">
<a href="<?php
echo bp_loggedin_user_domain();
?>
">
<?php
bp_loggedin_user_avatar('type=thumb&width=50&height=50');
?>
</a>
</div>
<div class="bp-login-widget-user-links">
<div class="bp-login-widget-user-link"><?php
echo bp_core_get_userlink(bp_loggedin_user_id());
?>
</div>
<div class="bp-login-widget-user-logout"><a class="logout" href="<?php
echo wp_logout_url(bp_get_requested_url());
?>
"><?php
_e('Log Out', 'buddypress');
?>
</a></div>
</div>
<?php
do_action('bp_after_login_widget_loggedin');
?>
<?php
} else {
?>
<?php
do_action('bp_before_login_widget_loggedout');
?>
<form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php
echo esc_url(site_url('wp-login.php', 'login_post'));
?>
" method="post">
<label for="bp-login-widget-user-login"><?php
_e('Username', 'buddypress');
?>
</label>
<input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
<label for="bp-login-widget-user-pass"><?php
_e('Password', 'buddypress');
?>
</label>
<input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" />
<div class="forgetmenot"><label><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php
_e('Remember Me', 'buddypress');
?>
</label></div>
<input type="submit" name="wp-submit" id="bp-login-widget-submit" value="<?php
esc_attr_e('Log In', 'buddypress');
?>
" />
<?php
if (bp_get_signup_allowed()) {
?>
<span class="bp-login-widget-register-link"><?php
printf(__('<a href="%s" title="Register for a new account">Register</a>', 'buddypress'), bp_get_signup_page());
?>
</span>
<?php
}
?>
//.........这里部分代码省略.........
示例7: call_edit_screen_save
/**
* Check the nonce, and call the edit_screen_save() method.
*
* @since BuddyPress (1.8.0)
*/
public function call_edit_screen_save()
{
if (empty($_POST)) {
return;
}
// When DOING_AJAX, the POST global will be populated, but we
// should assume it's a save
if (defined('DOING_AJAX') && DOING_AJAX) {
return;
}
$this->check_nonce('edit');
// Detect whether the screen_save_callback is performing a
// redirect, so that we don't do one of our own
add_filter('wp_redirect', array($this, 'detect_post_save_redirect'));
// Call the extension's save routine
call_user_func($this->screens['edit']['screen_save_callback'], $this->group_id);
// Clean up detection filters
remove_filter('wp_redirect', array($this, 'detect_post_save_redirect'));
// Perform a redirect only if one has not already taken place
if (empty($this->post_save_redirect)) {
/**
* Filters the URL to redirect to after group edit screen save.
*
* Only runs if a redirect has not already occurred.
*
* @since BuddyPress (2.1.0)
*
* @param string $value URL to redirect to.
*/
$redirect_to = apply_filters('bp_group_extension_edit_screen_save_redirect', bp_get_requested_url());
bp_core_redirect($redirect_to);
die;
}
}
示例8: bp_get_activity_load_more_link
function bp_get_activity_load_more_link() {
global $activities_template;
$link = bp_get_requested_url();
$link = add_query_arg( $activities_template->pag_arg, $activities_template->pag_page + 1, $link );
/**
* Filters the Load More link URL.
*
* @since BuddyPress (2.1.0)
*
* @param string $link The Load More link URL.
*/
return apply_filters( 'bp_get_activity_load_more_link', $link );
}
示例9: bp_get_canonical_url
/**
* Returns the canonical URL of the current page
*
* @since BuddyPress (1.6)
* @uses apply_filters() Filter bp_get_canonical_url to modify return value
* @param array $args
* @return string
*/
function bp_get_canonical_url($args = array())
{
global $bp;
// For non-BP content, return the requested url, and let WP do the work
if (bp_is_blog_page()) {
return bp_get_requested_url();
}
$defaults = array('include_query_args' => false);
$r = wp_parse_args($args, $defaults);
extract($r);
if (empty($bp->canonical_stack['canonical_url'])) {
// Build the URL in the address bar
$requested_url = bp_get_requested_url();
// Stash query args
$url_stack = explode('?', $requested_url);
// Build the canonical URL out of the redirect stack
if (isset($bp->canonical_stack['base_url'])) {
$url_stack[0] = $bp->canonical_stack['base_url'];
}
if (isset($bp->canonical_stack['component'])) {
$url_stack[0] = trailingslashit($url_stack[0] . $bp->canonical_stack['component']);
}
if (isset($bp->canonical_stack['action'])) {
$url_stack[0] = trailingslashit($url_stack[0] . $bp->canonical_stack['action']);
}
if (!empty($bp->canonical_stack['action_variables'])) {
foreach ((array) $bp->canonical_stack['action_variables'] as $av) {
$url_stack[0] = trailingslashit($url_stack[0] . $av);
}
}
// Add trailing slash
$url_stack[0] = trailingslashit($url_stack[0]);
// Stash in the $bp global
$bp->canonical_stack['canonical_url'] = implode('?', $url_stack);
}
$canonical_url = $bp->canonical_stack['canonical_url'];
if (!$include_query_args) {
$canonical_url = array_pop(array_reverse(explode('?', $canonical_url)));
}
return apply_filters('bp_get_canonical_url', $canonical_url, $args);
}
示例10: start_el
/**
* @see Walker::start_el()
* @since 1.9
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $page Page data object.
* @param int $depth Depth of page. Used for padding.
* @param int $current_page Page ID.
* @param array $args
*/
public function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0)
{
$group_id = bp_docs_get_folder_group($page->ID);
$user_id = bp_docs_get_folder_user($page->ID);
$parent_selector = bp_docs_folder_selector(array('name' => 'folder-parent-' . $page->ID, 'id' => 'folder-parent-' . $page->ID, 'class' => 'folder-parent', 'selected' => $page->post_parent, 'group_id' => $group_id, 'echo' => false));
$type_selector_markup = '';
if (empty($page->post_parent)) {
$selected = null;
if (!empty($group_id)) {
$selected = $group_id;
} else {
if (!empty($user_id)) {
$selected = 'me';
} else {
$selected = 'global';
}
}
$type_selector = bp_docs_folder_type_selector(array('echo' => false, 'selected' => $selected, 'name' => 'folder-type-' . $page->ID, 'id' => 'folder-type-' . $page->ID));
$type_selector_markup = sprintf('<label for="folder-type-%d">%s</label> %s
<div style="clear:both;"></div>', intval($page->ID), __('Type', 'bp-docs'), $type_selector);
}
$output .= sprintf('
<li class="folder folder-edit-closed" data-folder-id="%d">
<div class="folder-info">
<h4>%s<span class="folder-toggle-edit"> <a href="#">%s</a></span><span class="folder-toggle-close"> <a href="#">%s</a></span></h4>
<div class="folder-details">
<form method="post" action="">
<label for="folder-name-%d">%s</label> <input id="folder-name-%d" name="folder-name-%d" value="%s" />
<div style="clear:both;"></div>
<label for="folder-parent-%d">%s</label> %s
<div style="clear:both;"></div>
%s
<input type="hidden" class="folder-id" name="folder-id" value="%d" />
%s
<input type="submit" value="%s" class="primary-button" /> <a class="folder-delete" href="%s">%s</a>
</form>
</div>
</div>', intval($page->ID), esc_html($page->post_title), __('Edit', 'bp-docs'), __('Close', 'bp-docs'), intval($page->ID), __('Name', 'bp-docs'), intval($page->ID), intval($page->ID), esc_attr($page->post_title), intval($page->ID), __('Parent', 'bp-docs'), $parent_selector, $type_selector_markup, intval($page->ID), wp_nonce_field('bp-docs-edit-folder-' . $page->ID, 'bp-docs-edit-folder-nonce-' . $page->ID, false, false), __('Save Changes', 'bp-docs'), add_query_arg('delete-folder', $page->ID, bp_get_requested_url()), __('Delete', 'bp-docs'));
}
示例11: bp_docs_get_folders
<?php
$folders = bp_docs_get_folders('display=flat');
$walker = new BP_Docs_Folder_Walker();
?>
<?php
$f = $walker->walk($folders, 10, array('foo' => 'bar'));
?>
<?php
if (bp_docs_current_user_can('manage_folders')) {
?>
<a id="manage-folders-link" href="<?php
echo add_query_arg('view', 'manage', remove_query_arg('view', bp_get_requested_url()));
?>
"><?php
_e('Manage Folders', 'bp-docs');
?>
</a>
<?php
}
?>
<div style="clear:both"></div>
<ul class="docs-folder-tree">
<?php
echo $f;
?>
</ul>
示例12: bp_get_activity_load_more_link
/**
* Get the URL for the Load More link
*
* @since BuddyPress (2.1.0)
*/
function bp_get_activity_load_more_link()
{
global $activities_template;
$url = bp_get_requested_url();
$link = add_query_arg($activities_template->pag_arg, $activities_template->pag_page + 1, $url);
/**
* Filters the Load More link URL.
*
* @since BuddyPress (2.1.0)
*
* @param string $link The "Load More" link URL with appropriate query args
* @param string $url The original URL
* @param object $activities_template The activity template loop global
*/
return apply_filters('bp_get_activity_load_more_link', $link, $url, $activities_template);
}
示例13: bp_get_activity_load_more_link
function bp_get_activity_load_more_link()
{
global $activities_template;
$link = bp_get_requested_url();
$link = add_query_arg($activities_template->pag_arg, $activities_template->pag_page + 1, $link);
return apply_filters('bp_get_activity_load_more_link', $link);
}
示例14: set_permalink
/**
* Set permalink for oEmbed link discovery.
*
* This method will be called on the page we want to oEmbed. In most cases,
* you will not need to override this method. However, if you need to, do
* override in your extended class.
*
* @since 2.6.0
*/
protected function set_permalink()
{
$url = bp_get_requested_url();
// Remove querystring from bp_get_requested_url().
if (false !== strpos(bp_get_requested_url(), '?')) {
$url = substr(bp_get_requested_url(), 0, strpos(bp_get_requested_url(), '?'));
}
return $url;
}
示例15: widget
/**
* Display the login widget.
*
* @see WP_Widget::widget() for description of parameters.
*
* @param array $args Widget arguments.
* @param array $instance Widget settings, as saved by the user.
*/
public function widget($args, $instance)
{
$title = isset($instance['title']) ? $instance['title'] : '';
/**
* Filters the title of the Login widget.
*
* @since 1.9.0
* @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
*
* @param string $title The widget title.
* @param array $instance The settings for the particular instance of the widget.
* @param string $id_base Root ID for all widgets of this type.
*/
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $args['before_widget'];
echo $args['before_title'] . esc_html($title) . $args['after_title'];
?>
<?php
if (is_user_logged_in()) {
?>
<?php
/**
* Fires before the display of widget content if logged in.
*
* @since 1.9.0
*/
do_action('bp_before_login_widget_loggedin');
?>
<div class="bp-login-widget-user-avatar">
<a href="<?php
echo bp_loggedin_user_domain();
?>
">
<?php
bp_loggedin_user_avatar('type=thumb&width=50&height=50');
?>
</a>
</div>
<div class="bp-login-widget-user-links">
<div class="bp-login-widget-user-link"><?php
echo bp_core_get_userlink(bp_loggedin_user_id());
?>
</div>
<div class="bp-login-widget-user-logout"><a class="logout" href="<?php
echo wp_logout_url(bp_get_requested_url());
?>
"><?php
_e('Log Out', 'buddypress');
?>
</a></div>
</div>
<?php
/**
* Fires after the display of widget content if logged in.
*
* @since 1.9.0
*/
do_action('bp_after_login_widget_loggedin');
?>
<?php
} else {
?>
<?php
/**
* Fires before the display of widget content if logged out.
*
* @since 1.9.0
*/
do_action('bp_before_login_widget_loggedout');
?>
<form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php
echo esc_url(site_url('wp-login.php', 'login_post'));
?>
" method="post">
<label for="bp-login-widget-user-login"><?php
_e('Username', 'buddypress');
?>
</label>
<input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
<label for="bp-login-widget-user-pass"><?php
_e('Password', 'buddypress');
?>
</label>
//.........这里部分代码省略.........