bp_ps_Fields
Setup BuddyBoss profile search fields.
Description
Source
File: bp-core/profile-search/bps-fields.php
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | class bp_ps_Fields { private static $display = array ( 'text' => array ( 'contains' => 'textbox' , '' => 'textbox' , 'like' => 'textbox' ), 'integer' => array ( '' => 'number' , 'range' => 'range' ), 'decimal' => array ( '' => 'textbox' , 'range' => 'range' ), 'date' => array ( 'date_range' => 'date_range' ), 'location' => array ( 'distance' => 'distance' , 'contains' => 'textbox' , '' => 'textbox' , 'like' => 'textbox' ), 'text/e' => array ( '' => array ( 'selectbox' , 'radio' ), 'one_of' => array ( 'checkbox' , 'multiselectbox' )), 'decimal/e' => array ( '' => array ( 'selectbox' , 'radio' ), 'range' => 'range' ), 'set/e' => array ( 'match_any' => array ( 'checkbox' , 'multiselectbox' ), 'match_all' => array ( 'checkbox' , 'multiselectbox' )), ); public static function get_filters ( $f ) { $labels = array ( 'contains' => __( 'contains' , 'buddyboss' ), '' => __( 'is' , 'buddyboss' ), 'like' => __( 'is like' , 'buddyboss' ), 'range' => __( 'range' , 'buddyboss' ), 'date_range' => __( 'date range' , 'buddyboss' ), 'distance' => __( 'distance' , 'buddyboss' ), 'one_of' => __( 'is one of' , 'buddyboss' ), 'match_any' => __( 'match any' , 'buddyboss' ), 'match_all' => __( 'match all' , 'buddyboss' ), ); $filters = array (); foreach ( $f ->filters as $filter ) $filters [ $filter ] = $labels [ $filter ]; return $filters ; } public static function set_filters ( $f ) { $format = isset ( $f ->format)? $f ->format: 'none' ; $enum = (isset ( $f ->options) && is_array ( $f ->options))? count ( $f ->options): 0; $selector = $format . ( $enum ? '/e' : '' ); if (!isset (self:: $display [ $selector ])) return false; $f ->filters = array_keys (self:: $display [ $selector ]); return true; } public static function is_filter ( $f , $filter ) { return in_array ( $filter , $f ->filters); } public static function valid_filter ( $f , $filter ) { return in_array ( $filter , $f ->filters)? $filter : $f ->filters[0]; } public static function set_display ( $f , $filter ) { $format = isset ( $f ->format)? $f ->format: 'none' ; $enum = (isset ( $f ->options) && is_array ( $f ->options))? count ( $f ->options): 0; $selector = $format . ( $enum ? '/e' : '' ); if (!isset (self:: $display [ $selector ][ $filter ])) return false; $display = self:: $display [ $selector ][ $filter ]; if ( is_string ( $display )) { $f ->display = $display ; } else { $default = (isset ( $f ->type) && in_array ( $f ->type, $display ))? $f ->type: $display [0]; $choice = apply_filters ( 'bp_ps_field_display' , $default , $f ); $f ->display = in_array ( $choice , $display )? $choice : $default ; } return true; } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Methods
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.