[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-members/ -> bp-members-admin.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Members Admin
   4   *
   5   * @package BuddyPress
   6   * @subpackage MembersAdmin
   7   * @since 2.0.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  // Load the BP Members admin.
  14  add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) );
  15  
  16  /**
  17   * Create Users submenu to manage BuddyPress types.
  18   *
  19   * @since 7.0.0
  20   */
  21  function bp_members_type_admin_menu() {
  22      if ( ! bp_is_root_blog() ) {
  23          return;
  24      }
  25  
  26      if ( bp_is_network_activated() && is_network_admin() ) {
  27          // Adds a users.php submenu to go to the root blog Member types screen.
  28          $member_type_admin_url = add_query_arg( 'taxonomy', bp_get_member_type_tax_name(), get_admin_url( bp_get_root_blog_id(), 'edit-tags.php' ) );
  29  
  30          add_submenu_page(
  31              'users.php',
  32              __( 'Member Types', 'buddypress' ),
  33              __( 'Member Types', 'buddypress' ),
  34              'bp_moderate',
  35              esc_url( $member_type_admin_url )
  36          );
  37  
  38      } elseif ( ! is_network_admin() ) {
  39          add_submenu_page(
  40              'users.php',
  41              __( 'Member Types', 'buddypress' ),
  42              __( 'Member Types', 'buddypress' ),
  43              'bp_moderate',
  44              basename( add_query_arg( 'taxonomy', bp_get_member_type_tax_name(), bp_get_admin_url( 'edit-tags.php' ) ) )
  45          );
  46      }
  47  }
  48  add_action( 'bp_admin_menu', 'bp_members_type_admin_menu' );
  49  
  50  /**
  51   * Checks whether a member type already exists.
  52   *
  53   * @since 7.0.0
  54   *
  55   * @param  boolean $exists  True if the member type already exists. False otherwise.
  56   * @param  string  $type_id The member type identifier.
  57   * @return boolean          True if the member type already exists. False otherwise.
  58   */
  59  function bp_members_type_admin_type_exists( $exists = false, $type_id = '' ) {
  60      if ( ! $type_id ) {
  61          return $exists;
  62      }
  63  
  64      return ! is_null( bp_get_member_type_object( $type_id ) );
  65  }
  66  add_filter( bp_get_member_type_tax_name() . '_check_existing_type', 'bp_members_type_admin_type_exists', 1, 2 );
  67  
  68  /**
  69   * Set the feedback messages for the Member Types Admin actions.
  70   *
  71   * @since 7.0.0
  72   *
  73   * @param array  $messages The feedback messages.
  74   * @return array           The feedback messages including the ones for the Member Types Admin actions.
  75   */
  76  function bp_members_type_admin_updated_messages( $messages = array() ) {
  77      $type_taxonomy = bp_get_member_type_tax_name();
  78  
  79      $messages[ $type_taxonomy ] = array(
  80          0  => '',
  81          1  => __( 'Please define the Member Type ID field.', 'buddypress' ),
  82          2  => __( 'Member type successfully added.', 'buddypress' ),
  83          3  => __( 'Sorry, there was an error and the Member type wasn’t added.', 'buddypress' ),
  84          // The following one needs to be != 5.
  85          4  => __( 'Member type successfully updated.', 'buddypress' ),
  86          5  => __( 'Sorry, this Member type already exists.', 'buddypress' ),
  87          6  => __( 'Sorry, the Member type was not deleted: it does not exist.', 'buddypress' ),
  88          7  => __( 'Sorry, This Member type is registered using code, deactivate the plugin or remove the custom code before trying to delete it again.', 'buddypress' ),
  89          8  => __( 'Sorry, there was an error while trying to delete this Member type.', 'buddypress' ),
  90          9  => __( 'Member type successfully deleted.', 'buddypress' ),
  91          10 => __( 'Member type could not be updated due to missing required information.', 'buddypress' ),
  92      );
  93  
  94      return $messages;
  95  }
  96  add_filter( 'term_updated_messages', 'bp_members_type_admin_updated_messages' );


Generated: Wed Dec 2 01:01:35 2020 Cross-referenced by PHPXref 0.7.1