PluginProbe
WP Coder – Insert & Manage Code Snippets / 2.5.4
WP Coder – Insert & Manage Code Snippets v2.5.4
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
← All changes | public/shortcode.php +93 -111 2.3.22.5.4 View file →
@@ -1,116 +1,98 @@
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 - namespace wpcoder;
11 -
12 - if ( ! defined( 'ABSPATH' ) ) exit;
13 -
14 - extract( shortcode_atts ( array('id' => "" ), $atts ) );
15 - global $wpdb;
16 - $table = $wpdb->prefix . 'wow_' . $this->plugin_pref;
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' => "", 'title' => '', ), $atts ) );
18 +
19 +if ( ! empty( $atts['id'] ) ) {
20 + $id = absint( $atts['id'] );
21 +}
22 +
23 +global $wpdb;
24 +$table = $wpdb->prefix . 'wow_' . $this->plugin_pref;
25 +if ( ! empty( $id ) ) {
17 26 $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) {
21 - $param = unserialize($val->param);
27 +} elseif ( ! empty( $atts['title'] ) ) {
28 + $sSQL = $wpdb->prepare( "select * from $table WHERE title = %s", $atts['title'] );
29 +} else {
30 + return false;
31 +}
32 +$result = $wpdb->get_results( $sSQL );
33 +if ( count( $result ) > 0 ) {
34 + foreach ( $result as $key => $val ) {
35 + $param = unserialize( $val->param );
36 + $content = do_shortcode( $param['content_html'] );
37 + $path_style = $this->basedir . 'style-' . $val->id . '.css';
38 + $path_script = $this->basedir . 'script-' . $val->id . '.js';
39 + $file_style = $this->plugin_dir . 'admin/partials/generator/style.php';
40 + $file_script = $this->plugin_dir . 'admin/partials/generator/script.php';
41 + if ( file_exists( $file_style ) && ! file_exists( $path_style ) ) {
22 42 ob_start();
23 - include( 'partials/public.php' );
24 - $content = ob_get_contents();
43 + include( $file_style );
44 + $content_style = ob_get_contents();
25 45 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 ) ) {
31 - ob_start();
32 - include ( $file_style );
33 - $content_style = ob_get_contents();
34 - ob_end_clean();
35 - file_put_contents( $path_style, $content_style );
36 - }
37 - if ( file_exists( $file_script ) && !file_exists( $path_script ) ) {
38 - ob_start();
39 - include ( $file_script );
40 - $content_script = ob_get_contents();
41 - $script_packer = __NAMESPACE__ . '\\JavaScriptPacker';
42 - $packer = new $script_packer( $content_script, 'Normal', true, false );
43 - $packed = $packer->pack();
44 - ob_end_clean();
45 - file_put_contents( $path_script, $packed );
46 - }
47 -
48 - $param['item_user'] = !empty( $param['item_user'] ) ? $param['item_user'] : '1';
49 - if ( $param['item_user'] == 1 ) {
50 - $user = true;
51 - }
52 - else if ( $param['item_user'] == 2 ) {
53 - if ( is_user_logged_in() ) {
54 - if ( $param['user_role'] == 'all' ){
55 - $user = true;
56 - }
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 - }
46 + file_put_contents( $path_style, $content_style );
47 + }
48 + if ( file_exists( $file_script ) && ! file_exists( $path_script ) ) {
49 + ob_start();
50 + include( $file_script );
51 + $content_script = ob_get_contents();
52 + $script_packer = __NAMESPACE__ . '\\JavaScriptPacker';
53 + $packer = new $script_packer( $content_script, 'Normal', true, false );
54 + $packed = $packer->pack();
55 + ob_end_clean();
56 + file_put_contents( $path_script, $packed );
57 + }
58 +
59 + $user = apply_filters( 'wp_coder_pro_users', $param );
60 + if ( $user == false ) {
61 + return false;
62 + }
63 +
64 + $device = apply_filters( 'wp_coder_pro_devices', $param );
65 + if ( $device == false ) {
66 + return false;
67 + }
68 +
69 + $lang = apply_filters( 'wp_coder_pro_language', $param );
70 + if ( $lang == false ) {
71 + return false;
72 + }
73 +
74 + echo $content;
75 + $time = ! empty( $param['time'] ) ? $param['time'] : '';
76 +
77 + $count_include = ! empty( $param['include'] ) ? count( $param['include'] ) : 0;
78 + if ( $count_include > 0 ) {
79 + for ( $i = 0; $i < $count_include; $i ++ ) {
80 + if ( $param['include'][ $i ] == 'css' && ! empty( $param['include_file'][ $i ] ) ) {
81 + wp_enqueue_style( $this->plugin_slug . '-' . $val->id . '-css-' . $i, $param['include_file'][ $i ], array(), $this->plugin_version );
82 + } elseif ( $param['include'][ $i ] == 'js' && ! empty( $param['include_file'][ $i ] ) ) {
83 + wp_enqueue_script( $this->plugin_slug . '-' . $val->id . '-js-' . $i, $param['include_file'][ $i ], array( 'jquery' ), $this->plugin_version );
66 84 }
67 - else {
68 - $user = false;
69 - }
70 85 }
71 - else if ( $param['item_user'] == 3 ) {
72 - $user = !is_user_logged_in();
73 - }
74 -
75 -
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 -
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 - }
116 -return ;
86 + }
87 +
88 + if ( file_exists( $path_style ) && ! empty( $param['content_css'] ) ) {
89 + wp_enqueue_style( $this->plugin_slug . '-style-' . $val->id, $this->baseurl . 'style-' . $val->id . '.css', array(), $time );
90 + }
91 + if ( file_exists( $path_script ) && ! empty( $param['content_js'] ) ) {
92 + wp_enqueue_script( $this->plugin_slug . '-script-' . $val->id, $this->baseurl . 'script-' . $val->id . '.js', array( 'jquery' ), $time );
93 + }
94 +
95 + }
96 +}
97 +
98 +return;