]> _ Git - physioassist-wordpress.git/commitdiff
WIP #4147 @4
authorstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 9 Feb 2021 18:22:59 +0000 (18:22 +0000)
committerstephen@cubedesigners.com <stephen@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 9 Feb 2021 18:22:59 +0000 (18:22 +0000)
wp-content/mu-plugins/physioassist/src/Common/Setup.php
wp-content/themes/physioassist/app/setup.php
wp-content/themes/physioassist/resources/views/partials/head.blade.php

index 40d8663d27cfdd5cfd75bd0a8b59dc1333843f83..4f6f65a3bf57becc414ed6300fdc76166c27d4cb 100644 (file)
@@ -16,6 +16,68 @@ class Setup {
         //     Carbon_Fields::boot();
         // });
 
+        add_action('plugins_loaded', [$this, 'debug']);
+
+    }
+
+    // Adapted from: https://www.cozmoslabs.com/58990-remove-unused-css-js-files-in-wordpress/
+    public function debug() {
+
+        // Only run for admin users + when in debug mode
+        if (!(WP_DEBUG && current_user_can('delete_users'))) return false;
+
+        add_action('wp_print_footer_scripts', [$this, 'list_assets'], 900000);
+    }
+
+    public function list_assets() {
+
+        echo '<div style="padding: 2em; font-size: 80%; color: #333">';
+
+        // Print all loaded Scripts (JS)
+        echo '<h3 style="color:black; font-size: 2rem; margin-bottom: 1.5rem;">Scripts loaded</h3>';
+        global $wp_scripts;
+        $this->print_assets($wp_scripts);
+
+        echo '<h3 style="color:black; font-size: 2rem; margin: 3rem 0 1.5rem;">CSS loaded</h3>';
+        global $wp_styles;
+        $this->print_assets($wp_styles);
+
+        echo '</div>';
+    }
+
+    public function print_assets( $wp_asset ) {
+        $nb_of_asset = 0;
+
+        echo '<table border="1" cellspacing="0" cellpadding="5">';
+        echo '<tr>';
+        foreach(['Number', 'Handle', 'Source', 'Dependencies', 'Version'] as $heading) {
+            echo "<th style='background: #ddd; color: #000'>$heading</th>";
+        }
+        echo '</tr>';
+
+        foreach ( $wp_asset->queue as $asset ) : $nb_of_asset ++;
+            $asset_obj = $wp_asset->registered[ $asset ];
+            $this->asset_template($asset_obj, $nb_of_asset);
+        endforeach;
+
+        echo '</table>';
+    }
+
+    public function asset_template( $asset_obj, $nb_of_asset ) {
+
+        $base_URL = get_bloginfo('url');
+
+        if ( is_object( $asset_obj ) ) {
+            echo '<tr>';
+            echo "<td>$nb_of_asset</td>";
+            echo "<td>{$asset_obj->handle}</td>";
+            echo "<td>". str_replace($base_URL, '', $asset_obj->src) ."</td>";
+            echo "<td>";
+            echo implode(' / ', (array)$asset_obj->deps);
+            echo "</td>";
+            echo "<td>{$asset_obj->ver}</td>";
+            echo "</tr>";
+        }
     }
 
 }
index c0ae3ccc048026f98fa97a70ffe707da371a24f9..6af0bea392b79630e07adc093f47d1d8177cc777 100644 (file)
@@ -12,8 +12,6 @@ use Roots\Sage\Template\BladeProvider;
  * Ref: https://docs.elementor.com/article/286-speed-up-a-slow-site
  */
 add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
-add_action( 'wp_enqueue_scripts', function() { wp_dequeue_style( 'font-awesome' ); }, 50 );
-add_action( 'elementor/frontend/after_enqueue_styles', function () { wp_dequeue_style( 'font-awesome' ); } );
 add_action( 'elementor/frontend/after_enqueue_styles', function() {
     if ( is_admin() || current_user_can( 'manage_options' ) ) {
         return false; // Don't remove it in the backend
@@ -33,6 +31,7 @@ add_action('wp_enqueue_scripts', function() {
             wp_dequeue_style('woocommerce-layout');
             wp_dequeue_style('woocommerce-general');
             wp_dequeue_style('woocommerce-smallscreen');
+            wp_dequeue_style('woocommerce-inline');
             wp_dequeue_style('wc-block-style'); // Gutenberg
 
             ## Dequeue WooCommerce scripts
@@ -42,11 +41,27 @@ add_action('wp_enqueue_scripts', function() {
             wp_deregister_script('js-cookie');
             wp_dequeue_script('js-cookie');
             wp_dequeue_script('vc_woocommerce-add-to-cart-js');
+
+            # Colissimo Shipping Methods plugin
+            wp_dequeue_script('lpc_modal');
+            wp_dequeue_script('lpc_widget');
+            wp_dequeue_script('lpc_pick_up_ws');
+            wp_dequeue_script('wc-backbone-modal');
+            wp_dequeue_style('lpc_bal_return');
+            wp_dequeue_style('lpc_pickup_widget');
+            wp_dequeue_style('lpc_modal');
+            wp_dequeue_style('lpc_pick_up_ws');
+
         }
     }
 
 }, 99);
 
+/**
+ * WPML optimisations
+ */
+add_action('wp_enqueue_scripts', function() { wp_dequeue_style('wpml-legacy-horizontal-list-0'); }, 50);
+
 /**
  * Gutenberg Editor optimisations
  * Disable editor and styles since we don't use it on this site
index abf3acc9606b3ead556d333f4afaf5eb416371fc..44787e516fa2a6f2211cf828fe3040a93ab4519b 100644 (file)
     })(window,document,'script','dataLayer','GTM-M3NHJ8X');</script>
   <!-- End Google Tag Manager -->
 
-  <script>
-    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
-    ga('create', 'UA-74498434-1', 'auto');
-    ga('send', 'pageview');
-  </script>
-  <script async src='https://www.google-analytics.com/analytics.js'></script>
-
   @php(wp_head())
 </head>