How to stop jQuery.migrate manually

jQuery Migrate is nothing but a dependency of the jQuery script in WordPress, so one can simply remove that dependency. The code for that is pretty straightforward: function dequeue_jquery_migrate( $scripts ) { if ( ! is_admin() && ! empty( $scripts->registered[‘jquery’] ) ) { $scripts->registered[‘jquery’]->deps = array_diff( $scripts->registered[‘jquery’]->deps, [ ‘jquery-migrate’ ] ); } } add_action( ‘wp_default_scripts’, … Read more

What does the token %1$s in WordPress represent [closed]

Read the PHP docs on sprintf(). %s is just a placeholder for a string %d is just a placeholder for a number So an example of sprintf would look like this: $variable = sprintf( ‘The %s ran down the %s’, // String with placeholders ‘dog’, // Placed in the first %s placeholder ‘street’ // Placed … Read more

static variable loop not working in WordPress

Try something like this: function realistic_get_first_embed_video($post_id) { $post = get_post($post_id); $content = do_shortcode(apply_filters(‘the_content’, $post->post_content)); $embeds = get_media_embedded_in_content($content); if (!empty($embeds)) { //check what is the first embed containg video tag, youtube or vimeo $counter = 0; foreach ($embeds as $embed) { // Check condition if count is 0 then // it is the first iteration if( … Read more

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

$wpdb->get_results(…) returns empty array despite correct query

Use $wpdb->show_errors( true ) before the query and see what error comes back. My problem (because I’ve experienced the same thing) was that I should use $wpdb->posts instead of wp_posts inside the query. The prefix of the tables can change from WP installation to installation or even in the same installation depending on the time … Read more