Adding a character counter to the excerpt metabox

Ok, so I didn’t like the way that was written, so i slightly rewrote it with different syntax, and more readable structure. <?php // Add Character Counter to the Excerpt Meta Box function excerpt_count_js(){ if (‘page’ != get_post_type()) { ?> <script> (function($){ $(document).ready(function(){ if ( $(‘#postexcerpt’).length ) { var maxChar = 128; $excerpt = $(‘#excerpt’); … Read more

JQuery not working on WordPress Admin page [closed]

There are this type of problem occure. In case- 1- jQuery function conflict to other jquery function. To remove this type of problem, define below script in wp-config.php file. define(‘CONCATENATE_SCRIPTS’, false); 2- jQuery liberaray file are not include in frontend. 3- Jquery same file defined more than one time. then this type of issue show … Read more

WordPress audio player causing js error, mediaelementplayer is not a function

I can think of two possible options – although I am not been able to test either right now. Option 1 In theory the cleaner one, as you detect if the mediaelementplayer plugin has loaded itself in the jQuery namespace: <!–Change WordPress Audio Player Default Volume–> <script type=”text/javascript”> jQuery(document).ready(function ($) { if($.fn.mediaelementplayer) { $(“audio”).mediaelementplayer({ success: … Read more

How to speed up admin-ajax.php in wordpress

Here’s the answer you’re searching for: Ajax takes 10x as long as it should/could Unfortunately, the solution there involves very detailed knowledge of what parts to load / what not to load and why stuff would break. Reading through github issues / comments, it seems this doesn’t work with HTTPS. Otherwise, you really can’t speed … Read more

ajax_object is not defined when ajax calls the function

As Codex says, IMPORTANT! wp_localize_script() MUST be called after the script has been registered using wp_register_script() or wp_enqueue_script(). add_action( ‘init’, ‘my_script_enqueuer’ ); function my_script_enqueuer() { wp_enqueue_script( ‘jquery’ ); # before enqueue,if not register then register wp_enqueue_script( ‘add-order-front’ ); wp_localize_script( ‘add-order-front’, ‘ajax_object’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ) ); }

Automatic jQuery accordion from header tags

You can use shortcode function to do this. function accordion_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( ‘class’ => ‘accordion’, ), $atts ) ); return ‘<div class=”‘ . esc_attr($class) . ‘”>’ . $content . ‘</div>’; } add_shortcode( ‘accordion’, ‘accordion_shortcode’ ); In editor you wrap your content: [accordion] <h3>Headline 1</h3> <p>Content.. lorem ipsum</p> <h3>Headline … Read more

How to enable the content editor as a droppable target with jQuery-ui?

In the above example the following line: jQuery(“.myDiv”).find(“li”).each(function(){ should be: jQuery(“.keywords”).find(“li”).each(function(){ That should enable the list items to be dragged and dropped. To allow the items to be dropped on the TinyMCE textarea the following code works. $(‘#editorcontainer’).droppable({ drop: function(event, ui) { alert(‘dropped’); //NOW FIRES! //Dynamically add content tinyMCE.activeEditor.execCommand(‘mceInsertContent’, false, ‘New content.’); } });