| @@ -1,76 +1,90 @@ | ||
| 1 | -<?php | |
| 2 | - /** | |
| 3 | - * Shortcode | |
| 4 | - * | |
| 5 | - * @package Public | |
| 6 | - * @subpackage | |
| 7 | - * @copyright Copyright (c) 2017, Dmytro Lobov | |
| 8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 9 | - * @since 2.1 | |
| 10 | - */ | |
| 11 | - | |
| 12 | - if ( ! defined( 'ABSPATH' ) ) exit; | |
| 13 | - | |
| 14 | - extract(shortcode_atts(array('id' => ""), $atts)); | |
| 15 | - global $wpdb; | |
| 16 | - $table = $wpdb->prefix . 'wow_'.self::PREF; | |
| 17 | - $sSQL = $wpdb->prepare("select * from $table WHERE id = %d", $id); | |
| 18 | - $arrresult = $wpdb->get_results($sSQL); | |
| 19 | - if (count($arrresult) > 0) { | |
| 20 | - foreach ($arrresult as $key => $val) { | |
| 21 | - $param = unserialize($val->param); | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Shortcode | |
| 4 | + * | |
| 5 | + * @package Wow_Plugin | |
| 6 | + * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 7 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | |
| 8 | + * @since 1.0 | |
| 9 | + */ | |
| 10 | + | |
| 11 | +namespace wpcoder; | |
| 12 | + | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 17 | +extract( shortcode_atts( array( 'id' => "" ), $atts ) ); | |
| 18 | +global $wpdb; | |
| 19 | +$table = $wpdb->prefix . 'wow_' . $this->plugin_pref; | |
| 20 | +$sSQL = $wpdb->prepare( "select * from $table WHERE id = %d", $id ); | |
| 21 | +$result = $wpdb->get_results( $sSQL ); | |
| 22 | +if ( count( $result ) > 0 ) { | |
| 23 | + foreach ( $result as $key => $val ) { | |
| 24 | + $param = unserialize( $val->param ); | |
| 25 | + ob_start(); | |
| 26 | + include( 'partials/public.php' ); | |
| 27 | + $content = ob_get_contents(); | |
| 28 | + ob_end_clean(); | |
| 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 ) ) { | |
| 22 | 34 | ob_start(); |
| 23 | - include( 'partials/public.php' ); | |
| 24 | - $coder = ob_get_contents(); | |
| 35 | + include( $file_style ); | |
| 36 | + $content_style = ob_get_contents(); | |
| 25 | 37 | ob_end_clean(); |
| 26 | - | |
| 27 | - $path_style = $this->plugindir.'/asset/css/style-'.$val->id.'.css'; | |
| 28 | - $path_script = $this->plugindir.'/asset/js/script-'.$val->id.'.js'; | |
| 29 | - $file_style = $this->plugindir.'/admin/partials/generator/style.php'; | |
| 30 | - $file_script = $this->plugindir.'/admin/partials/generator/script.php'; | |
| 31 | - if (file_exists($file_style) && !file_exists($path_style)){ | |
| 32 | - ob_start(); | |
| 33 | - include ($file_style); | |
| 34 | - $content_style = ob_get_contents(); | |
| 35 | - ob_end_clean(); | |
| 36 | - file_put_contents($path_style, $content_style); | |
| 37 | - } | |
| 38 | - if (file_exists($file_script) && !file_exists($path_script)){ | |
| 39 | - ob_start(); | |
| 40 | - include ($file_script); | |
| 41 | - $content_script = ob_get_contents(); | |
| 42 | - $packer = new JavaScriptPacker($content_script, 'Normal', true, false); | |
| 43 | - $packed = $packer->pack(); | |
| 44 | - ob_end_clean(); | |
| 45 | - file_put_contents($path_script, $packed); | |
| 46 | - } | |
| 47 | - | |
| 48 | - echo $coder; | |
| 49 | - $time = !empty($param['time']) ? $param['time'] : ''; | |
| 50 | - if (file_exists($path_style) && !empty($param['content_css']) ) { | |
| 51 | - wp_enqueue_style( $this->pluginname.'-'.$val->id, $this->pluginurl. 'asset/css/style-'.$val->id.'.css', array(), $time); | |
| 52 | - } | |
| 53 | - if (file_exists($path_script) && !empty($param['content_js']) ) { | |
| 54 | - wp_enqueue_script( $this->pluginname.'-'.$val->id, $this->pluginurl. 'asset/js/script-'.$val->id.'.js', array( 'jquery' ), $time ); | |
| 55 | - } | |
| 56 | - | |
| 57 | - $count_include = !empty($param['include']) ? count($param['include']) : 0; | |
| 58 | - if ($count_include > 0){ | |
| 59 | - for ($i = 0; $i < $count_include; $i++) { | |
| 60 | - if( $param['include'][$i] == 'css' && !empty($param['include_file'][$i]) ) { | |
| 61 | - wp_enqueue_style( $this->pluginname.'-'.$val->id.'-css-'.$i, $param['include_file'][$i], array(), $this->version); | |
| 62 | - } | |
| 63 | - elseif( $param['include'][$i] == 'js' && !empty($param['include_file'][$i]) ) { | |
| 64 | - wp_enqueue_script( $this->pluginname.'-'.$val->id.'-js-'.$i, $param['include_file'][$i], array( 'jquery' ), $this->version ); | |
| 65 | - } | |
| 66 | - | |
| 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 | + | |
| 51 | + $user = apply_filters( 'wp_coder_pro_users', $param ); | |
| 52 | + if ( $user == false ) { | |
| 53 | + return false; | |
| 54 | + } | |
| 55 | + | |
| 56 | + $device = apply_filters( 'wp_coder_pro_devices', $param ); | |
| 57 | + if ( $device == false ) { | |
| 58 | + return false; | |
| 59 | + } | |
| 60 | + | |
| 61 | + $lang = apply_filters( 'wp_coder_pro_language', $param ); | |
| 62 | + if ( $lang == false ) { | |
| 63 | + return false; | |
| 64 | + } | |
| 65 | + | |
| 66 | + echo $content; | |
| 67 | + $time = ! empty( $param['time'] ) ? $param['time'] : ''; | |
| 68 | + | |
| 69 | + $count_include = ! empty( $param['include'] ) ? count( $param['include'] ) : 0; | |
| 70 | + if ( $count_include > 0 ) { | |
| 71 | + for ( $i = 0; $i < $count_include; $i ++ ) { | |
| 72 | + if ( $param['include'][ $i ] == 'css' && ! empty( $param['include_file'][ $i ] ) ) { | |
| 73 | + wp_enqueue_style( $this->plugin_slug . '-' . $val->id . '-css-' . $i, $param['include_file'][ $i ], array(), $this->plugin_version ); | |
| 74 | + } elseif ( $param['include'][ $i ] == 'js' && ! empty( $param['include_file'][ $i ] ) ) { | |
| 75 | + wp_enqueue_script( $this->plugin_slug . '-' . $val->id . '-js-' . $i, $param['include_file'][ $i ], array( 'jquery' ), $this->plugin_version ); | |
| 67 | 76 | } |
| 68 | 77 | } |
| 69 | - | |
| 70 | - | |
| 71 | - | |
| 72 | 78 | } |
| 73 | - | |
| 74 | - } | |
| 75 | - | |
| 76 | -return ; | |
| 79 | + | |
| 80 | + if ( file_exists( $path_style ) && ! empty( $param['content_css'] ) ) { | |
| 81 | + wp_enqueue_style( $this->plugin_slug . '-style-' . $val->id, $this->baseurl . 'style-' . $val->id . '.css', array(), $time ); | |
| 82 | + } | |
| 83 | + if ( file_exists( $path_script ) && ! empty( $param['content_js'] ) ) { | |
| 84 | + wp_enqueue_script( $this->plugin_slug . '-script-' . $val->id, $this->baseurl . 'script-' . $val->id . '.js', array( 'jquery' ), $time ); | |
| 85 | + } | |
| 86 | + | |
| 87 | + } | |
| 88 | +} | |
| 89 | + | |
| 90 | +return; | |