PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 2.0.0
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v2.0.0
4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
quickwebp / admin / class-settings.php

class-settings.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 2.0.0, at admin/class-settings.php

114 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link http://webdeclic.com
6 * @since 1.0.0
7 *
8 * @package Quickwebp
9 * @subpackage Quickwebp/admin
10 */
11 class Quickwebp_Settings {
12
13 /**
14 * The ID of this plugin.
15 *
16 * @since 1.0.0
17 * @access private
18 * @var string $plugin_name The ID of this plugin.
19 */
20 private $plugin_name;
21
22 /**
23 * The version of this plugin.
24 *
25 * @since 1.0.0
26 * @access private
27 * @var string $version The current version of this plugin.
28 */
29 private $version;
30
31 /**
32 * Initialize the class and set its properties.
33 *
34 * @since 1.0.0
35 * @param string $plugin_name The name of this plugin.
36 * @param string $version The version of this plugin.
37 */
38 public function __construct( $plugin_name, $version ) {
39
40 $this->plugin_name = $plugin_name;
41 $this->version = $version;
42
43 }
44
45 /**
46 * Enqueue scripts and styles
47 *
48 */
49 public function enqueue_scripts_styles( $hook_suffix ) {
50 if ( $hook_suffix == 'toplevel_page_quickwebp-settings' || $hook_suffix == 'media_page_quickwebp-settings' ) {
51
52 $admin_main_settings_assets = include( QUICKWEBP_PLUGIN_PATH . 'public/assets/build/admin-main-settings.asset.php' );
53 wp_enqueue_style( 'quickwebpoi_admin_main_settings', QUICKWEBP_PLUGIN_URL . 'public/assets/build/admin-main-settings.css', array(), $admin_main_settings_assets['version'], 'all' );
54 wp_enqueue_script( 'quickwebpoi_admin_main_settings', QUICKWEBP_PLUGIN_URL . 'public/assets/build/admin-main-settings.js', $admin_main_settings_assets['dependencies'], $admin_main_settings_assets['version'], true );
55 }
56 }
57
58 /**
59 * add_settings_menu
60 *
61 * @return void
62 */
63 public function add_settings_menu() {
64 add_submenu_page(
65 'upload.php',
66 __('Quickwebp Settings', QUICKWEBP_TEXT_DOMAIN),
67 __('Quickwebp', QUICKWEBP_TEXT_DOMAIN),
68 'manage_options',
69 'quickwebp-settings',
70 array( $this, 'render_settings_page' )
71 );
72 }
73
74 /**
75 * render_settings_page
76 *
77 * @return void
78 */
79 public function render_settings_page() {
80 require_once QUICKWEBP_PLUGIN_PATH . 'admin/templates/page-settings.php';
81 }
82
83 /**
84 * render_component
85 *
86 * @param mixed $data
87 * @return void
88 */
89 public function render_component( $data = array() ) {
90 $data['type'] = $data['type'] ?? 'text';
91 $data['name'] = $data['name'] ?? '';
92 $file_name = $data['type'] == 'text' || $data['type'] == 'email' || $data['type'] == 'tel' || $data['type'] == 'number' ? 'text' : $data['type'];
93 $path_to_component = QUICKWEBP_PLUGIN_PATH . 'admin/components/' . $file_name . '.php';
94
95 if( file_exists( $path_to_component ) ) {
96 ?>
97 <tr>
98 <th>
99 <label for="<?php echo esc_attr( $data['name'] ?? '' ); ?>"><?php echo esc_html( $data['label'] ?? '' ); ?></label>
100 </th>
101 <td class="<?php echo esc_attr( $data['name'] ?? '' ); ?>-container">
102 <?php include $path_to_component; ?>
103 <?php if( isset( $data['description'] ) ) {
104 ?>
105 <p class="description"><?php echo esc_html( $data['description'] ); ?></p>
106 <?php
107 }
108 ?>
109 </td>
110 </tr>
111 <?php
112 }
113 }
114 }