mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-19 22:54:03 +09:00
- wp-admin assets refactoring (in process);
This commit is contained in:
@@ -28,10 +28,6 @@ function um_builder_delete_field_ajax( callback ) {
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
jQuery(document).ajaxStart( function() {
|
||||
jQuery('.tipsy').hide();
|
||||
});
|
||||
|
||||
jQuery( document.body ).on('click', 'a[data-silent_action^="um_"]', function() {
|
||||
if ( typeof jQuery(this).attr('disabled') !== 'undefined' ) {
|
||||
return false;
|
||||
@@ -54,8 +50,6 @@ jQuery(document).ready(function() {
|
||||
in_group = demon_settings.data('in_group');
|
||||
}
|
||||
|
||||
jQuery('.tipsy').hide();
|
||||
|
||||
um_admin_remove_modal();
|
||||
jQuery.ajax({
|
||||
url: wp.ajax.settings.url,
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var um_components = wp.components,
|
||||
umSelectControl = um_components.SelectControl,
|
||||
umTextareaControl = um_components.TextareaControl;
|
||||
|
||||
|
||||
function um_admin_blocks_custom_fields( um_condition_fields, props ) {
|
||||
return wp.hooks.applyFilters( 'um_admin_blocks_custom_fields', [], um_condition_fields, props );
|
||||
}
|
||||
|
||||
var um_block_restriction = wp.compose.createHigherOrderComponent(
|
||||
function( BlockEdit ) {
|
||||
var um_condition_fields = {
|
||||
um_who_access: 'um_block_settings_hide',
|
||||
um_roles_access: 'um_block_settings_hide',
|
||||
um_message_type: 'um_block_settings_hide',
|
||||
um_message_content: 'um_block_settings_hide'
|
||||
};
|
||||
|
||||
um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_default', um_condition_fields );
|
||||
|
||||
return function( props ) {
|
||||
let initialIsRestrict = props.attributes.um_is_restrict !== undefined ? props.attributes.um_is_restrict : false;
|
||||
|
||||
if ( props.attributes.um_is_restrict !== true ) {
|
||||
um_condition_fields['um_who_access'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_type'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
} else {
|
||||
um_condition_fields['um_who_access'] = '';
|
||||
|
||||
if ( parseInt( props.attributes.um_who_access ) === 0 || typeof props.attributes.um_who_access === 'undefined' ) {
|
||||
um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_type'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
} else if ( parseInt( props.attributes.um_who_access ) === 1 ) {
|
||||
um_condition_fields['um_roles_access'] = '';
|
||||
um_condition_fields['um_message_type'] = '';
|
||||
|
||||
if ( parseInt( props.attributes.um_message_type ) === 2 ) {
|
||||
um_condition_fields['um_message_content'] = '';
|
||||
} else {
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
}
|
||||
} else {
|
||||
um_condition_fields['um_message_type'] = '';
|
||||
|
||||
if ( parseInt( props.attributes.um_message_type ) === 2 ) {
|
||||
um_condition_fields['um_message_content'] = '';
|
||||
} else {
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields', um_condition_fields, props );
|
||||
|
||||
return wp.element.createElement(
|
||||
wp.element.Fragment,
|
||||
{},
|
||||
wp.element.createElement( BlockEdit, props ),
|
||||
wp.element.createElement(
|
||||
wp.blockEditor.InspectorControls,
|
||||
{},
|
||||
wp.element.createElement(
|
||||
wp.components.PanelBody,
|
||||
{
|
||||
title: wp.i18n.__( 'Ultimate Member: Content Restriction', 'ultimate-member' ),
|
||||
className: 'um_block_settings'
|
||||
},
|
||||
wp.element.createElement(
|
||||
wp.components.ToggleControl,
|
||||
{
|
||||
label: wp.i18n.__( 'Restrict access?', 'ultimate-member' ),
|
||||
checked: initialIsRestrict,
|
||||
onChange: function onChange( value ) {
|
||||
props.setAttributes( { um_is_restrict: value } );
|
||||
if ( value === false ) {
|
||||
um_condition_fields['um_who_access'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_type'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
} else {
|
||||
um_condition_fields['um_who_access'] = '';
|
||||
}
|
||||
|
||||
um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_on_change', um_condition_fields, 'um_is_restrict', value );
|
||||
}
|
||||
}
|
||||
),
|
||||
wp.element.createElement(
|
||||
umSelectControl,
|
||||
{
|
||||
type: 'number',
|
||||
className: um_condition_fields['um_who_access'],
|
||||
label: wp.i18n.__( 'Who can access this block?', 'ultimate-member' ),
|
||||
value: props.attributes.um_who_access,
|
||||
options: [
|
||||
{
|
||||
label: wp.i18n.__( 'Everyone', 'ultimate-member' ),
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: wp.i18n.__( 'Logged in users', 'ultimate-member' ),
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: wp.i18n.__( 'Logged out users', 'ultimate-member' ),
|
||||
value: 2
|
||||
}
|
||||
],
|
||||
onChange: function onChange( value ) {
|
||||
props.setAttributes( { um_who_access: value } );
|
||||
if ( parseInt( value ) === 0 ) {
|
||||
um_condition_fields['um_message_type'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
|
||||
} else if ( parseInt( value ) === 1 ) {
|
||||
um_condition_fields['um_message_type'] = '';
|
||||
um_condition_fields['um_roles_access'] = '';
|
||||
} else {
|
||||
um_condition_fields['um_message_type'] = '';
|
||||
um_condition_fields['um_roles_access'] = 'um_block_settings_hide';
|
||||
}
|
||||
|
||||
um_condition_fields = wp.hooks.applyFilters( 'um_admin_blocks_condition_fields_on_change', um_condition_fields, 'um_who_access', value );
|
||||
}
|
||||
}
|
||||
),
|
||||
wp.element.createElement(
|
||||
umSelectControl,
|
||||
{
|
||||
multiple: true,
|
||||
className: um_condition_fields['um_roles_access'],
|
||||
label: wp.i18n.__( 'What roles can access this block?', 'ultimate-member' ),
|
||||
value: props.attributes.um_roles_access,
|
||||
options: um_restrict_roles,
|
||||
onChange: function onChange( value ) {
|
||||
props.setAttributes( { um_roles_access: value } );
|
||||
}
|
||||
}
|
||||
),
|
||||
wp.element.createElement(
|
||||
umSelectControl,
|
||||
{
|
||||
type: 'number',
|
||||
className: um_condition_fields['um_message_type'],
|
||||
label: wp.i18n.__( 'Restriction action', 'ultimate-member' ),
|
||||
value: props.attributes.um_message_type,
|
||||
options: [
|
||||
{
|
||||
label: wp.i18n.__( 'Hide block', 'ultimate-member' ),
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
label: wp.i18n.__( 'Show global default message', 'ultimate-member' ),
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: wp.i18n.__( 'Show custom message', 'ultimate-member' ),
|
||||
value: 2
|
||||
}
|
||||
],
|
||||
onChange: function onChange( value ) {
|
||||
props.setAttributes( { um_message_type: value } );
|
||||
if ( parseInt( value ) === 2 ) {
|
||||
um_condition_fields['um_message_content'] = '';
|
||||
} else {
|
||||
um_condition_fields['um_message_content'] = 'um_block_settings_hide';
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
wp.element.createElement(
|
||||
umTextareaControl,
|
||||
{
|
||||
type: 'number',
|
||||
className: um_condition_fields['um_message_content'],
|
||||
label: wp.i18n.__( 'Custom restricted access message', 'ultimate-member' ),
|
||||
value: props.attributes.um_message_content,
|
||||
onChange: function onChange( value ) {
|
||||
props.setAttributes( { um_message_content: value } );
|
||||
}
|
||||
}
|
||||
),
|
||||
um_admin_blocks_custom_fields( um_condition_fields, props )
|
||||
)
|
||||
)
|
||||
);
|
||||
};
|
||||
},
|
||||
'um_block_restriction'
|
||||
);
|
||||
|
||||
wp.hooks.addFilter( 'editor.BlockEdit', 'um-block/um_block_restriction', um_block_restriction );
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* This function updates the builder area with fields
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function um_admin_update_builder() {
|
||||
var form_id = jQuery('.um-admin-builder').data('form_id');
|
||||
|
||||
jQuery('.tipsy').hide();
|
||||
|
||||
jQuery.ajax({
|
||||
url: wp.ajax.settings.url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action:'um_update_builder',
|
||||
form_id: form_id,
|
||||
nonce: um_admin_scripts.nonce
|
||||
},
|
||||
success: function( data ) {
|
||||
jQuery('.um-admin-drag-ajax').html( data );
|
||||
jQuery('.tipsy').hide();
|
||||
|
||||
/* trigger columns at start */
|
||||
allow_update_via_col_click = false;
|
||||
jQuery('.um-admin-drag-ctrls.columns a.active').each( function() {
|
||||
jQuery(this).trigger('click');
|
||||
}).promise().done( function(){
|
||||
allow_update_via_col_click = true;
|
||||
});
|
||||
|
||||
UM_Rows_Refresh();
|
||||
},
|
||||
error: function( data ) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
jQuery( document ).ready( function() {
|
||||
if ( um_admin_builder_data.hide_footer ) {
|
||||
jQuery('#wpfooter').hide();
|
||||
}
|
||||
});
|
||||
@@ -85,7 +85,7 @@ function UM_Drag_and_Drop() {
|
||||
placeholder: "um-row-placeholder",
|
||||
forcePlaceholderSize:true,
|
||||
out: function(){
|
||||
jQuery('.tipsy').remove();
|
||||
UM.common.tipsy.hide();
|
||||
},
|
||||
update: function(){
|
||||
|
||||
@@ -110,7 +110,7 @@ function UM_update_rows() {
|
||||
c++;
|
||||
row = jQuery(this);
|
||||
if ( c != 1 ) {
|
||||
row.find('.um-admin-drag-row-icons').append( '<a href="#" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>' );
|
||||
row.find('.um-admin-drag-row-icons').append( '<a href="#" class="um-tip-n" title="Delete Row" data-remove_element="um-admin-drag-row"><i class="um-faicon-trash-o"></i></a>' );
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -123,7 +123,7 @@ function UM_update_subrows(){
|
||||
c++;
|
||||
row = jQuery(this);
|
||||
if ( c != 1 ) {
|
||||
row.find('.um-admin-drag-rowsub-icons').append('<a href="#" class="um-admin-tipsy-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>');
|
||||
row.find('.um-admin-drag-rowsub-icons').append('<a href="#" class="um-tip-n" title="Delete Row" data-remove_element="um-admin-drag-rowsub"><i class="um-faicon-trash-o"></i></a>');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -267,7 +267,7 @@ function UM_Rows_Refresh(){
|
||||
|
||||
function UM_Add_Icon(){
|
||||
|
||||
var add_icon_html = '<a href="#" class="um-admin-drag-add-field um-admin-tipsy-n" title="Add Field" data-modal="UM_fields" data-modal-size="normal" data-dynamic-content="um_admin_show_fields" data-arg2="'+jQuery('.um-admin-drag-ajax').data('form_id')+'" data-arg1=""><i class="um-icon-plus"></i></a>';
|
||||
var add_icon_html = '<a href="#" class="um-admin-drag-add-field um-tip-n" title="Add Field" data-modal="UM_fields" data-modal-size="normal" data-dynamic-content="um_admin_show_fields" data-arg2="'+jQuery('.um-admin-drag-ajax').data('form_id')+'" data-arg1=""><i class="um-icon-plus"></i></a>';
|
||||
|
||||
jQuery('.um-admin-drag-col').each(function(){
|
||||
if ( jQuery(this).find('.um-admin-drag-add-field').length == 0 ) {
|
||||
@@ -377,8 +377,8 @@ jQuery(document).ready(function() {
|
||||
|
||||
if ( UM.admin.builder.fieldsToDelete.length > 0 ) {
|
||||
um_builder_delete_field_ajax( function () {
|
||||
UM.common.tipsy.hide();
|
||||
deleteButton.parents('.' +element).remove();
|
||||
jQuery('.tipsy').remove();
|
||||
UM_Rows_Refresh();
|
||||
|
||||
jQuery.each( UM.admin.builder.deleteProcess, function(i) {
|
||||
@@ -391,8 +391,8 @@ jQuery(document).ready(function() {
|
||||
loadingWrapper.hide();
|
||||
} );
|
||||
} else {
|
||||
UM.common.tipsy.hide();
|
||||
jQuery(this).parents('.' +element).remove();
|
||||
jQuery('.tipsy').remove();
|
||||
UM_Rows_Refresh();
|
||||
|
||||
jQuery.each( UM.admin.builder.deleteProcess, function(i) {
|
||||
|
||||
@@ -91,7 +91,7 @@ jQuery(document).ready(function() {
|
||||
um_admin_modal_responsive();
|
||||
} else {
|
||||
jQuery('.um-col-demon-settings').data('in_row', '').data('in_sub_row', '').data('in_column', '').data('in_group', '');
|
||||
jQuery('.tipsy').hide();
|
||||
UM.common.tipsy.hide();
|
||||
um_admin_remove_modal();
|
||||
um_admin_update_builder();
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
function um_form_select_tab( tab, set_val ) {
|
||||
var mode_block = jQuery('input#form__um_mode');
|
||||
tab.parents('.um-admin-boxed-links').find('a').removeClass('um-admin-activebg');
|
||||
tab.addClass('um-admin-activebg');
|
||||
|
||||
jQuery('.um-admin div#side-sortables').show();
|
||||
jQuery('div[id^="um-admin-form"]').hide();
|
||||
jQuery('#submitdiv').show();
|
||||
jQuery('div#um-admin-form-mode,div#um-admin-form-title,div#um-admin-form-builder,div#um-admin-form-shortcode').show();
|
||||
jQuery('div[id^="um-admin-form-' + tab.data('role') + '"]').show();
|
||||
|
||||
if ( set_val ) {
|
||||
mode_block.val( tab.data('role') );
|
||||
}
|
||||
|
||||
jQuery('.empty-container').css({'border' : 'none'});
|
||||
jQuery('.um-admin-builder').removeClass().addClass( 'um-admin-builder ' + mode_block.val() );
|
||||
}
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
/* Default form tab */
|
||||
if ( jQuery('.um-admin-boxed-links').length > 0 ) {
|
||||
var tab = jQuery('.um-admin-boxed-links a[data-role="'+jQuery('input#form__um_mode').val()+'"]');
|
||||
um_form_select_tab( tab, false );
|
||||
}
|
||||
|
||||
|
||||
/* Creating new form button */
|
||||
jQuery('.um-admin-boxed-links:not(.is-core-form) a').on( 'click', function() {
|
||||
um_form_select_tab( jQuery(this), true );
|
||||
});
|
||||
});
|
||||
@@ -1,64 +0,0 @@
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
|
||||
jQuery(document.body).on('click', '#um_add_review_love', function (e) {
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="love"]').show();
|
||||
});
|
||||
|
||||
|
||||
jQuery(document.body).on('click', '#um_add_review_good', function (e) {
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="good"]').show();
|
||||
});
|
||||
|
||||
|
||||
jQuery(document.body).on('click', '#um_add_review_bad', function (e) {
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="bad"]').show();
|
||||
});
|
||||
|
||||
|
||||
jQuery(document.body).on('click', '.um_review_link', function (e) {
|
||||
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
|
||||
});
|
||||
|
||||
|
||||
jQuery(document.body).on('click', '.um_secondary_dimiss', function (e) {
|
||||
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
|
||||
});
|
||||
|
||||
|
||||
jQuery(document.body).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) {
|
||||
var notice_key = jQuery(this).parents('.um-admin-notice').data('key');
|
||||
|
||||
wp.ajax.send( 'um_dismiss_notice', {
|
||||
data: {
|
||||
key: notice_key,
|
||||
nonce: um_admin_scripts.nonce
|
||||
},
|
||||
success: function( data ) {
|
||||
return true;
|
||||
},
|
||||
error: function( data ) {
|
||||
um_admin_dismiss_notice_fallback( notice_key );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Dismiss fallback of ajax request
|
||||
*/
|
||||
function um_admin_dismiss_notice_fallback( notice_key ) {
|
||||
var href_index = "";
|
||||
if ( window.location.href.indexOf("?") > -1 ) {
|
||||
href_index = window.location.href + "&";
|
||||
} else {
|
||||
href_index = window.location.href + "?";
|
||||
}
|
||||
window.location.href = href_index + "um_dismiss_notice=" + notice_key + "&um_admin_nonce=" + um_admin_scripts.nonce;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ function um_admin_live_update_scripts() {
|
||||
function um_admin_new_modal( id, ajax, size ) {
|
||||
var modal = jQuery('body').find('.um-admin-overlay');
|
||||
|
||||
jQuery('.tipsy').hide();
|
||||
UM.common.tipsy.hide();
|
||||
|
||||
um_admin_remove_modal();
|
||||
|
||||
@@ -146,9 +146,8 @@ function um_admin_modal_ajaxcall( act_id, arg1, arg2, arg3 ) {
|
||||
jQuery('.um-admin-preview-overlay').css('height', jQuery('.um-admin-preview-overlay').siblings('.um').outerHeight(true)*1 + 20 + 'px' );
|
||||
}
|
||||
|
||||
um_init_tooltips();
|
||||
|
||||
um_admin_init_datetimepicker();
|
||||
UM.admin.tooltip.init();
|
||||
UM.admin.datetimePicker.init();
|
||||
},
|
||||
error: function(data) {
|
||||
|
||||
@@ -199,10 +198,8 @@ function um_admin_remove_modal() {
|
||||
jQuery('.um_tiny_placeholder').replaceWith( jQuery( $um_tiny_editor ).html() );
|
||||
}
|
||||
|
||||
if ( 'undefined' !== typeof window.UM.admin.allTooltips && window.UM.admin.allTooltips.length > 0 && 'function' === typeof window.UM.admin.allTooltips.tooltip ) {
|
||||
window.UM.admin.allTooltips.tooltip('close');
|
||||
}
|
||||
jQuery('.tipsy').hide();
|
||||
UM.admin.tooltip.close();
|
||||
UM.common.tipsy.hide();
|
||||
jQuery('body').removeClass('um-admin-modal-open');
|
||||
jQuery('.um-admin-modal div[id^="UM_"]').hide().appendTo('body');
|
||||
jQuery('.um-admin-modal,.um-admin-overlay').remove();
|
||||
@@ -322,7 +319,7 @@ jQuery(document).ready(function() {
|
||||
jQuery(document.body).on('click', '.um-admin-remove-condition', function(){
|
||||
var condition = jQuery(this).parents('.um-admin-cur-condition');
|
||||
jQuery('.um-admin-new-condition').removeClass('disabled');
|
||||
jQuery('.tipsy').remove();
|
||||
UM.common.tipsy.hide();
|
||||
condition.remove();
|
||||
//need fields refactor
|
||||
var conditions = jQuery('.um-admin-cur-condition');
|
||||
@@ -345,7 +342,7 @@ jQuery(document).ready(function() {
|
||||
remove modal via action
|
||||
**/
|
||||
jQuery(document.body).on('click', '.um-admin-overlay, a[data-action="UM_remove_modal"]', function(){
|
||||
jQuery('.tipsy').hide();
|
||||
UM.common.tipsy.hide();
|
||||
um_admin_remove_modal();
|
||||
});
|
||||
|
||||
@@ -406,7 +403,7 @@ jQuery(document).ready(function() {
|
||||
}
|
||||
jQuery(this).attr('data-code', '');
|
||||
if ( v_id == '.postbox' ) {
|
||||
jQuery('.tipsy').hide();
|
||||
UM.common.tipsy.hide();
|
||||
um_admin_remove_modal();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
var template = wp.template( 'um-nav-menus-fields' );
|
||||
|
||||
$( document ).on( 'menu-item-added', function ( e, $menuMarkup ) {
|
||||
var id = $( $menuMarkup ).attr('id').substr(10);
|
||||
|
||||
var template_content = template({
|
||||
menuItemID: id,
|
||||
restriction_data:{
|
||||
um_nav_public:0,
|
||||
um_nav_roles:[]
|
||||
}
|
||||
});
|
||||
|
||||
if ( $( $menuMarkup ).find( 'fieldset.field-move' ).length > 0 ) {
|
||||
$( $menuMarkup ).find( 'fieldset.field-move' ).before( template_content );
|
||||
} else {
|
||||
$( $menuMarkup ).find( '.menu-item-actions' ).before( template_content );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$( 'ul#menu-to-edit > li' ).each( function(){
|
||||
var id = $(this).attr('id').substr(10);
|
||||
var template_content = template({
|
||||
menuItemID: id,
|
||||
restriction_data: um_menu_restriction_data[ id ]
|
||||
});
|
||||
|
||||
if ( $( this ).find( 'fieldset.field-move' ).length > 0 ) {
|
||||
$( this ).find( 'fieldset.field-move' ).before( template_content );
|
||||
} else {
|
||||
$( this ).find( '.menu-item-actions' ).before( template_content );
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,42 +0,0 @@
|
||||
jQuery( document ).ready( function() {
|
||||
|
||||
jQuery( '#role' ).on('change', function() {
|
||||
|
||||
if ( typeof um_roles == 'object' ) {
|
||||
um_roles = Object.keys( um_roles ).map(function( key ) { return um_roles[ key ]; });
|
||||
}
|
||||
|
||||
if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) {
|
||||
jQuery( '#um_role_selector_wrapper' ).hide();
|
||||
jQuery( '#um-role' ).val('');
|
||||
|
||||
var hide = wp.hooks.applyFilters( 'um_user_screen_block_hiding', true );
|
||||
if ( hide ) {
|
||||
jQuery( '#um_user_screen_block' ).hide();
|
||||
}
|
||||
} else {
|
||||
jQuery( '#um_role_selector_wrapper' ).show();
|
||||
jQuery( '#um_user_screen_block' ).show();
|
||||
}
|
||||
}).trigger('change');
|
||||
|
||||
jQuery( '#adduser-role' ).on('change', function() {
|
||||
if ( typeof um_roles == 'object' ) {
|
||||
um_roles = Object.keys( um_roles ).map(function( key ) { return um_roles[ key ]; });
|
||||
}
|
||||
|
||||
if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) {
|
||||
jQuery( '#um_role_existing_selector_wrapper' ).hide();
|
||||
jQuery( '#um-role' ).val('');
|
||||
|
||||
var hide = wp.hooks.applyFilters( 'um_user_screen_block_hiding', true );
|
||||
if ( hide ) {
|
||||
jQuery( '#um_user_screen_block' ).hide();
|
||||
}
|
||||
} else {
|
||||
jQuery( '#um_role_existing_selector_wrapper' ).show();
|
||||
jQuery( '#um_user_screen_block' ).show();
|
||||
}
|
||||
}).trigger('change');
|
||||
|
||||
});
|
||||
@@ -1,286 +0,0 @@
|
||||
if ( typeof (window.UM) !== 'object' ) {
|
||||
window.UM = {};
|
||||
}
|
||||
|
||||
if ( typeof (window.UM.admin) !== 'object' ) {
|
||||
window.UM.admin = {};
|
||||
}
|
||||
|
||||
function um_admin_init_datetimepicker() {
|
||||
jQuery('.um-datepicker:not(.picker__input)').each(function(){
|
||||
elem = jQuery(this);
|
||||
|
||||
if ( typeof elem.attr('data-disabled_weekdays') != 'undefined' && elem.attr('data-disabled_weekdays') != '' ) {
|
||||
var disable = JSON.parse( elem.attr('data-disabled_weekdays') );
|
||||
} else {
|
||||
var disable = false;
|
||||
}
|
||||
|
||||
var years_n = null;
|
||||
if ( typeof elem.attr('data-years') != 'undefined' ) {
|
||||
years_n = elem.attr('data-years');
|
||||
}
|
||||
|
||||
var minRange = elem.attr('data-date_min');
|
||||
var maxRange = elem.attr('data-date_max');
|
||||
|
||||
var minSplit = [], maxSplit = [];
|
||||
if ( typeof minRange != 'undefined' ) {
|
||||
minSplit = minRange.split(",");
|
||||
}
|
||||
if ( typeof maxRange != 'undefined' ) {
|
||||
maxSplit = maxRange.split(",");
|
||||
}
|
||||
|
||||
var min = minSplit.length ? new Date(minSplit) : null;
|
||||
var max = minSplit.length ? new Date(maxSplit) : null;
|
||||
|
||||
// fix min date for safari
|
||||
if ( min && min.toString() == 'Invalid Date' && minSplit.length == 3 ) {
|
||||
var minDateString = minSplit[1] + '/' + minSplit[2] + '/' + minSplit[0];
|
||||
min = new Date(Date.parse(minDateString));
|
||||
}
|
||||
|
||||
// fix max date for safari
|
||||
if ( max && max.toString() == 'Invalid Date' && maxSplit.length == 3 ) {
|
||||
var maxDateString = maxSplit[1] + '/' + maxSplit[2] + '/' + maxSplit[0];
|
||||
max = new Date(Date.parse(maxDateString));
|
||||
}
|
||||
|
||||
var data = {
|
||||
disable: disable,
|
||||
format: elem.attr( 'data-format' ),
|
||||
formatSubmit: 'yyyy/mm/dd',
|
||||
hiddenName: true,
|
||||
onOpen: function() { elem.blur(); },
|
||||
onClose: function() { elem.blur(); }
|
||||
};
|
||||
|
||||
if ( years_n !== null ) {
|
||||
data.selectYears = years_n;
|
||||
}
|
||||
|
||||
if ( min !== null ) {
|
||||
data.min = min;
|
||||
}
|
||||
|
||||
if ( max !== null ) {
|
||||
data.max = max;
|
||||
}
|
||||
|
||||
elem.pickadate( data );
|
||||
});
|
||||
|
||||
jQuery('.um-timepicker:not(.picker__input)').each(function(){
|
||||
elem = jQuery(this);
|
||||
|
||||
elem.pickatime({
|
||||
format: elem.attr('data-format'),
|
||||
interval: parseInt( elem.attr('data-intervals') ),
|
||||
formatSubmit: 'HH:i',
|
||||
hiddenName: true,
|
||||
onOpen: function() { elem.blur(); },
|
||||
onClose: function() { elem.blur(); }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function um_init_tooltips() {
|
||||
if ( jQuery( '.um_tooltip' ).length > 0 ) {
|
||||
window.UM.admin.allTooltips = jQuery( '.um_tooltip' ).tooltip({
|
||||
tooltipClass: "um_tooltip",
|
||||
content: function () {
|
||||
return jQuery( this ).attr( 'title' );
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
/**
|
||||
clone a field dropdown
|
||||
**/
|
||||
jQuery(document.body).on('click', '.um-admin-clone', function(e){
|
||||
e.preventDefault();
|
||||
var container = jQuery(this).parents('.um-admin-field');
|
||||
var parent = jQuery(this).parents('p').find('.um-admin-field:last-child');
|
||||
container.find('select').select2('destroy');
|
||||
var cloned = container.clone();
|
||||
cloned.find('.um-admin-clone').replaceWith('<a href="#" class="um-admin-clone-remove button um-admin-tipsy-n" title="Remove Field"><i class="um-icon-close" style="margin-right:0!important"></i></a>');
|
||||
cloned.insertAfter( parent );
|
||||
cloned.find('select').val('');
|
||||
jQuery('.um-admin-field select').select2({
|
||||
allowClear: true,
|
||||
minimumResultsForSearch: 10
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
remove a field dropdown
|
||||
**/
|
||||
jQuery(document.body).on('click', '.um-admin-clone-remove', function(e){
|
||||
e.preventDefault();
|
||||
var container = jQuery(this).parents('.um-admin-field');
|
||||
jQuery('.tipsy').remove();
|
||||
container.remove();
|
||||
jQuery('.um-admin-field select').select2({
|
||||
allowClear: true,
|
||||
minimumResultsForSearch: 10
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
Ajax link
|
||||
**/
|
||||
jQuery('.um-admin-ajaxlink').on('click', function(e){
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
On/Off Buttons
|
||||
**/
|
||||
jQuery(document.body).on('click', '.um-admin-yesno span.btn', function(){
|
||||
if (!jQuery(this).parents('p').hasClass('disabled-on-off')){
|
||||
if ( jQuery(this).parent().find('input[type=hidden]').val() == 0 ){
|
||||
update_val = 1;
|
||||
jQuery(this).animate({'left': '48px'}, 200);
|
||||
jQuery(this).parent().find('input[type=hidden]').val( update_val ).trigger('change');
|
||||
} else {
|
||||
update_val = 0;
|
||||
jQuery(this).animate({'left': '0'}, 200);
|
||||
jQuery(this).parent().find('input[type=hidden]').val( update_val ).trigger('change');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
WP Color Picker
|
||||
**/
|
||||
if ( jQuery('.um-admin-colorpicker').length ) {
|
||||
jQuery('.um-admin-colorpicker').wpColorPicker();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Tooltips
|
||||
**/
|
||||
um_init_tooltips();
|
||||
|
||||
if( typeof tipsy !== 'undefined' ){
|
||||
jQuery('.um-admin-tipsy-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live' });
|
||||
jQuery('.um-admin-tipsy-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live' });
|
||||
jQuery('.um-admin-tipsy-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live' });
|
||||
jQuery('.um-admin-tipsy-s').tipsy({gravity: 's', opacity: 1, live: 'a.live' });
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Conditional fields
|
||||
**/
|
||||
jQuery( document.body ).on('change', '.um-adm-conditional', function(){
|
||||
|
||||
var value;
|
||||
if ( jQuery(this).attr("type") == 'checkbox' ) {
|
||||
value = jQuery(this).is(':checked') ? 1 : 0;
|
||||
} else {
|
||||
value = jQuery(this).val();
|
||||
}
|
||||
|
||||
if ( jQuery(this).data('cond1') ) {
|
||||
if ( value == jQuery(this).data('cond1') ) {
|
||||
jQuery('.' + jQuery(this).data('cond1-show') ).show();
|
||||
jQuery('.' + jQuery(this).data('cond1-hide') ).hide();
|
||||
|
||||
if ( jQuery(this).data('cond1-show') == '_roles' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
jQuery('.' + jQuery(this).data('cond1-show') ).hide();
|
||||
jQuery('.' + jQuery(this).data('cond1-hide') ).show();
|
||||
}
|
||||
}
|
||||
|
||||
if ( jQuery(this).data('cond2') ) {
|
||||
if ( value == jQuery(this).data('cond2') ) {
|
||||
jQuery('.' + jQuery(this).data('cond2-show') ).show();
|
||||
jQuery('.' + jQuery(this).data('cond2-hide') ).hide();
|
||||
|
||||
if ( jQuery(this).data('cond2-show') == '_roles' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
jQuery('.' + jQuery(this).data('cond2-show') ).hide();
|
||||
jQuery('.' + jQuery(this).data('cond2-hide') ).show();
|
||||
}
|
||||
}
|
||||
|
||||
if ( jQuery(this).data('cond3') ) {
|
||||
if ( value == jQuery(this).data('cond3') ) {
|
||||
jQuery('.' + jQuery(this).data('cond3-show') ).show();
|
||||
jQuery('.' + jQuery(this).data('cond3-hide') ).hide();
|
||||
} else {
|
||||
jQuery('.' + jQuery(this).data('cond3-show') ).hide();
|
||||
jQuery('.' + jQuery(this).data('cond3-hide') ).show();
|
||||
}
|
||||
}
|
||||
|
||||
});jQuery('.um-adm-conditional').each(function(){jQuery(this).trigger('change');});
|
||||
|
||||
/**
|
||||
Conditional fields for
|
||||
Radio Group
|
||||
**/
|
||||
jQuery('.um-conditional-radio-group input[type=radio]').on('click', function(){
|
||||
var holder = jQuery('.um-conditional-radio-group');
|
||||
|
||||
var val = jQuery(this).val();
|
||||
var cond1 = holder.data('cond1');
|
||||
var show1 = holder.data('cond1-show');
|
||||
if ( val == cond1 ) { // condition met
|
||||
jQuery('.' + show1).show();
|
||||
} else {
|
||||
jQuery('.' + show1).hide();
|
||||
}
|
||||
|
||||
var val2 = jQuery(this).val();
|
||||
var cond2 = holder.data('cond2');
|
||||
var show2 = holder.data('cond2-show');
|
||||
if ( val2 == cond2 ) { // condition met
|
||||
jQuery('.' + show2).show();
|
||||
} else {
|
||||
jQuery('.' + show2).hide();
|
||||
}
|
||||
|
||||
});jQuery('.um-conditional-radio-group input[type=radio]:checked').each(function(){jQuery(this).trigger('click');});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Conditional fields for
|
||||
nav-menu editor options
|
||||
**/
|
||||
|
||||
jQuery('.um-nav-mode').each( function() {
|
||||
if ( jQuery(this).find('select').val() == 2 ) {
|
||||
jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show();
|
||||
} else {
|
||||
jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
jQuery( document.body ).on('change', '.um-nav-mode select', function(){
|
||||
if ( jQuery(this).val() == 2 ) {
|
||||
jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show();
|
||||
} else {
|
||||
jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,78 +0,0 @@
|
||||
jQuery(document).on("ready", function(){
|
||||
|
||||
const scan_results_wrapper = jQuery(".um-secure-scan-results");
|
||||
const scan_button_elem = jQuery(".um-secure-scan-content");
|
||||
const scan_capabilities = jQuery("input[data-field_id^='banned_capabilities']");
|
||||
|
||||
var UM_Secure = {
|
||||
init: function() {
|
||||
scan_results_wrapper.css({
|
||||
'margin-top': '10px',
|
||||
'padding': '10px',
|
||||
'padding-bottom': '10px',
|
||||
'background-color': '#fff',
|
||||
'display': 'block',
|
||||
'max-height': '200px',
|
||||
'height': '500px',
|
||||
'overflow-y': 'scroll',
|
||||
});
|
||||
|
||||
scan_button_elem.on("click", function(e){
|
||||
UM_Secure.effect();
|
||||
e.preventDefault();
|
||||
var me = jQuery(this);
|
||||
me.prop("disabled", true);
|
||||
scan_results_wrapper.empty();
|
||||
|
||||
UM_Secure.log( wp.i18n.__( 'Scanning site..', 'ultimate-member' ) );
|
||||
|
||||
UM_Secure.ajax('');
|
||||
|
||||
});
|
||||
scan_capabilities.on("change", function(){
|
||||
scan_button_elem.after( ' <small style="color: red;">' + wp.i18n.__( 'You can start the scan now but you must save the settings to apply the selected capabilities after the scan is complete.', 'ultimate-member' ) + '</small>' );
|
||||
scan_capabilities.off("change");
|
||||
})
|
||||
},
|
||||
ajax: function( last_capability ) {
|
||||
let checkedCaps = [];
|
||||
let checkedCapsInputs = scan_results_wrapper.parents('.um-form-table').find('input[type="checkbox"][data-field_id^="banned_capabilities_"]:checked');
|
||||
checkedCapsInputs.each(function (){
|
||||
checkedCaps.push( jQuery(this).data('field_id').replace('banned_capabilities_', '') );
|
||||
});
|
||||
|
||||
var request = {
|
||||
nonce: um_admin_scripts.nonce,
|
||||
capabilities: checkedCaps,
|
||||
last_scanned_capability: last_capability,
|
||||
};
|
||||
|
||||
wp.ajax.send('um_secure_scan_affected_users', {
|
||||
data: request,
|
||||
success: function (response) {
|
||||
if ( ! response.completed ) {
|
||||
UM_Secure.ajax( response.last_scanned_capability );
|
||||
UM_Secure.log( response.message );
|
||||
} else if ( response.completed ) {
|
||||
scan_results_wrapper.empty();
|
||||
UM_Secure.log( response.recommendations );
|
||||
scan_results_wrapper.find('.current').removeClass('current');
|
||||
scan_button_elem.removeAttr('disabled');
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
log: function( str ) {
|
||||
scan_results_wrapper.find('.current').removeClass('current');
|
||||
scan_results_wrapper.append( '<span class="current">' + str + '</span><br/>' );
|
||||
},
|
||||
effect: function() {
|
||||
var blink = function(){
|
||||
scan_results_wrapper.find(".current").fadeTo(100, 0.1).fadeTo(200, 1.0);
|
||||
};
|
||||
setInterval(blink, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
UM_Secure.init();
|
||||
});
|
||||
Reference in New Issue
Block a user