Can inactive WordPress plugins still load scripts?

I recently deleted a contact form plugin (HubSpot All-In-One Marketing) on a site and the contact forms stopped working. Curiously, the forms work when the plugin is installed and INACTIVE, but they do NOT work when the inactive plugin is DELETED. This means that the plugin being present is affecting the site even when it is inactive. How is this possible? How can a contact form work when a plugin is present and inactive, but not when the plugin is …
Category: Web

Javascript code inside "<# #>" in core WordPress files .php

I found some interesting embeding JavaScript mix with HTML in WordPress php files, for instance: &lt;?php // Template for the Attachment Details two columns layout. ?&gt; &lt;script type=&quot;text/html&quot; id=&quot;tmpl-attachment-details-two-column&quot;&gt; &lt;div class=&quot;attachment-media-view {{ data.orientation }}&quot;&gt; &lt;h2 class=&quot;screen-reader-text&quot;&gt;&lt;?php _e( 'Attachment Preview' ); ?&gt;&lt;/h2&gt; &lt;div class=&quot;thumbnail thumbnail-{{ data.type }}&quot;&gt; &lt;# if ( data.uploading ) { #&gt; &lt;div class=&quot;media-progress-bar&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt; &lt;# } else if ( data.sizes &amp;&amp; data.sizes.large ) { #&gt; &lt;img class=&quot;details-image&quot; src=&quot;{{ data.sizes.large.url }}&quot; draggable=&quot;false&quot; alt=&quot;&quot; /&gt; &lt;# } else if ( data.sizes …
Category: Web

Script widget works only in admin view but not in Public

Script Widget bug in WordPress. The embed widget from Funda was working before, clueless why it suddenly stopped working. In Public view, it's not working. Preview mode while logged in to WordPress shows the correct page. Actually, the same embedded script from FUNDA is working on this page https://www.homecrew.nl/rent-out/. But the issue is with this page. The script isn’t working on this page https://www.homecrew.nl/reviews-recensies-beoordelingen-klanten-engels/. The Editor &amp; method of placing the script is the same. I cleared the cache etc. …
Category: Web

Custom PHP script throws critical error ONLY when editing page

I have the following script added to functions.php in my child theme: function getlatestfile() { $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('wp-content/uploads/cams/')); foreach ($iterator as $file) { if ($file-&gt;isDir()) continue; $path = $file-&gt;getPathname(); } return &quot;&lt;img src='https://mysite.url/&quot; . $path . &quot;' /&gt;&quot;; } // register shortcode add_shortcode('getfieldimage', 'getlatestfile'); I can save the code, insert the shortcode [getfieldimage] on the page, and the page indeed displays the latest image. No complains. But when trying to edit again the page containing the shortcode, WP …
Category: Web

Run one-time script calling plugin functions

I want to add a product programmatically using a wordpress plugin but programmatically as entering it manually is a hassle. I have a little bit of programming experience. I found this: What is your best practice to execute one-time scripts? The only issue that I'm having is how do I call functions from a plugin in this script? I guess more specifically, what is the base path of plugin .php files that I would pass in to include() ? An …
Category: Web

I can't enqueue my scripts - They literally aren't being added to my site

Ok, I've literally copy-pasted different enqueueing code from about 5 different sources (Including wordpress), and not a single one works. Here's the code I'm using in functions.php: &lt;?php function my_theme_scripts() { wp_register_script( 'main', get_stylesheet_directory_uri() . '/js/main.js', array( 'jquery' ), '1.0.0', true ); wp_enqueue_script('main'); } add_action( 'wp_enqueue_scripts', 'my_theme_scripts' ); ?&gt; and it literally does nothing. No scripts added into my HTML. nothing. This is my first time using wordpress, and nobody has explained the functions file to me completely right, but …
Category: Web

wp_dequeue_style and wp_dequeue_script not working on server but does work on local xampp

This is my entire code and it is working perfectly in my local system xampp but not working on server. function taqyeem_dequeue_scrips() { if(basename($_SERVER['REQUEST_URI'])=='my_page' || basename($_SERVER['REQUEST_URI'])=='') { wp_dequeue_style( 'taqyeem-style' ); wp_dequeue_script( 'taqyeem-main' ); wp_deregister_script( 'comment-reply' ); } } add_action( 'init', 'taqyeem_dequeue_scrips' ); function dequeue_scrips() { if(basename($_SERVER['REQUEST_URI'])=='my_page') { //css wp_dequeue_style( 'taxonomy-image-plugin-public' ); wp_dequeue_style( 'job-alerts-frontend' ); wp_dequeue_style('validate-engine-css'); wp_dequeue_style('cp-shortcode'); wp_dequeue_style('wsl-widget'); wp_dequeue_style('wp-job-manager-applications-frontend'); wp_dequeue_style('wp-job-manager-bookmarks-frontend'); wp_dequeue_style('wp-job-manager-resume-frontend'); wp_dequeue_style('wp-job-manager-frontend'); wp_dequeue_style('cp-widgets-css'); wp_dequeue_style('responsive-css'); wp_dequeue_style('owl-css'); wp_dequeue_style('svg-css'); wp_dequeue_style('cp-burgermenucss'); wp_dequeue_style('law-bx-slider-css'); wp_dequeue_style('prettyPhoto'); wp_dequeue_style('cp-bootstrap'); wp_dequeue_style('cp-wp-commerce'); wp_dequeue_style('cp-bx-slider'); wp_dequeue_style('googleFonts'); wp_dequeue_style('googleFonts-heading'); wp_dequeue_style('menu-googleFonts-heading'); wp_dequeue_style('wppb_stylesheet'); wp_dequeue_style('A2A_SHARE_SAVE'); //Script wp_dequeue_script( 'html5shiv' ); …
Category: Web

On click load iframe

I have this html &lt;a href=&quot;#1647278006925-e8321147-313b&quot; data-vc-accordion=&quot;&quot; data-vc-container=&quot;.vc_tta-container&quot;&gt;&lt;span class=&quot;vc_tta-title-text&quot;&gt;LISTEN&lt;/span&gt;&lt;/a&gt; that is printed in my page and opens an accordion with an iframe in it. The iframe: &lt;iframe id=&quot;myiFrame&quot; class=&quot;stop-lazy&quot; data-src=&quot;https://some.iframe&quot; frameborder=&quot;0&quot; allowtransparency=&quot;true&quot; style=&quot;width: 100%;min-height: 150px;&quot;&gt;&lt;/iframe&gt; I am trying to create a jquery code that will load the iframe only when the user click on the link. So i have tried to set the below script in the footer.php: &lt;script&gt; $(&quot;.vc_tta-title-text&quot;).click(function(){ var iframe = $(&quot;#myiFrame&quot;); iframe.attr(&quot;src&quot;, iframe.data(&quot;src&quot;)); }); &lt;/script&gt; but it …
Category: Web

Add Paypal button redirect to a specific page after completing

I have created a new page on my WordPress site to test the paypal payment flow. I have subscription based products. Attached code is for the paypal subscription button code. &lt;div id=&quot;paypal-button-container-P-91F08612M1573283BMIUWMOA&quot;&gt;&lt;/div&gt; &lt;script src=&quot;https://www.paypal.com/sdk/js?client-id=AfGWAPJxdGbCj7b51a2mpoZQYI5y63txxxxxxxxIe1UDh2Vxcr05AFJxxxxNSCNDf8y-xopaJ6&amp;vault=true&amp;intent=subscription&quot; data-sdk-integration-source=&quot;button-factory&quot;&gt;&lt;/script&gt; &lt;script&gt; paypal.Buttons({ style: { shape: 'rect', color: 'gold', layout: 'vertical', label: 'subscribe' }, createSubscription: function(data, actions) { return actions.subscription.create({ /* Creates the subscription */ plan_id: 'P-91xxxxxxxxxxxxxxx' }); }, onApprove: function(data, actions) { alert(data.subscriptionID); // You can add optional success message for the subscriber here } …
Category: Web

Pass user role to javascript code inside body

I know this question has been answered before, but it's not exactly the info I am looking for. Right now I am developing a chatbot for a client. I am kind of new to web development, but especially to wordpress (this is what the client is using). The chatbot is added to the pages using the Insert Headers and Footers plugin from wordpress. I add it to the header. But I guess it would also work in the body. Given …
Category: Web

Add table to WordPress database

I want to add an extra table on my WordPress database and I intend to query it with a custom script that will be embedded to WordPress. I'm worrying if this is a safe way to do it, or I should go with the option of adding an entirely new database, not a table on WordPress, as future updates of WordPress system might wipe my custom table? Any experience with such a scenario. Is this a valid risk/worry, or I …
Category: Web

Understrap child theme JS not working in custom-javascript.js file

I'm developing a Wordpress custom theme using the child-theme of Understrap. I'm adding my custom jQuery to child-theme &gt; src &gt; js &gt; custom-javascript.js, and the file is already commented with &quot;// Add your custom JS here.&quot; https://github.com/understrap/understrap-child/blob/main/src/js/custom-javascript.js I did this as instructed from the Understrap Documentation: &quot;Add your own JS to /src/js/custom-javascript.js to have them bundled into /js/child-theme.js.&quot; https://docs.understrap.com/#/understrap-child/npm I've run the script in the console, and it works as intended, so the error is not with my script. …
Category: Web

Wordpress load same script two times

I write a basic plugin with custom css/js. I use wp_enqueue_script for my custom script and use hook 'init' to register script in front-end page. But wordpress load this javascript file two times with different version. ( See in image ) And I don't know why. I load this script one time and load it in one point of my code. I have tried clean cache wordpress, cache browser, but nothing do. My site is esposte online : https://node.alfonsosomma.it/2022/02/04/articolo-prova/ I …
Category: Web

How do I display the handle for all front-end enqueued scripts in plugin options page?

I use the following function in my plugin to display all the scripts handles in my plugin options page but it display only the handles of admin scripts: function my_detected_scripts() { global $wp_scripts; foreach( $wp_scripts-&gt;queue as $handle ) : echo $handle . ' &lt;br /&gt; '; endforeach; } Then: echo my_detected_scripts() How can get the handles of all front-end enqueued scripts only? Thanks in advance!
Category: Web

Refused to execute as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type

We added an external script in the body tag of our (dev) website https://zonnebeke.reclamebureau-simplify.be/zonnebeke2022/. However, when checking the console, I see the error message: Refused to execute as script because &quot;X-Content-Type: nosniff&quot; was given and its Content-Type is not a script MIME type Any idea if this has to do with Wordpress, or another setting of our website, or how we can solve this issue? Thanks.
Category: Web

Integrating a Gutenberg custom block within a larger plugin

I am building a plugin that does many things, one of them being adding a Gutenberg custom block. I am wondering how to structure this. Can I use @wordpress/scripts to bundle the JavaScript or TypeScript that is NOT part of the custom Gutenberg block? And if yes, can you explain how? Or should I just separate this into two plugins? (I'd rather not)
Category: Web

How to properly dequeue scripts and styles in child theme?

I made a parent theme and a child theme in one of my project. I enqueued CSS and JavaScripts in my parent theme like below: function project_necessary_scripts() { //Stylesheets wp_register_style( 'bootstrap-css', get_template_directory_uri() .'/css/bootstrap.min.css' ); wp_register_style( 'bootstrap-map', get_template_directory_uri() .'/css/bootstrap.css.map' ); wp_register_style( 'project-css', get_stylesheet_uri() ); wp_enqueue_style( 'bootstrap-css' ); wp_enqueue_style( 'bootstrap-map' ); wp_enqueue_style( 'project-css' ); //JavaScripts wp_register_script( 'modernizr-js', get_template_directory_uri() .'/js/modernizr-2.8.3.min.js', array(), '2.8.3' ); wp_register_script( 'project-js', get_template_directory_uri() .'/js/project.min.js', array('jquery'), '20150401', true ); wp_enqueue_script( 'modernizr-js' ); wp_enqueue_script( 'project-js' ); } add_action( 'wp_enqueue_scripts', 'project_necessary_scripts' ); Now, …
Category: Web

How can I get a list of all enqueued scripts and styles?

I'm creating a plugin and I want to get the list of all scripts and CSS used by other plugins. This is my function: function crunchify_print_scripts_styles() { $result = []; $result['scripts'] = []; $result['styles'] = []; // Print all loaded Scripts global $wp_scripts; foreach( $wp_scripts-&gt;queue as $script ) : $result['scripts'][] = $wp_scripts-&gt;registered[$script]-&gt;src . ";"; endforeach; // Print all loaded Styles (CSS) global $wp_styles; foreach( $wp_styles-&gt;queue as $style ) : $result['styles'][] = $wp_styles-&gt;registered[$style]-&gt;src . ";"; endforeach; return $result; } add_action( 'wp_enqueue_scripts', …
Category: Web

Disable Cloudflare Rocket Loader for jQuery javascript and make it load first

I use Cloudflare Rocket Loader to speed up Javascript on my site. The problem is, it loads certain scripts that need jQuery before loading jQuery itself making them not working correctly. As soon as it is possible to disable Rocket Loader for specific script adding data-cfasync="false" to the &lt;script src=""&gt; I would like to know how can I add it to jQuery scripts as Wordpress doesn't simply load the jQuery via the script tag I guess. At the moment my …
Category: Web

Wordpress Sudden Loss of All CSS And Tons of JQuery Errors

All of a sudden all the css on the wp-admin page of a Wordpress Site that I'm providing some maintenance for dropped out. It really came out of nowhere. I'm not sure what caused it. I took some pics of errors that appeared in the console. Here is a pic of the source code for that first error &quot;wp-admin:53:1&quot; The error is on a script tag so I'm assuming it's just not able to find something that it's importing... Idk... …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.