| @@ -34,11 +34,17 @@ | ||
| 34 | 34 | */ |
| 35 | 35 | public function loadShortcodeAssets() { |
| 36 | 36 | global $post; |
| 37 | 37 | |
| 38 | + if ( !empty( \Depicter::options()->get( 'always_load_assets', 1 ) ) ) { | |
| 39 | + \Depicter::front()->assets()->enqueueStyles(); | |
| 40 | + \Depicter::front()->assets()->enqueueScripts(); | |
| 41 | + } | |
| 42 | + | |
| 38 | 43 | if( empty( $post->post_content ) ){ |
| 39 | 44 | return; |
| 40 | 45 | } |
| 46 | + | |
| 41 | 47 | $content = $post->post_content; |
| 42 | 48 | |
| 43 | 49 | $shortcodeInfo = Extract::shortcodeAttributes( $content, self::SHORTCODE_NAME, self::SHORTCODE_ATTRS ); |
| 44 | 50 | |
| @@ -49,14 +55,11 @@ | ||
| 49 | 55 | \Depicter::front()->assets()->enqueueScripts(); |
| 50 | 56 | |
| 51 | 57 | // Load custom css files |
| 52 | 58 | foreach( self::SHORTCODE_ATTRS as $documentAttribute ){ |
| 53 | - if( ! empty( $shortcodeInfo[ $documentAttribute ] ) ){ | |
| 54 | - if ( \Depicter::authorization()->currentUserCan( [ 'manage_options', 'publish_depicter' ] ) ) { | |
| 55 | - \Depicter::front()->assets()->enqueueCustomGoogleFonts( $shortcodeInfo[ $documentAttribute ][0] ); | |
| 56 | - } else { | |
| 57 | - \Depicter::front()->assets()->enqueueCustomStyles( $shortcodeInfo[ $documentAttribute ][0] ); | |
| 58 | - } | |
| 59 | + if( ! empty( $shortcodeInfo[ $documentAttribute ][0] ) ){ | |
| 60 | + \Depicter::front()->assets()->enqueueCustomAssets( $shortcodeInfo[ $documentAttribute ][0] ); | |
| 61 | + \Depicter::front()->assets()->enqueuePreloadTags( $shortcodeInfo[ $documentAttribute ][0] ); | |
| 59 | 62 | } |
| 60 | 63 | } |
| 61 | 64 | } |
| 62 | 65 | |
| @@ -67,13 +70,10 @@ | ||
| 67 | 70 | |
| 68 | 71 | preg_match_all( '/wp:depicter\/slider\s+{"id":(\d+)/', $post->post_content, $sliderIDs, PREG_SET_ORDER ); |
| 69 | 72 | if ( !empty( $sliderIDs ) ) { |
| 70 | 73 | foreach( $sliderIDs as $sliderID ) { |
| 71 | - if ( \Depicter::authorization()->currentUserCan( [ 'manage_options', 'publish_depicter' ] ) ) { | |
| 72 | - \Depicter::front()->assets()->enqueueCustomGoogleFonts( $sliderID[1] ); | |
| 73 | - } else { | |
| 74 | - \Depicter::front()->assets()->enqueueCustomStyles( $sliderID[1] ); | |
| 75 | - } | |
| 74 | + \Depicter::front()->assets()->enqueueCustomAssets( $sliderID[1] ); | |
| 75 | + \Depicter::front()->assets()->enqueuePreloadTags( $sliderID[1] ); | |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } |