Cannot run script properly with my custom plugin

I figured this out, maybe it will help someone – probably, my script was loading on the header, so html was loading after script fired. What I did was adding those few parameters, where this last ‘true’ is the most important (moves script to footer). Hope this helps to anyone wp_enqueue_script(‘js-file’, plugin_dir_url(__FILE__).’/js/plugin_pj_script.js’, ”, ‘1.0.0’, true);

Javascript embedded disappears for editors

WordPress Multisite disallows the unfiltered_html capability for non-super-admin (ie, any users who are not capable of performing network administration). Anyone without the unfiltered_html capability will not be able to save post content with disallowed HTML tags, including <script> tags. A quick search shows that there have been attempts at modifying this behaviour, but they may … Read more

How to send the featured image of a post to an API?

Here is an idea for sending a featured image (file data) on API and setting the image as a featured image on the server. Get File data from URL using following function: /*fetch the file from URL*/ function prefix_get_file_data_from_url( $url ) { $response = wp_remote_get( $url ); if ( is_array( $response ) && ! is_wp_error( … Read more

How can I send the mail once?

You can use meta to create a one time action something like this $order_id = $order->get_id(); if (get_post_meta($order_id, ‘is_mail_sent’, true)) return; update_post_meta($order_id, ‘is_mail_sent’, true); Add this right after the opening of the if block This code will first check if the order meta value of is_mail_sent is true, if true it will return (exit) from … Read more