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

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