Pass media upload value to input field

You can use some thing like this to add as many image as you want with the botton click for example add logos or advertisements etc jQuery(document).ready(function($){ var mediaUploader; /* function to add partner logo */ function display_ad( button, title, btnTxt, inputFieldId, outputDivId,formClass, e){ e.preventDefault(); if (mediaUploader) { mediaUploader.open(); return; } mediaUploader = wp.media.frames.file_frame =wp.media({ … Read more

WordPress 5.5 – ReferenceError: commonL10n is not defined error

This is Trac ticket 51223: commonL10n and other JS globals removed without backwards compatibility In WordPress 5.5, the localized translations under commonL10n were replaced by wp.i18n.__ without deprecation notice or backwards compatibility. Plugins using commonL10n now have JavaScript errors introduced by updating WordPress which can break site functionality. It was fixed in 5.5.1 by adding … Read more

Enable Submit Comment Without Page Reload (Using Ajax)?

Save the following javascrip file wpse54189-ajax-comments.js inside your plug-in folder – say plugins/plug-in-name/js (or if this must go your theme, in your theme folder). /* * jQuery autoResize (textarea auto-resizer) * @copyright James Padolsey http://james.padolsey.com * @version 1.04 */ (function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:150,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter(‘textarea’).each(function(){var c=a(this).css({resize:’none’,’overflow-y’:’hidden’}),k=c.height(),f=(function(){var l=[‘height’,’width’,’lineHeight’,’textDecoration’,’letterSpacing’],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr(‘id’).removeAttr(‘name’).css({position:’absolute’,top:0,left:-9999}).css(h).attr(‘tabIndex’,’-1′).insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css(‘overflow-y’,”);return}b.onResize.call(this);b.animate&&c.css(‘display’)===’block’?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind(‘.dynSiz’).bind(‘keyup.dynSiz’,g).bind(‘keydown.dynSiz’,g).bind(‘change.dynSiz’,g)});return this}})(jQuery); /* * Source: wp-comment-master WordPress Plugin * URL: http://wordpress.org/extend/plugins/wp-comment-master/ … Read more

tinymce is not defined when not using wp_editor

With help from a colleague, we dug through class-wp-editor.php Here are the necessary scripts to initialise jQuery tinyMCE if wp_editor has not been used beforehand (which calls these scripts). // Get the necessary scripts to launch tinymce $baseurl = includes_url( ‘js/tinymce’ ); $cssurl = includes_url(‘css/’); global $tinymce_version, $concatenate_scripts, $compress_scripts; $version = ‘ver=” . $tinymce_version; $css … Read more

wordpress json custom taxonomy problem

I would have done it as following, I am sure experts here will have a better way but following is what I could come up with in hurry. First create your controller file in your theme directory (or any other if you like) with the following content. For this example the file name is korkmaz.php … Read more

How to load the WordPress jquery in the section

By default if you enqueue jquery then it gets added in header but if any plugin is changing the default behavior of it and adding it in footer instead of header then you can use the following code to alter it and force it to add in header again. function insert_jquery(){ wp_enqueue_script(‘jquery’, false, array(), false, … Read more

Remove profile picture option (and other things) from profile.php (in admin)

We can use the show_avatars option to remove the Profile Picture section. We can visit /wp-admin/options.php to turn it off manually. Or update it with: update_option( ‘show_avatars’, 0 ); Or modify it through a filter: add_filter( ‘option_show_avatars’, ‘__return_false’ ); We could also restrict it to the profile.php page: add_action( ‘load-profile.php’, function() { add_filter( ‘option_show_avatars’, ‘__return_false’ … Read more

Do I need both jquery.js and jquery-migrate.min.js?

As stated in the official blog of jQuery. Note that WordPress is mentioned in the quote. jQuery Migrate 1.4.1 released, and the path to jQuery 3.0 Version 1.4.1 of the jQuery Migrate plugin has been released. It has only a few changes but the most important of them fixes a problem with unquoted selectors that … Read more