[ 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          );
  57  
  58          foreach ( bp_xprofile_get_field_types() as $field_type => $field_type_class ) {
  59              $field = new $field_type_class();
  60              if ( $field->do_settings_section() ) {
  61                  $strings['do_settings_section_field_types'][] = $field_type;
  62              }
  63          }
  64  
  65          // Load 'autolink' setting into JS so that we can provide smart defaults when switching field type.
  66          if ( ! empty( $_GET['field_id'] ) ) {
  67              $field_id = intval( $_GET['field_id'] );
  68  
  69              // Pull the raw data from the DB so we can tell whether the admin has saved a value yet.
  70              $strings['do_autolink'] = bp_xprofile_get_meta( $field_id, 'field', 'do_autolink' );
  71          }
  72  
  73          wp_localize_script( 'xprofile-admin-js', 'XProfileAdmin', $strings );
  74      }
  75  }
  76  add_action( 'bp_admin_enqueue_scripts', 'xprofile_add_admin_js', 1 );


Generated: Wed Nov 13 01:01:39 2019 Cross-referenced by PHPXref 0.7.1