PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 5.0.1
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v5.0.1
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / public / class-public.php

class-public.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 5.0.1, at public/class-public.php

176 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Public Class
4 *
5 * @package Wow_Plugin
6 * @subpackage Public
7 * @author Wow-Company <helper@wow-company.com>
8 * @copyright 2019 Wow-Company
9 * @license GNU Public License
10 * @version 1.0
11 */
12
13 namespace floatingbutton;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Class Wow_Plugin_Public
21 *
22 * @package wow_plugin
23 *
24 * @property array plugin - base information about the plugin
25 * @property array url - home, pro and other URL for plugin
26 * @property array rating - website and link for rating
27 * @property string basedir - filesystem directory path for the plugin
28 * @property string baseurl - URL directory path for the plugin
29 */
30 class Wow_Plugin_Public {
31
32 /**
33 * Setup to frontend of the plugin
34 *
35 * @param array $info general information about the plugin
36 *
37 * @since 1.0
38 */
39
40 public function __construct( $info ) {
41
42 $this->plugin = $info['plugin'];
43 $this->url = $info['url'];
44 $this->rating = $info['rating'];
45
46 add_shortcode( $this->plugin['shortcode'], array( $this, 'shortcode' ) );
47
48 // Display on the site
49 add_action( 'wp_footer', array( $this, 'display' ) );
50 add_filter( 'script_loader_tag', array( $this, 'add_defer_attribute' ), 10, 2 );
51
52 }
53
54
55 /**
56 * Display a shortcode
57 *
58 * @param $atts
59 *
60 * @return false|string
61 */
62 public function shortcode( $atts ) {
63 extract( shortcode_atts( array( 'id' => "" ), $atts ) );
64 $id = absint( $atts['id'] );
65
66 global $wpdb;
67 $table = $wpdb->prefix . 'wow_' . $this->plugin['prefix'];
68 $sSQL = $wpdb->prepare( "select * from $table WHERE id = %d", $id );
69 $result = $wpdb->get_results( $sSQL, 'OBJECT_K' );
70
71 if ( empty( $result ) ) {
72 return false;
73 }
74
75 $param = unserialize( $result[ $id ]->param );
76 $check = $this->check( $param, $id );
77
78 if ( $check === false ) {
79 return false;
80 }
81
82 $menu = '';
83 include( 'partials/public.php' );
84
85 $this->include_style_script( $param, $id );
86
87 return $menu;
88
89 }
90
91 private function include_style_script( $param, $id ) {
92
93 $slug = $this->plugin['slug'];
94 $version = $this->plugin['version'];
95
96 $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
97
98 $url_style = plugin_dir_url( __FILE__ ) . 'assets/css/style' . $pre_suffix . '.css';
99 wp_enqueue_style( $slug, $url_style, null, $version );
100
101 $inline_style = self::style( $param, $id );
102 wp_add_inline_style( $slug, $inline_style );
103
104 if ( empty( $param['disable_fontawesome'] ) ) {
105 $url_icons = $this->plugin['url'] . 'vendors/fontawesome/css/fontawesome-all' . $pre_suffix . '.css';
106 wp_enqueue_style( $slug . '-fontawesome', $url_icons, null, '5.14' );
107 }
108
109 }
110
111
112 /**
113 * Display the Item on the specific pages, not via the Shortcode
114 */
115 public function display() {
116 require plugin_dir_path( __FILE__ ) . 'display.php';
117 }
118
119 /**
120 * Create Inline style for elements
121 */
122 public function style( $param, $id ) {
123 $css = '';
124 require 'generator-style.php';
125
126 return $css;
127 }
128
129 /**
130 * Add the tag defer to script
131 */
132 function add_defer_attribute( $tag, $handle ) {
133 if ( $this->plugin['slug'] !== $handle ) {
134 return $tag;
135 }
136
137 return str_replace( ' src', ' defer="defer" src', $tag );
138 }
139
140 private function check_test_mode( $param ) {
141 if ( ! empty( $param['test_mode'] ) && ! current_user_can( 'administrator' ) ) {
142 return false;
143 }
144
145 return true;
146 }
147
148 private function check_status( $param ) {
149 $status = isset( $param['menu_status'] ) ? $param['menu_status'] : 1;
150 if ( empty( $status ) ) {
151 return false;
152 }
153
154 return true;
155 }
156
157 private function check( $param, $id ) {
158 $check = true;
159 $check_arr = array(
160 'status' => $this->check_status( $param ),
161 'test_mode' => $this->check_test_mode( $param ),
162 );
163
164 foreach ( $check_arr as $value ) {
165 if ( $value === false ) {
166 $check = false;
167 break;
168 }
169 }
170
171 return $check;
172 }
173
174
175 }
176