Changeset 10557
- Timestamp:
- 02/08/2016 04:52:44 PM (9 years ago)
- Location:
- trunk/src/bp-xprofile
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/admin/js/admin.js
r10141 r10557 77 77 */ 78 78 function show_options( forWhat ) { 79 var do_autolink; 80 79 81 for ( var i = 0; i < XProfileAdmin.supports_options_field_types.length; i++ ) { 80 82 document.getElementById( XProfileAdmin.supports_options_field_types[i] ).style.display = 'none'; … … 83 85 if ( XProfileAdmin.supports_options_field_types.indexOf( forWhat ) >= 0 ) { 84 86 document.getElementById( forWhat ).style.display = ''; 87 do_autolink = 'on'; 88 } else { 89 jQuery( '#do-autolink' ).val( '' ); 90 do_autolink = ''; 91 } 92 93 // Only overwrite the do_autolink setting if no setting is saved in the database. 94 if ( '' === XProfileAdmin.do_autolink ) { 95 jQuery( '#do-autolink' ).val( do_autolink ); 85 96 } 86 97 } -
trunk/src/bp-xprofile/bp-xprofile-admin.php
r10525 r10557 416 416 } 417 417 418 // Save autolink settings. 419 if ( 1 != $field_id ) { 420 if ( isset( $_POST['do_autolink'] ) && 'on' === wp_unslash( $_POST['do_autolink'] ) ) { 421 bp_xprofile_update_field_meta( $field_id, 'do_autolink', 'on' ); 422 } else { 423 bp_xprofile_update_field_meta( $field_id, 'do_autolink', 'off' ); 424 } 425 } 426 418 427 /** 419 428 * Fires at the end of the process to save a field for a user, if successful. -
trunk/src/bp-xprofile/bp-xprofile-cssjs.php
r10417 r10557 53 53 $strings = array( 54 54 'supports_options_field_types' => array(), 55 'do_autolink' => '', 55 56 ); 56 57 … … 62 63 } 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 64 73 wp_localize_script( 'xprofile-admin-js', 'XProfileAdmin', $strings ); 65 74 } -
trunk/src/bp-xprofile/bp-xprofile-filters.php
r10487 r10557 329 329 * - Not run on values without commas with less than 5 words. 330 330 * - URL's are made clickable. 331 * - To disable: remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 ); 331 * 332 * To disable globally: 333 * remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 3 ); 334 * 335 * To disable for a single field, use the 'Autolink' settings in Dashboard > Users > Profile Fields. 332 336 * 333 337 * @since 1.1.0 … … 338 342 */ 339 343 function xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) { 344 global $field; 345 346 if ( ! $field->get_do_autolink() ) { 347 return $field_value; 348 } 340 349 341 350 if ( 'datebox' === $field_type ) { -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field.php
r10434 r10557 129 129 */ 130 130 protected $allow_custom_visibility; 131 132 /** 133 * Whether values from this field are autolinked to directory searches. 134 * 135 * @since 2.5.0 136 * 137 * @var bool 138 */ 139 public $do_autolink; 131 140 132 141 /** … … 793 802 } 794 803 804 /** 805 * Get whether the field values should be auto-linked to a directory search. 806 * 807 * Lazy-loaded to reduce overhead. 808 * 809 * Defaults to true for multi and default fields, false for single fields. 810 * 811 * @since 2.5.0 812 * 813 * @return bool 814 */ 815 public function get_do_autolink() { 816 if ( ! isset( $this->do_autolink ) ) { 817 $do_autolink = bp_xprofile_get_meta( $this->id, 'field', 'do_autolink' ); 818 819 if ( '' === $do_autolink ) { 820 $this->do_autolink = $this->is_default_field() || $this->type_obj->supports_options; 821 } else { 822 $this->do_autolink = 'on' === $do_autolink; 823 } 824 } 825 826 return $this->do_autolink; 827 } 828 795 829 /* Static Methods ********************************************************/ 796 830 … … 1138 1172 // Output the field visibility metaboxes. 1139 1173 $this->visibility_metabox(); 1174 1175 // Output the autolink metabox. 1176 $this->autolink_metabox(); 1177 1140 1178 1141 1179 /** … … 1412 1450 1413 1451 /** 1452 * Private method used to output autolink metabox. 1453 * 1454 * @since 2.5.0 1455 * 1456 * @return void If default field id 1. 1457 */ 1458 private function autolink_metabox() { 1459 1460 // Default field cannot have custom visibility. 1461 if ( true === $this->is_default_field() ) { 1462 return; 1463 } 1464 1465 ?> 1466 1467 <div class="postbox"> 1468 <h2><label for="do-autolink"><?php esc_html_e( 'Autolink', 'buddypress' ); ?></label></h2> 1469 <div class="inside"> 1470 <p class="description"><?php esc_html_e( 'On user profiles, link this field to a search of the Members directory, using the field value as a search term:', 'buddypress' ); ?></p> 1471 1472 <p> 1473 <label> 1474 <select name="do_autolink" id="do-autolink"> 1475 <option value="on" <?php selected( $this->get_do_autolink() ); ?>><?php esc_html_e( 'Enabled', 'buddypress' ); ?></option> 1476 <option value="" <?php selected( $this->get_do_autolink(), false ); ?>><?php esc_html_e( 'Disabled', 'buddypress' ); ?></option> 1477 </select> 1478 </label> 1479 </p> 1480 </div> 1481 </div> 1482 1483 <?php 1484 } 1485 1486 /** 1414 1487 * Output the metabox for setting what type of field this is. 1415 1488 *
Note: See TracChangeset
for help on using the changeset viewer.