PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.4
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.4
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Admin / Options / CustomCSSJS.php

CustomCSSJS.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.4, at Inc/Admin/Options/CustomCSSJS.php

171 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Admin\Options;
4
5 use PXLBSAdminify\Inc\Utils;
6 use PXLBSAdminify\Inc\Admin\AdminSettingsModel;
7
8
9 if (!defined('ABSPATH')) {
10 die;
11 } // Cannot access directly.
12
13 if (!class_exists('CustomCSSJS')) {
14 class CustomCSSJS extends AdminSettingsModel
15 {
16
17 public $defaults = [];
18
19 public function __construct()
20 {
21 $this->developer_settings();
22 }
23
24 protected function get_defaults()
25 {
26 return [
27 'devtools_tabs' => [
28 'custom_css' => '',
29 'custom_js' => '',
30 ]
31 ];
32 }
33
34
35
36 /**
37 * Post Status Columns
38 */
39
40 public function devtools_admin_area_custom_css_js_fields( &$fields ) {
41
42 $fields[] = array(
43 'id' => 'custom_css',
44 'type' => 'code_editor',
45 'title' => __( 'Custom CSS', 'adminify' ),
46 'subtitle' => __( 'Write your own <strong>Custom CSS</strong> for WordPress Admin Area.', 'adminify' ),
47 'desc' => __( 'Don\'t place &lt;style&gt;&lt;/style&gt; tag inside editor.', 'adminify' ),
48 'settings' => array(
49 'theme' => 'monokai',
50 'mode' => 'css',
51 ),
52 'sanitize' => false,
53 'default' => $this->get_default_field('devtools_tabs')['custom_css'],
54 );
55
56 $fields[] = array(
57 'id' => 'custom_js',
58 'type' => 'code_editor',
59 'title' => __( 'Custom JavaScript', 'adminify' ),
60 'subtitle' => __('Write your own <strong>Custom Script</strong> for WordPress Admin Area.', 'adminify' ),
61 'desc' => __( 'Don\'t place &lt;script&gt;&lt;/script&gt; tag inside editor.', 'adminify' ),
62 'settings' => array(
63 'theme' => 'dracula',
64 'mode' => 'javascript',
65 ),
66 'sanitize' => false,
67 'default' => $this->get_default_field('devtools_tabs')['custom_js'],
68 );
69 }
70
71 /**
72 * Maybe Trigger Reset
73 *
74 * @param [type] $data
75 * @param [type] $class
76 *
77 * @return void
78 */
79 public function maybe_trigger_reset( $data, $class ) {
80
81 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only check, no state change.
82 if ( !empty( $_POST['adminify_transient']['reset'] ) ) {
83
84 delete_option( 'pxlbsadminify_custom_js_css' );
85
86 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only check, no state change.
87 } else if ( !empty( $_POST['adminify_transient']['reset_section'] ) && isset( $_POST['adminify_transient']['section'] ) ) {
88
89 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only check, no state change.
90 $section = sanitize_text_field( wp_unslash( $_POST['adminify_transient']['section'] ) );
91 if ( $class->pre_sections[ $section - 2 ]['id'] === 'custom_css_js' ) {
92 delete_option( 'pxlbsadminify_custom_js_css' );
93 }
94
95 }
96 }
97
98
99 /**
100 * Tabs: Frontend & Backend
101 *
102 * @param [type] $fields
103 *
104 * @return void
105 */
106 public function devtools_tabbed_settings( &$fields ){
107
108 $backend_custom_scripts = [];
109 $frontend_custom_scripts = [];
110 $this->devtools_admin_area_custom_css_js_fields( $backend_custom_scripts );
111
112 if ( !Utils::is_plugin_active( 'adminify-header-footer-scripts/adminify-header-footer-scripts.php' ) ) {
113 $frontend_custom_scripts[] = [
114 'type' => 'notice',
115 'title' => ' ',
116 'class' => 'adminify-missing-plugins adminify-one-col',
117 'style' => 'warning',
118 'content' => Utils::missing_plugin_notice('Custom Header & Footer'),
119 ];
120 } else {
121
122 add_action( "adminify_pxlbsadminify_settings_save_after", [ $this, 'maybe_trigger_reset' ], 10, 2 );
123
124 if ( class_exists( '\PXLBSAdminify\Modules\CustomHeaderFooter\Inc\CustomHeaderFooter\CustomHeaderFooterSettings' ) ) {
125 $customHeaderFooterSettings = new \PXLBSAdminify\Modules\CustomHeaderFooter\Inc\CustomHeaderFooter\CustomHeaderFooterSettings();
126 $frontend_custom_scripts = $customHeaderFooterSettings->get_fields();
127 }
128 }
129
130 $fields = [
131 [
132 'id' => 'devtools_tabs',
133 'type' => 'tabbed',
134 'title' => '',
135 'tabs' => [
136 [
137 'title' => __( 'Admin Scripts', 'adminify' ),
138 'fields' => $backend_custom_scripts,
139 ],
140 [
141 'title' => __( 'Frontend Scripts', 'adminify' ),
142 'fields' => $frontend_custom_scripts,
143 ],
144 ]
145 ]
146 ];
147 }
148
149 public function developer_settings()
150 {
151 if (!class_exists('ADMINIFY')) {
152 return;
153 }
154
155 $fields = array();
156 $this->devtools_tabbed_settings( $fields );
157
158 // DevTools Section
159 \ADMINIFY::createSection(
160 $this->prefix,
161 [
162 'title' => __('Code Snippets', 'adminify'),
163 'id' => 'custom_css_js',
164 'icon' => 'fas fa-code',
165 'fields' => $fields,
166 ]
167 );
168 }
169 }
170 }
171