* * @param array $args Arguments for get_posts() used to fetch a post object. * @param string $email_type Unique identifier for a particular type of email. */ $args = apply_filters( 'bp_get_email_args', $args, $email_type ); $post = get_posts( $args ); if ( ! $post ) { if ( $switched ) { restore_current_blog(); } return new WP_Error( 'missing_email', __FUNCTION__, array( $email_type, $args ) ); } /** * Filters arguments used to create the BP_Email object. * * @since 2.5.0 * * @param WP_Post $post Post object containing the contents of the email. * @param string $email_type Unique identifier for a particular type of email. * @param array $args Arguments used with get_posts() to fetch a post object. * @param WP_Post $post All posts retrieved by get_posts( $args ). May only contain $post. */ $post = apply_filters( 'bp_get_email_post', $post[0], $email_type, $args, $post ); $email = new BP_Email( $email_type ); /* * Set some email properties for convenience. */ // Post object (sets subject, content, template). $email->set_post_object( $post ); /** * Filters the BP_Email object returned by bp_get_email(). * * @since 2.5.0 * * @param BP_Email $email An object representing a single email, ready for mailing. * @param string $email_type Unique identifier for a particular type of email. * @param array $args Arguments used with get_posts() to fetch a post object. * @param WP_Post $post All posts retrieved by get_posts( $args ). May only contain $post. */ $retval = apply_filters( 'bp_get_email', $email, $email_type, $args, $post ); if ( $switched ) { restore_current_blog(); } return $retval; } /** * Send email, similar to WordPress' wp_mail(). * * A true return value does not automatically mean that the user received the * email successfully. It just only means that the method used was able to * process the request without any errors. * * @since 2.5.0 * * @param string $email_type Type of email being sent. * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object, * or an array containing the address and name. * @param array $args { * Optional. Array of extra parameters. * * @type array $tokens Optional. Associative arrays of string replacements for the email. * } * @return bool|WP_Error True if the email was sent successfully. Otherwise, a WP_Error object * describing why the email failed to send. The contents will vary based * on the email delivery class you are using. */ function bp_send_email( $email_type, $to, $args = array() ) { static $is_default_wpmail = null; static $wp_html_emails = null; // Has wp_mail() been filtered to send HTML emails? if ( is_null( $wp_html_emails ) ) { /** This filter is documented in wp-includes/pluggable.php */ $wp_html_emails = apply_filters( 'wp_mail_content_type', 'text/plain' ) === 'text/html'; } // Since wp_mail() is a pluggable function, has it been re-defined by another plugin? if ( is_null( $is_default_wpmail ) ) { try { $mirror = new ReflectionFunction( 'wp_mail' ); $is_default_wpmail = substr( $mirror->getFileName(), -strlen( 'pluggable.php' ) ) === 'pluggable.php'; } catch ( Exception $e ) { $is_default_wpmail = true; } } $args = bp_parse_args( $args, array( 'tokens' => array(), ), 'send_email' ); /* * Build the email. */ $email = bp_get_email( $email_type ); if ( is_wp_error( $email ) ) { return $email; } // From, subject, content are set automatically. if ( 'settings-verify-email-change' === $email_type && isset( $args['tokens']['displayname'] ) ) { $email->set_to( $to, $args['tokens']['displayname'] ); // Emails sent to nonmembers will have no recipient.name populated. } else if ( 'bp-members-invitation' === $email_type ) { $email->set_to( $to, $to ); } else { $email->set_to( $to ); } $email->set_tokens( $args['tokens'] ); /** * Gives access to an email before it is sent. * * @since 2.8.0 * * @param BP_Email $email The email (object) about to be sent. * @param string $email_type Type of email being sent. * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object, * or an array containing the address and name. * @param array $args { * Optional. Array of extra parameters. * * @type array $tokens Optional. Associative arrays of string replacements for the email. * } */ do_action_ref_array( 'bp_send_email', array( &$email, $email_type, $to, $args ) ); $status = $email->validate(); if ( is_wp_error( $status ) ) { return $status; } /** * Filter this to skip BP's email handling and instead send everything to wp_mail(). * * This is done if wp_mail_content_type() has been configured for HTML, * or if wp_mail() has been redeclared (it's a pluggable function). * * @since 2.5.0 * * @param bool $use_wp_mail Whether to fallback to the regular wp_mail() function or not. */ $must_use_wpmail = apply_filters( 'bp_email_use_wp_mail', $wp_html_emails || ! $is_default_wpmail ); if ( $must_use_wpmail ) { $to = $email->get( 'to' ); return wp_mail( array_shift( $to )->get_address(), $email->get( 'subject', 'replace-tokens' ), $email->get( 'content_plaintext', 'replace-tokens' ) ); } /* * Send the email. */ /** * Filter the email delivery class. * * Defaults to BP_PHPMailer, which as you can guess, implements PHPMailer. * * @since 2.5.0 * * @param string $deliver_class The email delivery class name. * @param string $email_type Type of email being sent. * @param array|string $to Array or comma-separated list of email addresses to the email to. * @param array $args { * Optional. Array of extra parameters. * * @type array $tokens Optional. Associative arrays of string replacements for the email. * } */ $delivery_class = apply_filters( 'bp_send_email_delivery_class', 'BP_PHPMailer', $email_type, $to, $args ); if ( ! class_exists( $delivery_class ) ) { return new WP_Error( 'missing_class', 'No class found by that name', $delivery_class ); } $delivery = new $delivery_class(); $status = $delivery->bp_email( $email ); if ( is_wp_error( $status ) ) { /** * Fires after BuddyPress has tried - and failed - to send an email. * * @since 2.5.0 * * @param WP_Error $status A WP_Error object describing why the email failed to send. The contents * will vary based on the email delivery class you are using. * @param BP_Email $email The email we tried to send. */ do_action( 'bp_send_email_failure', $status, $email ); } else { /** * Fires after BuddyPress has successfully sent an email. * * @since 2.5.0 * * @param bool $status True if the email was sent successfully. * @param BP_Email $email The email sent. */ do_action( 'bp_send_email_success', $status, $email ); } return $status; } /** * Return email appearance settings. * * @since 2.5.0 * @since 3.0.0 Added "direction" parameter for LTR/RTL email support, and * "link_text_color" to override that in the email body. * * @return array */ function bp_email_get_appearance_settings() { $footer_text = array( sprintf( /* translators: 1. Copyright year, 2. Site name */ _x( '© %1$s %2$s', 'copyright text for email footers', 'buddypress' ), date_i18n( 'Y' ), bp_get_option( 'blogname' ) ) ); $privacy_policy_url = get_privacy_policy_url(); if ( $privacy_policy_url ) { $footer_text[] = sprintf( '%s', esc_url( $privacy_policy_url ), esc_html__( 'Privacy Policy', 'buddypress' ) ); } $default_args = array( 'body_bg' => '#FFFFFF', 'body_text_color' => '#555555', 'body_text_size' => 15, 'email_bg' => '#F7F3F0', 'footer_bg' => '#F7F3F0', 'footer_text_color' => '#525252', 'footer_text_size' => 12, 'header_bg' => '#F7F3F0', 'highlight_color' => '#D84800', 'header_text_color' => '#000000', 'header_text_size' => 30, 'direction' => is_rtl() ? 'right' : 'left', 'footer_text' => implode( ' · ', $footer_text ), ); $options = bp_parse_args( bp_get_option( 'bp_email_options', array() ), $default_args, 'email_appearance_settings' ); // Link text colour defaults to the highlight colour. if ( ! isset( $options['link_text_color'] ) ) { $options['link_text_color'] = $options['highlight_color']; } return $options; } /** * Get the paths to possible templates for the specified email object. * * @since 2.5.0 * * @param WP_Post $object Post to get email template for. * @return array */ function bp_email_get_template( WP_Post $object ) { $single = "single-{$object->post_type}"; /** * Filter the possible template paths for the specified email object. * * @since 2.5.0 * * @param array $value Array of possible template paths. * @param WP_Post $object WP_Post object. */ return apply_filters( 'bp_email_get_template', array( "assets/emails/{$single}-{$object->post_name}.php", "{$single}-{$object->post_name}.php", "{$single}.php", "assets/emails/{$single}.php", ), $object ); } /** * Replace all tokens in the input text with appropriate values. * * Intended for use with the email system introduced in BuddyPress 2.5.0. * * @since 2.5.0 * * @param string $text Text to replace tokens in. * @param array $tokens Token names and replacement values for the $text. * @return string */ function bp_core_replace_tokens_in_text( $text, $tokens ) { $unescaped = array(); $escaped = array(); foreach ( $tokens as $token => $value ) { if ( ! is_string( $value ) && is_callable( $value ) ) { $value = call_user_func( $value ); } // Tokens could be objects or arrays. if ( ! is_scalar( $value ) ) { continue; } $unescaped[ '{{{' . $token . '}}}' ] = $value; $escaped[ '{{' . $token . '}}' ] = esc_html( $value ); } $text = strtr( $text, $unescaped ); // Do first. $text = strtr( $text, $escaped ); /** * Filters text that has had tokens replaced. * * @since 2.5.0 * * @param string $text * @param array $tokens Token names and replacement values for the $text. */ return apply_filters( 'bp_core_replace_tokens_in_text', $text, $tokens ); } /** * Get a list of emails for populating the email post type. * * @since 2.5.1 * @since 10.0.0 Added members-membership-request and * members-membership-request-rejected email types. * * @return array */ function bp_email_get_schema() { /** * Filters the list of `bp_email_get_schema()` allowing anyone to add/remove emails. * * @since 7.0.0 * * @param array $emails The array of emails schema. */ return (array) apply_filters( 'bp_email_get_schema', array( 'core-user-activation' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Welcome!', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Welcome to {{site.name}}!\n\nVisit your profile, where you can tell us more about yourself, change your preferences, or make new connections, to get started.\n\nForgot your password? Don't worry, you can reset it with your email address from this page of our site", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Welcome to {{site.name}}!\n\nVisit your profile, where you can tell us more about yourself, change your preferences, or make new connections, to get started: {{{profile.url}}}\n\nForgot your password? Don't worry, you can reset it with your email address from this page of our site: {{{lostpassword.url}}}", 'buddypress' ), ), 'activity-comment' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] {{poster.name}} replied to one of your updates', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{poster.name}} replied to one of your updates:\n\n
"{{usermessage}}"
\n\nGo to the discussion to reply or catch up on the conversation.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{poster.name}} replied to one of your updates:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{thread.url}}}", 'buddypress' ), ), 'activity-comment-author' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] {{poster.name}} replied to one of your comments', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{poster.name}} replied to one of your comments:\n\n
"{{usermessage}}"
\n\nGo to the discussion to reply or catch up on the conversation.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{poster.name}} replied to one of your comments:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{thread.url}}}", 'buddypress' ), ), 'activity-at-message' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] {{poster.name}} mentioned you in a status update', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{poster.name}} mentioned you in a status update:\n\n
"{{usermessage}}"
\n\nGo to the discussion to reply or catch up on the conversation.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{poster.name}} mentioned you in a status update:\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{mentioned.url}}}", 'buddypress' ), ), 'groups-at-message' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] {{poster.name}} mentioned you in an update', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{poster.name}} mentioned you in the group \"{{group.name}}\":\n\n
"{{usermessage}}"
\n\nGo to the discussion to reply or catch up on the conversation.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{poster.name}} mentioned you in the group \"{{group.name}}\":\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{mentioned.url}}}", 'buddypress' ), ), 'core-user-registration' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Activate your account', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link and click on the Activate button:\n{{{activate.url}}}\n\nIf the 'Activation Key' field is empty, copy and paste the following into the field - {{key}}", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account, go to the following link and click on the 'Activate' button: {{{activate.url}}}\n\nIf the 'Activation Key' field is empty, copy and paste the following into the field - {{key}}", 'buddypress' ) ), 'core-user-registration-with-blog' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Activate {{{user-site.url}}}', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: {{{activate-site.url}}}.\n\nAfter you activate, you can visit your site at {{{user-site.url}}}.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Thanks for registering!\n\nTo complete the activation of your account and site, go to the following link: {{{activate-site.url}}}\n\nAfter you activate, you can visit your site at {{{user-site.url}}}.", 'buddypress' ), 'args' => array( 'multisite' => true, ), ), 'friends-request' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] New friendship request from {{initiator.name}}', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{initiator.name}} wants to add you as a friend.\n\nTo accept this request and manage all of your pending requests, visit: {{{friend-requests.url}}}", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{initiator.name}} wants to add you as a friend.\n\nTo accept this request and manage all of your pending requests, visit: {{{friend-requests.url}}}\n\nTo view {{initiator.name}}'s profile, visit: {{{initiator.url}}}", 'buddypress' ), ), 'friends-request-accepted' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] {{friend.name}} accepted your friendship request', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{friend.name}} accepted your friend request.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{friend.name}} accepted your friend request.\n\nTo learn more about them, visit their profile: {{{friendship.url}}}", 'buddypress' ), ), 'groups-details-updated' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Group details updated', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Group details for the group "{{group.name}}" were updated:\n
{{changed_text}}
", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Group details for the group \"{{group.name}}\" were updated:\n\n{{changed_text}}\n\nTo view the group, visit: {{{group.url}}}", 'buddypress' ), ), 'groups-invitation' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] You have an invitation to the group: "{{group.name}}"', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{inviter.name}} has invited you to join the group: "{{group.name}}".\n\n{{invite.message}}\n\nGo here to accept your invitation or visit the group to learn more.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{inviter.name}} has invited you to join the group: \"{{group.name}}\".\n\n{{invite.message}}\n\nTo accept your invitation, visit: {{{invites.url}}}\n\nTo learn more about the group, visit: {{{group.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ), ), 'groups-member-promoted' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] You have been promoted in the group: "{{group.name}}"', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "You have been promoted to {{promoted_to}} in the group "{{group.name}}".", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "You have been promoted to {{promoted_to}} in the group: \"{{group.name}}\".\n\nTo visit the group, go to: {{{group.url}}}", 'buddypress' ), ), 'groups-membership-request' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Membership request for group: {{group.name}}', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{requesting-user.name}} wants to join the group "{{group.name}}".\n {{request.message}}\n As you are an administrator of this group, you must either accept or reject the membership request.\n\nGo here to manage this and all other pending requests.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{requesting-user.name}} wants to join the group \"{{group.name}}\". As you are the administrator of this group, you must either accept or reject the membership request.\n\nTo manage this and all other pending requests, visit: {{{group-requests.url}}}\n\nTo view {{requesting-user.name}}'s profile, visit: {{{profile.url}}}", 'buddypress' ), ), 'messages-unread' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] New message from {{sender.name}}', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{sender.name}} sent you a new message: "{{usersubject}}"\n\n
"{{usermessage}}"
\n\nGo to the discussion to reply or catch up on the conversation.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{sender.name}} sent you a new message: \"{{usersubject}}\"\n\n\"{{usermessage}}\"\n\nGo to the discussion to reply or catch up on the conversation: {{{message.url}}}", 'buddypress' ), ), 'settings-verify-email-change' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Verify your new email address', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "You recently changed the email address associated with your account on {{site.name}} to {{user.email}}. If this is correct, go here to confirm the change.\n\nOtherwise, you can safely ignore and delete this email if you have changed your mind, or if you think you have received this email in error.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "You recently changed the email address associated with your account on {{site.name}} to {{user.email}}. If this is correct, go to the following link to confirm the change: {{{verify.url}}}\n\nOtherwise, you can safely ignore and delete this email if you have changed your mind, or if you think you have received this email in error.", 'buddypress' ), ), 'groups-membership-request-accepted' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" accepted', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Your membership request for the group "{{group.name}}" has been accepted.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Your membership request for the group \"{{group.name}}\" has been accepted.\n\nTo view the group, visit: {{{group.url}}}", 'buddypress' ), ), 'groups-membership-request-rejected' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" rejected', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Your membership request for the group "{{group.name}}" has been rejected.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Your membership request for the group \"{{group.name}}\" has been rejected.\n\nTo request membership again, visit: {{{group.url}}}", 'buddypress' ), ), 'groups-membership-request-accepted-by-admin' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" accepted', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "An administrator accepted an invitation to join "{{group.name}}" on your behalf.\n\nIf you disagree with this, you can leave the group at anytime visiting your groups memberships page.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "An administrator accepted an invitation to join \"{{group.name}}\" on your behalf.\n\nIf you disagree with this, you can leave the group at anytime visiting your groups memberships page: {{{leave-group.url}}}", 'buddypress' ), ), 'groups-membership-request-rejected-by-admin' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '[{{{site.name}}}] Membership request for group "{{group.name}}" rejected', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "An administrator rejected an invitation to join "{{group.name}}" on your behalf.\n\nIf you disagree with this, please contact the site administrator.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "An administrator rejected an invitation to join \"{{group.name}}\" on your behalf.\n\nIf you disagree with this, please contact the site administrator.", 'buddypress' ), ), 'bp-members-invitation' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '{{inviter.name}} has invited you to join {{site.name}}', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{inviter.name}} has invited you to join the site: "{{site.name}}".\n\n{{usermessage}}\n\nAccept your invitation or visit the site to learn more.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{inviter.name}} has invited you to join the site \"{{site.name}}\".\n\n{{usermessage}}\n\nTo accept your invitation, visit: {{{invite.accept_url}}}\n\nTo learn more about the site, visit: {{{site.url}}}.\nTo view {{inviter.name}}'s profile, visit: {{{inviter.url}}}", 'buddypress' ), ), 'members-membership-request' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( '{{requesting-user.user_login}} would like to join {{site.name}}', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "{{requesting-user.user_login}} would like to join the site: "{{site.name}}".\n\nManage the request.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "{{requesting-user.user_login}} would like to join the site \"{{site.name}}\".\n\nTo manage the request, visit: {{{manage.url}}}.", 'buddypress' ), ), 'members-membership-request-rejected' => array( /* translators: do not remove {} brackets or translate its contents. */ 'post_title' => __( 'Your request to join {{site.name}} has been declined', 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_content' => __( "Sorry, your request to join the site "{{site.name}}" has been declined.", 'buddypress' ), /* translators: do not remove {} brackets or translate its contents. */ 'post_excerpt' => __( "Sorry, your request to join the site \"{{site.name}}\" has been declined.", 'buddypress' ), ), ) ); } /** * Get a list of emails for populating email type taxonomy terms. * * @since 2.5.1 * @since 2.7.0 $field argument added. * * @param string $field Optional; defaults to "description" for backwards compatibility. Other values: "all". * @return array { * The array of email types and their schema. * * @type string $description The description of the action which causes this to trigger. * @type array $unsubscribe { * Replacing this with false indicates that a user cannot unsubscribe from this type. * * @type string $meta_key The meta_key used to toggle the email setting for this notification. * @type string $message The message shown when the user has successfully unsubscribed. * } */ function bp_email_get_type_schema( $field = 'description' ) { $activity_comment = array( 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_activity_new_reply', 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ), ), ); $activity_comment_author = array( 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_activity_new_reply', 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ), ), ); $activity_at_message = array( 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_activity_new_mention', 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ), ), ); $groups_at_message = array( 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_activity_new_mention', 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ), ), ); $core_user_registration = array( 'description' => __( 'Recipient has registered for an account.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => false, ); $core_user_registration_with_blog = array( 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => false, ); $friends_request = array( 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_friends_friendship_request', 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ), ), ); $friends_request_accepted = array( 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_friends_friendship_accepted', 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ), ), ); $groups_details_updated = array( 'description' => __( "A group's details were updated.", 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_groups_group_updated', 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ), ), ); $groups_invitation = array( 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_groups_invite', 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ), ), ); $groups_member_promoted = array( 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_groups_admin_promotion', 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ), ), ); $groups_membership_request = array( 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_groups_membership_request', 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ), ), ); $messages_unread = array( 'description' => __( 'Recipient has received a private message.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_messages_new_message', 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ), ), ); $settings_verify_email_change = array( 'description' => __( 'Recipient has changed their email address.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => false, ); $groups_membership_request_accepted = array( 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_membership_request_completed', 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), ), ); $groups_membership_request_rejected = array( 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_membership_request_completed', 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), ), ); $groups_membership_request_accepted_by_admin = array( 'description' => __( 'Recipient had requested to join a group, which was accepted by admin.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => false, ); $groups_membership_request_rejected_by_admin = array( 'description' => __( 'Recipient had requested to join a group, which was rejected by admin.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => false, ); $core_user_activation = array( 'description' => __( 'Recipient has successfully activated an account.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => false, ); $members_invitation = array( 'description' => __( 'A site member has sent a site invitation to the recipient.', 'buddypress' ), 'named_salutation' => false, 'unsubscribe' => array( 'meta_key' => 'notification_bp_members_invite', 'message' => __( 'You will no longer receive emails when you are invited to join this site.', 'buddypress' ), ), ); $members_membership_request = array( 'description' => __( 'Someone has requested membership on this site.', 'buddypress' ), 'named_salutation' => true, 'unsubscribe' => array( 'meta_key' => 'notification_members_membership_request', 'message' => __( 'You will no longer receive emails when people submit requests to join this site.', 'buddypress' ), ), ); $members_membership_request_rejected = array( 'description' => __( 'A site membership request has been rejected.', 'buddypress' ), 'named_salutation' => false, 'unsubscribe' => false, ); $types = array( 'activity-comment' => $activity_comment, 'activity-comment-author' => $activity_comment_author, 'activity-at-message' => $activity_at_message, 'groups-at-message' => $groups_at_message, 'core-user-registration' => $core_user_registration, 'core-user-registration-with-blog' => $core_user_registration_with_blog, 'friends-request' => $friends_request, 'friends-request-accepted' => $friends_request_accepted, 'groups-details-updated' => $groups_details_updated, 'groups-invitation' => $groups_invitation, 'groups-member-promoted' => $groups_member_promoted, 'groups-membership-request' => $groups_membership_request, 'messages-unread' => $messages_unread, 'settings-verify-email-change' => $settings_verify_email_change, 'groups-membership-request-accepted' => $groups_membership_request_accepted, 'groups-membership-request-rejected' => $groups_membership_request_rejected, 'core-user-activation' => $core_user_activation, 'bp-members-invitation' => $members_invitation, 'members-membership-request' => $members_membership_request, 'members-membership-request-rejected' => $members_membership_request_rejected, 'groups-membership-request-accepted-by-admin' => $groups_membership_request_accepted_by_admin, 'groups-membership-request-rejected-by-admin' => $groups_membership_request_rejected_by_admin, ); if ( $field !== 'all' ) { return wp_list_pluck( $types, $field ); } else { return $types; } } /** * Handles unsubscribing user from notification emails. * * @since 2.7.0 */ function bp_email_unsubscribe_handler() { $emails = bp_email_get_unsubscribe_type_schema(); $raw_email_type = ! empty( $_GET['nt'] ) ? $_GET['nt'] : ''; $raw_hash = ! empty( $_GET['nh'] ) ? $_GET['nh'] : ''; $raw_user_id = ! empty( $_GET['uid'] ) ? absint( $_GET['uid'] ) : 0; $raw_user_email = ! empty( $_GET['uem'] ) ? $_GET['uem'] : ''; $raw_member_id = ! empty( $_GET['mid'] ) ? absint( $_GET['mid'] ) : 0; $redirect_to = ''; $new_hash = ''; if ( ! empty( $raw_user_id ) ) { $new_hash = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_id}", bp_email_get_salt() ); } else if ( ! empty( $raw_user_email ) ) { $new_hash = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_email}", bp_email_get_salt() ); } // Check required values. if ( ( ! $raw_user_id && ! $raw_user_email ) || ! $raw_email_type || ! $raw_hash || ! array_key_exists( $raw_email_type, $emails ) ) { $redirect_to = wp_login_url(); $result_msg = __( 'Something has gone wrong.', 'buddypress' ); $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' ); // Check valid hash. } elseif ( ! hash_equals( $new_hash, $raw_hash ) ) { $redirect_to = wp_login_url(); $result_msg = __( 'Something has gone wrong.', 'buddypress' ); $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' ); // Don't let authenticated users unsubscribe other users' email notifications. } elseif ( is_user_logged_in() && get_current_user_id() !== $raw_user_id ) { $result_msg = __( 'Something has gone wrong.', 'buddypress' ); $unsub_msg = __( 'Please go to your notifications settings to unsubscribe from emails.', 'buddypress' ); if ( bp_is_active( 'settings' ) ) { $redirect_to = bp_members_get_user_url( get_current_user_id(), bp_members_get_path_chunks( array( bp_get_settings_slug(), 'notifications' ) ) ); } else { $redirect_to = bp_members_get_user_url( get_current_user_id() ); } // This is an unsubscribe request from a nonmember. } else if ( $raw_user_email ) { // Unsubscribe. if ( bp_user_has_opted_out( $raw_user_email ) ) { $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message']; $unsub_msg = __( 'You have already unsubscribed from all communication from this site.', 'buddypress' ); } else { $optout_args = array( 'email_address' => $raw_user_email, 'user_id' => $raw_member_id, 'email_type' => $raw_email_type, 'date_modified' => bp_core_current_time(), ); bp_add_optout( $optout_args ); $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message']; $unsub_msg = __( 'You have been unsubscribed.', 'buddypress' ); } // This is an unsubscribe request from a current member. } else { if ( bp_is_active( 'settings' ) ) { $redirect_to = bp_members_get_user_url( $raw_user_id, bp_members_get_path_chunks( array( bp_get_settings_slug(), 'notifications' ) ) ); } else { $redirect_to = bp_members_get_user_url( $raw_user_id ); } // Unsubscribe. $meta_key = $emails[ $raw_email_type ]['unsubscribe']['meta_key']; bp_update_user_meta( $raw_user_id, $meta_key, 'no' ); $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message']; $unsub_msg = __( 'You can change this or any other email notification preferences in your email settings.', 'buddypress' ); } if ( $raw_user_id && $redirect_to ) { $message = sprintf( '%1$s %3$s', $result_msg, esc_url( $redirect_to ), esc_html( $unsub_msg ) ); // Template notices are only displayed on BP pages. bp_core_add_message( $message ); bp_core_redirect( bp_members_get_user_url( $raw_user_id ) ); exit; } else { wp_die( sprintf( '%1$s %2$s', esc_html( $unsub_msg ), esc_html( $result_msg ) ), esc_html( $unsub_msg ), array( 'link_url' => esc_url( home_url() ), 'link_text' => esc_html__( 'Go to website\'s home page.', 'buddypress' ), ) ); } } /** * Creates unsubscribe link for notification emails. * * @since 2.7.0 * * @param string $redirect_to The URL to which the unsubscribe query string is appended. * @param array $args { * Used to build unsubscribe query string. * * @type string $notification_type Which notification type is being sent. * @type string $user_id The ID of the user to whom the notification is sent. * @type string $redirect_to Optional. The url to which the user will be redirected. Default is the activity directory. * @type string $email Optional. The email address of the user to whom the notification is sent. * } * @return string The unsubscribe link. */ function bp_email_get_unsubscribe_link( $args ) { $emails = bp_email_get_unsubscribe_type_schema(); if ( empty( $args['notification_type'] ) || ! array_key_exists( $args['notification_type'], $emails ) ) { return wp_login_url(); } $email_type = $args['notification_type']; $redirect_to = ! empty( $args['redirect_to'] ) ? $args['redirect_to'] : site_url(); $user_id = (int) $args['user_id']; // Bail out if the activity type is not un-unsubscribable. if ( empty( $emails[ $email_type ]['unsubscribe'] ) ) { return ''; } $link = ''; // Case where the recipient is a member of the site. if ( ! empty( $user_id ) ) { $link = add_query_arg( array( 'action' => 'unsubscribe', 'nh' => hash_hmac( 'sha1', "{$email_type}:{$user_id}", bp_email_get_salt() ), 'nt' => $args['notification_type'], 'uid' => $user_id, ), $redirect_to ); // Case where the recipient is not a member of the site. } else if ( ! empty( $args['email_address'] ) ) { $email_address = $args['email_address']; $member_id = (int) $args['member_id']; $link = add_query_arg( array( 'action' => 'unsubscribe', 'nh' => hash_hmac( 'sha1', "{$email_type}:{$email_address}", bp_email_get_salt() ), 'nt' => $args['notification_type'], 'mid' => $member_id, 'uem' => $email_address, ), $redirect_to ); } /** * Filters the unsubscribe link. * * @since 2.7.0 */ return apply_filters( 'bp_email_get_link', $link, $redirect_to, $args ); } /** * Get a persistent salt for email unsubscribe links. * * @since 2.7.0 * * @return string|null Returns null if value isn't set, otherwise string. */ function bp_email_get_salt() { return bp_get_option( 'bp-emails-unsubscribe-salt', null ); } /** * Get a list of emails for use in our unsubscribe functions. * * @since 2.8.0 * * @see https://buddypress.trac.wordpress.org/ticket/7431 * * @return array The array of email types and their schema. */ function bp_email_get_unsubscribe_type_schema() { $emails = bp_email_get_type_schema( 'all' ); /** * Filters the return of `bp_email_get_type_schema( 'all' )` for use with * our unsubscribe functionality. * * @since 2.8.0 * * @param array $emails The array of email types and their schema. */ return (array) apply_filters( 'bp_email_get_unsubscribe_type_schema', $emails ); } /** * Gets the BP Email type of a BP Email ID or object. * * @since 8.0.0 * * @param int|WP_Post $email Optional. BP Email ID or BP Email object. Defaults to global $post. * @return string The type of the BP Email object. */ function bp_email_get_type( $email = null ) { $email = get_post( $email ); if ( ! $email ) { return ''; } $types = bp_get_object_terms( $email->ID, bp_get_email_tax_type(), array( 'fields' => 'slugs' ) ); $type = reset( $types ); return $type; } /** * Get BuddyPress content allowed tags. * * @since 3.0.0 * * @global array $allowedtags KSES allowed HTML elements. * @return array BuddyPress content allowed tags. */ function bp_get_allowedtags() { global $allowedtags; return array_merge_recursive( $allowedtags, array( 'a' => array( 'aria-label' => array(), 'class' => array(), 'data-bp-tooltip' => array(), 'id' => array(), 'rel' => array(), ), 'img' => array( 'src' => array(), 'alt' => array(), 'width' => array(), 'height' => array(), 'class' => array(), 'id' => array(), ), 'span'=> array( 'class' => array(), 'data-livestamp' => array(), ), 'ul' => array(), 'ol' => array(), 'li' => array(), ) ); } /** * Remove script and style tags from a string. * * @since 3.0.1 * * @param string $string The string to strip tags from. * @return string The stripped tags string. */ function bp_strip_script_and_style_tags( $string ) { return preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $string ); } /** * Checks whether the current installation is "large". * * By default, an installation counts as "large" if there are 10000 users or more. * Filter 'bp_is_large_install' to adjust. * * @since 4.1.0 * * @return bool */ function bp_is_large_install() { // Use the Multisite function if available. if ( is_multisite() ) { $is_large = wp_is_large_network( 'users' ); } else { $is_large = bp_core_get_total_member_count() > 10000; } /** * Filters whether the current installation is "large". * * @since 4.1.0 * * @param bool $is_large True if the network is "large". */ return (bool) apply_filters( 'bp_is_large_install', $is_large ); } /** * Add a new BP_Optout. * * @since 8.0.0 * * @param array $args { * An array of arguments describing the new opt-out. * @type string $email_address Email address of user who has opted out. * @type int $user_id Optional. ID of user whose communication * prompted the user to opt-out. * @type string $email_type Optional. Name of the email type that * prompted the user to opt-out. * @type string $date_modified Optional. Specify a time, else now will be used. * } * @return false|int False on failure, ID of new (or existing) opt-out if successful. */ function bp_add_optout( $args = array() ) { $optout = new BP_Optout(); $r = bp_parse_args( $args, array( 'email_address' => '', 'user_id' => 0, 'email_type' => '', 'date_modified' => bp_core_current_time(), ), 'add_optout' ); // Opt-outs must have an email address. if ( empty( $r['email_address'] ) ) { return false; } // Avoid creating duplicate opt-outs. $optout_id = $optout->optout_exists( array( 'email_address' => $r['email_address'], 'user_id' => $r['user_id'], 'email_type' => $r['email_type'], ) ); if ( ! $optout_id ) { // Set up the new opt-out. $optout->email_address = $r['email_address']; $optout->user_id = $r['user_id']; $optout->email_type = $r['email_type']; $optout->date_modified = $r['date_modified']; $optout_id = $optout->save(); } return $optout_id; } /** * Find matching BP_Optouts. * * @since 8.0.0 * * @see BP_Optout::get() for a description of parameters and return values. * * @param array $args See {@link BP_Optout::get()}. * @return array See {@link BP_Optout::get()}. */ function bp_get_optouts( $args = array() ) { $optout_class = new BP_Optout(); return $optout_class::get( $args ); } /** * Check an email address to see if that individual has opted out. * * @since 8.0.0 * * @param string $email_address Email address to check. * @return bool True if the user has opted out, false otherwise. */ function bp_user_has_opted_out( $email_address = '' ) { if ( ! $email_address ) { return false; } $optout_class = new BP_Optout(); $optout_id = $optout_class->optout_exists( array( 'email_address' => $email_address, ) ); return (bool) $optout_id; } /** * Delete a BP_Optout by ID. * * @since 8.0.0 * * @param int $id ID of the optout to delete. * @return bool */ function bp_delete_optout_by_id( $id = 0 ) { $optout_class = new BP_Optout(); return $optout_class::delete_by_id( $id ); } /** * Get the list of versions needing their deprecated functions to be loaded. * * @since 11.0.0 * * @return array The list of versions needing their deprecated functions to be loaded. */ function bp_get_deprecated_functions_versions() { $ignore_deprecated = null; // Do ignore deprecated => ignore all deprecated code. if ( defined( 'BP_IGNORE_DEPRECATED' ) && BP_IGNORE_DEPRECATED ) { $ignore_deprecated = (bool) BP_IGNORE_DEPRECATED; } // Do not ignore deprecated => load all deprecated code. if ( defined( 'BP_LOAD_DEPRECATED' ) && BP_LOAD_DEPRECATED ) { $ignore_deprecated = ! (bool) BP_LOAD_DEPRECATED; } /* * Respect the site owner's choice to ignore deprecated functions. * Return an empty array to inform no deprecated version files should be loaded. */ if ( true === $ignore_deprecated ) { return array(); } // List of versions containing deprecated functions. $deprecated_functions_versions = array( 1.2, 1.5, 1.6, 1.7, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 4.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 14.0, ); /* * Respect the site owner's choice to load all deprecated functions. * Return an empty array to inform no deprecated version files should be loaded. */ if ( false === $ignore_deprecated ) { return $deprecated_functions_versions; } /* * Unless the `BP_IGNORE_DEPRECATED` constant is used & set to false, the development * version of BuddyPress do not load deprecated functions. */ if ( defined( 'BP_SOURCE_SUBDIRECTORY' ) && BP_SOURCE_SUBDIRECTORY === 'src' ) { return array(); } /* * If the constant is not defined, put our logic in place so that only the * 2 last versions deprecated functions will be loaded for upgraded installs. */ $initial_version = (float) bp_get_initial_version(); $current_major_version = (float) bp_get_major_version( bp_get_version() ); $load_latest_deprecated = $initial_version < $current_major_version; // New installs. if ( ! $load_latest_deprecated ) { // Run some additional checks if PHPUnit is running. if ( defined( 'BP_TESTS_DIR' ) ) { $deprecated_files = array_filter( array_map( function( $file ) { if ( false !== strpos( $file, '.php' ) ) { return (float) str_replace( '.php', '', $file ); }; }, scandir( buddypress()->plugin_dir . 'bp-core/deprecated' ) ) ); if ( array_diff( $deprecated_files, $deprecated_functions_versions ) ) { return false; } } // Only load 12.0 deprecated functions. return array( 12.0 ); } $index_first_major = array_search( $initial_version, $deprecated_functions_versions, true ); if ( false === $index_first_major ) { return array_splice( $deprecated_functions_versions, -2 ); } $latest_deprecated_functions_versions = array_splice( $deprecated_functions_versions, $index_first_major ); if ( 2 <= count( $latest_deprecated_functions_versions ) ) { $latest_deprecated_functions_versions = array_splice( $latest_deprecated_functions_versions, -2 ); } $index_initial_version = array_search( $initial_version, $latest_deprecated_functions_versions, true ); if ( false !== $index_initial_version && 12.0 !== $initial_version ) { unset( $latest_deprecated_functions_versions[ $index_initial_version ] ); } return $latest_deprecated_functions_versions; } /** * Get the BuddyPress Post Type site ID. * * @since 12.0.0 * * @return int The site ID the BuddyPress Post Type should be registered on. */ function bp_get_post_type_site_id() { $site_id = bp_get_root_blog_id(); /** * Filter here to edit the site ID. * * @todo This will need to be improved to take in account * specific configurations like multiblog. * * @since 12.0.0 * * @param integer $site_id The site ID to register the post type on. */ return (int) apply_filters( 'bp_get_post_type_site_id', $site_id ); } /** * Returns registered navigation items for all or a specific component. * * @since 12.0.0 * * @param string $component The component ID. * @return array The list of registered navigation items. */ function bp_get_component_navigations( $component = '' ) { $args = array(); if ( $component ) { $args['id'] = $component; } $components = bp_core_get_active_components( $args, 'objects' ); $navigations = array(); foreach ( $components as $key_component => $component ) { if ( isset( $component->main_nav['rewrite_id'] ) ) { $navigations[ $key_component ]['main_nav'] = $component->main_nav; } if ( isset( $component->sub_nav ) && is_array( $component->sub_nav ) && $component->sub_nav ) { $navigations[ $key_component ]['sub_nav'] = $component->sub_nav; } } // We possibly need to move some members nav items. if ( isset( $navigations['members']['sub_nav'], $navigations['profile']['sub_nav'] ) ) { $profile_subnav_slugs = wp_list_pluck( $navigations['profile']['sub_nav'], 'slug' ); foreach ( $navigations['members']['sub_nav'] as $members_subnav ) { if ( 'profile' === $members_subnav['parent_slug'] && ! in_array( $members_subnav['slug'], $profile_subnav_slugs, true ) ) { $navigations['profile']['sub_nav'][] = $members_subnav; } } } return $navigations; } /** * Get the community visibility value calculated from the * saved visibility setting. * * @since 12.0.0 * * @param string $component Whether we want the visibility for a single component * or for all components. * * @return arrary|string $retval The calculated visbility settings for the site. */ function bp_get_community_visibility( $component = 'global' ) { $retval = ( 'all' === $component ) ? array( 'global' => 'anyone' ) : 'anyone'; if ( 'rewrites' !== bp_core_get_query_parser() ) { return $retval; } $saved_value = (array) bp_get_option( '_bp_community_visibility', array() ); // If the global value has not been set, we assume that the site is open. if ( ! isset( $saved_value['global'] ) ) { $saved_value['global'] = 'anyone'; } if ( 'all' === $component ) { // Build the component list. $retval = array( 'global' => $saved_value['global'] ); $directory_pages = bp_core_get_directory_pages(); foreach ( $directory_pages as $component_id => $component_page ) { if ( in_array( $component_id, array( 'register', 'activate' ), true ) ) { continue; } $retval[ $component_id ] = isset( $saved_value[ $component_id ] ) ? $saved_value[ $component_id ] : $saved_value['global']; } } else { // We are checking a particular component. // Fall back to the global value if not set. $retval = isset( $saved_value[ $component ] ) ? $saved_value[ $component ] : $saved_value['global']; } /** * Filter the community visibility value calculated from the * saved visibility setting. * * @since 12.0.0 * * @param arrary|string $retval The calculated visbility settings for the site. * @param string $component The component value to get the visibility for. */ return apply_filters( 'bp_get_community_visibility', $retval, $component ); } /** * Returns the list of unread Admin Notification IDs. * * @since 11.4.0 * * @return array The list of unread Admin Notification IDs. */ function bp_core_get_unread_admin_notifications() { return (array) bp_get_option( 'bp_unread_admin_notifications', array() ); } /** * Dismisses an Admin Notification. * * @since 11.4.0 * * @param string $notification_id The Admin Notification to dismiss. */ function bp_core_dismiss_admin_notification( $notification_id = '' ) { $unread = bp_core_get_unread_admin_notifications(); $remaining = array_diff( $unread, array( $notification_id ) ); bp_update_option( 'bp_unread_admin_notifications', $remaining ); } /** * @since 11.4.0 * * @return array The list of Admin notifications. */ function bp_core_get_admin_notifications() { $unreads = bp_core_get_unread_admin_notifications(); if ( ! $unreads ) { return array(); } $admin_notifications = array( 'bp100-welcome-addons' => (object) array( 'id' => 'bp100-welcome-addons', 'href' => add_query_arg( array( 'tab' => 'bp-add-ons', 'n' => 'bp100-welcome-addons', ), bp_get_admin_url( 'plugin-install.php' ) ), 'text' => __( 'Discover BuddyPress Add-ons', 'buddypress' ), 'title' => __( 'Hello BuddyPress Add-ons!', 'buddypress' ), 'content' => __( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ) . __( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ), 'version' => 10.0, ), 'bp114-prepare-for-rewrites' => (object) array( 'id' => 'bp114-prepare-for-rewrites', 'href' => add_query_arg( array( 'tab' => 'bp-add-ons', 'show' => 'bp-classic', 'n' => 'bp114-prepare-for-rewrites' ), bp_get_admin_url( 'plugin-install.php' ) ), 'text' => __( 'Get The BP Classic Add-on', 'buddypress' ), 'title' => __( 'Get ready for the brand-new BP Rewrites API!', 'buddypress' ), 'content' => __( 'Our next major version (12.0.0) will introduce several large changes that could be incompatible with your site\'s configuration. To prevent problems, we\'ve built the BP Classic Add-on, which you may want to proactively install if any of the following cases:', 'buddypress' ) . '

' . '' . __( 'Some of your BuddyPress plugins have not been updated lately.', 'buddypress' ) . '
' . __( 'BuddyPress 12.0.0 introduces the BP Rewrites API, which completely changes the way BuddyPress URLs are built and routed. This fundamental change requires most BuddyPress plugins to update how they deal with BuddyPress URLs. If your BuddyPress plugins have not been updated in the last few months, they are probably not ready for BuddyPress 12.0.0.', 'buddypress' ) . '

' . '' . __( 'You are still using the BP Default theme.', 'buddypress' ) . '

' . '' . __( 'You still use a BP Legacy Widget.', 'buddypress' ) . '

' . __( 'If any of the above items are true, we strongly advise you to install and activate the Classic Add-on before updating to BuddyPress 12.0.0.', 'buddypress' ), 'version' => 11.4, ), 'bp120-new-installs-warning' => (object) array( 'id' => 'bp120-new-installs-warning', 'href' => add_query_arg( array( 'tab' => 'bp-add-ons', 'show' => 'bp-classic', 'n' => 'bp120-new-installs-warning' ), bp_get_admin_url( 'plugin-install.php' ) ), 'text' => __( 'Get The BP Classic Add-on', 'buddypress' ), 'title' => __( 'Thank you for installing BuddyPress 12.0!', 'buddypress' ), 'content' => __( 'BuddyPress 12.0 introduces major core changes, overhauling the way that BuddyPress builds and parses URLs.', 'buddypress' ) . '

' . __( 'If you find that your site is not working correctly with the new version, try installing the new BP Classic Add-on that adds backwards compatibility for plugins and themes that have not yet been updated to work with BuddyPress 12.0.', 'buddypress' ), 'version' => 12.0, ), ); // Only keep unread notifications. foreach ( array_keys( $admin_notifications ) as $notification_id ) { if ( ! in_array( $notification_id, $unreads, true ) ) { unset( $admin_notifications[ $notification_id ] ); } } return $admin_notifications; }
Fatal error: Uncaught Error: Call to undefined function bp_get_deprecated_functions_versions() in /home/nimaghor/public_html/wp-content/plugins/buddypress/class-buddypress.php:649 Stack trace: #0 /home/nimaghor/public_html/wp-content/plugins/buddypress/class-buddypress.php(252): BuddyPress->includes() #1 /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-loader.php(49): BuddyPress::instance() #2 /home/nimaghor/public_html/wp-content/plugins/buddypress/bp-loader.php(93): buddypress() #3 /home/nimaghor/public_html/wp-settings.php(517): include_once('/home/nimaghor/...') #4 /home/nimaghor/public_html/wp-config.php(83): require_once('/home/nimaghor/...') #5 /home/nimaghor/public_html/wp-load.php(50): require_once('/home/nimaghor/...') #6 /home/nimaghor/public_html/wp-blog-header.php(13): require_once('/home/nimaghor/...') #7 /home/nimaghor/public_html/index.php(17): require('/home/nimaghor/...') #8 {main} thrown in /home/nimaghor/public_html/wp-content/plugins/buddypress/class-buddypress.php on line 649