initial commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*! One User Avatar - 2.3.9
|
||||
* Copyright One Designs
|
||||
* Copyright ProfilePress
|
||||
* Copyright Flippercode
|
||||
* Copyright Bangbay Siboliban
|
||||
* Licensed GPLv2
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var args = one_user_avatar_tinymce_editor_args || {};
|
||||
|
||||
tinymce.create('tinymce.plugins.wpUserAvatar', {
|
||||
init: function (ed, url) {
|
||||
ed.addCommand('mceWpUserAvatar', function() {
|
||||
ed.windowManager.open({
|
||||
file: ajaxurl + '?action=wp_user_avatar_tinymce',
|
||||
width: 500,
|
||||
height: 360,
|
||||
inline: 1
|
||||
}, {
|
||||
plugin_url: url,
|
||||
});
|
||||
});
|
||||
|
||||
ed.addButton('wpUserAvatar', {
|
||||
title: ( typeof args.insert_avatar != 'undefined' ? args.insert_avatar : 'Insert Avatar' ),
|
||||
cmd: 'mceWpUserAvatar',
|
||||
image: url + '/../images/wpua-20x20.png',
|
||||
onPostRender: function() {
|
||||
var ctrl = this;
|
||||
|
||||
ed.on('NodeChange', function(e) {
|
||||
ctrl.active(e.element.nodeName == 'IMG');
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
createControl: function(n, cm) {
|
||||
return null;
|
||||
},
|
||||
getInfo: function () {
|
||||
return {
|
||||
longname: 'One User Avatar',
|
||||
author: 'One Designs',
|
||||
authorurl: 'https://onedesigns.com/',
|
||||
infourl: 'https://onedesigns.com/plugins/one-user-avatar/',
|
||||
version: '2.3.9',
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
tinymce.PluginManager.add('wpUserAvatar', tinymce.plugins.wpUserAvatar);
|
||||
})();
|
@@ -0,0 +1,101 @@
|
||||
/*! One User Avatar - 2.3.9
|
||||
* Copyright One Designs
|
||||
* Copyright ProfilePress
|
||||
* Copyright Flippercode
|
||||
* Copyright Bangbay Siboliban
|
||||
* Licensed GPLv2
|
||||
*/
|
||||
|
||||
function wpuaInsertAvatar() {
|
||||
// Custom shortcode values
|
||||
var shortcode,
|
||||
closing_tag,
|
||||
user = document.getElementById('wp_user_avatar_user').value,
|
||||
size = document.getElementById('wp_user_avatar_size').value,
|
||||
size_number = document.getElementById('wp_user_avatar_size_number').value,
|
||||
align = document.getElementById('wp_user_avatar_align').value,
|
||||
link = document.getElementById('wp_user_avatar_link').value,
|
||||
link_external = document.getElementById('wp_user_avatar_link_external').value,
|
||||
target = document.getElementById('wp_user_avatar_target').value,
|
||||
caption = document.getElementById('wp_user_avatar_caption').value;
|
||||
|
||||
// Add tag to shortcode only if not blank
|
||||
var user_tag = (user != '') ? ' user="' + user + '"' : '';
|
||||
var size_tag = (size != '' && size_number == '') ? ' size="' + size + '"' : '';
|
||||
|
||||
size_tag = (size_number != '') ? ' size="' + size_number + '"' : size_tag;
|
||||
|
||||
var align_tag = (align != '') ? ' align="' + align + '"' : '';
|
||||
|
||||
var link_tag = (link != '' && link != 'custom-url' && link_external == '') ? ' link="' + link + '"' : '';
|
||||
|
||||
link_tag = (link_external != '') ? ' link="' + link_external + '"' : link_tag;
|
||||
|
||||
var target_tag = document.getElementById('wp_user_avatar_target').checked && (link_tag != '') ? ' target="' + target + '"' : '';
|
||||
|
||||
// Assemble the shortcode
|
||||
closing_tag = (caption != '') ? "]" + caption + "[/avatar]" : " /]";
|
||||
shortcode = "<p>[avatar" + user_tag + size_tag + align_tag + link_tag + target_tag + closing_tag + "</p>";
|
||||
|
||||
// Insert into Visual Editor
|
||||
if ( window.tinyMCE ) {
|
||||
var tmce_ver = window.tinyMCE.majorVersion;
|
||||
|
||||
if ( tmce_ver >= "4" ) {
|
||||
window.tinyMCE.execCommand( 'mceInsertContent', false, shortcode );
|
||||
} else {
|
||||
window.tinyMCE.execInstanceCommand( window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode );
|
||||
}
|
||||
|
||||
tinyMCEPopup.editor.execCommand( 'mceRepaint' );
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function wpuaInsertAvatarUpload() {
|
||||
// Upload shortcode
|
||||
var shortcode = "<p>[avatar_upload /]</p>";
|
||||
|
||||
// Insert into Visual Editor
|
||||
if ( window.tinyMCE ) {
|
||||
var tmce_ver = window.tinyMCE.majorVersion;
|
||||
|
||||
if ( tmce_ver >= "4" ) {
|
||||
window.tinyMCE.execCommand( 'mceInsertContent', false, shortcode );
|
||||
} else {
|
||||
window.tinyMCE.execInstanceCommand( window.tinyMCE.activeEditor.id, 'mceInsertContent', false, shortcode );
|
||||
}
|
||||
|
||||
tinyMCEPopup.editor.execCommand( 'mceRepaint' );
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
jQuery(function($) {
|
||||
// Show link input
|
||||
$('#wp_user_avatar_link').change(function() {
|
||||
$('#wp_user_avatar_link_external_section').toggle( $('#wp_user_avatar_link').val() == 'custom-url' );
|
||||
});
|
||||
|
||||
// Show size input
|
||||
$('#wp_user_avatar_size').change(function() {
|
||||
$('#wp_user_avatar_size_number_section').toggle( $('#wp_user_avatar_size').val() == 'custom' );
|
||||
});
|
||||
|
||||
$("#wpua-tabs li a").click(function(){
|
||||
tab_id = $(this).attr('href');
|
||||
|
||||
if( tab_id == '#wpua') {
|
||||
$("#wpua-upload").hide();
|
||||
} else {
|
||||
$('#wpua').hide();
|
||||
}
|
||||
|
||||
$(tab_id).show();
|
||||
});
|
||||
});
|
@@ -0,0 +1,48 @@
|
||||
/*! One User Avatar - 2.3.9
|
||||
* Copyright One Designs
|
||||
* Copyright ProfilePress
|
||||
* Copyright Flippercode
|
||||
* Copyright Bangbay Siboliban
|
||||
* Licensed GPLv2
|
||||
*/
|
||||
|
||||
jQuery(function($) {
|
||||
// Show size info only if allow uploads is checked
|
||||
$('#wp_user_avatar_allow_upload').change(function() {
|
||||
$('#wpua-contributors-subscribers').slideToggle($('#wp_user_avatar_allow_upload').is(':checked'));
|
||||
});
|
||||
|
||||
// Show resize info only if resize uploads is checked
|
||||
$('#wp_user_avatar_resize_upload').change(function() {
|
||||
$('#wpua-resize-sizes').slideToggle($('#wp_user_avatar_resize_upload').is(':checked'));
|
||||
});
|
||||
|
||||
// Hide Gravatars if disable Gravatars is checked
|
||||
$('#wp_user_avatar_disable_gravatar').change(function() {
|
||||
if( $('#wp-avatars').length ) {
|
||||
$('#wp-avatars, #avatar-rating').slideToggle(!$('#wp_user_avatar_disable_gravatar').is(':checked'));
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
// Update readable size on keyup
|
||||
$('#wp_user_avatar_upload_size_limit').on('input', function() {
|
||||
var wpuaUploadSizeLimit = $(this).val();
|
||||
|
||||
wpuaUploadSizeLimit = wpuaUploadSizeLimit.replace(/\D/g, "");
|
||||
|
||||
$(this).val(wpuaUploadSizeLimit);
|
||||
|
||||
$('#wpua-readable-size').html( Math.floor( wpuaUploadSizeLimit / 1024 ) + 'KB' );
|
||||
$('#wpua-readable-size-error').toggle( wpuaUploadSizeLimit > parseInt( wpua_admin.max_upload_size ) );
|
||||
$('#wpua-readable-size').toggleClass( 'wpua-error', wpuaUploadSizeLimit > parseInt( wpua_admin.max_upload_size ) );
|
||||
});
|
||||
|
||||
// Confirm deleting avatar
|
||||
$('.wpua-media-form .submitdelete').on('click', function() {
|
||||
console.log(typeof showNotice);
|
||||
if ( typeof showNotice == 'object' && typeof showNotice.warn == 'function' ) {
|
||||
return showNotice.warn();
|
||||
}
|
||||
});
|
||||
});
|
@@ -0,0 +1,79 @@
|
||||
/*! One User Avatar - 2.3.9
|
||||
* Copyright One Designs
|
||||
* Copyright ProfilePress
|
||||
* Copyright Flippercode
|
||||
* Copyright Bangbay Siboliban
|
||||
* Licensed GPLv2
|
||||
*/
|
||||
|
||||
jQuery(function($) {
|
||||
// Add enctype to form with JavaScript as backup
|
||||
$('#your-profile').attr('enctype', 'multipart/form-data');
|
||||
|
||||
// Store One User Avatar ID
|
||||
var wpuaID = $('#wp-user-avatar').val();
|
||||
|
||||
// Store One User Avatar src
|
||||
var wpuaSrc = $('#wpua-preview').find('img').attr('src');
|
||||
|
||||
$('#wpua-undo-button-existing').hide();
|
||||
|
||||
// Remove One User Avatar
|
||||
$('body').on('click', '#wpua-remove', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original').remove();
|
||||
$('#wpua-remove-button, #wpua-thumbnail').hide();
|
||||
$('#wpua-preview').find('img:first').hide();
|
||||
$('#wpua-preview').prepend('<img id="wpua-original" />');
|
||||
$('#wpua-original').attr('src', wpua_custom.avatar_thumb);
|
||||
$('#wp-user-avatar').val("");
|
||||
$('#wpua-original, #wpua-undo-button').show();
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
});
|
||||
|
||||
// Undo One User Avatar
|
||||
$('body').on('click', '#wpua-undo', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original').remove();
|
||||
$('#wpua-images').removeAttr('style');
|
||||
$('#wpua-undo-button').hide();
|
||||
$('#wpua-remove-button, #wpua-thumbnail').show();
|
||||
$('#wpua-preview').find('img:first').attr('src', wpuaSrc).show();
|
||||
$('#wp-user-avatar').val(wpuaID);
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
});
|
||||
|
||||
// Store WP Existing User Avatar ID
|
||||
var wpuaEID = $('#wp-user-avatar-existing').val();
|
||||
|
||||
// Store WP Existing User Avatar src
|
||||
var wpuaESrc = $('#wpua-preview-existing').find('img').attr('src');
|
||||
|
||||
// Remove WP Existing User Avatar
|
||||
$('body').on('click', '#wpua-remove-existing', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original-existing').remove();
|
||||
$('#wpua-remove-button-existing, #wpua-thumbnail-existing').hide();
|
||||
$('#wpua-preview-existing').find('img:first').hide();
|
||||
$('#wpua-preview-existing').prepend('<img id="wpua-original-existing" />');
|
||||
$('#wpua-original-existing').attr('src', wpua_custom.avatar_thumb);
|
||||
$('#wp-user-avatar-existing').val("");
|
||||
$('#wpua-original-existing, #wpua-undo-button-existing').show();
|
||||
$('#wp_user_avatar_radio-existing').trigger('click');
|
||||
});
|
||||
// Undo WP Existing User Avatar
|
||||
$('body').on('click', '#wpua-undo-existing', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original-existing').remove();
|
||||
$('#wpua-images-existing').removeAttr('style');
|
||||
$('#wpua-undo-button-existing').hide();
|
||||
$('#wpua-remove-button-existing, #wpua-thumbnail-existing').show();
|
||||
$('#wpua-preview-existing').find('img:first').attr('src', wpuaSrc).show();
|
||||
$('#wp-user-avatar-existing').val(wpuaID);
|
||||
$('#wp_user_avatar_radio-existing').trigger('click');
|
||||
});
|
||||
});
|
@@ -0,0 +1,163 @@
|
||||
/*! One User Avatar - 2.3.9
|
||||
* Copyright One Designs
|
||||
* Copyright ProfilePress
|
||||
* Copyright Flippercode
|
||||
* Copyright Bangbay Siboliban
|
||||
* Licensed GPLv2
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
var id;
|
||||
|
||||
wp.media.wpUserAvatar = {
|
||||
get: function() {
|
||||
return wp.media.view.settings.post.wpUserAvatarId;
|
||||
},
|
||||
set: function(a) {
|
||||
var b = wp.media.view.settings;
|
||||
|
||||
b.post.wpUserAvatarId = a;
|
||||
b.post.wpUserAvatarSrc = $('div.attachment-info').find('img').attr('src');
|
||||
|
||||
if ( b.post.wpUserAvatarId && b.post.wpUserAvatarSrc ) {
|
||||
$('#wp-user-avatar' + id).val( b.post.wpUserAvatarId );
|
||||
$('#wpua-images' + id + ', #wpua-undo-button' + id).show();
|
||||
$('#wpua-preview' + id).find('img').attr('src', b.post.wpUserAvatarSrc).removeAttr('height', '');
|
||||
$('#wpua-remove-button' + id + ', #wpua-thumbnail' + id).hide();
|
||||
$('#wp_user_avatar_radio').trigger('click')
|
||||
}
|
||||
|
||||
wp.media.wpUserAvatar.frame().close();
|
||||
},
|
||||
frame: function() {
|
||||
if ( this._frame ) {
|
||||
return this._frame;
|
||||
}
|
||||
|
||||
this._frame = wp.media({
|
||||
library: {
|
||||
type: 'image',
|
||||
},
|
||||
multiple: false,
|
||||
title: $('#wpua-add' + id).data('title'),
|
||||
});
|
||||
|
||||
this._frame.on('open', function() {
|
||||
var a = $('#wp-user-avatar' + id).val();
|
||||
|
||||
if ( a == '' ) {
|
||||
$('div.media-router').find('a:first').trigger('click');
|
||||
} else {
|
||||
var b = this.state().get('selection');
|
||||
|
||||
attachment = wp.media.attachment(a);
|
||||
|
||||
attachment.fetch();
|
||||
|
||||
b.add( attachment ? [attachment] : [] );
|
||||
}
|
||||
}, this._frame);
|
||||
|
||||
this._frame.state('library').on('select', this.select);
|
||||
|
||||
return this._frame;
|
||||
},
|
||||
select: function(a) {
|
||||
selection = this.get('selection').single();
|
||||
|
||||
wp.media.wpUserAvatar.set( selection ? selection.id : -1 );
|
||||
},
|
||||
init: function() {
|
||||
$('body').on('click', '#wpua-add', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
id = '';
|
||||
|
||||
wp.media.wpUserAvatar.frame().open();
|
||||
})
|
||||
$('body').on('click', '#wpua-add-existing', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
id = '-existing';
|
||||
|
||||
wp.media.wpUserAvatar.frame().open();
|
||||
});
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
jQuery(function($) {
|
||||
if ( typeof wp != 'undefined' ) {
|
||||
wp.media.wpUserAvatar.init();
|
||||
}
|
||||
|
||||
$('#your-profile').attr( 'enctype', 'multipart/form-data' );
|
||||
|
||||
var a = $('#wp-user-avatar').val();
|
||||
var b = $('#wpua-preview').find('img').attr('src');
|
||||
|
||||
$('body').on('click', '#wpua-remove', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original').remove();
|
||||
$('#wpua-remove-button, #wpua-thumbnail').hide();
|
||||
$('#wpua-preview').find('img:first').hide();
|
||||
$('#wpua-preview').prepend('<img id="wpua-original" />');
|
||||
$('#wpua-original').attr('src', wpua_custom.avatar_thumb);
|
||||
$('#wp-user-avatar').val("");
|
||||
$('#wpua-original, #wpua-undo-button').show();
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
});
|
||||
|
||||
$('body').on('click', '#wpua-undo', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original').remove();
|
||||
$('#wpua-images').removeAttr('style');
|
||||
$('#wpua-undo-button').hide();
|
||||
$('#wpua-remove-button, #wpua-thumbnail').show();
|
||||
$('#wpua-preview').find('img:first').attr('src', b).show();
|
||||
$('#wp-user-avatar').val(a);
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
});
|
||||
});
|
||||
|
||||
jQuery(function($) {
|
||||
if ( typeof wp != 'undefined' ) {
|
||||
wp.media.wpUserAvatar.init();
|
||||
}
|
||||
|
||||
$('#your-profile').attr('enctype', 'multipart/form-data');
|
||||
|
||||
var a = $('#wp-user-avatar-existing').val();
|
||||
var b = $('#wpua-preview-existing').find('img').attr('src');
|
||||
|
||||
$('#wpua-undo-button-existing').hide();
|
||||
|
||||
$('body').on('click', '#wpua-remove-existing', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original-existing').remove();
|
||||
$('#wpua-remove-button-existing, #wpua-thumbnail-existing').hide();
|
||||
$('#wpua-preview-existing').find('img:first').hide();
|
||||
$('#wpua-preview-existing').prepend('<img id="wpua-original-existing" />');
|
||||
$('#wpua-original-existing').attr('src', wpua_custom.avatar_thumb);
|
||||
$('#wp-user-avatar-existing').val("");
|
||||
$('#wpua-original-existing, #wpua-undo-button-existing').show();
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
});
|
||||
|
||||
$('body').on('click', '#wpua-undo-existing', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#wpua-original-existing').remove();
|
||||
$('#wpua-images-existing').removeAttr('style');
|
||||
$('#wpua-undo-button-existing').hide();
|
||||
$('#wpua-remove-button-existing, #wpua-thumbnail-existing').show();
|
||||
$('#wpua-preview-existing').find('img:first').attr('src', b).show();
|
||||
$('#wp-user-avatar-existing').val(a);
|
||||
$('#wp_user_avatar_radio').trigger('click');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user