PluginProbe
Float menu – awesome floating side menu / 7.2.5
Float menu – awesome floating side menu v7.2.5
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 / admin / class-wowp-admin.php

class-wowp-admin.php in Float menu – awesome floating side menu 7.2.5, at admin/class-wowp-admin.php

138 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class WOWP_Admin
5 *
6 * The main admin class responsible for initializing the admin functionality of the plugin.
7 *
8 * @package FloatMenuLite
9 * @subpackage Admin
10 * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company
11 * @copyright 2024 Dmytro Lobov
12 * @license GPL-2.0+
13 */
14
15 namespace FloatMenuLite;
16
17 use FloatMenuLite\Admin\AdminActions;
18 use FloatMenuLite\Admin\Dashboard;
19 use FloatMenuLite\Admin\Demo;
20 use FloatMenuLite\Admin\Settings;
21
22 defined( 'ABSPATH' ) || exit;
23
24 class WOWP_Admin {
25 public function __construct() {
26 Dashboard::init();
27 AdminActions::init();
28 Demo::init();
29
30 add_action( 'wp_ajax_' . WOWP_Plugin::PREFIX . '_ajax_settings', [ Settings::class, 'save_item' ] );
31 add_action( WOWP_Plugin::PREFIX . '_admin_header_links', [ $this, 'plugin_links' ] );
32 add_filter( WOWP_Plugin::PREFIX . '_save_settings', [ $this, 'save_settings' ] );
33 add_action( WOWP_Plugin::PREFIX . '_admin_load_assets', [ $this, 'load_assets' ] );
34 }
35
36 public function plugin_links(): void {
37 $links = [
38 'change' => __( 'Check for Updates', 'float-menu' ),
39 'rating' => __( 'Rate Us', 'float-menu', ),
40 'pro' => __( 'Pro Plugin', 'float-menu' ),
41 'docs' => __( 'Documentation', 'float-menu' ),
42 'demo' => __( 'Pro Demo', 'float-menu' ),
43 ];
44
45 echo '<div class="wpie-links">';
46
47 $i = 1;
48 foreach ( $links as $slug => $title ) {
49
50 $link = WOWP_Plugin::info( $slug );
51 if ( empty( $link ) ) {
52 continue;
53 }
54
55 if ( $i % 3 === 0 ) {
56 echo '<span class="wpie-links-divider">|</span>';
57 }
58
59 echo '<a href="' . esc_url( $link ) . '" class="wowp-link-' . esc_attr( $slug ) . '" target="_blank">' . esc_html( $title ) . '</a>';
60
61 $i ++;
62 }
63
64 echo '</div>';
65 }
66
67 public function save_settings( $request ) {
68
69 $param = ! empty( $request ) ? map_deep( wp_unslash( $request ), 'sanitize_text_field' ) : [];
70
71 if ( isset( $request['menu_1']['item_text'] ) ) {
72 $param['menu_1']['item_text'] = map_deep( wp_unslash( $request['menu_1']['item_text'] ), array(
73 $this,
74 'sanitize_text'
75 ) );
76 }
77
78 if ( isset( $request['menu_1']['popupcontent'] ) ) {
79 $param['menu_1']['popupcontent'] = map_deep( wp_unslash( $request['menu_1']['popupcontent'] ), array(
80 $this,
81 'sanitize_text'
82 ) );
83 }
84
85 if ( isset( $request['menu_1']['item_link'] ) ) {
86 $param['menu_1']['item_link'] = map_deep( wp_unslash( $request['menu_1']['item_link'] ), array($this, 'sanitize_link') );
87 }
88
89 if ( isset( $request['link'] ) ) {
90 $param['link'] = $this->sanitize_link( wp_unslash( $request['link'] ) );
91 }
92
93 return $param;
94 }
95
96 public function sanitize_text( $text ): string {
97 return wp_kses_post( wp_unslash( $text ) );
98 }
99
100 public function sanitize_tooltip( $text ): string {
101 return sanitize_text_field( wp_unslash( $text ) );
102 }
103
104 public function sanitize_link( $link ) {
105 if ( wp_http_validate_url( $link ) ) {
106 return esc_url_raw( $link );
107 }
108 return sanitize_text_field( $link );
109 }
110
111
112 public function load_assets(): void {
113
114 wp_enqueue_style( 'wp-color-picker' );
115 wp_enqueue_script( 'wp-color-picker' );
116 wp_enqueue_script( 'jquery-ui-sortable' );
117 wp_enqueue_editor();
118 wp_enqueue_media();
119
120 $handle = WOWP_Plugin::SLUG;
121 $version = WOWP_Plugin::info( 'version' );
122 $url_assets = WOWP_Plugin::url() . 'vendors/';
123
124 $url_fontawesome = $url_assets . 'fontawesome/css/all.min.css';
125 wp_enqueue_style( $handle . '-fontawesome', $url_fontawesome, null, '7.1' );
126
127 $fonticonpicker_js = $url_assets . 'fonticonpicker/js/jquery.fonticonpicker.js';
128 wp_enqueue_script( $handle . '-fonticonpicker', $fonticonpicker_js, array( 'jquery' ), $version, true );
129
130 $fonticonpicker_css = $url_assets . 'fonticonpicker/css/base/jquery.fonticonpicker.css';
131 wp_enqueue_style( $handle . '-fonticonpicker', $fonticonpicker_css, null, $version );
132
133 $fonticonpicker_dark_css = $url_assets . 'fonticonpicker/css/themes/dark-grey-theme/jquery.fonticonpicker.darkgrey.css';
134 wp_enqueue_style( $handle . '-fonticonpicker-darkgrey', $fonticonpicker_dark_css, null, $version );
135
136 }
137
138 }