PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 5.1.1
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v5.1.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.1.1, at public/class-public.php

177 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 add_action( 'amp_post_template_footer', array( $this, 'display' ) );
52
53 }
54
55
56 /**
57 * Display a shortcode
58 *
59 * @param $atts
60 *
61 * @return false|string
62 */
63 public function shortcode( $atts ) {
64 extract( shortcode_atts( array( 'id' => "" ), $atts ) );
65 $id = absint( $atts['id'] );
66
67 global $wpdb;
68 $table = $wpdb->prefix . 'wow_' . $this->plugin['prefix'];
69 $sSQL = $wpdb->prepare( "select * from $table WHERE id = %d", $id );
70 $result = $wpdb->get_results( $sSQL, 'OBJECT_K' );
71
72 if ( empty( $result ) ) {
73 return false;
74 }
75
76 $param = unserialize( $result[ $id ]->param );
77 $check = $this->check( $param, $id );
78
79 if ( $check === false ) {
80 return false;
81 }
82
83 $menu = '';
84 include( 'partials/public.php' );
85
86 $this->include_style_script( $param, $id );
87
88 return $menu;
89
90 }
91
92 private function include_style_script( $param, $id ) {
93
94 $slug = $this->plugin['slug'];
95 $version = $this->plugin['version'];
96
97 $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
98
99 $url_style = plugin_dir_url( __FILE__ ) . 'assets/css/style' . $pre_suffix . '.css';
100 wp_enqueue_style( $slug, $url_style, null, $version );
101
102 $inline_style = self::style( $param, $id );
103 wp_add_inline_style( $slug, $inline_style );
104
105 if ( empty( $param['disable_fontawesome'] ) ) {
106 $url_icons = $this->plugin['url'] . 'vendors/fontawesome/css/fontawesome-all' . $pre_suffix . '.css';
107 wp_enqueue_style( $slug . '-fontawesome', $url_icons, null, '5.14' );
108 }
109
110 }
111
112
113 /**
114 * Display the Item on the specific pages, not via the Shortcode
115 */
116 public function display() {
117 require plugin_dir_path( __FILE__ ) . 'display.php';
118 }
119
120 /**
121 * Create Inline style for elements
122 */
123 public function style( $param, $id ) {
124 $css = '';
125 require 'generator-style.php';
126
127 return $css;
128 }
129
130 /**
131 * Add the tag defer to script
132 */
133 function add_defer_attribute( $tag, $handle ) {
134 if ( $this->plugin['slug'] !== $handle ) {
135 return $tag;
136 }
137
138 return str_replace( ' src', ' defer="defer" src', $tag );
139 }
140
141 private function check_test_mode( $param ) {
142 if ( ! empty( $param['test_mode'] ) && ! current_user_can( 'administrator' ) ) {
143 return false;
144 }
145
146 return true;
147 }
148
149 private function check_status( $param ) {
150 $status = isset( $param['menu_status'] ) ? $param['menu_status'] : 1;
151 if ( empty( $status ) ) {
152 return false;
153 }
154
155 return true;
156 }
157
158 private function check( $param, $id ) {
159 $check = true;
160 $check_arr = array(
161 'status' => $this->check_status( $param ),
162 'test_mode' => $this->check_test_mode( $param ),
163 );
164
165 foreach ( $check_arr as $value ) {
166 if ( $value === false ) {
167 $check = false;
168 break;
169 }
170 }
171
172 return $check;
173 }
174
175
176 }
177