PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.7.4
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.7.4
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
image-optimization / vendor / elementor / wp-one-package / src / Admin / Components / Fields.php

Fields.php in Image Optimizer – Compress Images and Convert to WebP or AVIF 1.7.4, at vendor/elementor/wp-one-package/src/Admin/Components/Fields.php

101 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ElementorOne\Admin\Components;
4
5 use ElementorOne\Admin\Helpers\Utils;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * Class Fields
13 * Handles WordPress settings registration
14 */
15 class Fields {
16
17 const SETTING_PREFIX = 'elementor_one_';
18
19 /**
20 * Instance
21 * @var Fields|null
22 */
23 private static ?Fields $instance = null;
24
25 /**
26 * Get instance
27 * @return Fields|null
28 */
29 public static function instance(): ?Fields {
30 if ( ! self::$instance ) {
31 self::$instance = new self();
32 }
33 return self::$instance;
34 }
35
36 /**
37 * Register fields
38 * @return void
39 */
40 public function register_fields() {
41 foreach ( $this->get_settings() as $setting => $args ) {
42 register_setting( 'options', self::SETTING_PREFIX . $setting, $args );
43 }
44 }
45
46 /**
47 * Get settings
48 * @return array
49 */
50 public static function get_settings(): array {
51 return [
52 'welcome_screen_completed' => [
53 'type' => 'boolean',
54 'show_in_rest' => true,
55 'description' => 'Elementor One Welcome Screen Completed',
56 ],
57 'dismiss_connect_alert' => [
58 'type' => 'boolean',
59 'single' => true,
60 'show_in_rest' => true,
61 'description' => 'Elementor One Dismiss Connect Alert',
62 ],
63 'editor_update_notification_dismissed' => [
64 'type' => 'boolean',
65 'show_in_rest' => true,
66 'description' => 'Elementor One Dismiss Editor Update Notification',
67 ],
68 ];
69 }
70
71 /**
72 * Get plugin settings
73 * @return array
74 */
75 public function get_plugin_settings(): array {
76 $connect_utils = Utils::get_one_connect()->utils();
77
78 return [
79 'siteName' => get_bloginfo( 'name' ),
80 'activeTheme' => wp_get_theme()->get( 'Name' ),
81 'isConnected' => $connect_utils->is_connected(),
82 'isUrlMismatch' => ! $connect_utils->is_valid_home_url(),
83 'isDevelopment' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
84 'siteUrl' => get_site_url(),
85 'welcomeScreenCompleted' => (bool) get_option( self::SETTING_PREFIX . 'welcome_screen_completed' ),
86 'dismissConnectAlert' => (bool) get_option( self::SETTING_PREFIX . 'dismiss_connect_alert' ),
87 'editorUpdateNotificationDismissed' => (bool) get_option( self::SETTING_PREFIX . 'editor_update_notification_dismissed' ),
88 'userLocale' => get_user_locale( get_current_user_id() ),
89 'isRTL' => is_rtl(),
90 ];
91 }
92
93 /**
94 * Fields constructor
95 * @return void
96 */
97 private function __construct() {
98 add_action( 'rest_api_init', [ $this, 'register_fields' ] );
99 }
100 }
101