| 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 floatingbutton; |
| 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['prefix']; |
| 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 ) ) { |
| 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; |
| 51 |
$time = ! empty( $param['time'] ) ? $param['time'] : ''; |
| 52 |
$slug = $this->plugin['slug']; |
| 53 |
$version = $this->plugin['version']; |
| 54 |
|
| 55 |
if ( empty( $param['disable_fontawesome'] ) ) { |
| 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' ); |
| 58 |
} |
| 59 |
|
| 60 |
$url_style = $this->plugin['url'] . 'assets/css/style.min.css'; |
| 61 |
wp_enqueue_style( $slug, $url_style, null, $version ); |
| 62 |
|
| 63 |
$url_script = $this->plugin['url'] . 'assets/js/script.min.js'; |
| 64 |
wp_enqueue_script( $slug, $url_script, array( 'jquery' ), $version ); |
| 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 |
} |
| 76 |
|
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
return; |