PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.1.2
Adminify – White Label, Admin Menu Editor, Login Customizer v3.1.2
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 / Modules / CustomHeaderFooter / CustomHeaderFooterSettings.php

CustomHeaderFooterSettings.php in Adminify – White Label, Admin Menu Editor, Login Customizer 3.1.2, at Inc/Modules/CustomHeaderFooter/CustomHeaderFooterSettings.php

205 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\CustomHeaderFooter;
4
5 use WPAdminify\Inc\Utils ;
6 // no direct access allowed
7 if ( !defined( 'ABSPATH' ) ) {
8 exit;
9 }
10 /**
11 * WPAdminify
12 *
13 * @package Module: Dashboard Widget
14 *
15 * @author Jewel Theme <support@jeweltheme.com>
16 */
17 class CustomHeaderFooterSettings extends CustomHeaderFooterModel
18 {
19 public function __construct()
20 {
21 // this should be first so the default values get stored
22 $this->custom_header_footer_settings();
23 parent::__construct( (array) get_option( $this->prefix ) );
24 }
25
26 public function get_defaults()
27 {
28 return [
29 'custom_scripts' => [
30 'title' => '',
31 'display_on' => 'full_site',
32 'custom_posts' => '',
33 'custom_category' => '',
34 'custom_post_types' => '',
35 'custom_pages' => '',
36 'custom_tags' => '',
37 'location' => 'header',
38 'device_type' => 'all_devices',
39 'script_type' => 'css',
40 'custom_js' => '',
41 'custom_css' => '',
42 ],
43 ];
44 }
45
46 /**
47 * Settings Fields
48 *
49 * @return void
50 */
51 public function custom_header_footer_setting_fields( &$fields )
52 {
53 $fields[] = [
54 'id' => 'title',
55 'type' => 'text',
56 'title' => __( 'Snippet Title', 'adminify' ),
57 'default' => $this->get_default_field( 'custom_scripts' )['title'],
58 ];
59 $fields[] = [
60 'id' => 'display_on',
61 'type' => 'select',
62 'title' => __( 'Display on', 'adminify' ),
63 'placeholder' => __( 'Select an option', 'adminify' ),
64 'options' => [
65 'full_site' => __( 'Full Site', 'adminify' ),
66 'posts_pro' => __( 'Specific Posts (Pro)', 'adminify' ),
67 'pages_pro' => __( 'Specific Page (Pro)', 'adminify' ),
68 'categories_pro' => __( 'Specific Categories (Pro)', 'adminify' ),
69 'custom_posts_pro' => __( 'Specific Post Types (Pro)', 'adminify' ),
70 'tags_pro' => __( 'Specific Tags (Pro)', 'adminify' ),
71 ],
72 'default' => $this->get_default_field( 'custom_scripts' )['display_on'],
73 ];
74 $fields[] = [
75 'id' => 'location',
76 'type' => 'button_set',
77 'title' => __( 'Location', 'adminify' ),
78 'options' => [
79 'header' => __( 'Header', 'adminify' ),
80 'footer' => __( 'Footer', 'adminify' ),
81 'content_before_pro' => __( 'Before Content (Pro)', 'adminify' ),
82 'content_after_pro' => __( 'After Content (Pro)', 'adminify' ),
83 ],
84 'default' => $this->get_default_field( 'custom_scripts' )['location'],
85 ];
86 $fields[] = [
87 'id' => 'device_type_notice',
88 'type' => 'notice',
89 'title' => __( 'Display Device', 'adminify' ),
90 'style' => 'warning',
91 'content' => Utils::adminify_upgrade_pro(),
92 ];
93 $fields[] = [
94 'id' => 'script_type',
95 'type' => 'button_set',
96 'title' => __( 'Snippet Type', 'adminify' ),
97 'options' => [
98 'css' => 'CSS',
99 'js' => 'JS',
100 ],
101 'default' => $this->get_default_field( 'custom_scripts' )['script_type'],
102 ];
103 $fields[] = [
104 'id' => 'custom_js',
105 'type' => 'code_editor',
106 'title' => __( 'Custom JavaScript', 'adminify' ),
107 'subtitle' => __( 'Write your own Custom JS script.', 'adminify' ),
108 'desc' => __( 'Don\'t place &lt;script&gt;&lt;/script&gt; tag inside editor.', 'adminify' ),
109 'settings' => [
110 'theme' => 'dracula',
111 'mode' => 'htmlmixed',
112 ],
113 'sanitize' => false,
114 'dependency' => [ 'script_type', '==', 'js' ],
115 'default' => $this->get_default_field( 'custom_scripts' )['custom_js'],
116 ];
117 $fields[] = [
118 'id' => 'custom_css',
119 'type' => 'code_editor',
120 'title' => __( 'Custom CSS', 'adminify' ),
121 'subtitle' => __( 'Write your own Custom CSS.', 'adminify' ),
122 'desc' => __( 'Don\'t place &lt;style&gt;&lt;/style&gt; tag inside editor.', 'adminify' ),
123 'settings' => [
124 'theme' => 'monokai',
125 'mode' => 'htmlmixed',
126 ],
127 'sanitize' => false,
128 'dependency' => [ 'script_type', '==', 'css' ],
129 'default' => $this->get_default_field( 'custom_scripts' )['custom_css'],
130 ];
131 }
132
133 public function custom_header_footer_settings()
134 {
135 if ( !class_exists( 'ADMINIFY' ) ) {
136 return;
137 }
138 // WP Adminify Custom Header & Footer Options
139 \ADMINIFY::createOptions( $this->prefix, [
140 'framework_title' => __( 'WP Adminify Custom CSS/JS <small>by WP Adminify</small>', 'adminify' ),
141 'framework_class' => 'adminify-custom-css-js',
142 'menu_title' => __( 'Custom CSS / JS', 'adminify' ),
143 'menu_slug' => 'adminify-custom-css-js',
144 'menu_type' => 'submenu',
145 'menu_capability' => 'manage_options',
146 'menu_icon' => '',
147 'menu_position' => 54,
148 'menu_hidden' => false,
149 'menu_parent' => 'wp-adminify-settings',
150 'footer_text' => ' ',
151 'footer_after' => ' ',
152 'footer_credit' => ' ',
153 'show_bar_menu' => false,
154 'show_sub_menu' => false,
155 'show_in_network' => false,
156 'show_in_customizer' => false,
157 'show_search' => false,
158 'show_reset_all' => false,
159 'show_reset_section' => false,
160 'show_footer' => true,
161 'show_all_options' => true,
162 'show_form_warning' => true,
163 'sticky_header' => false,
164 'save_defaults' => true,
165 'ajax_save' => true,
166 'admin_bar_menu_icon' => '',
167 'admin_bar_menu_priority' => 45,
168 'database' => 'options',
169 'transient_time' => 0,
170 'enqueue_webfont' => true,
171 'async_webfont' => false,
172 'output_css' => false,
173 'nav' => 'normal',
174 'theme' => 'dark',
175 'class' => 'wp-adminify-custom-css-js',
176 ] );
177 $fields = [];
178 $this->custom_header_footer_setting_fields( $fields );
179 // Custom CSS/JS Settings
180 \ADMINIFY::createSection( $this->prefix, [
181 'title' => __( 'Others', 'adminify' ),
182 'icon' => 'fas fa-bolt',
183 'fields' => [ [
184 'type' => 'subheading',
185 'content' => Utils::adminfiy_help_urls(
186 __( 'Header/Footer Snippets', 'adminify' ),
187 'https://wpadminify.com/kb/how-to-add-custom-css-or-js-in-full-site-or-specific-page/',
188 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8',
189 'https://www.facebook.com/groups/jeweltheme',
190 'https://wpadminify.com/support/header-footer-scripts/'
191 ),
192 ], [
193 'id' => 'custom_scripts',
194 'type' => 'group',
195 'title' => '',
196 'accordion_title_prefix' => __( 'Snippet Name: ', 'adminify' ),
197 'accordion_title_number' => true,
198 'accordion_title_auto' => true,
199 'button_title' => __( 'Add New Snippet', 'adminify' ),
200 'fields' => $fields,
201 ] ],
202 ] );
203 }
204
205 }