Plugin Directory

Changeset 3020021


Ignore:
Timestamp:
01/10/2024 08:03:02 PM (2 years ago)
Author:
spanrig
Message:

Fixed: Styles and Scripts were loading on all pages. Now loads on only those pages where shortcode is used.

Location:
embed-swagger-ui
Files:
41 added
2 edited

Legend:

Unmodified
Added
Removed
  • embed-swagger-ui/trunk/core/includes/classes/class-wp-swagger-ui-run.php

    r2901159 r3020021  
    121121     */
    122122    public function enqueue_frontend_scripts_and_styles() {
    123         wp_enqueue_style( 'wpsgui-swagger-ui-css', WPSGUI_PLUGIN_URL . 'core/includes/assets/css/swagger-ui.css', array(), WPSGUI_VERSION, 'all' );
    124         wp_enqueue_script( 'wpsgui-swagger-ui-js', WPSGUI_PLUGIN_URL . 'core/includes/assets/js/swagger-ui.js', array(), WPSGUI_VERSION, 'all' );
    125         wp_enqueue_script( 'wpsgui-swagger-ui-bundle', WPSGUI_PLUGIN_URL . 'core/includes/assets/js/swagger-ui-bundle.js', array(), WPSGUI_VERSION, true );
    126         wp_enqueue_script( 'wpsgui-swagger-ui-standalone-preset', WPSGUI_PLUGIN_URL . 'core/includes/assets/js/swagger-ui-standalone-preset.js', array('wpsgui-swagger-ui-bundle'), WPSGUI_VERSION, true );
     123        global $post;
     124        if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'wpsgui') ) {
     125            wp_enqueue_style( 'wpsgui-swagger-ui-css', WPSGUI_PLUGIN_URL . 'core/includes/assets/css/swagger-ui.css', array(), WPSGUI_VERSION, 'all' );
     126            wp_enqueue_script( 'wpsgui-swagger-ui-js', WPSGUI_PLUGIN_URL . 'core/includes/assets/js/swagger-ui.js', array(), WPSGUI_VERSION, 'all' );
     127            wp_enqueue_script( 'wpsgui-swagger-ui-bundle', WPSGUI_PLUGIN_URL . 'core/includes/assets/js/swagger-ui-bundle.js', array(), WPSGUI_VERSION, true );
     128            wp_enqueue_script( 'wpsgui-swagger-ui-standalone-preset', WPSGUI_PLUGIN_URL . 'core/includes/assets/js/swagger-ui-standalone-preset.js', array('wpsgui-swagger-ui-bundle'), WPSGUI_VERSION, true );
     129        }
    127130    }
    128131
  • embed-swagger-ui/trunk/readme.txt

    r2901161 r3020021  
    88Tested up to: 6.2
    99Requires PHP: 7.4
    10 Stable tag: 1.0.0
     10Stable tag: 1.0.1
    1111License: GPLv3 or later
    1212License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.