| @@ -21,13 +21,34 @@ | ||
| 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 | 54 | |
| @@ -38,12 +59,22 @@ | ||
| 38 | 59 | |
| 39 | 60 | $url_style = $this->plugin['url'] . 'assets/css/style.min.css'; |
| 40 | 61 | wp_enqueue_style( $slug, $url_style, null, $version ); |
| 41 | 62 | |
| 42 | - $inline_style = self::style( $param, $id ); | |
| 43 | - 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 ); | |
| 44 | 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 | + } | |
| 45 | 76 | |
| 46 | 77 | } |
| 47 | 78 | } |
| 48 | 79 | |
| 49 | 80 | return; |