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

212 lines 8.3 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' => '<script>
41 ;(function($) {
42 "use strict";
43 $(document).ready( function() {
44 // Write your Dashboard Widget JS code here
45 });
46 })( jQuery );
47 </script>',
48 'custom_css' => '<style>
49 /* Write your Dashboard Widget CSS code here */
50 </style>',
51 ],
52 ];
53 }
54
55 /**
56 * Settings Fields
57 *
58 * @return void
59 */
60 public function custom_header_footer_setting_fields( &$fields )
61 {
62 $fields[] = [
63 'id' => 'title',
64 'type' => 'text',
65 'title' => __( 'Snippet Title', 'adminify' ),
66 'default' => $this->get_default_field( 'custom_scripts' )['title'],
67 ];
68 $fields[] = [
69 'id' => 'display_on',
70 'type' => 'select',
71 'title' => __( 'Display on', 'adminify' ),
72 'placeholder' => __( 'Select an option', 'adminify' ),
73 'options' => [
74 'full_site' => __( 'Full Site', 'adminify' ),
75 'posts_pro' => __( 'Specific Posts (Pro)', 'adminify' ),
76 'pages_pro' => __( 'Specific Page (Pro)', 'adminify' ),
77 'categories_pro' => __( 'Specific Categories (Pro)', 'adminify' ),
78 'custom_posts_pro' => __( 'Specific Post Types (Pro)', 'adminify' ),
79 'tags_pro' => __( 'Specific Tags (Pro)', 'adminify' ),
80 ],
81 'default' => $this->get_default_field( 'custom_scripts' )['display_on'],
82 ];
83 $fields[] = [
84 'id' => 'location',
85 'type' => 'button_set',
86 'title' => __( 'Location', 'adminify' ),
87 'options' => [
88 'header' => __( 'Header', 'adminify' ),
89 'footer' => __( 'Footer', 'adminify' ),
90 'content_before_pro' => __( 'Before Content (Pro)', 'adminify' ),
91 'content_after_pro' => __( 'After Content (Pro)', 'adminify' ),
92 ],
93 'default' => $this->get_default_field( 'custom_scripts' )['location'],
94 ];
95 $fields[] = [
96 'id' => 'device_type_notice',
97 'type' => 'notice',
98 'title' => __( 'Display Device', 'adminify' ),
99 'style' => 'warning',
100 'content' => Utils::adminify_upgrade_pro(),
101 ];
102 $fields[] = [
103 'id' => 'script_type',
104 'type' => 'button_set',
105 'title' => __( 'Snippet Type', 'adminify' ),
106 'options' => [
107 'css' => 'CSS',
108 'js' => 'JS',
109 ],
110 'default' => $this->get_default_field( 'custom_scripts' )['script_type'],
111 ];
112 $fields[] = [
113 'id' => 'custom_js',
114 'type' => 'code_editor',
115 'title' => __( 'Custom JavaScript', 'adminify' ),
116 'subtitle' => __( 'Add Custom script inside <strong>&lt;script&gt;&lt;/script&gt;</strong> tag.', 'adminify' ),
117 'settings' => [
118 'theme' => 'dracula',
119 'mode' => 'htmlmixed',
120 ],
121 'sanitize' => false,
122 'dependency' => [ 'script_type', '==', 'js' ],
123 'default' => $this->get_default_field( 'custom_scripts' )['custom_js'],
124 ];
125 $fields[] = [
126 'id' => 'custom_css',
127 'type' => 'code_editor',
128 'title' => __( 'Custom CSS', 'adminify' ),
129 'subtitle' => __( 'Write CSS code inside <strong>&lt;style&gt;&lt;/style&gt;</strong> tag.', 'adminify' ),
130 'settings' => [
131 'theme' => 'monokai',
132 'mode' => 'htmlmixed',
133 ],
134 'sanitize' => false,
135 'dependency' => [ 'script_type', '==', 'css' ],
136 'default' => $this->get_default_field( 'custom_scripts' )['custom_css'],
137 ];
138 }
139
140 public function custom_header_footer_settings()
141 {
142 if ( !class_exists( 'ADMINIFY' ) ) {
143 return;
144 }
145 // WP Adminify Custom Header & Footer Options
146 \ADMINIFY::createOptions( $this->prefix, [
147 'framework_title' => __( 'WP Adminify Custom CSS/JS <small>by WP Adminify</small>', 'adminify' ),
148 'framework_class' => 'adminify-custom-css-js',
149 'menu_title' => __( 'Custom CSS / JS', 'adminify' ),
150 'menu_slug' => 'adminify-custom-css-js',
151 'menu_type' => 'submenu',
152 'menu_capability' => 'manage_options',
153 'menu_icon' => '',
154 'menu_position' => 54,
155 'menu_hidden' => false,
156 'menu_parent' => 'wp-adminify-settings',
157 'footer_text' => ' ',
158 'footer_after' => ' ',
159 'footer_credit' => ' ',
160 'show_bar_menu' => false,
161 'show_sub_menu' => false,
162 'show_in_network' => false,
163 'show_in_customizer' => false,
164 'show_search' => false,
165 'show_reset_all' => false,
166 'show_reset_section' => false,
167 'show_footer' => true,
168 'show_all_options' => true,
169 'show_form_warning' => true,
170 'sticky_header' => false,
171 'save_defaults' => true,
172 'ajax_save' => true,
173 'admin_bar_menu_icon' => '',
174 'admin_bar_menu_priority' => 45,
175 'database' => 'options',
176 'transient_time' => 0,
177 'enqueue_webfont' => true,
178 'async_webfont' => false,
179 'output_css' => false,
180 'nav' => 'normal',
181 'theme' => 'dark',
182 'class' => 'wp-adminify-custom-css-js',
183 ] );
184 $fields = [];
185 $this->custom_header_footer_setting_fields( $fields );
186 // Custom CSS/JS Settings
187 \ADMINIFY::createSection( $this->prefix, [
188 'title' => __( 'Others', 'adminify' ),
189 'icon' => 'fas fa-bolt',
190 'fields' => [ [
191 'type' => 'subheading',
192 'content' => Utils::adminfiy_help_urls(
193 __( 'Header/Footer Snippets', 'adminify' ),
194 'https://wpadminify.com/kb/how-to-add-custom-css-or-js-in-full-site-or-specific-page/',
195 'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8',
196 'https://www.facebook.com/groups/jeweltheme',
197 'https://wpadminify.com/support/header-footer-scripts/'
198 ),
199 ], [
200 'id' => 'custom_scripts',
201 'type' => 'group',
202 'title' => '',
203 'accordion_title_prefix' => __( 'Snippet Name: ', 'adminify' ),
204 'accordion_title_number' => true,
205 'accordion_title_auto' => true,
206 'button_title' => __( 'Add New Snippet', 'adminify' ),
207 'fields' => $fields,
208 ] ],
209 ] );
210 }
211
212 }