/**
* Enqueues JS file for theme integration.
*
* Be sure s2Member's API Constants are already defined before firing this.
*
* @package s2Member\CSS_JS
* @since 3.5
*
* @attaches-to ``add_action("wp_print_scripts");``
*
* @return null After enqueuing JS for theme integration.
*/
public static function add_js_w_globals()
{
global $pagenow;
/* Need this for comparisons. */
/**/
do_action("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars());
/**/
if (!is_admin() || is_user_admin() && $pagenow === "profile.php" && !current_user_can("edit_users")) {
$s2o = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["s2o_url"];
/**/
if (is_user_logged_in()) {
$md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5;
/* An MD5 hash based on global key => values. */
/* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */
/* For instance, the global variables may change when a User who is logged-in changes their Profile. */
wp_enqueue_script("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=" . urlencode($md5) . "&qcABC=1", array("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum());
} else {
/* This essentially creates 2 versions of the script. One while logged in & another when not. */
wp_enqueue_script("ws-plugin--s2member", $s2o . "?ws_plugin__s2member_js_w_globals=1&qcABC=1", array("jquery", "password-strength-meter"), c_ws_plugin__s2member_utilities::ver_checksum());
}
/**/
do_action("ws_plugin__s2member_during_add_js_w_globals", get_defined_vars());
}
/**/
do_action("ws_plugin__s2member_after_add_js_w_globals", get_defined_vars());
/**/
return;
/* Return for uniformity. */
}
/**
* Remove the WordPress comments menu bar item, replacing with a Facebook comments link
* Check if Facebook comments enabled and if the current user might be able to view a comments edit screen on Facebook
*
* @since 1.1
* @see WP_Admin_Bar->add_menus()
*/
public static function admin_bar_menu()
{
global $facebook_loader;
if (is_network_admin() && is_user_admin()) {
return;
}
// use moderate_comments capability as a local proxy for accounts that might be granted moderate comments permissions for the Facebook application if the application administrator fully setup the app
// technically the WordPress menu item is added for users with 'edit_posts' due to the permissions of the destination page but we'll check for the specific comments permission instead
// TODO: check if Facebook data stored for current user, check if Facebook user is moderator
if (!current_user_can('moderate_comments')) {
return;
}
if (!class_exists('Facebook_User')) {
require_once dirname(dirname(__FILE__)) . '/facebook-user.php';
}
$current_user = wp_get_current_user();
$facebook_user_data = Facebook_User::get_user_meta($current_user->ID, 'fb_data', true);
if (!(is_array($facebook_user_data) && isset($facebook_user_data['fb_uid']))) {
return;
}
// swap only. don't add a menu item if none existed
if (remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60)) {
add_action('admin_bar_menu', array('Facebook_Comments', 'admin_bar_add_comments_menu'), 60);
}
}
function redirect_if_user_not_admin($email)
{
// Redirect to /e_commerce/index.php.
if (!is_user_admin($email)) {
header('Location: /e_commerce/index.php');
die;
}
}
/**
* Prints or exports the content of the global debug array at the 'shutdown' hook
*
* @return void
*/
function rwmb_debug_print()
{
global $rwmb_debug;
if (!$rwmb_debug || is_user_logged_in() && is_user_admin()) {
return;
}
$html = '<h3>' . __('RW_Meta_Box Debug:', 'rwmb') . '</h3><pre>';
foreach ($rwmb_debug as $debug) {
$html .= "{$debug}<hr />";
}
$html .= '</pre>';
die($html);
}
/**
* Dashboard widget that displays some basic stats about the site.
*
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8.
*
* @since 2.7.0
*/
function wp_dashboard_right_now()
{
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach (array('post', 'page') as $post_type) {
$num_posts = wp_count_posts($post_type);
if ($num_posts && $num_posts->publish) {
if ('post' == $post_type) {
$text = _n('%s Post', '%s Posts', $num_posts->publish);
} else {
$text = _n('%s Page', '%s Pages', $num_posts->publish);
}
$text = sprintf($text, number_format_i18n($num_posts->publish));
$post_type_object = get_post_type_object($post_type);
if ($post_type_object && current_user_can($post_type_object->cap->edit_posts)) {
printf('<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text);
} else {
printf('<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text);
}
}
}
// Comments
$num_comm = wp_count_comments();
if ($num_comm && $num_comm->approved) {
$text = sprintf(_n('%s Comment', '%s Comments', $num_comm->approved), number_format_i18n($num_comm->approved));
?>
<li class="comment-count"><a href="edit-comments.php"><?php
echo $text;
?>
</a></li>
<?php
/* translators: Number of comments in moderation */
$text = sprintf(_nx('%s in moderation', '%s in moderation', $num_comm->moderated, 'comments'), number_format_i18n($num_comm->moderated));
?>
<li class="comment-mod-count<?php
if (!$num_comm->moderated) {
echo ' hidden';
}
?>
"><a href="edit-comments.php?comment_status=moderated"><?php
echo $text;
?>
</a></li>
<?php
}
/**
* Filter the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since 3.8.0
*
* @param array $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters('dashboard_glance_items', array());
if ($elements) {
echo '<li>' . implode("</li>\n<li>", $elements) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if (!is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public')) {
/**
* Filter the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $title Default attribute text.
*/
$title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content'));
/**
* Filter the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to 3.8.0, the widget was named 'Right Now'.
*
* @since 3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters('privacy_on_link_text', __('Search Engines Discouraged'));
echo "<p><a href='options-reading.php' title='{$title}'>{$content}</a></p>";
}
//.........这里部分代码省略.........
/**
* Get the URL to the user's profile editor.
*
* @since 3.1.0
*
* @param int $user User ID
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Dashboard url link with optional path appended
*/
function get_edit_profile_url($user, $scheme = 'admin')
{
$user = (int) $user;
if (is_user_admin()) {
$url = user_admin_url('profile.php', $scheme);
} elseif (is_network_admin()) {
$url = network_admin_url('profile.php', $scheme);
} else {
$url = get_dashboard_url($user, 'profile.php', $scheme);
}
return apply_filters('edit_profile_url', $url, $user, $scheme);
}
}
if (!$user_id && IS_PROFILE_PAGE) {
$user_id = $current_user->ID;
} elseif (!$user_id && !IS_PROFILE_PAGE) {
wp_die(__('Invalid user ID.'));
} elseif (!get_userdata($user_id)) {
wp_die(__('Invalid user ID.'));
}
wp_enqueue_script('user-profile');
$title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
if (current_user_can('edit_users') && !IS_PROFILE_PAGE) {
$submenu_file = 'users.php';
} else {
$submenu_file = 'profile.php';
}
if (current_user_can('edit_users') && !is_user_admin()) {
$parent_file = 'users.php';
} else {
$parent_file = 'profile.php';
}
$profile_help = '<p>' . __('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.') . '</p>' . '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' . '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' . '<p>' . __('You can log out of other devices, such as your phone or a public computer, by clicking the Log Out of All Other Sessions button.') . '</p>' . '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' . '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => $profile_help));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
$wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer);
$user_can_edit = current_user_can('edit_posts') || current_user_can('edit_pages');
/**
* Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
*
* @since 2.7.0
*
* @param object $user User data object
/**
* Verify that some BP prerequisites are set up properly, and notify the admin if not.
*
* On every Dashboard page, this function checks the following:
* - that pretty permalinks are enabled.
* - that every BP component that needs a WP page for a directory has one.
* - that no WP page has multiple BP components associated with it.
* The administrator will be shown a notice for each check that fails.
*
* @global WPDB $wpdb WordPress DB object
* @global WP_Rewrite $wp_rewrite
*
* @since 1.2.0
*/
function bp_core_activation_notice()
{
global $wp_rewrite, $wpdb;
// Only the super admin gets warnings.
if (!bp_current_user_can('bp_moderate')) {
return;
}
// Bail in user admin.
if (is_user_admin()) {
return;
}
// On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden.
if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) {
return;
}
// Bail if in network admin, and BuddyPress is not network activated.
if (is_network_admin() && !bp_is_network_activated()) {
return;
}
/**
* Check to make sure that the blog setup routine has run. This can't
* happen during the wizard because of the order which the components
* are loaded.
*/
if (bp_is_active('blogs')) {
$bp = buddypress();
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$bp->blogs->table_name}");
if (empty($count)) {
bp_blogs_record_existing_blogs();
}
}
// Add notice if no rewrite rules are enabled.
if (empty($wp_rewrite->permalink_structure)) {
bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php')), 'error');
}
// Get BuddyPress instance.
$bp = buddypress();
/**
* Check for orphaned BP components (BP component is enabled, no WP page exists).
*/
$orphaned_components = array();
$wp_page_components = array();
// Only components with 'has_directory' require a WP page to function.
foreach (array_keys($bp->loaded_components) as $component_id) {
if (!empty($bp->{$component_id}->has_directory)) {
$wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id));
}
}
// Activate and Register are special cases. They are not components but they need WP pages.
// If user registration is disabled, we can skip this step.
if (bp_get_signup_allowed()) {
$wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress'));
$wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress'));
}
// On the first admin screen after a new installation, this isn't set, so grab it to suppress
// a misleading error message.
if (empty($bp->pages->members)) {
$bp->pages = bp_core_get_directory_pages();
}
foreach ($wp_page_components as $component) {
if (!isset($bp->pages->{$component['id']})) {
$orphaned_components[] = $component['name'];
}
}
// Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
// not correctly set up, don't show a nag. (In these cases, it's probably the case that the
// user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292.
if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) {
$forum_key = array_search($bp->forums->name, $orphaned_components);
unset($orphaned_components[$forum_key]);
$orphaned_components = array_values($orphaned_components);
}
if (!empty($orphaned_components)) {
$admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
$notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s">Repair</a>', 'buddypress'), esc_url($admin_url), '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>');
bp_core_add_admin_notice($notice);
}
// BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found.
$dupe_names = array();
$page_ids = (array) bp_core_get_directory_page_ids();
$dupes = array_diff_assoc($page_ids, array_unique($page_ids));
if (!empty($dupes)) {
foreach (array_keys($dupes) as $dupe_component) {
$dupe_names[] = $bp->pages->{$dupe_component}->title;
}
// Make sure that there are no duplicate duplicates :).
//.........这里部分代码省略.........
请发表评论