PluginProbe
Float menu – awesome floating side menu / 4.2
Float menu – awesome floating side menu v4.2
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
float-menu / public / class-public.php

class-public.php in Float menu – awesome floating side menu 4.2, at public/class-public.php

168 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 * @copyright Copyright (c) 2018, Dmytro Lobov
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.0
10 */
11
12 namespace float_menu_free;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 class Wow_Plugin_Public {
19
20 /**
21 * Setup to admin panel of the plugin
22 *
23 * @param array $info general information about the plugin
24 *
25 * @since 1.0
26 */
27 public function __construct( $info ) {
28 $this->plugin = $info['plugin'];
29 $this->url = $info['url'];
30 $this->rating = $info['rating'];
31
32
33 add_shortcode( $this->plugin['shortcode'], array( $this, 'shortcode' ) );
34 // Display on the site
35 add_action( 'wp_footer', array( $this, 'display' ) );
36 }
37
38 static function sub_menu_array( $var ) {
39 return ( ! empty( $var ) );
40 }
41
42 /**
43 * Display a shortcode
44 *
45 * @param $atts
46 *
47 * @return false|string
48 */
49 public function shortcode( $atts ) {
50 extract( shortcode_atts( array( 'id' => "" ), $atts ) );
51 $id = absint( $atts['id'] );
52
53 global $wpdb;
54 $table = $wpdb->prefix . 'wow_' . $this->plugin['prefix'];
55 $sSQL = $wpdb->prepare( "select * from $table WHERE id = %d", $id );
56 $result = $wpdb->get_results( $sSQL, 'OBJECT_K' );
57
58 if ( empty( $result ) ) {
59 return false;
60 }
61
62 $param = unserialize( $result[ $id ]->param );
63 $check = $this->check( $param, $id );
64
65 if ( $check === false ) {
66 return false;
67 }
68 ob_start();
69 include( 'partials/public.php' );
70 $menu = ob_get_contents();
71 ob_end_clean();
72
73 $this->include_style_script( $param, $id );
74
75 return $menu;
76
77 }
78
79 private function include_style_script( $param, $id ) {
80 $slug = $this->plugin['slug'];
81 $version = $this->plugin['version'];
82
83 if ( empty( $param['disable_fontawesome'] ) ) {
84 $url_icons = $this->plugin['url'] . 'vendors/fontawesome/css/fontawesome-all.min.css';
85 wp_enqueue_style( $slug . '-fontawesome', $url_icons, null, '5.11.2' );
86 }
87
88 $url_style = plugin_dir_url(__FILE__) . 'assets/css/style.min.css';
89 wp_enqueue_style( $slug, $url_style, null, $version );
90
91 $inline_style = self::style( $param, $id );
92 wp_add_inline_style( $slug, $inline_style );
93
94 $url_velocity = plugin_dir_url(__FILE__) . 'assets/js/velocity.min.js';
95 wp_enqueue_script( 'velocity', $url_velocity, array( 'jquery' ), $version );
96
97 $url_script = plugin_dir_url(__FILE__) . 'assets/js/floatMenu.min.js';
98 wp_enqueue_script( $slug, $url_script, array( 'jquery' ), $version );
99
100 $inline_script = self::script( $param, $id );
101 wp_add_inline_script( $slug, $inline_script );
102 }
103
104
105 /**
106 * Display the Item on the specific pages, not via the Shortcode
107 */
108 public function display() {
109 require plugin_dir_path( __FILE__ ) . 'display.php';
110 }
111
112 /**
113 * Create Inline style for elements
114 */
115 public function style( $param, $id ) {
116 $css = '';
117 require 'generator-style.php';
118
119 return $css;
120
121 }
122
123 /**
124 * Create Inline script for elements
125 */
126 public function script( $param, $id ) {
127 $js = '';
128 require 'generator-script.php';
129
130 return $js;
131
132 }
133
134 private function check_status( $param ) {
135 $status = isset( $param['menu_status'] ) ? $param['menu_status'] : 1;
136 if ( empty( $status ) ) {
137 return false;
138 }
139
140 return true;
141 }
142
143 private function check_test_mode( $param ) {
144 if ( ! empty( $param['test_mode'] ) && ! current_user_can( 'administrator' ) ) {
145 return false;
146 }
147
148 return true;
149 }
150
151 private function check( $param, $id ) {
152 $check = true;
153 $check_arr = array(
154 'status' => $this->check_status( $param ),
155 'test_mode' => $this->check_test_mode( $param ),
156 );
157
158 foreach ( $check_arr as $value ) {
159 if ( $value === false ) {
160 $check = false;
161 break;
162 }
163 }
164
165 return $check;
166 }
167
168 }