| @@ -1,116 +1,76 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Shortcode |
| 4 | 4 | * |
| 5 | - * @package Wow_Plugin | |
| 6 | - * @copyright Copyright (c) 2018, Dmytro Lobov | |
| 5 | + * @package Public | |
| 6 | + * @subpackage | |
| 7 | + * @copyright Copyright (c) 2017, Dmytro Lobov | |
| 7 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 8 | - * @since 1.0 | |
| 9 | + * @since 2.1 | |
| 9 | 10 | */ |
| 10 | - namespace wpcoder; | |
| 11 | 11 | |
| 12 | 12 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 13 | 13 | |
| 14 | - extract( shortcode_atts ( array('id' => "" ), $atts ) ); | |
| 14 | + extract(shortcode_atts(array('id' => ""), $atts)); | |
| 15 | 15 | global $wpdb; |
| 16 | - $table = $wpdb->prefix . 'wow_' . $this->plugin_pref; | |
| 17 | - $sSQL = $wpdb->prepare( "select * from $table WHERE id = %d", $id ); | |
| 18 | - $result = $wpdb->get_results( $sSQL ); | |
| 19 | - if ( count( $result ) > 0 ) { | |
| 20 | - foreach ($result as $key => $val) { | |
| 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 | 21 | $param = unserialize($val->param); |
| 22 | 22 | ob_start(); |
| 23 | 23 | include( 'partials/public.php' ); |
| 24 | - $content = ob_get_contents(); | |
| 24 | + $coder = ob_get_contents(); | |
| 25 | 25 | ob_end_clean(); |
| 26 | - $path_style = $this->basedir . 'style-' . $val->id . '.css'; | |
| 27 | - $path_script = $this->basedir . 'script-' . $val->id . '.js'; | |
| 28 | - $file_style = $this->plugin_dir . 'admin/partials/generator/style.php'; | |
| 29 | - $file_script = $this->plugin_dir . 'admin/partials/generator/script.php'; | |
| 30 | - if ( file_exists( $file_style ) && !file_exists( $path_style ) ) { | |
| 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)){ | |
| 31 | 32 | ob_start(); |
| 32 | - include ( $file_style ); | |
| 33 | + include ($file_style); | |
| 33 | 34 | $content_style = ob_get_contents(); |
| 34 | 35 | ob_end_clean(); |
| 35 | - file_put_contents( $path_style, $content_style ); | |
| 36 | + file_put_contents($path_style, $content_style); | |
| 36 | 37 | } |
| 37 | - if ( file_exists( $file_script ) && !file_exists( $path_script ) ) { | |
| 38 | + if (file_exists($file_script) && !file_exists($path_script)){ | |
| 38 | 39 | ob_start(); |
| 39 | - include ( $file_script ); | |
| 40 | + include ($file_script); | |
| 40 | 41 | $content_script = ob_get_contents(); |
| 41 | - $script_packer = __NAMESPACE__ . '\\JavaScriptPacker'; | |
| 42 | - $packer = new $script_packer( $content_script, 'Normal', true, false ); | |
| 42 | + $packer = new JavaScriptPacker($content_script, 'Normal', true, false); | |
| 43 | 43 | $packed = $packer->pack(); |
| 44 | 44 | ob_end_clean(); |
| 45 | - file_put_contents( $path_script, $packed ); | |
| 46 | - } | |
| 45 | + file_put_contents($path_script, $packed); | |
| 46 | + } | |
| 47 | 47 | |
| 48 | - $param['item_user'] = !empty( $param['item_user'] ) ? $param['item_user'] : '1'; | |
| 49 | - if ( $param['item_user'] == 1 ) { | |
| 50 | - $user = true; | |
| 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); | |
| 51 | 52 | } |
| 52 | - else if ( $param['item_user'] == 2 ) { | |
| 53 | - if ( is_user_logged_in() ) { | |
| 54 | - if ( $param['user_role'] == 'all' ){ | |
| 55 | - $user = true; | |
| 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); | |
| 56 | 62 | } |
| 57 | - else { | |
| 58 | - $current_user = wp_get_current_user(); | |
| 59 | - if ( $param['user_role'] == $current_user->roles[0] ){ | |
| 60 | - $user = true; | |
| 61 | - } | |
| 62 | - else { | |
| 63 | - $user = false; | |
| 64 | - } | |
| 65 | - } | |
| 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 | + | |
| 66 | 67 | } |
| 67 | - else { | |
| 68 | - $user = false; | |
| 69 | - } | |
| 70 | 68 | } |
| 71 | - else if ( $param['item_user'] == 3 ) { | |
| 72 | - $user = !is_user_logged_in(); | |
| 73 | - } | |
| 74 | 69 | |
| 75 | 70 | |
| 76 | - if ( !empty($param['depending_language'] ) ) { | |
| 77 | - $item_lang = $param['lang']; | |
| 78 | - $site_lang = get_locale(); | |
| 79 | - if (substr($site_lang, 0, 2) == $item_lang) { | |
| 80 | - $lang = true; | |
| 81 | - } | |
| 82 | - else { | |
| 83 | - $lang = false; | |
| 84 | - } | |
| 85 | - } | |
| 86 | - else if ( empty( $param['depending_language'] ) ) { | |
| 87 | - $lang = true; | |
| 88 | - } | |
| 89 | 71 | |
| 90 | - if ($user == true && $lang == true) { | |
| 91 | - echo $content; | |
| 92 | - $time = !empty( $param['time'] ) ? $param['time'] : ''; | |
| 93 | - | |
| 94 | - $count_include = !empty( $param['include'] ) ? count( $param['include'] ) : 0; | |
| 95 | - if ( $count_include > 0 ) { | |
| 96 | - for ( $i = 0; $i < $count_include; $i++ ) { | |
| 97 | - if( $param['include'][$i] == 'css' && !empty( $param['include_file'][$i] ) ) { | |
| 98 | - wp_enqueue_style( $this->plugin_slug . '-' . $val->id . '-css-' . $i, $param['include_file'][$i], array(), $this->plugin_version ); | |
| 99 | - } | |
| 100 | - elseif( $param['include'][$i] == 'js' && !empty( $param['include_file'][$i] ) ) { | |
| 101 | - wp_enqueue_script( $this->plugin_slug . '-' . $val->id . '-js-' . $i, $param['include_file'][$i], array( 'jquery' ), $this->plugin_version ); | |
| 102 | - } | |
| 103 | - } | |
| 104 | - } | |
| 105 | - | |
| 106 | - if ( file_exists( $path_style ) && !empty( $param['content_css'] ) ) { | |
| 107 | - wp_enqueue_style( $this->plugin_slug . '-style-' . $val->id, $this->baseurl . 'style-' . $val->id . '.css', array(), $time); | |
| 108 | - } | |
| 109 | - if ( file_exists( $path_script ) && !empty( $param['content_js'] ) ) { | |
| 110 | - wp_enqueue_script( $this->plugin_slug . '-script-' . $val->id, $this->baseurl . 'script-' . $val->id . '.js', array( 'jquery' ), $time ); | |
| 111 | - } | |
| 112 | - | |
| 113 | - } | |
| 114 | - } | |
| 115 | - } | |
| 72 | + } | |
| 73 | + | |
| 74 | + } | |
| 75 | + | |
| 116 | 76 | return ; |