本文整理汇总了PHP中bp_xprofile_create_field_type函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_xprofile_create_field_type函数的具体用法?PHP bp_xprofile_create_field_type怎么用?PHP bp_xprofile_create_field_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_xprofile_create_field_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_admin_profile_metaboxes
/**
* Render the xprofile metabox for Community Profile screen.
*
* @since 2.0.0
*
* @param WP_User|null $user The WP_User object for the user being edited.
* @param array $args Aray of arguments for metaboxes.
*/
public function user_admin_profile_metaboxes($user = null, $args = array())
{
// Bail if no user ID.
if (empty($user->ID)) {
return;
}
$r = bp_parse_args($args['args'], array('profile_group_id' => 0, 'user_id' => $user->ID), 'bp_xprofile_user_admin_profile_loop_args');
// We really need these args.
if (empty($r['profile_group_id']) || empty($r['user_id'])) {
return;
}
// Bail if no profile fields are available.
if (!bp_has_profile($r)) {
return;
}
// Loop through profile groups & fields.
while (bp_profile_groups()) {
bp_the_profile_group();
?>
<input type="hidden" name="field_ids[]" id="<?php
echo esc_attr('field_ids_' . bp_get_the_profile_group_slug());
?>
" value="<?php
echo esc_attr(bp_get_the_profile_group_field_ids());
?>
" />
<?php
if (bp_get_the_profile_group_description()) {
?>
<p class="description"><?php
bp_the_profile_group_description();
?>
</p>
<?php
}
?>
<?php
while (bp_profile_fields()) {
bp_the_profile_field();
?>
<div<?php
bp_field_css_class('bp-profile-field');
?>
>
<?php
$field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type());
$field_type->edit_field_html(array('user_id' => $r['user_id']));
if (bp_get_the_profile_field_description()) {
?>
<p class="description"><?php
bp_the_profile_field_description();
?>
</p>
<?php
}
/**
* Fires before display of visibility form elements for profile metaboxes.
*
* @since 1.7.0
*/
do_action('bp_custom_profile_edit_fields_pre_visibility');
$can_change_visibility = bp_current_user_can('bp_xprofile_change_field_visibility');
?>
<p class="field-visibility-settings-<?php
echo $can_change_visibility ? 'toggle' : 'notoggle';
?>
" id="field-visibility-settings-toggle-<?php
bp_the_profile_field_id();
?>
">
<?php
printf(__('This field can be seen by: %s', 'buddypress'), '<span class="current-visibility-level">' . bp_get_the_profile_field_visibility_level_label() . '</span>');
?>
<?php
if ($can_change_visibility) {
?>
<a href="#" class="button visibility-toggle-link"><?php
esc_html_e('Change', 'buddypress');
?>
//.........这里部分代码省略.........
示例2: admin_new_field_html
/**
* Output HTML for this field type's children options on the wp-admin Profile Fields "Add Field" and "Edit Field" screens.
*
* You don't need to implement this method for all field types. It's used in core by the
* selectbox, multi selectbox, checkbox, and radio button fields, to allow the admin to
* enter the child option values (e.g. the choices in a select box).
*
* Must be used inside the {@link bp_profile_fields()} template loop.
*
* @param BP_XProfile_Field $current_field The current profile field on the add/edit screen.
* @param string $control_type Optional. HTML input type used to render the current field's child options.
* @since BuddyPress (2.0.0)
*/
public function admin_new_field_html(BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<h3><?php
esc_html_e('Please enter options for this Field:', 'buddypress');
?>
</h3>
<div class="inside">
<p>
<label for="sort_order_<?php
echo esc_attr($type);
?>
"><?php
esc_html_e('Sort Order:', 'buddypress');
?>
</label>
<select name="sort_order_<?php
echo esc_attr($type);
?>
" id="sort_order_<?php
echo esc_attr($type);
?>
" >
<option value="custom" <?php
selected('custom', $current_field->order_by);
?>
><?php
esc_html_e('Custom', 'buddypress');
?>
</option>
<option value="asc" <?php
selected('asc', $current_field->order_by);
?>
><?php
esc_html_e('Ascending', 'buddypress');
?>
</option>
<option value="desc" <?php
selected('desc', $current_field->order_by);
?>
><?php
esc_html_e('Descending', 'buddypress');
?>
</option>
</select>
</p>
<?php
$options = $current_field->get_children(true);
// If no children options exists for this field, check in $_POST for a submitted form (e.g. on the "new field" screen).
if (!$options) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
// Multiselectbox and checkboxes support MULTIPLE default options; all other core types support only ONE.
if ($current_type_obj->supports_options && !$current_type_obj->supports_multiple_defaults && isset($_POST["isDefault_{$type}_option"][$i]) && (int) $_POST["isDefault_{$type}_option"] === $i) {
$is_default_option = true;
} elseif (isset($_POST["isDefault_{$type}_option"][$i])) {
$is_default_option = (bool) $_POST["isDefault_{$type}_option"][$i];
} else {
$is_default_option = false;
}
// Grab the values from $_POST to use as the form's options
$options[] = (object) array('id' => -1, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
++$i;
}
// If there are still no children options set, this must be the "new field" screen, so add one new/empty option.
if (!$options) {
$options[] = (object) array('id' => -1, 'is_default_option' => false, 'name' => '');
}
}
// Render the markup for the children options
if (!empty($options)) {
//.........这里部分代码省略.........
示例3: xprofile_set_field_data
/**
* A simple function to set profile data for a specific field for a specific user.
*
* @package BuddyPress Core
* @param int|string $field The ID of the field, or the $name of the field.
* @param int|$user_id The ID of the user
* @param mixed $value The value for the field you want to set for the user.
* @param $is_required Whether or not the field is required
* @uses xprofile_get_field_id_from_name() Gets the ID for the field based on the name.
* @return bool True on success, false on failure.
*/
function xprofile_set_field_data($field, $user_id, $value, $is_required = false)
{
if (is_numeric($field)) {
$field_id = $field;
} else {
$field_id = xprofile_get_field_id_from_name($field);
}
if (empty($field_id)) {
return false;
}
$field = new BP_XProfile_Field($field_id);
$field_type = BP_XProfile_Field::get_type($field_id);
$field_type_obj = bp_xprofile_create_field_type($field_type);
/**
* Filter the raw submitted profile field value.
*
* Use this filter to modify the values submitted by users before
* doing field-type-specific validation.
*
* @since BuddyPress (2.1.0)
*
* @param mixed $value Value passed to xprofile_set_field_data()
* @param BP_XProfile_Field $field Field object.
* @param BP_XProfile_Field_Type $field_type_obj Field type object.
*/
$value = apply_filters('bp_xprofile_set_field_data_pre_validate', $value, $field, $field_type_obj);
// Special-case support for integer 0 for the number field type
if ($is_required && !is_integer($value) && $value !== '0' && (empty($value) || !is_array($value) && !strlen(trim($value)))) {
return false;
}
/**
* Certain types of fields (checkboxes, multiselects) may come through empty.
* Save as empty array so this isn't overwritten by the default on next edit.
*
* Special-case support for integer 0 for the number field type
*/
if (empty($value) && !is_integer($value) && $value !== '0' && $field_type_obj->accepts_null_value) {
$value = array();
}
// If the value is empty, then delete any field data that exists, unless the field is of a type where null values are semantically meaningful
if (empty($value) && !is_integer($value) && $value !== '0' && !$field_type_obj->accepts_null_value) {
xprofile_delete_field_data($field_id, $user_id);
return true;
}
// For certain fields, only certain parameters are acceptable, so add them to the whitelist.
if ($field_type_obj->supports_options) {
$field_type_obj->set_whitelist_values(wp_list_pluck($field->get_children(), 'name'));
}
// Check the value is in an accepted format for this form field.
if (!$field_type_obj->is_valid($value)) {
return false;
}
$field = new BP_XProfile_ProfileData();
$field->field_id = $field_id;
$field->user_id = $user_id;
$field->value = maybe_serialize($value);
return $field->save();
}
示例4: while
?>
<div class="clear"></div>
<?php
while (bp_profile_fields()) {
bp_the_profile_field();
?>
<div<?php
bp_field_css_class('editfield');
?>
>
<?php
$field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type());
$field_type->edit_field_html();
/**
* Fires before the display of visibility options for the field.
*
* @since 1.7.0
*/
do_action('bp_custom_profile_edit_fields_pre_visibility');
?>
<?php
if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
?>
<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php
bp_the_profile_field_id();
?>
示例5: admin_new_field_html
/**
* Output HTML for this field type's children options on the wp-admin Profile Fields "Add Field" and "Edit Field" screens.
*
* You don't need to implement this method for all field types. It's used in core by the
* selectbox, multi selectbox, checkbox, and radio button fields, to allow the admin to
* enter the child option values (e.g. the choices in a select box).
*
* Must be used inside the {@link bp_profile_fields()} template loop.
*
* @since 2.0.0
*
* @param BP_XProfile_Field $current_field The current profile field on the add/edit screen.
* @param string $control_type Optional. HTML input type used to render the current
* field's child options.
*/
public function admin_new_field_html(BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<h3><?php
esc_html_e('Please enter options for this Field:', 'buddypress');
?>
</h3>
<div class="inside" aria-live="polite" aria-atomic="true" aria-relevant="all">
<p>
<label for="sort_order_<?php
echo esc_attr($type);
?>
"><?php
esc_html_e('Sort Order:', 'buddypress');
?>
</label>
<select name="sort_order_<?php
echo esc_attr($type);
?>
" id="sort_order_<?php
echo esc_attr($type);
?>
" >
<option value="custom" <?php
selected('custom', $current_field->order_by);
?>
><?php
esc_html_e('Custom', 'buddypress');
?>
</option>
<option value="asc" <?php
selected('asc', $current_field->order_by);
?>
><?php
esc_html_e('Ascending', 'buddypress');
?>
</option>
<option value="desc" <?php
selected('desc', $current_field->order_by);
?>
><?php
esc_html_e('Descending', 'buddypress');
?>
</option>
</select>
</p>
<?php
// Does option have children?
$options = $current_field->get_children(true);
// If no children options exists for this field, check in $_POST
// for a submitted form (e.g. on the "new field" screen).
if (empty($options)) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
// Multiselectbox and checkboxes support MULTIPLE default options; all other core types support only ONE.
if ($current_type_obj->supports_options && !$current_type_obj->supports_multiple_defaults && isset($_POST["isDefault_{$type}_option"][$i]) && (int) $_POST["isDefault_{$type}_option"] === $i) {
$is_default_option = true;
} elseif (isset($_POST["isDefault_{$type}_option"][$i])) {
$is_default_option = (bool) $_POST["isDefault_{$type}_option"][$i];
} else {
$is_default_option = false;
}
// Grab the values from $_POST to use as the form's options.
$options[] = (object) array('id' => -1, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
++$i;
}
// If there are still no children options set, this must be the "new field" screen, so add one new/empty option.
if (empty($options)) {
$options[] = (object) array('id' => -1, 'is_default_option' => false, 'name' => '');
//.........这里部分代码省略.........
示例6: admin_new_field_html
public function admin_new_field_html(\BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
$options = $current_field->get_children(true);
if (!$options) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
if ($current_type_obj->supports_options && !$current_type_obj->supports_multiple_defaults && isset($_POST["isDefault_{$type}_option"][$i]) && (int) $_POST["isDefault_{$type}_option"] === $i) {
$is_default_option = true;
} elseif (isset($_POST["isDefault_{$type}_option"][$i])) {
$is_default_option = (bool) $_POST["isDefault_{$type}_option"][$i];
} else {
$is_default_option = false;
}
$options[] = (object) array('id' => -1, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
++$i;
}
if (!$options) {
$options[] = (object) array('id' => -1, 'is_default_option' => false, 'name' => '');
}
}
$taxonomies = get_taxonomies(array('public' => true, '_builtin' => false));
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<?php
if (!$taxonomies) {
?>
<h3><?php
_e('There is no custom taxonomy. You need to create at least one to use this field.', 'bxcft');
?>
</h3>
<?php
} else {
?>
<h3><?php
esc_html_e('Select a custom taxonomy:', 'bxcft');
?>
</h3>
<div class="inside">
<p>
<?php
_e('Select a custom taxonomy:', 'bxcft');
?>
<select name="<?php
echo esc_attr("{$type}_option[1]");
?>
" id="<?php
echo esc_attr("{$type}_option[1]");
?>
">
<option value=""><?php
_e('Select...', 'bxcft');
?>
</option>
<?php
foreach ($taxonomies as $k => $v) {
?>
<option value="<?php
echo $k;
?>
"<?php
if ($options[0]->name == $k) {
?>
selected="selected"<?php
}
?>
><?php
echo $v;
?>
</option>
<?php
}
?>
</select>
</p>
</div>
<?php
}
?>
</div>
<?php
}
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:94,代码来源:Bxcft_Field_Type_SelectCustomTaxonomy.php
示例7: render_admin_form_children
/**
* This function populates the items for radio buttons checkboxes and drop
* down boxes.
*/
public function render_admin_form_children()
{
foreach (array_keys(bp_xprofile_get_field_types()) as $field_type) {
$type_obj = bp_xprofile_create_field_type($field_type);
$type_obj->admin_new_field_html($this);
}
}
示例8: admin_new_field_html
public function admin_new_field_html(\BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
$options = $current_field->get_children(true);
if (!$options) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
$is_default_option = true;
$options[] = (object) array('id' => -1, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
++$i;
}
if (!$options) {
$options[] = (object) array('id' => -1, 'is_default_option' => false, 'name' => '2');
}
}
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<h3><?php
esc_html_e('Select max number of decimals:', 'bxcft');
?>
</h3>
<div class="inside">
<p>
<select name="<?php
echo esc_attr("{$type}_option[1]");
?>
" id="<?php
echo esc_attr("{$type}_option1");
?>
">
<?php
for ($j = 1; $j <= 6; $j++) {
?>
<option value="<?php
echo $j;
?>
"<?php
if ($j === (int) $options[0]->name) {
?>
selected="selected"<?php
}
?>
><?php
echo $j;
?>
</option>
<?php
}
?>
</select>
</p>
</div>
</div>
<?php
}
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:67,代码来源:Bxcft_Field_Type_DecimalNumber.php
示例9: admin_new_field_html
public function admin_new_field_html(\BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
$options = $current_field->get_children(true);
$min = '';
$max = '';
if (!$options) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
$is_default_option = true;
$options[] = (object) array('id' => -1, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
++$i;
}
if (!$options) {
$options[] = (object) array('id' => -1, 'is_default_option' => false, 'name' => '2');
}
} else {
foreach ($options as $o) {
if (strpos($o->name, 'min_') !== false) {
$min = str_replace('min_', '', $o->name);
}
if (strpos($o->name, 'max_') !== false) {
$max = str_replace('max_', '', $o->name);
}
}
}
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<h3><?php
esc_html_e('Write min and max values. You can leave any field blank if you want.', 'bxcft');
?>
</h3>
<div class="inside">
<p>
<label for="<?php
echo esc_attr("{$type}_option1");
?>
">
<?php
esc_html_e('Minimum:', 'bxcft');
?>
</label>
<input type="text" name="<?php
echo esc_attr("{$type}_option[1]");
?>
"
id="<?php
echo esc_attr("{$type}_option1");
?>
" value="<?php
echo $min;
?>
" />
<label for="<?php
echo esc_attr("{$type}_option2");
?>
">
<?php
esc_html_e('Maximum:', 'bxcft');
?>
</label>
<input type="text" name="<?php
echo esc_attr("{$type}_option[2]");
?>
"
id="<?php
echo esc_attr("{$type}_option2");
?>
" value="<?php
echo $max;
?>
" />
</p>
</div>
</div>
<script>
var error_msg_number_minmax = '<?php
esc_html_e("Min value cannot be bigger than max value.", "bxcft");
?>
',
error_msg_number_minmax_empty = '<?php
esc_html_e("You have to fill at least one field.", "bxcft");
?>
';
</script>
<?php
}
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:99,代码来源:Bxcft_Field_Type_NumberMinMax.php
示例10: test_placeholder_validate_any_value
/**
* @group BP_XProfile_Field_Group_Type_Placeholder
*/
public function test_placeholder_validate_any_value()
{
$field = bp_xprofile_create_field_type('foo');
$this->assertTrue($field->is_valid(''));
$this->assertTrue($field->is_valid('bar'));
$this->assertTrue($field->is_valid(array('bar')));
}
示例11: may_be_show_field
public function may_be_show_field()
{
$field_id = bp_get_the_profile_field_id();
if (!$this->was_shown($field_id) && in_array(bp_get_the_profile_field_type(), $this->field_types)) {
$field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type());
$field_type->edit_field_html();
}
}
开发者ID:buddydev,项目名称:bp-xprofile-member-type-field,代码行数:8,代码来源:bp-xprofile-member-type-field-loader.php
示例12: admin_new_field_html
public function admin_new_field_html(\BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
$text = '';
$options = $current_field->get_children(true);
if (!$options) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
if ($current_type_obj->supports_options && !$current_type_obj->supports_multiple_defaults && isset($_POST["isDefault_{$type}_option"][$i]) && (int) $_POST["isDefault_{$type}_option"] === $i) {
$is_default_option = true;
} elseif (isset($_POST["isDefault_{$type}_option"][$i])) {
$is_default_option = (bool) $_POST["isDefault_{$type}_option"][$i];
} else {
$is_default_option = false;
}
$options[] = (object) array('id' => 0, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
$text .= sanitize_text_field(stripslashes($_POST[$type . '_option'][$i]));
++$i;
}
if (!$options) {
$options[] = (object) array('id' => 0, 'is_default_option' => false, 'name' => '');
}
} else {
foreach ($options as $option) {
$text .= rawurldecode($option->name);
}
}
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<h3><?php
esc_html_e('Use this field to write a text that should be displayed beside the checkbox:', 'bxcft');
?>
</h3>
<div class="inside">
<p>
<textarea name="<?php
echo esc_attr("{$type}_text");
?>
"
id="<?php
echo esc_attr("{$type}_text");
?>
" rows="5" cols="60"><?php
echo $text;
?>
</textarea>
</p>
</div>
<?php
if ($options) {
$i = 1;
?>
<?php
foreach ($options as $option) {
?>
<input type="hidden" name="<?php
echo esc_attr("{$type}_option[{$i}]");
?>
"
id ="<?php
echo esc_attr("{$type}_option{$i}");
?>
" value="<?php
echo $option->name;
?>
" />
<?php
$i++;
}
?>
<?php
}
?>
</div>
<?php
}
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:88,代码来源:Bxcft_Field_Type_CheckboxAcceptance.php
示例13: xprofile_admin_field
/**
* Handles the WYSIWYG display of each profile field on the edit screen.
*
* @since 1.5.0
*
* @param object $admin_field Admin field.
* @param object $admin_group Admin group object.
* @param string $class Classes to append to output.
*/
function xprofile_admin_field($admin_field, $admin_group, $class = '')
{
global $field;
$field = $admin_field;
?>
<fieldset id="draggable_field_<?php
echo esc_attr($field->id);
?>
"class="sortable<?php
echo ' ' . $field->type;
if (!empty($class)) {
echo ' ' . $class;
}
?>
">
<legend>
<span>
<?php
bp_the_profile_field_name();
?>
<?php
if (empty($field->can_delete)) {
esc_html_e('(Primary)', 'buddypress');
}
?>
<?php
bp_the_profile_field_required_label();
?>
<?php
if (bp_xprofile_get_meta($field->id, 'field', 'signup_position')) {
esc_html_e('(Sign-up)', 'buddypress');
}
?>
<?php
if (bp_get_member_types()) {
echo $field->get_member_type_label();
}
?>
<?php
/**
* Fires at end of legend above the name field in base xprofile group.
*
* @since 2.2.0
*
* @param BP_XProfile_Field $field Current BP_XProfile_Field
* object being rendered.
*/
do_action('xprofile_admin_field_name_legend', $field);
?>
</span>
</legend>
<div class="field-wrapper">
<?php
if (in_array($field->type, array_keys(bp_xprofile_get_field_types()))) {
$field_type = bp_xprofile_create_field_type($field->type);
$field_type->admin_field_html();
} else {
/**
* Fires after the input if the current field is not in default field types.
*
* @since 1.5.0
*
* @param BP_XProfile_Field $field Current BP_XProfile_Field
* object being rendered.
* @param int $value Integer 1.
*/
do_action('xprofile_admin_field', $field, 1);
}
?>
<?php
if ($field->description) {
?>
<p class="description"><?php
echo esc_attr($field->description);
?>
</p>
<?php
}
?>
<div class="actions">
<a class="button edit" href="users.php?page=bp-profile-setup&group_id=<?php
echo esc_attr($admin_group->id);
?>
//.........这里部分代码省略.........
示例14: admin_new_field_html
public function admin_new_field_html(\BP_XProfile_Field $current_field, $control_type = '')
{
$type = array_search(get_class($this), bp_xprofile_get_field_types());
if (false === $type) {
return;
}
$class = $current_field->type != $type ? 'display: none;' : '';
$current_type_obj = bp_xprofile_create_field_type($type);
$options = $current_field->get_children(true);
if (!$options) {
$options = array();
$i = 1;
while (isset($_POST[$type . '_option'][$i])) {
$is_default_option = true;
$options[] = (object) array('id' => -1, 'is_default_option' => $is_default_option, 'name' => sanitize_text_field(stripslashes($_POST[$type . '_option'][$i])));
++$i;
}
if (!$options) {
$options[] = (object) array('id' => -1, 'is_default_option' => false, 'name' => '');
}
}
?>
<div id="<?php
echo esc_attr($type);
?>
" class="postbox bp-options-box" style="<?php
echo esc_attr($class);
?>
margin-top: 15px;">
<h3><?php
esc_html_e('Show age (hide birthdate):', 'bxcft');
?>
</h3>
<div class="inside">
<p>
<?php
_e('Check this if you want to show age instead of birthdate:', 'bxcft');
?>
<input type="hidden" name="<?php
echo esc_attr("{$type}_option[0]");
?>
" id="<?php
echo esc_attr("{$type}_option0");
?>
" value="show_birthdate" />
<input type="checkbox" name="<?php
echo esc_attr("{$type}_option[1]");
?>
" id="<?php
echo esc_attr("{$type}_option1");
?>
" value="show_age"
<?php
if ($options[0]->name == 'show_age') {
?>
checked="checked"<?php
}
?>
/>
</p>
</div>
</div>
<?php
}
开发者ID:baden03,项目名称:buddypress-xprofile-custom-fields-type,代码行数:64,代码来源:Bxcft_Field_Type_Birthdate.php
示例15: user_admin_profile_metaboxes
/**
* Render the xprofile metabox for Community Profile screen.
*
* @access public
* @since BuddyPress (2.0.0)
*
* @param WP_User $user The WP_User object for the user being edited.
*/
public function user_admin_profile_metaboxes($user = null, $args = array())
{
if (empty($user->ID)) {
return;
}
$r = bp_parse_args($args['args'], array('profile_group_id' => 0, 'user_id' => $user->ID), 'bp_xprofile_user_admin_profile_loop_args');
// We really need these args
if (empty($r['profile_group_id']) || empty($r['user_id'])) {
return;
}
if (bp_has_profile($r)) {
while (bp_profile_groups()) {
bp_the_profile_group();
?>
<input type="hidden" name="field_ids[]" id="<?php
echo esc_attr('field_ids_' . bp_get_the_profile_group_slug());
?>
" value="<?php
echo esc_attr(bp_get_the_profile_group_field_ids());
?>
" />
<?php
if (bp_get_the_profile_group_description()) {
?>
<p class="description"><?php
bp_the_profile_group_description();
?>
</p>
<?php
}
while (bp_profile_fields()) {
bp_the_profile_field();
?>
<div<?php
bp_field_css_class('bp-profile-field');
?>
>
<?php
$field_type = bp_xprofile_create_field_type(bp_get_the_profile_field_type());
$field_type->edit_field_html(array('user_id' => $r['user_id']));
if (bp_get_the_profile_field_description()) {
?>
<p class="description"><?php
bp_the_profile_field_description();
?>
</p>
<?php
}
do_action('bp_custom_profile_edit_fields_pre_visibility');
$can_change_visibility = bp_current_user_can('bp_xprofile_change_field_visibility');
?>
<p class="field-visibility-settings-<?php
echo $can_change_visibility ? 'toggle' : 'notoggle';
?>
" id="field-visibility-settings-toggle-<?php
bp_the_profile_field_id();
?>
">
<?php
printf(__('This field can be seen by: <span class="%s">%s</span>', 'buddypress'), esc_attr('current-visibility-level'), bp_get_the_profile_field_visibility_level_label());
if ($can_change_visibility) {
?>
<a href="#" class="button visibility-toggle-link"><?php
_e('Change', 'buddypress');
?>
</a>
<?php
}
?>
</p>
<?php
if ($can_change_visibility) {
?>
<div class="field-visibility-settings" id="field-visibility-settings-<?php
bp_the_profile_field_id();
?>
">
<fieldset>
<legend><?php
_e('Who can see this field?', 'buddypress');
?>
</legend>
<?php
bp_profile_visibility_radio_buttons();
?>
</fieldset>
<a class="button field-visibility-settings-close" href="#"><?php
_e('Close', 'buddypress');
//.........这里部分代码省略.........