├── bp-xprofile-custom-fields-type.php ├── classes ├── Bxcft_Field_Type_Birthdate.php ├── Bxcft_Field_Type_CheckboxAcceptance.php ├── Bxcft_Field_Type_Color.php ├── Bxcft_Field_Type_Datepicker.php ├── Bxcft_Field_Type_DecimalNumber.php ├── Bxcft_Field_Type_Email.php ├── Bxcft_Field_Type_File.php ├── Bxcft_Field_Type_Image.php ├── Bxcft_Field_Type_MultiSelectCustomPostType.php ├── Bxcft_Field_Type_MultiSelectCustomTaxonomy.php ├── Bxcft_Field_Type_NumberMinMax.php ├── Bxcft_Field_Type_SelectCustomPostType.php ├── Bxcft_Field_Type_SelectCustomTaxonomy.php ├── Bxcft_Field_Type_Slider.php └── Bxcft_Field_Type_Web.php ├── css └── select2 │ └── select2.min.css ├── js ├── admin.js ├── jscolor │ ├── arrow.gif │ ├── cross.gif │ ├── hs.png │ ├── hv.png │ └── jscolor.js ├── modernizr.js ├── public.js └── select2 │ ├── i18n │ ├── en_US.js │ └── es_ES.js │ └── select2.min.js ├── lang ├── buddypress-xprofile-custom-fields-type.pot ├── de_DE.mo ├── de_DE.po ├── en_US.mo ├── en_US.po ├── es_ES.mo ├── es_ES.po ├── fr_FR.mo ├── fr_FR.po ├── hu_HU.mo ├── hu_HU.po ├── pt_BR.mo ├── pt_BR.po ├── ru_RU.mo ├── ru_RU.po ├── sk_SK.mo ├── sk_SK.po ├── uk_UA.mo └── uk_UA.po └── readme.txt /classes/Bxcft_Field_Type_CheckboxAcceptance.php: -------------------------------------------------------------------------------- 1 | name = _x( 'Checkbox Acceptance', 'xprofile field type', 'bxcft' ); 13 | 14 | $this->accepts_null_value = true; 15 | $this->supports_options = true; 16 | 17 | $this->set_format( '/^.+$/', 'replace' ); 18 | do_action( 'bp_xprofile_field_type_checkbox_acceptance', $this ); 19 | } 20 | 21 | public function admin_field_html (array $raw_properties = array ()) 22 | { 23 | global $field; 24 | 25 | $options = $field->get_children( true ); 26 | $text = ''; 27 | foreach ($options as $option) { 28 | $text .= rawurldecode($option->name); 29 | } 30 | 31 | $html = $this->get_edit_field_html_elements( array_merge( 32 | array( 'type' => 'checkbox' ), 33 | $raw_properties 34 | ) ); 35 | ?> 36 | 40 | 60 | 61 | 62 | 63 | type != $type ? 'display: none;' : ''; 74 | $current_type_obj = bp_xprofile_create_field_type( $type ); 75 | 76 | $text = ''; 77 | $options = $current_field->get_children( true ); 78 | if ( ! $options ) { 79 | $options = array(); 80 | $i = 1; 81 | while ( isset( $_POST[$type . '_option'][$i] ) ) { 82 | if ( $current_type_obj->supports_options && ! $current_type_obj->supports_multiple_defaults && isset( $_POST["isDefault_{$type}_option"][$i] ) && (int) $_POST["isDefault_{$type}_option"] === $i ) { 83 | $is_default_option = true; 84 | } elseif ( isset( $_POST["isDefault_{$type}_option"][$i] ) ) { 85 | $is_default_option = (bool) $_POST["isDefault_{$type}_option"][$i]; 86 | } else { 87 | $is_default_option = false; 88 | } 89 | 90 | $options[] = (object) array( 91 | 'id' => 0, 92 | 'is_default_option' => $is_default_option, 93 | 'name' => sanitize_text_field( stripslashes( $_POST[$type . '_option'][$i] ) ), 94 | ); 95 | 96 | $text .= sanitize_text_field( stripslashes( $_POST[$type . '_option'][$i] ) ); 97 | ++$i; 98 | } 99 | 100 | if ( ! $options ) { 101 | $options[] = (object) array( 102 | 'id' => 0, 103 | 'is_default_option' => false, 104 | 'name' => '', 105 | ); 106 | } 107 | } else { 108 | foreach ($options as $option) { 109 | $text .= rawurldecode($option->name); 110 | } 111 | } 112 | ?> 113 |
128 | field_obj->get_children(); 134 | $checkbox_acceptance = maybe_unserialize(BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] )); 135 | 136 | if ( !empty($_POST['field_' . $this->field_obj->id]) ) { 137 | $new_checkbox_acceptance = $_POST['field_' . $this->field_obj->id]; 138 | $checkbox_acceptance = ( $checkbox_acceptance != $new_checkbox_acceptance ) ? $new_checkbox_acceptance : $checkbox_acceptance; 139 | } 140 | 141 | $html = 'name); 159 | } 160 | } 161 | 162 | // Javascript. 163 | $html .= ' 164 | 175 | '; 176 | 177 | echo apply_filters( 'bp_get_the_profile_field_checkbox_acceptance', $html, $args['type'], $this->field_obj->id, $checkbox_acceptance ); 178 | } 179 | 180 | public function is_valid( $values ) { 181 | $this->validation_whitelist = null; 182 | return parent::is_valid($values); 183 | } 184 | 185 | /** 186 | * Modify the appearance of value. Apply autolink if enabled. 187 | * 188 | * @param string $value Original value of field 189 | * @param int $field_id Id of field 190 | * @return string Value formatted 191 | */ 192 | public static function display_filter($field_value, $field_id = '') { 193 | 194 | $new_field_value = $field_value; 195 | 196 | if ($field_value !== '' && !empty($field_id)) { 197 | $field = BP_XProfile_Field::get_instance($field_id); 198 | 199 | if ($field) { 200 | $new_field_value = ((int)$field_value == 1) ? 201 | __('yes', 'bxcft') : __('no', 'bxcft'); 202 | 203 | $do_autolink = apply_filters('bxcft_do_autolink', 204 | $field->get_do_autolink()); 205 | 206 | if ($do_autolink) { 207 | $query_arg = bp_core_get_component_search_query_arg( 'members' ); 208 | $search_url = add_query_arg( array( $query_arg => urlencode( $field_value ) ), 209 | bp_get_members_directory_permalink() ); 210 | $new_field_value = '' . $new_field_value . ''; 212 | } 213 | } 214 | } 215 | 216 | /** 217 | * bxcft_checkbox_acceptance_display_filter 218 | * 219 | * Use this filter to modify the appearance of Checkbox Acceptance 220 | * field value. 221 | * @param $new_field_value Value of field 222 | * @param $field_id Id of field. 223 | * @return Filtered value of field. 224 | */ 225 | return apply_filters('bxcft_checkbox_acceptance_display_filter', 226 | $new_field_value, $field_id); 227 | } 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /classes/Bxcft_Field_Type_Color.php: -------------------------------------------------------------------------------- 1 | name = _x( 'Color (HTML5 field)', 'xprofile field type', 'bxcft' ); 13 | 14 | $this->set_format( '/^.+$/', 'replace' ); 15 | do_action( 'bp_xprofile_field_type_color', $this ); 16 | } 17 | 18 | public function admin_field_html (array $raw_properties = array ()) 19 | { 20 | $html = $this->get_edit_field_html_elements( array_merge( 21 | array( 'type' => 'color' ), 22 | $raw_properties 23 | ) ); 24 | ?> 25 | > 26 | get_edit_field_html_elements( array_merge( 41 | array( 42 | 'type' => 'color', 43 | 'value' => bp_get_the_profile_field_edit_value(), 44 | ), 45 | $raw_properties 46 | ) ); 47 | ?> 48 | 49 | 50 | > 51 | 57 | get_do_autolink()); 79 | if ($do_autolink) { 80 | $query_arg = bp_core_get_component_search_query_arg( 'members' ); 81 | $search_url = add_query_arg( array( 82 | $query_arg => urlencode( $field_value ) 83 | ), bp_get_members_directory_permalink() ); 84 | $new_field_value = '' . $new_field_value . ''; 86 | } 87 | } 88 | } 89 | } 90 | 91 | /** 92 | * bxcft_color_display_filter 93 | * 94 | * Use this filter to modify the appearance of Color 95 | * field value. 96 | * @param $new_field_value Value of field 97 | * @param $field_id Id of field. 98 | * @return Filtered value of field. 99 | */ 100 | return apply_filters('bxcft_color_display_filter', $new_field_value, $field_id); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /classes/Bxcft_Field_Type_Datepicker.php: -------------------------------------------------------------------------------- 1 | name = _x( 'Datepicker (HTML5 field)', 'xprofile field type', 'bxcft' ); 13 | 14 | $this->set_format( '/^\d{4}-\d{1,2}-\d{1,2}$/', 'replace' ); // "Y-m-d 00:00:00" 15 | do_action( 'bp_xprofile_field_type_datepicker', $this ); 16 | } 17 | 18 | public function admin_field_html (array $raw_properties = array ()) 19 | { 20 | $html = $this->get_edit_field_html_elements( array_merge( 21 | array( 'type' => 'date' ), 22 | $raw_properties 23 | ) ); 24 | ?> 25 | /> 26 | get_edit_field_html_elements( array_merge( 41 | array( 42 | 'type' => 'date', 43 | 'value' => bp_get_the_profile_field_edit_value(), 44 | ), 45 | $raw_properties 46 | ) ); 47 | 48 | $label = sprintf( 49 | '', 50 | bp_get_the_profile_field_input_name(), 51 | bp_get_the_profile_field_name(), 52 | (bp_get_the_profile_field_is_required()) ? 53 | ' ' . esc_html__( '(required)', 'buddypress' ) : '' 54 | ); 55 | // Label. 56 | echo apply_filters('bxcft_field_label', $label, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_name(), bp_get_the_profile_field_is_required()); 57 | // Errors. 58 | do_action( bp_get_the_profile_field_errors_action() ); 59 | // Input. 60 | ?> 61 | /> 62 | get_do_autolink()); 87 | if ($do_autolink) { 88 | $query_arg = bp_core_get_component_search_query_arg( 'members' ); 89 | $search_url = add_query_arg( array( $query_arg => urlencode( $field_value ) ), 90 | bp_get_members_directory_permalink() ); 91 | $new_field_value = '' . $new_field_value . ''; 93 | } 94 | } 95 | } 96 | } 97 | 98 | /** 99 | * 'bxcft_datepicker_display_filter' 100 | * 101 | * Use this filter to modify the appearance of Color 102 | * field value. 103 | * 104 | * @param $value Value 105 | * @param $field_id Id of field 106 | * @return Filtered value of field 107 | */ 108 | return apply_filters('bxcft_datepicker_display_filter', $new_field_value, 109 | $field_id); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /classes/Bxcft_Field_Type_DecimalNumber.php: -------------------------------------------------------------------------------- 1 | name = __( 'Decimal number (HTML5 field)', 'bxcft' ); 13 | 14 | $this->accepts_null_value = true; 15 | $this->supports_options = true; 16 | 17 | $this->set_format( '/^\d+\.?\d*$/', 'replace' ); 18 | 19 | do_action( 'bp_xprofile_field_type_decimal_number', $this ); 20 | } 21 | 22 | public function admin_field_html (array $raw_properties = array ()) 23 | { 24 | global $field; 25 | 26 | $options = $field->get_children( true ); 27 | if (count($options) > 0) { 28 | $step = (1 / (pow(10, (int)$options[0]->name))); 29 | } else { 30 | $step = 0.01; 31 | } 32 | 33 | $html = $this->get_edit_field_html_elements( array_merge( 34 | array( 35 | 'type' => 'number', 36 | 'step' => $step, 37 | ), 38 | $raw_properties 39 | ) ); 40 | ?> 41 | /> 42 | get_children( true ); 59 | if (count($options) > 0) { 60 | $step = (1 / (pow(10, (int)$options[0]->name))); 61 | } else { 62 | $step = 0.01; 63 | } 64 | 65 | $html = $this->get_edit_field_html_elements( array_merge( 66 | array( 67 | 'type' => 'number', 68 | 'step' => $step, 69 | 'value' => bp_get_the_profile_field_edit_value(), 70 | ), 71 | $raw_properties 72 | ) ); 73 | 74 | $label = sprintf( 75 | '', 76 | bp_get_the_profile_field_input_name(), 77 | bp_get_the_profile_field_name(), 78 | (bp_get_the_profile_field_is_required()) ? 79 | ' ' . esc_html__( '(required)', 'buddypress' ) : '' 80 | ); 81 | // Label. 82 | echo apply_filters('bxcft_field_label', $label, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_name(), bp_get_the_profile_field_is_required()); 83 | // Errors. 84 | do_action( bp_get_the_profile_field_errors_action() ); 85 | // Input. 86 | ?> 87 | /> 88 | type != $type ? 'display: none;' : ''; 99 | $current_type_obj = bp_xprofile_create_field_type( $type ); 100 | 101 | $options = $current_field->get_children( true ); 102 | if ( ! $options ) { 103 | $options = array(); 104 | $i = 1; 105 | while ( isset( $_POST[$type . '_option'][$i] ) ) { 106 | $is_default_option = true; 107 | 108 | $options[] = (object) array( 109 | 'id' => -1, 110 | 'is_default_option' => $is_default_option, 111 | 'name' => sanitize_text_field( stripslashes( $_POST[$type . '_option'][$i] ) ), 112 | ); 113 | 114 | ++$i; 115 | } 116 | 117 | if ( ! $options ) { 118 | $options[] = (object) array( 119 | 'id' => -1, 120 | 'is_default_option' => false, 121 | 'name' => '2', 122 | ); 123 | } 124 | } 125 | ?> 126 | 138 | validation_whitelist = null; 143 | return parent::is_valid($values); 144 | } 145 | 146 | /** 147 | * Modify the appearance of value. Apply autolink if enabled. 148 | * 149 | * @param string $value Original value of field 150 | * @param int $field_id Id of field 151 | * @return string Value formatted 152 | */ 153 | public static function display_filter($field_value, $field_id = '') { 154 | 155 | $new_field_value = $field_value; 156 | 157 | if (!empty($field_value)) { 158 | if (!empty($field_id)) { 159 | $field = BP_XProfile_Field::get_instance($field_id); 160 | if ($field) { 161 | $do_autolink = apply_filters('bxcft_do_autolink', 162 | $field->get_do_autolink()); 163 | if ($do_autolink) { 164 | $query_arg = bp_core_get_component_search_query_arg( 'members' ); 165 | $search_url = add_query_arg( array( 166 | $query_arg => urlencode( $field_value ) 167 | ), bp_get_members_directory_permalink() ); 168 | $new_field_value = '' . $new_field_value . ''; 170 | } 171 | } 172 | } 173 | } 174 | 175 | /** 176 | * bxcft_decimal_number_display_filter 177 | * 178 | * Use this filter to modify the appearance of Decimal Number 179 | * field value. 180 | * @param $new_field_value Value of field 181 | * @param $field_id Id of field. 182 | * @return Filtered value of field. 183 | */ 184 | return apply_filters('bxcft_decimal_number_display_filter', 185 | $new_field_value, $field_id); 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /classes/Bxcft_Field_Type_Email.php: -------------------------------------------------------------------------------- 1 | name = _x( 'Email (HTML5 field)', 'xprofile field type', 'bxcft' ); 13 | 14 | $this->set_format( '/^[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}$/', 'replace' ); // "something@something.some" 15 | do_action( 'bp_xprofile_field_type_email', $this ); 16 | } 17 | 18 | public function admin_field_html (array $raw_properties = array ()) 19 | { 20 | $html = $this->get_edit_field_html_elements( array_merge( 21 | array( 'type' => 'email' ), 22 | $raw_properties 23 | ) ); 24 | ?> 25 | /> 26 | get_edit_field_html_elements( array_merge( 41 | array( 42 | 'type' => 'email', 43 | 'value' => bp_get_the_profile_field_edit_value(), 44 | ), 45 | $raw_properties 46 | ) ); 47 | 48 | $label = sprintf( 49 | '', 50 | bp_get_the_profile_field_input_name(), 51 | bp_get_the_profile_field_name(), 52 | (bp_get_the_profile_field_is_required()) ? 53 | ' ' . esc_html__( '(required)', 'buddypress' ) : '' 54 | ); 55 | // Label. 56 | echo apply_filters('bxcft_field_label', $label, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_name(), bp_get_the_profile_field_is_required()); 57 | // Errors. 58 | do_action( bp_get_the_profile_field_errors_action() ); 59 | // Input. 60 | ?> 61 | /> 62 | %1$s', 80 | $field_value); 81 | 82 | if (!empty($field_id)) { 83 | $field = BP_XProfile_Field::get_instance($field_id); 84 | if ($field) { 85 | $do_autolink = apply_filters('bxcft_do_autolink', 86 | $field->get_do_autolink()); 87 | if ($do_autolink) { 88 | $query_arg = bp_core_get_component_search_query_arg( 'members' ); 89 | $search_url = add_query_arg( array( 90 | $query_arg => urlencode( $field_value ) 91 | ), bp_get_members_directory_permalink() ); 92 | $new_field_value = '' . $field_value . ''; 94 | } 95 | } 96 | } 97 | } 98 | 99 | /** 100 | * bxcft_email_display_filter 101 | * 102 | * Use this filter to modify the appearance of Email 103 | * field value. 104 | * @param $new_field_value Value of field 105 | * @param $field_id Id of field. 106 | * @return Filtered value of field. 107 | */ 108 | return apply_filters('bxcft_email_display_filter', 109 | $new_field_value, $field_id); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /classes/Bxcft_Field_Type_File.php: -------------------------------------------------------------------------------- 1 | name = _x( 'File', 'xprofile field type', 'bxcft' ); 13 | 14 | $this->set_format( '/^.+$/', 'replace' ); 15 | do_action( 'bp_xprofile_field_type_file', $this ); 16 | } 17 | 18 | public function admin_field_html (array $raw_properties = array ()) 19 | { 20 | $html = $this->get_edit_field_html_elements( array_merge( 21 | array( 'type' => 'file' ), 22 | $raw_properties 23 | ) ); 24 | ?> 25 | > 26 | get_edit_field_html_elements( array_merge( 35 | array( 36 | 'type' => 'file', 37 | ), 38 | $raw_properties 39 | ) ); 40 | 41 | $uploads = wp_upload_dir(); 42 | 43 | // Label. 44 | $label = sprintf('', 45 | bp_get_the_profile_field_input_name(), 46 | bp_get_the_profile_field_name(), 47 | (bp_get_the_profile_field_is_required()) ? 48 | esc_html( '(required)', 'buddypress') : ''); 49 | // Input file. 50 | $input = sprintf('', 51 | bp_get_the_profile_field_input_name(), 52 | (bp_get_the_profile_field_edit_value() != '' && bp_get_the_profile_field_edit_value() != '-') ? 53 | bp_get_the_profile_field_edit_value() : '-', 54 | $html); 55 | // Actual file. 56 | if (bp_get_the_profile_field_edit_value() != '' && bp_get_the_profile_field_edit_value() != '-') { 57 | $actual_file = sprintf('%1$s', 58 | apply_filters('bxcft_show_download_file_link', '' . __('Download file', 'bxcft') . '', bp_get_the_profile_field_type(), bp_get_the_profile_field_id(), bp_get_the_profile_field_edit_value()), 59 | bp_get_the_profile_field_input_name(), 60 | __('Check this to delete this file', 'bxcft'), 61 | bp_get_the_profile_field_edit_value()); 62 | } elseif (bp_get_profile_field_data(array('field' => bp_get_the_profile_field_id())) != '' && 63 | bp_get_profile_field_data(array('field' => bp_get_the_profile_field_id())) != '-') { 64 | $actual_file = sprintf('%1$s', 65 | apply_filters('bxcft_show_download_file_link', bp_get_profile_field_data(array('field' => bp_get_the_profile_field_id())), bp_get_the_profile_field_type(), bp_get_the_profile_field_id(), bp_get_the_profile_field_edit_value()), 66 | bp_get_the_profile_field_input_name(), 67 | __('Check this to delete this file', 'bxcft'), 68 | (isset($_POST['field_'.bp_get_the_profile_field_id().'_hiddenfile']))?$_POST['field_'.bp_get_the_profile_field_id().'_hiddenfile']:''); 69 | } else { 70 | $actual_file = ''; 71 | } 72 | 73 | echo apply_filters( 'bxcft_field_label', $label, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_name(), bp_get_the_profile_field_is_required() ); 74 | do_action( bp_get_the_profile_field_errors_action() ); 75 | echo apply_filters( 'bxcft_field_input', $input, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_is_required() ); 76 | echo apply_filters('bxcft_field_actual_file', $actual_file, bp_get_the_profile_field_id(), bp_get_the_profile_field_type(), bp_get_the_profile_field_input_name(), bp_get_the_profile_field_edit_value()); 77 | ?> 78 | 102 | %s', 124 | $new_field_value, __('Download file', 'bxcft')); 125 | } 126 | 127 | /** 128 | * bxcft_file_display_filter 129 | * 130 | * Use this filter to modify the appearance of File 131 | * field value. 132 | * @param $new_field_value Value of field 133 | * @param $field_id Id of field. 134 | * @return Filtered value of field. 135 | */ 136 | return apply_filters('bxcft_file_display_filter', 137 | $new_field_value, $field_id); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /classes/Bxcft_Field_Type_Image.php: -------------------------------------------------------------------------------- 1 | name = _x( 'Image', 'xprofile field type', 'bxcft' ); 13 | 14 | $this->set_format( '/^.+$/', 'replace' ); 15 | do_action( 'bp_xprofile_field_type_image', $this ); 16 | } 17 | 18 | public function admin_field_html (array $raw_properties = array ()) 19 | { 20 | $html = $this->get_edit_field_html_elements( array_merge( 21 | array( 'type' => 'file' ), 22 | $raw_properties 23 | ) ); 24 | ?> 25 | > 26 | get_edit_field_html_elements( array_merge( 35 | array( 36 | 'type' => 'file', 37 | ), 38 | $raw_properties 39 | ) ); 40 | 41 | $uploads = wp_upload_dir(); 42 | 43 | // Label. 44 | $label = sprintf('', 45 | bp_get_the_profile_field_input_name(), 46 | bp_get_the_profile_field_name(), 47 | (bp_get_the_profile_field_is_required()) ? 48 | esc_html( '(required)', 'buddypress') : ''); 49 | // Input file. 50 | $input = sprintf('', 51 | bp_get_the_profile_field_input_name(), 52 | (bp_get_the_profile_field_edit_value() != '' && bp_get_the_profile_field_edit_value() != '-') ? 53 | bp_get_the_profile_field_edit_value() : '-', 54 | $html); 55 | // Actual image. 56 | if (bp_get_the_profile_field_edit_value() != '' && bp_get_the_profile_field_edit_value() != '-') { 57 | $actual_image = sprintf('