/**
 * 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
0
/**
 * 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;
}
/**
 * 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()) {
        $bp_title_parts = array(__('Create a Group', 'buddypress'));
        // Blog creation page.
    } elseif (bp_is_create_blog()) {
        $bp_title_parts = array(__('Create a Site', 'buddypress'));
    }
    // Strip spans.
    $bp_title_parts = array_map('_bp_strip_spans_from_title', $bp_title_parts);
    // Sep on right, so reverse the order.
    if ('right' === $seplocation) {
        $bp_title_parts = array_reverse($bp_title_parts);
    }
    /**
     * Filter BuddyPress title parts before joining.
     *
     * @since 2.4.3
     *
     * @param array $bp_title_parts Current BuddyPress title parts.
     * @return array
     */
    return (array) apply_filters('bp_get_title_parts', $bp_title_parts);
}
/**
 * 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;
}
        ?>
		</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
0
    /**
     * 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 
            }
            ?>

			</form>

			<?php 
            do_action('bp_after_login_widget_loggedout');
            ?>

		<?php 
        }
        echo $args['after_widget'];
    }
 /**
  * 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;
     }
 }
	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 );
	}
/**
 * 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);
}
    /**
     * @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'));
    }
<?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
0
/**
 * 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
0
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);
}
 /**
  * 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
0
    /**
     * 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>
				<input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" <?php 
            bp_form_field_attributes('password');
            ?>
 />

				<div class="forgetmenot"><label for="bp-login-widget-rememberme"><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 
            }
            ?>

				<?php 
            /**
             * Fires inside the display of the login widget form.
             *
             * @since 2.4.0
             */
            do_action('bp_login_widget_form');
            ?>

			</form>

			<?php 
            /**
             * Fires after the display of widget content if logged out.
             *
             * @since 1.9.0
             */
            do_action('bp_after_login_widget_loggedout');
            ?>

		<?php 
        }
        echo $args['after_widget'];
    }
Пример #16
0
/**
 * Get the canonical URL of the current page.
 *
 * @since 1.6.0
 *
 * @uses apply_filters() Filter bp_get_canonical_url to modify return value.
 *
 * @param array $args {
 *     Optional array of arguments.
 *     @type bool $include_query_args Whether to include current URL arguments
 *                                    in the canonical URL returned from the function.
 * }
 * @return string Canonical URL for the current page.
 */
function bp_get_canonical_url($args = array())
{
    // For non-BP content, return the requested url, and let WP do the work.
    if (bp_is_blog_page()) {
        return bp_get_requested_url();
    }
    $bp = buddypress();
    $defaults = array('include_query_args' => false);
    $r = wp_parse_args($args, $defaults);
    extract($r);
    // Special case: when a BuddyPress directory (eg example.com/members)
    // is set to be the front page, ensure that the current canonical URL
    // is the home page URL.
    if ('page' == get_option('show_on_front') && ($page_on_front = (int) get_option('page_on_front'))) {
        $front_page_component = array_search($page_on_front, bp_core_get_directory_page_ids());
        // If requesting the front page component directory, canonical
        // URL is the front page. We detect whether we're detecting a
        // component *directory* by checking that bp_current_action()
        // is empty - ie, this not a single item or a feed.
        if (false !== $front_page_component && bp_is_current_component($front_page_component) && !bp_current_action()) {
            $bp->canonical_stack['canonical_url'] = trailingslashit(bp_get_root_domain());
            // Except when the front page is set to the registration page
            // and the current user is logged in. In this case we send to
            // the members directory to avoid redirect loops.
        } elseif (bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in()) {
            /**
             * Filters the logged in register page redirect URL.
             *
             * @since 1.5.1
             *
             * @param string $value URL to redirect logged in members to.
             */
            $bp->canonical_stack['canonical_url'] = apply_filters('bp_loggedin_register_page_redirect_to', bp_get_members_directory_permalink());
        }
    }
    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_reverse(explode('?', $canonical_url));
        $canonical_url = array_pop($canonical_url);
    }
    /**
     * Filters the canonical url of the current page.
     *
     * @since 1.6.0
     *
     * @param string $canonical_url Canonical URL of the current page.
     * @param array  $args          Array of arguments to help determine canonical URL.
     */
    return apply_filters('bp_get_canonical_url', $canonical_url, $args);
}
Пример #17
0
    function widget($args, $instance)
    {
        extract($args);
        global $user_ID;
        $title = apply_filters('widget_title', empty($instance['title']) ? 'Entrar' : $instance['title']);
        if (empty($user_ID)) {
            echo $before_widget . $before_title . $title . $after_title;
            ?>
        <form name="loginform" id="loginform" action="<?php 
            print wp_login_url($_SERVER['REQUEST_URI']);
            ?>
" method="post">
            <fieldset>
                <label for="userLogin" class="login">Entrar:</label>
                <div class="formfield">
                    <div class="login inputDefault">
                    	<input type="text" name="log" id="userLogin" placeholder="Nome de usuário" tabindex="10" /></div>
                    <div class="pw inputDefault"><input type="password" name="pwd" class="userPass" placeholder="Senha" tabindex="20" /></div>
                    <div class="clearfix"></div>
                    <div class="forever">
                        <a  href="<?php 
            print wp_lostpassword_url();
            ?>
" title="Esqueci minha senha">Recuperar senha</a>
                        <div class="clearfix"></div>
                        <a href="<?php 
            print get_bloginfo('url');
            ?>
/cadastro" title="Esqueci minha senha">Não sou cadastrado</a>
                    </div>
                    <div class="clearfix"></div>
                    
                    <input name="submit" type="submit" id="submit" class="userSubmit submitDefault submit" value="Entrar">
                </div>
            </fieldset>
        </form>
        <?php 
            echo $after_widget;
            $before_widget_ = strstr('#', $before_widget);
            $before_pos = strpos('"', $before_widget_);
            $before_widget_ = substr($before_widget_, 0, $before_pos - 1);
        } else {
            echo $before_widget . $before_title . 'Minha conta' . $after_title;
            global $bp;
            ?>
	        <div class="panel">
		        <div class="bp-login-widget-user-link">Olá <?php 
            echo bp_core_get_userlink(bp_loggedin_user_id());
            ?>
</div>
		        <div class="clearfix"></div>
		        
		        <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-logout"><a class="logout" href="<?php 
            echo wp_logout_url(bp_get_requested_url());
            ?>
"><?php 
            _e('Log Out', 'buddypress');
            ?>
</a></div>
				</div>
			</div>

	        <?php 
            echo $after_widget;
        }
    }
Пример #18
0
 function get_share_link($network, $media_url = '', $i = 0, $post_link = '', $post_title = '')
 {
     if ('' !== $network) {
         $monarch_options = $this->monarch_options;
         if (isset($monarch_options['general_main_reset_postdata']) && true == $monarch_options['general_main_reset_postdata']) {
             wp_reset_postdata();
         }
         $link = '';
         if ('' !== $post_link) {
             $permalink = rawurlencode($post_link);
         } else {
             $permalink = class_exists('WooCommerce') && is_checkout() || is_front_page() ? rawurlencode(get_bloginfo('url')) : rawurlencode(get_permalink());
             if (class_exists('BuddyPress') && is_buddypress()) {
                 $permalink = rawurlencode(bp_get_requested_url());
             }
         }
         if ('' !== $post_title) {
             $title = rawurlencode(wp_strip_all_tags(html_entity_decode($post_title, ENT_QUOTES, 'UTF-8')));
         } else {
             $title = class_exists('WooCommerce') && is_checkout() || is_front_page() ? rawurlencode(wp_strip_all_tags(html_entity_decode(get_bloginfo('name'), ENT_QUOTES, 'UTF-8'))) : rawurlencode(wp_strip_all_tags(html_entity_decode(get_the_title(), ENT_QUOTES, 'UTF-8')));
         }
         switch ($network) {
             case 'facebook':
                 $link = sprintf('http://www.facebook.com/sharer.php?u=%1$s&t=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'twitter':
                 $link = sprintf('http://twitter.com/share?text=%2$s&url=%1$s&via=%3$s', esc_attr($permalink), esc_attr($title), !empty($this->monarch_options['sharing_networks_networks_sorting']['username'][$i]) ? $this->monarch_options['sharing_networks_networks_sorting']['username'][$i] : '');
                 break;
             case 'googleplus':
                 $link = sprintf('https://plus.google.com/share?url=%1$s&t=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'pinterest':
                 $link = '' !== $media_url ? sprintf('http://www.pinterest.com/pin/create/button/?url=%1$s&media=%2$s&description=%3$s', esc_attr($permalink), urlencode($media_url), esc_attr($title)) : '#';
                 break;
             case 'stumbleupon':
                 $link = sprintf('http://www.stumbleupon.com/badge?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'tumblr':
                 $link = sprintf('https://www.tumblr.com/share?v=3&u=%1$s&t=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'blogger':
                 $link = sprintf('https://www.blogger.com/blog_this.pyra?t&u=%1$s&n=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'myspace':
                 $link = sprintf('https://myspace.com/post?u=%1$s', esc_attr($permalink));
                 break;
             case 'delicious':
                 $link = sprintf('https://delicious.com/post?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'amazon':
                 $link = sprintf('http://www.amazon.com/gp/wishlist/static-add?u=%1$s&t=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'printfriendly':
                 $link = sprintf('http://www.printfriendly.com/print?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'yahoomail':
                 $link = sprintf('http://compose.mail.yahoo.com/?body=%1$s', esc_attr($permalink));
                 break;
             case 'gmail':
                 $link = sprintf('https://mail.google.com/mail/u/0/?view=cm&fs=1&su=%2$s&body=%1$s&ui=2&tf=1', esc_attr($permalink), esc_attr($title));
                 break;
             case 'aol':
                 $link = sprintf('http://webmail.aol.com/Mail/ComposeMessage.aspx?subject=%2$s&body=%1$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'newsvine':
                 $link = sprintf('http://www.newsvine.com/_tools/seed&save?u=%1$s&h=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'hackernews':
                 $link = sprintf('https://news.ycombinator.com/submitlink?u=%1$s&t=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'evernote':
                 $link = sprintf('http://www.evernote.com/clip.action?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'digg':
                 $link = sprintf('http://digg.com/submit?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'livejournal':
                 $link = sprintf('http://www.livejournal.com/update.bml?subject=%2$s&event=%1$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'friendfeed':
                 $link = sprintf('http://friendfeed.com/?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'buffer':
                 $link = sprintf('https://bufferapp.com/add?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'reddit':
                 $link = sprintf('http://www.reddit.com/submit?url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
             case 'vkontakte':
                 $link = sprintf('http://vk.com/share.php?url=%1$s', esc_attr($permalink));
                 break;
             case 'linkedin':
                 $link = sprintf('http://www.linkedin.com/shareArticle?mini=true&url=%1$s&title=%2$s', esc_attr($permalink), esc_attr($title));
                 break;
         }
         return $link;
     }
 }