[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-xprofile/ -> bp-xprofile-cssjs.php (source)

   1  <?php
   2  /**
   3   * BuddyPress XProfile CSS and JS.
   4   *
   5   * @package BuddyPress
   6   * @subpackage XProfileScripts
   7   * @since 1.0.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Enqueue the CSS for XProfile admin styling.
  15   *
  16   * @since 1.1.0
  17   */
  18  function xprofile_add_admin_css() {
  19      if ( !empty( $_GET['page'] ) && strpos( $_GET['page'], 'bp-profile-setup' ) !== false ) {
  20          $min = bp_core_get_minified_asset_suffix();
  21  
  22          wp_enqueue_style( 'xprofile-admin-css', buddypress()->plugin_url . "bp-xprofile/admin/css/admin{$min}.css", array(), bp_get_version() );
  23  
  24          wp_style_add_data( 'xprofile-admin-css', 'rtl', 'replace' );
  25          if ( $min ) {
  26              wp_style_add_data( 'xprofile-admin-css', 'suffix', $min );
  27          }
  28      }
  29  }
  30  add_action( 'bp_admin_enqueue_scripts', 'xprofile_add_admin_css' );
  31  
  32  /**
  33   * Enqueue the jQuery libraries for handling drag/drop/sort.
  34   *
  35   * @since 1.5.0
  36   */
  37  function xprofile_add_admin_js() {
  38      if ( !empty( $_GET['page'] ) && strpos( $_GET['page'], 'bp-profile-setup' ) !== false ) {
  39          wp_enqueue_script( 'jquery-ui-core'      );
  40          wp_enqueue_script( 'jquery-ui-tabs'      );
  41          wp_enqueue_script( 'jquery-ui-mouse'     );
  42          wp_enqueue_script( 'jquery-ui-draggable' );
  43          wp_enqueue_script( 'jquery-ui-droppable' );
  44          wp_enqueue_script( 'jquery-ui-sortable'  );
  45  
  46          $min = bp_core_get_minified_asset_suffix();
  47          wp_enqueue_script( 'xprofile-admin-js', buddypress()->plugin_url . "bp-xprofile/admin/js/admin{$min}.js", array( 'jquery', 'jquery-ui-sortable' ), bp_get_version() );
  48  
  49          // Localize strings.
  50          // supports_options_field_types is a dynamic list of field
  51          // types that support options, for use in showing/hiding the
  52          // "please enter options for this field" section.
  53          $strings = array(
  54              'do_settings_section_field_types'      => array(),
  55              'do_autolink'                          => '',
  56              'hide_do_autolink_metabox'             => array(),
  57              'hide_allow_custom_visibility_metabox' => array(),
  58              'hide_required_metabox'                => array(),
  59              'hide_member_types_metabox'            => array(),
  60              'hide_signup_position_metabox'         => array(),
  61              'text'                                 => array(
  62                  'defaultValue' => __( 'Default Value', 'buddypress' ),
  63                  'deleteLabel'  => __( 'Delete', 'buddypress' ),
  64              ),
  65              'signup_info'                          => _x( '(Sign-up)', 'xProfile Group Admin Screen Signup field information', 'buddypress' ),
  66          );
  67  
  68          foreach ( bp_xprofile_get_field_types() as $field_type => $field_type_class ) {
  69              $field = new $field_type_class();
  70              if ( $field->do_settings_section() ) {
  71                  $strings['do_settings_section_field_types'][] = $field_type;
  72              }
  73  
  74              if ( isset( $field::$supported_features ) && is_array( $field::$supported_features ) ) {
  75                  foreach ( $field::$supported_features as $feature => $support ) {
  76                      if ( isset( $strings['hide_' . $feature . '_metabox'] ) && ! $support ) {
  77                          $strings['hide_' . $feature . '_metabox'][] = $field_type;
  78                      }
  79                  }
  80              }
  81          }
  82  
  83          // Load 'autolink' setting into JS so that we can provide smart defaults when switching field type.
  84          if ( ! empty( $_GET['field_id'] ) ) {
  85              $field_id = intval( $_GET['field_id'] );
  86  
  87              // Pull the raw data from the DB so we can tell whether the admin has saved a value yet.
  88              $strings['do_autolink'] = bp_xprofile_get_meta( $field_id, 'field', 'do_autolink' );
  89          }
  90  
  91          wp_localize_script( 'xprofile-admin-js', 'XProfileAdmin', $strings );
  92      }
  93  }
  94  add_action( 'bp_admin_enqueue_scripts', 'xprofile_add_admin_js', 1 );


Generated: Thu Mar 28 01:00:56 2024 Cross-referenced by PHPXref 0.7.1