mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 10:46:11 +09:00
- changed form builder > icon field to new dropdown type;
This commit is contained in:
@@ -140,6 +140,13 @@
|
||||
width: 33%;
|
||||
position: relative;
|
||||
}
|
||||
.um-admin-tri[data-select2-id] {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
._heading_text[data-select2-id] {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.um-admin-error-block,
|
||||
.um-admin-success-block {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -98,7 +98,12 @@
|
||||
float: left
|
||||
width: 33%
|
||||
position: relative
|
||||
&[data-select2-id]
|
||||
position: relative
|
||||
|
||||
._heading_text
|
||||
&[data-select2-id]
|
||||
position: relative
|
||||
|
||||
.#{$prefix}admin-error-block,
|
||||
.#{$prefix}admin-success-block
|
||||
|
||||
@@ -6261,7 +6261,7 @@
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.ttf") format("truetype");
|
||||
src: url("../libs/fontawesome/webfonts/fa-brands-400.woff2") format("woff2"), url("../libs/fontawesome/webfonts/fa-brands-400.ttf") format("truetype");
|
||||
}
|
||||
.um .fab,
|
||||
.um .fa-brands {
|
||||
@@ -7851,7 +7851,7 @@
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.ttf") format("truetype");
|
||||
src: url("../libs/fontawesome/webfonts/fa-regular-400.woff2") format("woff2"), url("../libs/fontawesome/webfonts/fa-regular-400.ttf") format("truetype");
|
||||
}
|
||||
.um .far,
|
||||
.um .fa-regular {
|
||||
@@ -7866,7 +7866,7 @@
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
font-display: block;
|
||||
src: url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.ttf") format("truetype");
|
||||
src: url("../libs/fontawesome/webfonts/fa-solid-900.woff2") format("woff2"), url("../libs/fontawesome/webfonts/fa-solid-900.ttf") format("truetype");
|
||||
}
|
||||
.um .fas,
|
||||
.um .fa-solid {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
//$fa-css-prefix: 'um .fa'
|
||||
$fa-font-path: "../libs/fontawesome/webfonts"
|
||||
|
||||
.um
|
||||
@import "../libs/fontawesome/scss/fontawesome.scss"
|
||||
|
||||
@@ -188,6 +188,7 @@ wp.hooks.addAction( 'um_admin_modal_success_result', 'um_admin_builder', functio
|
||||
|
||||
UM.admin.colorPicker.init();
|
||||
UM.common.datetimePicker.init();
|
||||
UM.admin.iconSelector.init();
|
||||
});
|
||||
|
||||
wp.hooks.addAction( 'um_admin_modal_resize', 'um_admin_builder', function() {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -33,10 +33,78 @@ UM.admin = {
|
||||
$colorPicker.wpColorPicker();
|
||||
}
|
||||
}
|
||||
},
|
||||
iconSelector: {
|
||||
init: function () {
|
||||
let $iconSelector = jQuery('.um-icon-select-field');
|
||||
if ( $iconSelector.length ) {
|
||||
|
||||
function iformat( icon ) {
|
||||
let originalOption = icon.element;
|
||||
if ( 'undefined' !== typeof originalOption ) {
|
||||
return jQuery('<span><i class="' + jQuery( originalOption ).val() + '"></i> ' + icon.text + '</span>');
|
||||
} else {
|
||||
return jQuery('<span><i class="' + icon.id + '"></i> ' + icon.text + '</span>');
|
||||
}
|
||||
}
|
||||
|
||||
let select2_atts = {
|
||||
ajax: {
|
||||
url: wp.ajax.settings.url,
|
||||
dataType: 'json',
|
||||
delay: 250, // delay in ms while typing when to perform a AJAX search
|
||||
data: function( params ) {
|
||||
return {
|
||||
search: params.term, // search query
|
||||
action: 'um_get_icons', // AJAX action for admin-ajax.php
|
||||
page: params.page || 1, // infinite scroll pagination
|
||||
nonce: um_admin_scripts.nonce
|
||||
};
|
||||
},
|
||||
processResults: function( response, params ) {
|
||||
params.page = params.page || 1;
|
||||
var options = [];
|
||||
|
||||
if ( response.data.icons ) {
|
||||
// data is the array of arrays, and each of them contains ID and the Label of the option
|
||||
jQuery.each( response.data.icons, function( index, text ) {
|
||||
options.push( { id: index, text: text.label } );
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
results: options,
|
||||
pagination: {
|
||||
more: ( params.page * 50 ) < response.data.total_count
|
||||
}
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
minimumInputLength: 0, // the minimum of symbols to input before perform a search
|
||||
allowClear: true,
|
||||
width: "100%",
|
||||
allowHtml: true,
|
||||
templateSelection: iformat,
|
||||
templateResult: iformat,
|
||||
dropdownCssClass: 'um-select2-icon-dropdown',
|
||||
containerCssClass : 'um-select2-icon-container'
|
||||
};
|
||||
|
||||
if ( $iconSelector.parents('.um-admin-tri').length ) {
|
||||
select2_atts.dropdownParent = $iconSelector.parents('.um-admin-tri');
|
||||
} else if ( $iconSelector.parents('._heading_text').length ) {
|
||||
select2_atts.dropdownParent = $iconSelector.parents('._heading_text');
|
||||
}
|
||||
|
||||
$iconSelector.select2( select2_atts );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
UM.admin.tooltip.init();
|
||||
UM.admin.colorPicker.init();
|
||||
UM.admin.iconSelector.init();
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
"object"!=typeof window.UM&&(window.UM={}),"object"!=typeof window.UM.admin&&(window.UM.admin={}),UM.admin={tooltip:{all:null,init:function(){var o=jQuery(".um_tooltip");0<o.length&&(UM.admin.tooltip.all=o.tooltip({tooltipClass:"um_tooltip",content:function(){return jQuery(this).attr("title")}}))},close:function(){null!==UM.admin.tooltip.all&&0<UM.admin.tooltip.all&&"function"==typeof UM.admin.tooltip.all.tooltip&&UM.admin.tooltip.all.tooltip("close")}},colorPicker:{init:function(){var o=jQuery(".um-admin-colorpicker");o.length&&o.wpColorPicker()}}},jQuery(document).ready(function(){UM.admin.tooltip.init(),UM.admin.colorPicker.init()});
|
||||
"object"!=typeof window.UM&&(window.UM={}),"object"!=typeof window.UM.admin&&(window.UM.admin={}),UM.admin={tooltip:{all:null,init:function(){var t=jQuery(".um_tooltip");0<t.length&&(UM.admin.tooltip.all=t.tooltip({tooltipClass:"um_tooltip",content:function(){return jQuery(this).attr("title")}}))},close:function(){null!==UM.admin.tooltip.all&&0<UM.admin.tooltip.all&&"function"==typeof UM.admin.tooltip.all.tooltip&&UM.admin.tooltip.all.tooltip("close")}},colorPicker:{init:function(){var t=jQuery(".um-admin-colorpicker");t.length&&t.wpColorPicker()}},iconSelector:{init:function(){var t,n=jQuery(".um-icon-select-field");function e(t){var n=t.element;return void 0!==n?jQuery('<span><i class="'+jQuery(n).val()+'"></i> '+t.text+"</span>"):jQuery('<span><i class="'+t.id+'"></i> '+t.text+"</span>")}n.length&&(t={ajax:{url:wp.ajax.settings.url,dataType:"json",delay:250,data:function(t){return{search:t.term,action:"um_get_icons",page:t.page||1,nonce:um_admin_scripts.nonce}},processResults:function(t,n){n.page=n.page||1;var e=[];return t.data.icons&&jQuery.each(t.data.icons,function(t,n){e.push({id:t,text:n.label})}),{results:e,pagination:{more:50*n.page<t.data.total_count}}},cache:!0},minimumInputLength:0,allowClear:!0,width:"100%",allowHtml:!0,templateSelection:e,templateResult:e,dropdownCssClass:"um-select2-icon-dropdown",containerCssClass:"um-select2-icon-container"},n.parents(".um-admin-tri").length?t.dropdownParent=n.parents(".um-admin-tri"):n.parents("._heading_text").length&&(t.dropdownParent=n.parents("._heading_text")),n.select2(t))}}},jQuery(document).ready(function(){UM.admin.tooltip.init(),UM.admin.colorPicker.init(),UM.admin.iconSelector.init()});
|
||||
@@ -30,7 +30,12 @@ UM.admin.modal = {
|
||||
UM.common.tipsy.hide();
|
||||
|
||||
jQuery('body').removeClass('um-admin-modal-open');
|
||||
jQuery('.um-admin-modal div[id^="UM_"]').hide().appendTo('body');
|
||||
|
||||
let $modalBlock = jQuery('.um-admin-modal div[id^="UM_"]');
|
||||
let $modalInner = $modalBlock.find( '.um-admin-modal-body.um-admin-metabox' );
|
||||
$modalInner.html('').attr('data-select2-id', null);
|
||||
$modalBlock.hide().appendTo('body');
|
||||
|
||||
jQuery('.um-admin-modal,.um-admin-overlay').remove();
|
||||
},
|
||||
resize: function () {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -624,7 +624,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
'sanitize' => 'text',
|
||||
),
|
||||
'_icon' => array(
|
||||
'sanitize' => 'key',
|
||||
'sanitize' => 'text',
|
||||
),
|
||||
'_css_class' => array(
|
||||
'sanitize' => 'text',
|
||||
|
||||
@@ -392,7 +392,8 @@ final class Enqueue extends \um\common\Enqueue {
|
||||
wp_localize_script( 'um_admin_forms', 'um_forms_data', $forms_data );
|
||||
wp_enqueue_script( 'um_admin_forms' );
|
||||
|
||||
wp_register_style( 'um_admin_forms', $css_url . 'admin/forms' . $suffix . '.css', array( 'wp-color-picker', 'um_ui', 'select2' ), UM_VERSION );
|
||||
$deps = array_merge( array( 'wp-color-picker', 'um_ui', 'select2' ), self::$fonticons_handlers );
|
||||
wp_register_style( 'um_admin_forms', $css_url . 'admin/forms' . $suffix . '.css', $deps, UM_VERSION );
|
||||
// RTL styles.
|
||||
if ( is_rtl() ) {
|
||||
wp_style_add_data( 'um_admin_forms', 'rtl', true );
|
||||
|
||||
@@ -541,42 +541,82 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
|
||||
if ( empty( $field_data['id'] ) ) {
|
||||
return false;
|
||||
}
|
||||
$html = '';
|
||||
|
||||
// Required modal scripts for proper functioning
|
||||
UM()->admin()->enqueue()->load_modal();
|
||||
$first_activation_date = get_option( 'um_first_activation_date', false );
|
||||
// @todo new version
|
||||
if ( empty( $first_activation_date ) || $first_activation_date >= 1713342395 || UM()->options()->get( 'enable_new_fonticons' ) ) {
|
||||
UM()->setup()->set_icons_options();
|
||||
|
||||
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
||||
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
||||
$um_icons_list = get_option( 'um_icons_list' );
|
||||
|
||||
$name = $field_data['id'];
|
||||
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
||||
$name_attr = ' name="' . esc_attr( $name ) . '" ';
|
||||
if ( 'row' === $this->set_field_type ) {
|
||||
?>
|
||||
|
||||
$value = $this->get_field_value( $field_data );
|
||||
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
||||
<p class="_heading_text">
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<select name="_icon" id="_icon" class="um-icon-select-field" data-placeholder="<?php esc_attr_e( 'Select Icon', 'ultimate-member' ); ?>" >
|
||||
<option value=""><?php esc_html_e( 'Select Icon', 'ultimate-member' ); ?></option>
|
||||
<?php if ( ! empty( $this->edit_mode_value ) && array_key_exists( $this->edit_mode_value, $um_icons_list ) ) { ?>
|
||||
<option value="<?php echo esc_attr( $this->edit_mode_value ); ?>" selected><?php echo esc_html( $um_icons_list[ $this->edit_mode_value ]['label'] ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
$html = '<span class="um_admin_fonticon_wrapper"><a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="" data-icon_field="' . esc_attr( $id ) . '">' . esc_html__( 'Choose Icon', 'ultimate-member' ) . '</a>
|
||||
<span class="um-admin-icon-value">';
|
||||
<?php } else { ?>
|
||||
|
||||
if ( ! empty( $value ) ) {
|
||||
$html .= '<i class="' . esc_attr( $value ) . '"></i>';
|
||||
<div class="um-admin-tri">
|
||||
<p>
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<select name="_icon" id="_icon" class="um-icon-select-field" data-placeholder="<?php esc_attr_e( 'Select Icon', 'ultimate-member' ); ?>">
|
||||
<option value=""><?php esc_html_e( 'Select Icon', 'ultimate-member' ); ?></option>
|
||||
<?php if ( ! empty( $this->edit_mode_value ) && array_key_exists( $this->edit_mode_value, $um_icons_list ) ) { ?>
|
||||
<option value="<?php echo esc_attr( $this->edit_mode_value ); ?>" selected><?php echo esc_html( $um_icons_list[ $this->edit_mode_value ]['label'] ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
} else {
|
||||
$html .= esc_html__( 'No Icon', 'ultimate-member' );
|
||||
// Required modal scripts for proper functioning
|
||||
UM()->admin()->enqueue()->load_modal();
|
||||
|
||||
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
||||
$id_attr = ' id="' . esc_attr( $id ) . '" ';
|
||||
|
||||
$name = $field_data['id'];
|
||||
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
||||
$name_attr = ' name="' . esc_attr( $name ) . '" ';
|
||||
|
||||
$value = $this->get_field_value( $field_data );
|
||||
$value_attr = ' value="' . esc_attr( $value ) . '" ';
|
||||
|
||||
$html = '<span class="um_admin_fonticon_wrapper"><a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="" data-icon_field="' . esc_attr( $id ) . '">' . esc_html__( 'Choose Icon', 'ultimate-member' ) . '</a>
|
||||
<span class="um-admin-icon-value">';
|
||||
|
||||
if ( ! empty( $value ) ) {
|
||||
$html .= '<i class="' . esc_attr( $value ) . '"></i>';
|
||||
} else {
|
||||
$html .= esc_html__( 'No Icon', 'ultimate-member' );
|
||||
}
|
||||
|
||||
$html .= '</span><input type="hidden" ' . $name_attr . ' ' . $id_attr . ' ' . $value_attr . ' />';
|
||||
|
||||
if ( ! empty( $value ) ) {
|
||||
$html .= '<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>';
|
||||
} else {
|
||||
$html .= '<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>';
|
||||
}
|
||||
|
||||
$html .= '</span></span>';
|
||||
|
||||
// Required include the fonticons modal *.php file.
|
||||
UM()->metabox()->init_icon = true;
|
||||
}
|
||||
|
||||
$html .= '</span><input type="hidden" ' . $name_attr . ' ' . $id_attr . ' ' . $value_attr . ' />';
|
||||
|
||||
if ( ! empty( $value ) ) {
|
||||
$html .= '<span class="um-admin-icon-clear show"><i class="um-icon-android-cancel"></i></span>';
|
||||
} else {
|
||||
$html .= '<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>';
|
||||
}
|
||||
|
||||
$html .= '</span></span>';
|
||||
|
||||
// Required include the fonticons modal *.php file.
|
||||
UM()->metabox()->init_icon = true;
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
@@ -1320,6 +1320,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Old interface for icon selector in UM admin forms field-type 'icon'.
|
||||
if ( $this->init_icon ) {
|
||||
include_once UM_PATH . 'includes/admin/templates/modal/forms/fonticons.php';
|
||||
}
|
||||
@@ -1554,12 +1555,50 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
break;
|
||||
|
||||
case '_icon':
|
||||
if ( 'row' === $this->set_field_type ) {
|
||||
$back = 'UM_edit_row';
|
||||
?>
|
||||
<p class="_heading_text">
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<span class="um_admin_fonticon_wrapper">
|
||||
$first_activation_date = get_option( 'um_first_activation_date', false );
|
||||
// @todo new version
|
||||
if ( empty( $first_activation_date ) || $first_activation_date >= 1713342395 || UM()->options()->get( 'enable_new_fonticons' ) ) {
|
||||
UM()->setup()->set_icons_options();
|
||||
|
||||
$um_icons_list = get_option( 'um_icons_list' );
|
||||
|
||||
if ( 'row' === $this->set_field_type ) {
|
||||
?>
|
||||
|
||||
<p class="_heading_text">
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<select name="_icon" id="_icon" class="um-icon-select-field" data-placeholder="<?php esc_attr_e( 'Select Icon', 'ultimate-member' ); ?>" >
|
||||
<option value=""><?php esc_html_e( 'Select Icon', 'ultimate-member' ); ?></option>
|
||||
<?php if ( ! empty( $this->edit_mode_value ) && array_key_exists( $this->edit_mode_value, $um_icons_list ) ) { ?>
|
||||
<option value="<?php echo esc_attr( $this->edit_mode_value ); ?>" selected><?php echo esc_html( $um_icons_list[ $this->edit_mode_value ]['label'] ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<div class="um-admin-tri">
|
||||
<p>
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<select name="_icon" id="_icon" class="um-icon-select-field" data-placeholder="<?php esc_attr_e( 'Select Icon', 'ultimate-member' ); ?>">
|
||||
<option value=""><?php esc_html_e( 'Select Icon', 'ultimate-member' ); ?></option>
|
||||
<?php if ( ! empty( $this->edit_mode_value ) && array_key_exists( $this->edit_mode_value, $um_icons_list ) ) { ?>
|
||||
<option value="<?php echo esc_attr( $this->edit_mode_value ); ?>" selected><?php echo esc_html( $um_icons_list[ $this->edit_mode_value ]['label'] ); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
} else {
|
||||
if ( 'row' === $this->set_field_type ) {
|
||||
$back = 'UM_edit_row';
|
||||
?>
|
||||
<p class="_heading_text">
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<span class="um_admin_fonticon_wrapper">
|
||||
<a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php esc_html_e( 'Choose Icon', 'ultimate-member' ); ?></a>
|
||||
|
||||
<span class="um-admin-icon-value"><?php if ( ! empty( $this->edit_mode_value ) ) { ?><i class="<?php echo esc_attr( $this->edit_mode_value ); ?>"></i><?php } else { ?><?php esc_html_e( 'No Icon', 'ultimate-member' ); ?><?php } ?></span>
|
||||
@@ -1572,19 +1611,19 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
|
||||
<?php } ?>
|
||||
</span>
|
||||
</p>
|
||||
<?php
|
||||
} else {
|
||||
if ( $this->in_edit ) {
|
||||
$back = 'UM_edit_field';
|
||||
</p>
|
||||
<?php
|
||||
} else {
|
||||
$back = 'UM_add_field';
|
||||
}
|
||||
?>
|
||||
<div class="um-admin-tri">
|
||||
<p>
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<span class="um_admin_fonticon_wrapper">
|
||||
if ( $this->in_edit ) {
|
||||
$back = 'UM_edit_field';
|
||||
} else {
|
||||
$back = 'UM_add_field';
|
||||
}
|
||||
?>
|
||||
<div class="um-admin-tri">
|
||||
<p>
|
||||
<label for="_icon"><?php esc_html_e( 'Icon', 'ultimate-member' ); ?> <?php UM()->tooltip( __( 'Select an icon to appear in the field. Leave blank if you do not want an icon to show in the field.', 'ultimate-member' ) ); ?></label>
|
||||
<span class="um_admin_fonticon_wrapper">
|
||||
<a href="javascript:void(0);" class="button" data-modal="UM_fonticons" data-modal-size="normal" data-dynamic-content="um_admin_fonticon_selector" data-arg1="" data-arg2="" data-back="<?php echo esc_attr( $back ); ?>"><?php esc_html_e( 'Choose Icon', 'ultimate-member' ); ?></a>
|
||||
|
||||
<span class="um-admin-icon-value"><?php if ( ! empty( $this->edit_mode_value ) ) { ?><i class="<?php echo esc_attr( $this->edit_mode_value ); ?>"></i><?php } else { ?><?php esc_html_e( 'No Icon', 'ultimate-member' ) ?><?php } ?></span>
|
||||
@@ -1597,9 +1636,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
|
||||
<span class="um-admin-icon-clear"><i class="um-icon-android-cancel"></i></span>
|
||||
<?php } ?>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,23 +1,33 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) {
|
||||
<?php
|
||||
// @todo deprecate this way to select the icon as soon as possible.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
} ?>
|
||||
}
|
||||
|
||||
<div id="UM_fonticons" style="display:none">
|
||||
$first_activation_date = get_option( 'um_first_activation_date', false );
|
||||
// @todo new version
|
||||
if ( empty( $first_activation_date ) || $first_activation_date >= 1713342395 || UM()->options()->get( 'enable_new_fonticons' ) ) {
|
||||
|
||||
} else {
|
||||
?>
|
||||
<div id="UM_fonticons" style="display:none">
|
||||
|
||||
<div class="um-admin-modal-head">
|
||||
<h3>
|
||||
<?php
|
||||
// translators: %s: icons nubber.
|
||||
echo wp_kses( sprintf( __( 'Choose from %s available icons', 'ultimate-member' ), count( UM()->fonticons()->all ) ), UM()->get_allowed_html( 'admin_notice' ) );
|
||||
?>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="um-admin-modal-body"></div>
|
||||
|
||||
<div class="um-admin-modal-foot">
|
||||
<a href="javascript:void(0);" class="button-primary um-admin-modal-back" data-code=""><?php _e( 'Finish', 'ultimate-member' ) ?></a>
|
||||
<a href="javascript:void(0);" class="button um-admin-modal-back um-admin-modal-cancel" data-action="UM_remove_modal"><?php _e( 'Cancel', 'ultimate-member' ) ?></a>
|
||||
</div>
|
||||
|
||||
<div class="um-admin-modal-head">
|
||||
<h3>
|
||||
<?php
|
||||
// translators: %s: icons nubber.
|
||||
echo wp_kses( sprintf( __( 'Choose from %s available icons', 'ultimate-member' ), count( UM()->fonticons()->all ) ), UM()->get_allowed_html( 'admin_notice' ) );
|
||||
?>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="um-admin-modal-body"></div>
|
||||
|
||||
<div class="um-admin-modal-foot">
|
||||
<a href="javascript:void(0);" class="button-primary um-admin-modal-back" data-code=""><?php _e( 'Finish', 'ultimate-member' ) ?></a>
|
||||
<a href="javascript:void(0);" class="button um-admin-modal-back um-admin-modal-cancel" data-action="UM_remove_modal"><?php _e( 'Cancel', 'ultimate-member' ) ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace um\ajax;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Forms
|
||||
*
|
||||
* @package um\ajax
|
||||
*/
|
||||
class Forms {
|
||||
|
||||
/**
|
||||
* Forms constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_um_get_icons', array( $this, 'get_icons' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of the icons.
|
||||
*/
|
||||
public function get_icons() {
|
||||
UM()->admin()->check_ajax_nonce();
|
||||
|
||||
$search_request = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
|
||||
$page = ! empty( $_REQUEST['page'] ) ? absint( $_REQUEST['page'] ) : 1;
|
||||
$per_page = 50;
|
||||
|
||||
UM()->setup()->set_icons_options();
|
||||
|
||||
$um_icons_list = get_option( 'um_icons_list' );
|
||||
if ( ! empty( $search_request ) ) {
|
||||
$um_icons_list = array_filter(
|
||||
$um_icons_list,
|
||||
function( $item ) use ( $search_request ) {
|
||||
$result = array_filter(
|
||||
$item['search'],
|
||||
function( $search_item ) use ( $search_request ) {
|
||||
return stripos( $search_item, $search_request ) !== false;
|
||||
}
|
||||
);
|
||||
return count( $result ) > 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$total_count = count( $um_icons_list );
|
||||
|
||||
$um_icons_list = array_slice( $um_icons_list, $per_page * ( $page - 1 ), $per_page );
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'icons' => $um_icons_list,
|
||||
'total_count' => $total_count,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,23 @@ if ( ! class_exists( 'um\ajax\Init' ) ) {
|
||||
* @used-by \UM::includes()
|
||||
*/
|
||||
public function includes() {
|
||||
$this->forms();
|
||||
$this->pages();
|
||||
$this->secure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.8.6
|
||||
*
|
||||
* @return Forms
|
||||
*/
|
||||
public function forms() {
|
||||
if ( empty( UM()->classes['um\ajax\forms'] ) ) {
|
||||
UM()->classes['um\ajax\forms'] = new Forms();
|
||||
}
|
||||
return UM()->classes['um\ajax\forms'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.8.3
|
||||
*
|
||||
|
||||
@@ -38,6 +38,13 @@ class Enqueue {
|
||||
|
||||
public static $fonticons_handlers = array();
|
||||
|
||||
/**
|
||||
* FontAwesome version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $fa_version = '6.5.2';
|
||||
|
||||
/**
|
||||
* Enqueue constructor.
|
||||
*
|
||||
@@ -267,7 +274,7 @@ class Enqueue {
|
||||
// @todo new version
|
||||
if ( empty( $first_activation_date ) || $first_activation_date >= 1713342395 || UM()->options()->get( 'enable_new_fonticons' ) ) {
|
||||
// First install set this option to true by default and use new FontAwesome icons
|
||||
wp_register_style( 'um_fontawesome', $css_url . 'um-fontawesome' . $suffix . '.css', array(), '6.5.2' ); // New FontAwesome
|
||||
wp_register_style( 'um_fontawesome', $css_url . 'um-fontawesome' . $suffix . '.css', array(), self::$fa_version ); // New FontAwesome
|
||||
$fonticons_handlers[] = 'um_fontawesome';
|
||||
}
|
||||
self::$fonticons_handlers = $fonticons_handlers;
|
||||
|
||||
@@ -352,5 +352,49 @@ KEY meta_value_indx (um_value(191))
|
||||
update_user_meta( $user_id, 'account_status', 'approved' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function set_icons_options() {
|
||||
$fa_version = get_option( 'um_fa_version' );
|
||||
$um_icons_list = get_option( 'um_icons_list' );
|
||||
|
||||
if ( empty( $um_icons_list ) || UM()->admin()->enqueue()::$fa_version !== $fa_version ) {
|
||||
update_option( 'um_fa_version', UM()->admin()->enqueue()::$fa_version, false );
|
||||
|
||||
$common_icons = array();
|
||||
|
||||
$icons = file_get_contents( UM_PATH . 'assets/libs/fontawesome/metadata/icons.json' );
|
||||
$icons = json_decode( $icons );
|
||||
|
||||
foreach ( $icons as $key => $data ) {
|
||||
if ( ! isset( $data->styles ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $data->styles as $style ) {
|
||||
$style_class = '';
|
||||
if ( 'solid' === $style ) {
|
||||
$style_class = 'fas fa-';
|
||||
} elseif ( 'regular' === $style ) {
|
||||
$style_class = 'far fa-';
|
||||
} elseif ( 'brands' === $style ) {
|
||||
$style_class = 'fab fa-';
|
||||
}
|
||||
|
||||
$label = count( $data->styles ) > 1 ? $data->label . ' (' . $style . ')' : $data->label;
|
||||
$search = array_unique( array_merge( $data->search->terms, array( $key, strtolower( $data->label ) ) ) );
|
||||
|
||||
$common_icons[ $style_class . $key ] = array(
|
||||
'label' => $label,
|
||||
'search' => $search,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'um_icons_list', $common_icons, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user