| @@ -21,31 +21,60 @@ | ||
| 21 | 21 | $result = $wpdb->get_results( $sSQL ); |
| 22 | 22 | if ( count( $result ) > 0 ) { |
| 23 | 23 | foreach ( $result as $key => $val ) { |
| 24 | 24 | $param = unserialize( $val->param ); |
| 25 | - | |
| 26 | 25 | ob_start(); |
| 27 | 26 | include( 'partials/public.php' ); |
| 27 | + $content = ob_get_contents(); | |
| 28 | 28 | ob_end_clean(); |
| 29 | - | |
| 29 | + $path_style = $this->basedir . 'style-' . $val->id . '.css'; | |
| 30 | + $path_script = $this->basedir . 'script-' . $val->id . '.js'; | |
| 31 | + $file_style = $this->plugin['dir'] . 'admin/partials/generator/style.php'; | |
| 32 | + $file_script = $this->plugin['dir'] . 'admin/partials/generator/script.php'; | |
| 33 | + if ( file_exists( $file_style ) && ! file_exists( $path_style ) ) { | |
| 34 | + ob_start(); | |
| 35 | + include( $file_style ); | |
| 36 | + $content_style = ob_get_contents(); | |
| 37 | + ob_end_clean(); | |
| 38 | + file_put_contents( $path_style, $content_style ); | |
| 39 | + } | |
| 40 | + if ( file_exists( $file_script ) && ! file_exists( $path_script ) ) { | |
| 41 | + ob_start(); | |
| 42 | + include( $file_script ); | |
| 43 | + $content_script = ob_get_contents(); | |
| 44 | + $script_packer = __NAMESPACE__ . '\\JavaScriptPacker'; | |
| 45 | + $packer = new $script_packer( $content_script, 'Normal', true, false ); | |
| 46 | + $packed = $packer->pack(); | |
| 47 | + ob_end_clean(); | |
| 48 | + file_put_contents( $path_script, $packed ); | |
| 49 | + } | |
| 50 | + echo $content; | |
| 30 | 51 | $time = ! empty( $param['time'] ) ? $param['time'] : ''; |
| 31 | 52 | $slug = $this->plugin['slug']; |
| 32 | 53 | $version = $this->plugin['version']; |
| 33 | - | |
| 34 | - $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 35 | 54 | |
| 36 | 55 | if ( empty( $param['disable_fontawesome'] ) ) { |
| 37 | - $url_icons = $this->plugin['url'] . 'assets/vendors/fontawesome/css/fontawesome-all' . $pre_suffix . '.css'; | |
| 38 | - wp_enqueue_style( $slug . '-fontawesome', $url_icons, null, '5.14' ); | |
| 56 | + $url_icons = $this->plugin['url'] . 'assets/vendors/fontawesome/css/fontawesome-all.min.css'; | |
| 57 | + wp_enqueue_style( $slug . '-fontawesome', $url_icons, null, '5.6.3' ); | |
| 39 | 58 | } |
| 40 | 59 | |
| 41 | - $url_style = $this->plugin['url'] . 'assets/css/style' . $pre_suffix . '.css'; | |
| 60 | + $url_style = $this->plugin['url'] . 'assets/css/style.min.css'; | |
| 42 | 61 | wp_enqueue_style( $slug, $url_style, null, $version ); |
| 43 | 62 | |
| 44 | - $inline_style = self::style( $param, $id ); | |
| 45 | - wp_add_inline_style( $slug, $inline_style ); | |
| 63 | + $url_script = $this->plugin['url'] . 'assets/js/script.min.js'; | |
| 64 | + wp_enqueue_script( $slug, $url_script, array( 'jquery' ), $version ); | |
| 46 | 65 | |
| 66 | + | |
| 67 | + if ( file_exists( $path_style ) ) { | |
| 68 | + $url_css = $this->baseurl . 'style-' . $val->id . '.css'; | |
| 69 | + wp_enqueue_style( $slug . '-' . $val->id, $url_css, array(), $time ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + if ( file_exists( $path_script ) ) { | |
| 73 | + $url_js = $this->baseurl . 'script-' . $val->id . '.js'; | |
| 74 | + wp_enqueue_script( $slug . '-' . $val->id, $url_js, array( 'jquery' ), $time ); | |
| 75 | + } | |
| 47 | 76 | |
| 48 | 77 | } |
| 49 | 78 | } |
| 50 | 79 | |
| 51 | 80 | return; |