- fixed admin forms;

This commit is contained in:
nikitasinelnikov
2018-12-13 18:54:36 +02:00
parent 2203007194
commit 3e89e9e9f8
4 changed files with 28 additions and 22 deletions
+1 -3
View File
@@ -19,10 +19,8 @@ jQuery(document).ready( function() {
var selector_html = jQuery( '<div>' ).append( list.siblings('.um-hidden-multi-selects').clone() ).html();
var classes = list.find('li:last').attr('class');
list.append(
'<li class="' + classes + '"><span class="um-field-wrapper">' + selector_html +
'<li class="um-multi-selects-option-line"><span class="um-field-wrapper">' + selector_html +
'</span><span class="um-field-control"><a href="javascript:void(0);" class="um-select-delete">' + php_data.texts.remove + '</a></span></li>'
);
+11 -6
View File
@@ -774,8 +774,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
*/
function render_multi_selects( $field_data ) {
if ( empty( $field_data['id'] ) )
if ( empty( $field_data['id'] ) ) {
return false;
}
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
@@ -801,7 +802,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$values = $this->get_field_value( $field_data );
$options = '';
foreach ( $field_data['options'] as $key=>$option ) {
foreach ( $field_data['options'] as $key => $option ) {
$options .= '<option value="' . $key . '">' . $option . '</option>';
}
@@ -809,12 +810,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$html .= "<ul class=\"um-multi-selects-list\" $data_attr>";
if ( ! empty( $values ) ) {
foreach ( $values as $k=>$value ) {
foreach ( $values as $k => $value ) {
if ( ! in_array( $value, array_keys( $field_data['options'] ) ) ) {
continue ;
}
$id_attr = ' id="' . $id . '-' . $k . '" ';
$options = '';
foreach ( $field_data['options'] as $key=>$option ) {
foreach ( $field_data['options'] as $key => $option ) {
$options .= '<option value="' . $key . '" ' . selected( $key == $value, true, false ) . '>' . $option . '</option>';
}
@@ -824,11 +829,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
} elseif ( ! empty( $field_data['show_default_number'] ) && is_numeric( $field_data['show_default_number'] ) && $field_data['show_default_number'] > 0 ) {
$i = 0;
while( $i < $field_data['show_default_number'] ) {
while ( $i < $field_data['show_default_number'] ) {
$id_attr = ' id="' . $id . '-' . $i . '" ';
$options = '';
foreach ( $field_data['options'] as $key=>$option ) {
foreach ( $field_data['options'] as $key => $option ) {
$options .= '<option value="' . $key . '">' . $option . '</option>';
}
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
$premium['bbpress'] = array(
'url' => 'https://ultimatemember.com/extensions/bbpress/',
'image' => 'https://ultimatemember.com/wp-content/uploads/edd/2017/05/bbpress.png',
@@ -1,25 +1,27 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<div class="um-admin-metabox">
<?php $user_fields = array();
foreach ( UM()->builtin()->all_user_fields() as $key => $arr ) {
$user_fields[$key] = isset( $arr['title'] ) ? $arr['title'] : '';
$user_fields[ $key ] = isset( $arr['title'] ) ? $arr['title'] : '';
}
$post_id = get_the_ID();
$_um_search_fields = get_post_meta( $post_id, '_um_profile_metafields', true );
UM()->admin_forms( array(
'class' => 'um-form-profile-settings um-top-label',
'prefix_id' => 'form',
'fields' => array(
'class' => 'um-form-profile-settings um-top-label',
'prefix_id' => 'form',
'fields' => array(
array(
'id' => '_um_profile_metafields',
'type' => 'multi_selects',
'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ),
'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ),
'value' => $_um_search_fields,
'options' => $user_fields,
'add_text' => __( 'Add New Field', 'ultimate-member' ),
'show_default_number' => 1,
'id' => '_um_profile_metafields',
'type' => 'multi_selects',
'label' => __( 'Field(s) to show in user meta', 'ultimate-member' ),
'tooltip' => __( 'Fields selected here will appear in the profile header area below the user\'s display name', 'ultimate-member' ),
'value' => $_um_search_fields,
'options' => $user_fields,
'add_text' => __( 'Add New Field', 'ultimate-member' ),
'show_default_number' => 1,
)
)
) )->render_form(); ?>