PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 8.2.3
Admin and Site Enhancements (ASE) v8.2.3
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / settings.php
admin-site-enhancements Last commit date
assets 7 months ago classes 7 months ago includes 7 months ago languages 7 months ago vendor 7 months ago CHANGELOG.md 7 months ago LICENSE.md 7 months ago README.md 7 months ago admin-site-enhancements.php 7 months ago bootstrap.php 7 months ago functions.php 7 months ago settings.php 7 months ago
settings.php
1301 lines
1 <?php
2
3 /**
4 * Initialize options. [TODO] Move this into activation class at v7.
5 *
6 * @since 6.4.1
7 */
8 if ( false === get_option( ASENHA_SLUG_U ) ) {
9 add_option(
10 ASENHA_SLUG_U,
11 array(),
12 '',
13 true
14 );
15 }
16 if ( false === get_option( ASENHA_SLUG_U . '_stats' ) ) {
17 add_option(
18 ASENHA_SLUG_U . '_stats',
19 array(),
20 '',
21 false
22 );
23 }
24 if ( false === get_option( ASENHA_SLUG_U . '_extra' ) ) {
25 add_option(
26 ASENHA_SLUG_U . '_extra',
27 array(),
28 '',
29 true
30 );
31 }
32 // Bugfix in v7.1.2 for Custom Content Type module
33 $options_extra = get_option( ASENHA_SLUG_U . '_extra', array() );
34 if ( !isset( $options_extra['cfgroup_next_field_id'] ) ) {
35 $options_extra['cfgroup_next_field_id'] = 1;
36 update_option( ASENHA_SLUG_U . '_extra', $options_extra, true );
37 }
38 // Move Admin Menu Organizer options storage to extra table since v7.8.5
39 if ( !isset( $options_extra['admin_menu'] ) ) {
40 $options = get_option( ASENHA_SLUG_U, array() );
41 $options_extra['admin_menu']['custom_menu_order'] = ( isset( $options['custom_menu_order'] ) ? $options['custom_menu_order'] : '' );
42 unset($options['custom_menu_order']);
43 $options_extra['admin_menu']['custom_menu_titles'] = ( isset( $options['custom_menu_titles'] ) ? $options['custom_menu_titles'] : '' );
44 unset($options['custom_menu_titles']);
45 $options_extra['admin_menu']['custom_menu_hidden'] = ( isset( $options['custom_menu_hidden'] ) ? trim( $options['custom_menu_hidden'], ',' ) : '' );
46 unset($options['custom_menu_hidden']);
47 update_option( ASENHA_SLUG_U . '_extra', $options_extra, true );
48 update_option( ASENHA_SLUG_U, $options, true );
49 }
50 /**
51 * Register admin menu
52 *
53 * @since 1.0.0
54 */
55 function asenha_register_admin_menu() {
56 add_submenu_page(
57 'tools.php',
58 // Parent page/menu
59 'Admin and Site Enhancements',
60 // Browser tab/window title
61 __( 'Enhancements', 'admin-site-enhancements' ),
62 // Sube menu title
63 'manage_options',
64 // Minimal user capabililty
65 ASENHA_SLUG,
66 // Page slug. Shows up in URL.
67 'asenha_add_settings_page'
68 );
69 }
70
71 /**
72 * Create the settings page of the plugin
73 *
74 * @since 1.0.0
75 */
76 function asenha_add_settings_page() {
77 $options = get_option( ASENHA_SLUG_U, array() );
78 ?>
79 <div class="wrap asenha">
80
81 <div id="asenha-header" class="asenha-header">
82 <div class="asenha-header-left">
83 <img src="<?php
84 echo esc_html( ASENHA_URL ) . 'assets/img/ase_icon.png';
85 ?>" class="asenha-icon"/>
86 <h1 class="asenha-heading">
87 <?php
88 echo esc_html( get_admin_page_title() );
89 ?>
90 (ASE)
91 <?php
92 ?>
93 </h1>
94 <input id="module-search-input" type="search" placeholder="<?php
95 echo esc_attr__( 'Search...', 'admin-site-enhancements' );
96 ?>" />
97 <!-- <a href="https://wordpress.org/plugins/admin-site-enhancements/" target="_blank" class="asenha-header-action"><span>&#8505;</span> <?php
98 // esc_html_e( 'Info', 'admin-site-enhancements' );
99 ?></a> -->
100 </div>
101 <div class="asenha-header-right">
102 <?php
103 // https://icon-sets.iconify.design/iconamoon/star-bold/
104 $svg_star = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="2.5" d="m12 2l3.104 6.728l7.358.873l-5.44 5.03l1.444 7.268L12 18.28L5.534 21.9l1.444-7.268L1.538 9.6l7.359-.873L12 2Z"/></svg>';
105 // https://icon-sets.iconify.design/octicon/question-16/
106 $svg_support = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="currentColor" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13a6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725c0 .448-.115.83-.329 1.15c-.205.307-.47.513-.692.662c-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16a.952.952 0 0 0-.276.245a.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661c.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0a1 1 0 0 1 2 0Z"/></svg>';
107 // https://icon-sets.iconify.design/octicon/comment-16/
108 $svg_feedback = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16"><path fill="currentColor" d="M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"/></svg>';
109 // https://icon-sets.iconify.design/ic/baseline-translate/
110 $svg_translate = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="m12.87 15.07l-2.54-2.51l.03-.03A17.52 17.52 0 0 0 14.07 6H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35C8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5l3.11 3.11zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2zm-2.62 7l1.62-4.33L19.12 17z"/></svg>';
111 // https://icon-sets.iconify.design/iconamoon/file-document/
112 $svg_docs = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="2"><path stroke-linecap="round" d="M7 21a2 2 0 0 1-2-2V3h9l5 5v11a2 2 0 0 1-2 2H7Z"/><path d="M13 3v6h6"/><path stroke-linecap="round" d="M9 13h6m-6 4h6"/></g></svg>';
113 // https://icon-sets.iconify.design/pajamas/heart/
114 $svg_sponsor = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M8.753 2.247L8 3l-.753-.753A4.243 4.243 0 0 0 1.25 8.25l5.69 5.69L8 15l1.06-1.06l5.69-5.69a4.243 4.243 0 0 0-5.997-6.003ZM8 12.879l5.69-5.69a2.743 2.743 0 0 0-3.877-3.881l-.752.753L8 5.12L6.94 4.06l-.753-.752v-.001A2.743 2.743 0 0 0 2.31 7.189L8 12.88Z" clip-rule="evenodd"/></svg>';
115 ?>
116 <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="asenha-header-action review"><?php
117 echo wp_kses( $svg_star, get_kses_with_svg_ruleset() ) . esc_html__( 'Review', 'admin-site-enhancements' );
118 ?></a>
119 <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank" class="asenha-header-action feedback"><?php
120 echo wp_kses( $svg_feedback, get_kses_with_svg_ruleset() ) . esc_html__( 'Feedback', 'admin-site-enhancements' );
121 ?></a>
122 <a href="https://www.wpase.com/trnslt-plgnhdr" target="_blank" class="asenha-header-action translate"><?php
123 echo wp_kses( $svg_translate, get_kses_with_svg_ruleset() ) . esc_html__( 'Translate', 'admin-site-enhancements' );
124 ?></a>
125 <!--<a href="https://www.wpasenha.com/docs/" target="_blank" class="asenha-header-action docs"><?php
126 // echo $svg_docs . esc_html__( 'Docs', 'admin-site-enhancements' );
127 ?></a>-->
128 <!--<a id="plugin-sponsor" href="#" class="asenha-header-action sponsor"><?php
129 // echo $svg_sponsor . esc_html__( 'Sponsor', 'admin-site-enhancements' );
130 ?></a>-->
131 <a href="https://www.wpase.com/upgrade-btn" target="_blank" id="plugin-upgrade" class="button button-primary plugin-upgrade"><?php
132 echo esc_html__( 'Get ASE Pro', 'admin-site-enhancements' );
133 ?></a>
134 <?php
135 ?>
136 <a class="button button-primary asenha-save-button"><?php
137 echo esc_html__( 'Save Changes', 'admin-site-enhancements' );
138 ?></a>
139 <!-- https://icon-sets.iconify.design/svg-spinners/180-ring-with-bg/ -->
140 <div class="asenha-saving-changes" style="display:none;"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#2271b1" d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25"/><path fill="#2271b1" d="M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"><animateTransform attributeName="transform" dur="0.75s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></svg></div>
141 <div class="asenha-changes-saved" style="display:none;"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path fill="seagreen" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10s10-4.48 10-10S17.52 2 12 2zM9.29 16.29L5.7 12.7a.996.996 0 1 1 1.41-1.41L10 14.17l6.88-6.88a.996.996 0 1 1 1.41 1.41l-7.59 7.59a.996.996 0 0 1-1.41 0z"/></svg></div>
142 </div>
143 </div>
144
145 <div class="asenha-body">
146 <?php
147 $is_yearend_promo_period = is_yearend_promo_period();
148 ?>
149 <?php
150 if ( $is_yearend_promo_period ) {
151 ?>
152 <!-- <div class="asenha-upgrade-nudge" style="display: none;">
153 <div class="asenha-upgrade-nudge__message"><?php
154 // echo esc_html__( 'Lifetime Deal (LTD) is available for the Pro version of ASE.', 'admin-site-enhancements' );
155 ?></div>
156 <a href="https://www.wpase.com/upgrade-ndg" class="button asenha-upgrade-nudge__button" target="_blank"><?php
157 // echo esc_html__( 'Find Out More', 'admin-site-enhancements' );
158 ?></a>
159 <a href="#" id="dismiss-upgrade-nudge" class="asenha-upgrade-nudge__dismiss">
160 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="currentColor" d="M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z"/></svg>
161 </a>
162 </div> -->
163 <div class="asenha-promo-nudge" style="display: none;">
164 <div class="asenha-promo-nudge__message"><?php
165 echo esc_html__( 'ASE Pro YEAR-END SALE! 20% DISCOUNT. Lifetime Deal (LTD) available.', 'admin-site-enhancements' );
166 ?></div>
167 <a href="https://www.wpase.com/promo-ndg" class="button asenha-promo-nudge__button" target="_blank"><?php
168 echo esc_html__( 'Get It Now', 'admin-site-enhancements' );
169 ?></a>
170 <a href="#" id="dismiss-promo-nudge" class="asenha-promo-nudge__dismiss">
171 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="currentColor" d="M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z"/></svg>
172 </a>
173 </div>
174 <?php
175 } else {
176 ?>
177 <div class="asenha-upgrade-nudge" style="display: none;">
178 <div class="asenha-upgrade-nudge__message"><?php
179 echo esc_html__( 'Lifetime Deal (LTD) is available for the Pro version of ASE.', 'admin-site-enhancements' );
180 ?></div>
181 <a href="https://www.wpase.com/upgrade-ndg" class="button asenha-upgrade-nudge__button" target="_blank"><?php
182 echo esc_html__( 'Find Out More', 'admin-site-enhancements' );
183 ?></a>
184 <a href="#" id="dismiss-upgrade-nudge" class="asenha-upgrade-nudge__dismiss">
185 <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="currentColor" d="M24 2.4L21.6 0L12 9.6L2.4 0L0 2.4L9.6 12L0 21.6L2.4 24l9.6-9.6l9.6 9.6l2.4-2.4l-9.6-9.6z"/></svg>
186 </a>
187 </div>
188 <?php
189 }
190 ?>
191 <?php
192 ?>
193 <div class="asenha-support-nudge nudge-show-more is-enabled" style="display: none;">
194 <h3><?php
195 _e( 'Looks like some of these free enhancements have been useful for your site?', 'admin-site-enhancements' );
196 ?></h3>
197 <p class="nudge-description intro"><?php
198 _e( 'Please consider supporting ASE.', 'admin-site-enhancements' );
199 ?></p>
200 <div class="nudge-content">
201 <div class="nudge-primary">
202 <h4><?php
203 _e( 'Write a quick, 5-star review for ASE', 'admin-site-enhancements' );
204 ?></h4>
205 <div class="nudge-ctas">
206 <a href="https://wordpress.org/plugins/admin-site-enhancements/#reviews" target="_blank" class="button button-outline asenha-review-button"><?php
207 _e( 'Add Your Review', 'admin-site-enhancements' );
208 ?></a>
209 <a href="#" id="have-reviewed" class="asenha-have-supported"><?php
210 _e( 'I\'ve reviewed', 'admin-site-enhancements' );
211 ?></a>
212 </div>
213 <p class="nudge-description"><?php
214 _e( 'Or, help improve ASE by <a href="https://wordpress.org/support/plugin/admin-site-enhancements/" target="_blank">providing feedback</a>.', 'admin-site-enhancements' );
215 ?></p>
216 </div>
217 <div class="nudge-secondary">
218 <h4><?php
219 _e( 'Share about ASE on:', 'admin-site-enhancements' );
220 ?></h4>
221 <div class="nudge-ctas">
222 <a href="https://www.facebook.com/sharer.php?u=<?php
223 echo urlencode( 'https://www.wpase.com' );
224 ?>" target="_blank" class="button button-outline asenha-share-button"><?php
225 _e( 'Facebook', 'admin-site-enhancements' );
226 ?></a>
227 <a href="https://twitter.com/intent/post?url=<?php
228 echo urlencode( 'https://www.wpase.com' );
229 ?>&text=<?php
230 echo esc_attr( urlencode( 'Admin and Site Enhancements (ASE)' ) );
231 ?>" target="_blank" class="button button-outline asenha-share-button"><?php
232 _e( 'X / Twitter', 'admin-site-enhancements' );
233 ?></a>
234 <a href="https://www.wpase.com/video-reviews/" target="_blank" class="button button-outline asenha-share-button"><?php
235 _e( 'YouTube', 'admin-site-enhancements' );
236 ?></a>
237 <a href="#" id="have-shared" class="asenha-have-supported"><?php
238 _e( 'I\'ve shared', 'admin-site-enhancements' );
239 ?></a>
240 </div>
241 <div class="nudge-info">
242 <p class="nudge-description"><?php
243 _e( 'Help others discover ASE and maybe <a href="https://www.wpase.com/trnslt-plgnndg" target="_blank">translate</a> to your language.', 'admin-site-enhancements' );
244 ?></p>
245 </div>
246 </div>
247 </div>
248 <div class="dismiss-support-nudge"><a href="#" id="support-nudge-dismiss" class="asenha-support-nudge-dismiss"><?php
249 _e( 'Dismiss', 'admin-site-enhancements' );
250 ?></a></div>
251 </div>
252 <?php
253 ?>
254 <form action="options.php" method="post">
255 <div class="asenha-vertical-tabs">
256 <div class="asenha-tab-buttons">
257 <?php
258 // https://icon-sets.iconify.design/mdi/database-check-outline/ -- db check
259 // https://icon-sets.iconify.design/mdi/file-document-box-multiple-outline/ -- docs
260 // https://icon-sets.iconify.design/fluent/content-view-28-regular/ -- content
261 // https://icon-sets.iconify.design/lucide/shapes/ -- shapes
262 $icon_content_management = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z"/><rect width="7" height="7" x="3" y="14" rx="1"/><circle cx="17.5" cy="17.5" r="3.5"/></g></svg>';
263 // https://icon-sets.iconify.design/mingcute/layout-line/
264 $icon_admin_interface = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0h24ZM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035c-.01-.004-.019-.001-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427c-.002-.01-.009-.017-.017-.018Zm.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093c.012.004.023 0 .029-.008l.004-.014l-.034-.614c-.003-.012-.01-.02-.02-.022Zm-.715.002a.023.023 0 0 0-.027.006l-.006.014l-.034.614c0 .012.007.02.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01l-.184-.092Z"/><path fill="currentColor" d="M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm16 0H5v3h14V5ZM5 19v-9h4v9H5Zm6 0h8v-9h-8v9Z"/></g></svg>';
265 // https://icon-sets.iconify.design/ri/login-circle-line/
266 $icon_login_logout = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="m10.998 16l5-4l-5-4v3h-9v2h9z"/><path fill="currentColor" d="M12.999 2.999a8.938 8.938 0 0 0-6.364 2.637L8.049 7.05c1.322-1.322 3.08-2.051 4.95-2.051s3.628.729 4.95 2.051S20 10.13 20 12s-.729 3.628-2.051 4.95s-3.08 2.051-4.95 2.051s-3.628-.729-4.95-2.051l-1.414 1.414c1.699 1.7 3.959 2.637 6.364 2.637s4.665-.937 6.364-2.637C21.063 16.665 22 14.405 22 12s-.937-4.665-2.637-6.364a8.938 8.938 0 0 0-6.364-2.637z"/></svg>';
267 // https://icon-sets.iconify.design/mingcute/code-line/
268 $icon_custom_code = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none"><path d="M0 0h24v24H0z"/><path fill="currentColor" d="M14.486 3.143a1 1 0 0 1 .692 1.233l-4.43 15.788a1 1 0 0 1-1.926-.54l4.43-15.788a1 1 0 0 1 1.234-.693ZM7.207 7.05a1 1 0 0 1 0 1.414L3.672 12l3.535 3.535a1 1 0 1 1-1.414 1.415L1.55 12.707a1 1 0 0 1 0-1.414L5.793 7.05a1 1 0 0 1 1.414 0Zm9.586 1.414a1 1 0 1 1 1.414-1.414l4.243 4.243a1 1 0 0 1 0 1.414l-4.243 4.242a1 1 0 0 1-1.414-1.414L20.328 12l-3.535-3.536Z"/></g></svg>';
269 // https://icon-sets.iconify.design/mdi/forbid/
270 $icon_disable_components = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2c5.5 0 10 4.5 10 10s-4.5 10-10 10S2 17.5 2 12S6.5 2 12 2m0 2c-1.9 0-3.6.6-4.9 1.7l11.2 11.2c1-1.4 1.7-3.1 1.7-4.9c0-4.4-3.6-8-8-8m4.9 14.3L5.7 7.1C4.6 8.4 4 10.1 4 12c0 4.4 3.6 8 8 8c1.9 0 3.6-.6 4.9-1.7Z"/></svg>';
271 // https://icon-sets.iconify.design/jam/shield-check/
272 $icon_security = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="m8 1.75l5.25 2v5c0 2.25-2 4.5-5.25 5.5c-3.25-1-5.25-3-5.25-5.5v-5z"/><path d="m5.75 7.75l1.5 1.5l3-3.5"/></g></svg>';
273 // https://icon-sets.iconify.design/streamline/image-flash-1-flash-power-connect-charge-electricity-lightning/
274 $icon_optimizations = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 14 14"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" d="M4.25.5L2 5.81a.5.5 0 0 0 .46.69h2.79l-2 7l8.59-8.14a.5.5 0 0 0-.34-.86H7.75l2-4Z"/></svg>';
275 // https://icon-sets.iconify.design/iconoir/tools/
276 $icon_utilities = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="m10.05 10.607l-7.07 7.07a2 2 0 0 0 0 2.83v0a2 2 0 0 0 2.828 0l7.07-7.072m4.315.365l3.878 3.878a2 2 0 0 1 0 2.828v0a2 2 0 0 1-2.828 0l-6.209-6.208M6.733 5.904L4.61 6.61L2.49 3.075l1.414-1.414L7.44 3.782l-.707 2.122Zm0 0l2.83 2.83"/><path d="M10.05 10.607c-.844-2.153-.679-4.978 1.061-6.718c1.74-1.74 4.95-2.121 6.717-1.06l-3.04 3.04l-.283 3.111l3.111-.282l3.04-3.041c1.062 1.768.68 4.978-1.06 6.717c-1.74 1.74-4.564 1.905-6.717 1.061"/></g></svg>';
277 ?>
278 <input id="tab-content-management" type="radio" name="tabs" checked><label for="tab-content-management" class="modules-tab"><?php
279 echo wp_kses( $icon_content_management, get_kses_with_svg_ruleset() );
280 ?><span><?php
281 echo esc_html__( 'Content Management', 'admin-site-enhancements' );
282 ?></span></label>
283 <input id="tab-admin-interface" type="radio" name="tabs"><label for="tab-admin-interface" class="modules-tab"><?php
284 echo wp_kses( $icon_admin_interface, get_kses_with_svg_ruleset() );
285 ?><span><?php
286 echo esc_html__( 'Admin Interface', 'admin-site-enhancements' );
287 ?></span></label>
288 <input id="tab-login-logout" type="radio" name="tabs"><label for="tab-login-logout" class="modules-tab"><?php
289 echo wp_kses( $icon_login_logout, get_kses_with_svg_ruleset() );
290 ?><span><?php
291 echo esc_html__( 'Log In/Out | Register', 'admin-site-enhancements' );
292 ?></span></label>
293 <input id="tab-custom-code" type="radio" name="tabs"><label for="tab-custom-code" class="modules-tab"><?php
294 echo wp_kses( $icon_custom_code, get_kses_with_svg_ruleset() );
295 ?><span><?php
296 echo esc_html__( 'Custom Code', 'admin-site-enhancements' );
297 ?></span></label>
298 <input id="tab-disable-components" type="radio" name="tabs"><label for="tab-disable-components" class="modules-tab"><?php
299 echo wp_kses( $icon_disable_components, get_kses_with_svg_ruleset() );
300 ?><span><?php
301 echo esc_html__( 'Disable Components', 'admin-site-enhancements' );
302 ?></span></label>
303 <input id="tab-security" type="radio" name="tabs"><label for="tab-security" class="modules-tab"><?php
304 echo wp_kses( $icon_security, get_kses_with_svg_ruleset() );
305 ?><span><?php
306 echo esc_html__( 'Security', 'admin-site-enhancements' );
307 ?></span></label>
308 <input id="tab-optimizations" type="radio" name="tabs"><label for="tab-optimizations" class="modules-tab"><?php
309 echo wp_kses( $icon_optimizations, get_kses_with_svg_ruleset() );
310 ?><span><?php
311 echo esc_html__( 'Optimizations', 'admin-site-enhancements' );
312 ?></span></label>
313 <input id="tab-utilities" type="radio" name="tabs"><label for="tab-utilities" class="modules-tab"><?php
314 echo wp_kses( $icon_utilities, get_kses_with_svg_ruleset() );
315 ?><span><?php
316 echo esc_html__( 'Utilities', 'admin-site-enhancements' );
317 ?></span></label>
318 <label for="tab-search" class="search-tab" style="display:none;height:52px;"><span><?php
319 echo esc_html__( 'Search results:', 'admin-site-enhancements' );
320 ?></span></label>
321 </div>
322 <div class="asenha-tab-contents">
323 <section class="asenha-fields fields-content-management">
324 <table class="form-table" role="presentation">
325 <tbody></tbody>
326 </table>
327 </section>
328 <section class="asenha-fields fields-admin-interface">
329 <table class="form-table" role="presentation">
330 <tbody></tbody>
331 </table>
332 </section>
333 <section class="asenha-fields fields-login-logout">
334 <table class="form-table" role="presentation">
335 <tbody></tbody>
336 </table>
337 </section>
338 <section class="asenha-fields fields-custom-code">
339 <table class="form-table" role="presentation">
340 <tbody></tbody>
341 </table>
342 </section>
343 <section class="asenha-fields fields-disable-components">
344 <table class="form-table" role="presentation">
345 <tbody></tbody>
346 </table>
347 </section>
348 <section class="asenha-fields fields-security">
349 <table class="form-table" role="presentation">
350 <tbody></tbody>
351 </table>
352 </section>
353 <section class="asenha-fields fields-optimizations">
354 <table class="form-table" role="presentation">
355 <tbody></tbody>
356 </table>
357 </section>
358 <section class="asenha-fields fields-utilities">
359 <table class="form-table" role="presentation">
360 <tbody></tbody>
361 </table>
362 </section>
363 </div>
364 </div>
365 <div style="display:none;"><!-- Hide to prevent flash of fields appearing at the bottom of the page -->
366 <?php
367 settings_fields( ASENHA_ID );
368 ?>
369 <?php
370 do_settings_sections( ASENHA_SLUG );
371 ?>
372 <?php
373 submit_button(
374 __( 'Save Changes', 'admin-site-enhancements' ),
375 // Button copy
376 'primary',
377 // Type: 'primary', 'small', or 'large'
378 'submit',
379 // The 'name' attribute
380 true,
381 // Whether to wrap in <p> tag
382 array(
383 'id' => 'asenha-submit',
384 )
385 );
386 ?>
387 </div>
388 </form>
389 <?php
390 ?>
391 <div id="bottom-upgrade-nudge" class="asenha-upgrade-nudge-bottom" style="display:none;">
392 <div class="asenha-upgrade-nudge-bottom__message"><?php
393 echo __( 'Do more with <a href="https://www.wpase.com/upgrade-ndg-btm" target="_blank">ASE Pro</a>. Lifetime deal (LTD) <a href="https://www.wpase.com/upgrade-ndg-btm-prc" target="_blank">available</a>.', 'admin-site-enhancements' );
394 ?> <?php
395 if ( $is_yearend_promo_period ) {
396 echo __( 'Currently on YEAR-END SALE. <a href="https://www.wpase.com/promo-ndg" target="_blank">20% discount</a>.', 'admin-site-enhancements' );
397 }
398 ?></div>
399 </div>
400 <?php
401 ?>
402 </div>
403
404 <?php
405 ?>
406
407 </div>
408 <?php
409 // Record the number of times changes were saved as well as the date of last save
410 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
411 $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ? true : false );
412 if ( $changes_saved ) {
413 $current_date = date( 'Y-m-d', time() );
414 if ( !isset( $asenha_stats['first_save_date'] ) ) {
415 $asenha_stats['first_save_date'] = $current_date;
416 $asenha_stats['last_save_date'] = $current_date;
417 $asenha_stats['save_count'] = 1;
418 $asenha_stats['have_supported'] = false;
419 $asenha_stats['support_nudge_dismissed'] = false;
420 $asenha_stats['support_nudge_last_shown_date'] = '';
421 $asenha_stats['support_nudge_last_shown_save_count'] = 0;
422 } else {
423 $asenha_stats['last_save_date'] = $current_date;
424 $save_count = $asenha_stats['save_count'];
425 $save_count++;
426 $asenha_stats['save_count'] = $save_count;
427 }
428 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
429 }
430 }
431
432 /**
433 * Check whether it's the year-end promo period
434 *
435 * @since 7.8.11
436 */
437 function is_yearend_promo_period() {
438 // For year end promo between October 1 to December 31
439 $current_month = intval( date( 'n', time() ) );
440 // n is for numeric value of month, 1 to 12
441 if ( $current_month >= 10 ) {
442 $is_yearend_promo_period = true;
443 // Clear out last year's promo nudge dismissal data
444 $current_year = date( 'Y', time() );
445 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
446 if ( isset( $asenha_stats['promo_nudge_dismissed'] ) && $asenha_stats['promo_nudge_dismissed'] ) {
447 $last_dismissed_year = date( 'Y', strtotime( $asenha_stats['promo_nudge_dismissed_date'] ) );
448 if ( $current_year > $last_dismissed_year ) {
449 $asenha_stats['promo_nudge_dismissed'] = false;
450 $asenha_stats['promo_nudge_dismissed_date'] = '';
451 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
452 }
453 }
454 } else {
455 $is_yearend_promo_period = false;
456 }
457 // For year end promo between November 15 to December 31
458 // $tz = wp_timezone(); // WordPress timezone; or: new DateTimeZone('UTC')
459 // $current_date = new DateTimeImmutable('now', $tz);
460 // // $current_date = new DateTimeImmutable('2025-11-15', $tz); // For testing
461 // // $current_date = new DateTimeImmutable('2026-01-01', $tz); // For testing
462 // // $current_date = new DateTimeImmutable('2027-11-15', $tz); // For testing
463 // $year = (int) $current_date->format('Y');
464 // $start = new DateTimeImmutable("$year-11-15 00:00:00", $tz);
465 // $end = new DateTimeImmutable("$year-12-31 23:59:59", $tz);
466 // $is_between = ($current_date >= $start && $current_date <= $end);
467 // if ( $is_between ) {
468 // $is_yearend_promo_period = true;
469 // } else {
470 // $is_yearend_promo_period = false;
471 // }
472 // // Clear out last year's promo nudge dismissal data
473 // if ( $is_yearend_promo_period ) {
474 // $current_year = $year;
475 // $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
476 // if ( isset( $asenha_stats['promo_nudge_dismissed'] ) && $asenha_stats['promo_nudge_dismissed'] ) {
477 // $last_dismissed_year = date( 'Y', strtotime( $asenha_stats['promo_nudge_dismissed_date'] ) );
478 // if ( $current_year > $last_dismissed_year ) {
479 // $asenha_stats['promo_nudge_dismissed'] = false;
480 // $asenha_stats['promo_nudge_dismissed_date'] = '';
481 // update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
482 // }
483 // }
484 // }
485 return $is_yearend_promo_period;
486 }
487
488 /**
489 * Suppress all notices, then add notice for successful settings update
490 *
491 * @since 1.1.0
492 */
493 function asenha_suppress_add_notices() {
494 global $plugin_page;
495 // Suppress all notices
496 if ( ASENHA_SLUG === $plugin_page ) {
497 remove_all_actions( 'admin_notices' );
498 }
499 // Add notice for successful settings update
500 if ( isset( $_GET['page'] ) && ASENHA_SLUG == $_GET['page'] && isset( $_GET['settings-updated'] ) && true == $_GET['settings-updated'] ) {
501 ?>
502 <script>
503 jQuery(document).ready( function() {
504 jQuery('.asenha-changes-saved').fadeIn(400).delay(2500).fadeOut(400);
505 });
506 </script>
507
508 <?php
509 }
510 }
511
512 /**
513 * Suppress all generic notices on the plugin settings page
514 *
515 * @since 2.7.0
516 */
517 function asenha_suppress_generic_notices() {
518 global $plugin_page;
519 // Suppress all notices
520 if ( ASENHA_SLUG === $plugin_page ) {
521 remove_all_actions( 'all_admin_notices' );
522 }
523 }
524
525 /**
526 * Enqueue admin scripts
527 *
528 * @since 1.0.0
529 */
530 function asenha_admin_scripts( $hook_suffix ) {
531 global
532 $wp_version,
533 $pagenow,
534 $typenow,
535 $taxnow,
536 $hook_suffix,
537 $current_user
538 ;
539 $current_screen = get_current_screen();
540 // Get all WP Enhancements options, default to empty array in case it's not been created yet
541 $options = get_option( 'admin_site_enhancements', array() );
542 // For main page of this plugin
543 if ( is_asenha() ) {
544 wp_enqueue_style(
545 'asenha-jbox',
546 ASENHA_URL . 'assets/css/jBox.all.min.css',
547 array(),
548 ASENHA_VERSION
549 );
550 wp_enqueue_script(
551 'asenha-jbox',
552 ASENHA_URL . 'assets/js/jBox.all.min.js',
553 array(),
554 ASENHA_VERSION,
555 false
556 );
557 wp_enqueue_script(
558 'asenha-jsticky',
559 ASENHA_URL . 'assets/js/jquery.jsticky.mod.min.js',
560 array('jquery'),
561 ASENHA_VERSION,
562 false
563 );
564 wp_enqueue_script(
565 'asenha-js-cookie',
566 ASENHA_URL . 'assets/js/js.cookie.min.js',
567 array(),
568 ASENHA_VERSION,
569 false
570 );
571 // First, we unload the CodeMirror libraries included in WP core
572 wp_deregister_script( 'wp-codemirror' );
573 wp_deregister_script( 'code-editor' );
574 wp_deregister_script( 'htmlhint' );
575 wp_deregister_script( 'csslint' );
576 wp_deregister_script( 'esprima' );
577 wp_deregister_script( 'jshint' );
578 // Then, we load ASENHA's CodeMirror libraries. In use, e.g. for Utilities >> Enable Custom Admin / Frontend CSS / ads.txt / app-ads.txt
579 wp_enqueue_style(
580 'asenha-codemirror',
581 ASENHA_URL . 'assets/css/codemirror/codemirror.min.css',
582 array(),
583 ASENHA_VERSION
584 );
585 wp_enqueue_script(
586 'asenha-codemirror',
587 ASENHA_URL . 'assets/js/codemirror/codemirror.min.js',
588 array('jquery'),
589 ASENHA_VERSION,
590 true
591 );
592 wp_enqueue_script(
593 'asenha-codemirror-htmlmixed-mode',
594 ASENHA_URL . 'assets/js/codemirror/htmlmixed.js',
595 array('asenha-codemirror'),
596 ASENHA_VERSION,
597 true
598 );
599 wp_enqueue_script(
600 'asenha-codemirror-xml-mode',
601 ASENHA_URL . 'assets/js/codemirror/xml.js',
602 array('asenha-codemirror'),
603 ASENHA_VERSION,
604 true
605 );
606 wp_enqueue_script(
607 'asenha-codemirror-javascript-mode',
608 ASENHA_URL . 'assets/js/codemirror/javascript.js',
609 array('asenha-codemirror'),
610 ASENHA_VERSION,
611 true
612 );
613 wp_enqueue_script(
614 'asenha-codemirror-css-mode',
615 ASENHA_URL . 'assets/js/codemirror/css.js',
616 array('asenha-codemirror'),
617 ASENHA_VERSION,
618 true
619 );
620 wp_enqueue_script(
621 'asenha-codemirror-markdown-mode',
622 ASENHA_URL . 'assets/js/codemirror/markdown.js',
623 array('asenha-codemirror'),
624 ASENHA_VERSION,
625 true
626 );
627 // DataTables. In use, e.g. for Security >> Limit Login Attempts
628 wp_enqueue_style(
629 'asenha-datatables',
630 ASENHA_URL . 'assets/css/datatables/datatables.min.css',
631 array(),
632 ASENHA_VERSION
633 );
634 wp_enqueue_script(
635 'asenha-datatables',
636 ASENHA_URL . 'assets/js/datatables/datatables.min.js',
637 array('jquery'),
638 ASENHA_VERSION,
639 false
640 );
641 // Add WP media library assets
642 wp_enqueue_media();
643 // Add WP color picker assets
644 wp_enqueue_style( 'wp-color-picker' );
645 wp_enqueue_script( 'wp-color-picker' );
646 // We force loading the uncompressed version of TinyMCE. This ensures we load 'wp-tinymce-root' and then 'wp-tinymce',
647 // which prevents issue where the Visual tab is unusable in some scenarios
648 $wp_scripts = wp_scripts();
649 $wp_scripts->remove( 'wp-tinymce' );
650 wp_register_tinymce_scripts( $wp_scripts, true );
651 // Main style and script for the admin page
652 wp_enqueue_style(
653 'asenha-admin-page',
654 ASENHA_URL . 'assets/css/admin-page.css',
655 array(
656 'asenha-jbox',
657 'asenha-codemirror',
658 'asenha-datatables',
659 'wp-color-picker'
660 ),
661 ASENHA_VERSION
662 );
663 wp_enqueue_script(
664 'asenha-admin-page',
665 ASENHA_URL . 'assets/js/admin-page.js',
666 array(
667 'asenha-jsticky',
668 'asenha-jbox',
669 'asenha-js-cookie',
670 'asenha-codemirror-htmlmixed-mode',
671 'asenha-codemirror-xml-mode',
672 'asenha-codemirror-javascript-mode',
673 'asenha-codemirror-css-mode',
674 'asenha-codemirror-markdown-mode',
675 'asenha-datatables',
676 'wp-color-picker',
677 'wp-mediaelement',
678 'wp-tinymce-root',
679 'wp-tinymce'
680 ),
681 ASENHA_VERSION,
682 false
683 );
684 $jsvars = array(
685 'nonce' => wp_create_nonce( 'asenha-' . get_current_user_id() ),
686 'siteUrl' => get_site_url(),
687 'wpcontentUrl' => content_url(),
688 'mediaFrameTitle' => __( 'Select an Image', 'admin-site-enhancements' ),
689 'mediaFrameButtonText' => __( 'Use Selected Image', 'admin-site-enhancements' ),
690 'resetMenuNonce' => wp_create_nonce( 'reset-menu-nonce' ),
691 'sendTestEmailNonce' => wp_create_nonce( 'send-test-email-nonce_' . get_current_user_id() ),
692 'formBuilderSendTestEmailNonce' => wp_create_nonce( 'formbuilder_ajax' ),
693 'expandText' => __( 'Expand', 'admin-site-enhancements' ),
694 'collapseText' => __( 'Collapse', 'admin-site-enhancements' ),
695 'dataTable' => array(
696 'emptyTable' => __( 'No data available in table', 'admin-site-enhancements' ),
697 'info' => __( 'Showing _START_ to _END_ of _TOTAL_ entries', 'admin-site-enhancements' ),
698 'infoEmpty' => __( 'Showing 0 to 0 of 0 entries', 'admin-site-enhancements' ),
699 'infoFiltered' => __( '(filtered from _MAX_ total entries)', 'admin-site-enhancements' ),
700 'lengthMenu' => __( 'Show _MENU_ entries', 'admin-site-enhancements' ),
701 'search' => __( 'Search:', 'admin-site-enhancements' ),
702 'zeroRecords' => __( 'No matching records found', 'admin-site-enhancements' ),
703 'paginate' => array(
704 'first' => __( 'First', 'admin-site-enhancements' ),
705 'last' => __( 'Last', 'admin-site-enhancements' ),
706 'next' => __( 'Next', 'admin-site-enhancements' ),
707 'previous' => __( 'Previous', 'admin-site-enhancements' ),
708 ),
709 ),
710 );
711 wp_localize_script( 'asenha-admin-page', 'adminPageVars', $jsvars );
712 }
713 // Enqueue on all wp-admin
714 wp_enqueue_style(
715 'asenha-wp-admin',
716 ASENHA_URL . 'assets/css/wp-admin.css',
717 array(),
718 ASENHA_VERSION
719 );
720 // Content Management >> Show IDs, for list tables in wp-admin, e.g. All Posts page
721 if ( false !== strpos( $current_screen->base, 'edit' ) || false !== strpos( $current_screen->base, 'users' ) || false !== strpos( $current_screen->base, 'upload' ) ) {
722 wp_enqueue_style(
723 'asenha-list-table',
724 ASENHA_URL . 'assets/css/list-table.css',
725 array(),
726 ASENHA_VERSION
727 );
728 }
729 // Content Management >> Enable Media Replacement
730 if ( $current_screen->base == 'upload' || $current_screen->id == 'attachment' ) {
731 // wp_enqueue_style( 'asenha-jbox', ASENHA_URL . 'assets/css/jBox.all.min.css', array(), ASENHA_VERSION );
732 // wp_enqueue_script( 'asenha-jbox', ASENHA_URL . 'assets/js/jBox.all.min.js', array(), ASENHA_VERSION, false );
733 wp_enqueue_style(
734 'asenha-media-replace',
735 ASENHA_URL . 'assets/css/media-replace.css',
736 array(),
737 ASENHA_VERSION
738 );
739 wp_enqueue_script(
740 'asenha-media-replace',
741 ASENHA_URL . 'assets/js/media-replace.js',
742 array(),
743 ASENHA_VERSION,
744 false
745 );
746 $media_replace = array(
747 'selectMediaText' => __( 'Select New Media File', 'admin-site-enhancements' ),
748 'performReplacementText' => __( 'Perform Replacement', 'admin-site-enhancements' ),
749 );
750 wp_localize_script( 'asenha-media-replace', 'mediaReplace', $media_replace );
751 }
752 // Admin Interface >> Admin Menu Organizer
753 if ( 'settings_page_admin-menu-organizer' == $current_screen->base ) {
754 // Re-register and re-enqueue jQuery UI Core and plugins required for sortable, draggable and droppable when ordering menu items
755 wp_deregister_script( 'jquery-ui-core' );
756 wp_register_script(
757 'jquery-ui-core',
758 get_site_url() . '/wp-includes/js/jquery/ui/core.min.js',
759 array('jquery'),
760 ASENHA_VERSION,
761 false
762 );
763 wp_enqueue_script( 'jquery-ui-core' );
764 if ( version_compare( $wp_version, '5.6.0', '>=' ) ) {
765 wp_deregister_script( 'jquery-ui-mouse' );
766 wp_register_script(
767 'jquery-ui-mouse',
768 get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js',
769 array('jquery-ui-core'),
770 ASENHA_VERSION,
771 false
772 );
773 wp_enqueue_script( 'jquery-ui-mouse' );
774 } else {
775 wp_deregister_script( 'jquery-ui-widget' );
776 wp_register_script(
777 'jquery-ui-widget',
778 get_site_url() . '/wp-includes/js/jquery/ui/widget.min.js',
779 array('jquery'),
780 ASENHA_VERSION,
781 false
782 );
783 wp_enqueue_script( 'jquery-ui-widget' );
784 wp_deregister_script( 'jquery-ui-mouse' );
785 wp_register_script(
786 'jquery-ui-mouse',
787 get_site_url() . '/wp-includes/js/jquery/ui/mouse.min.js',
788 array('jquery-ui-core', 'jquery-ui-widget'),
789 ASENHA_VERSION,
790 false
791 );
792 wp_enqueue_script( 'jquery-ui-mouse' );
793 }
794 wp_deregister_script( 'jquery-ui-sortable' );
795 wp_register_script(
796 'jquery-ui-sortable',
797 get_site_url() . '/wp-includes/js/jquery/ui/sortable.min.js',
798 array('jquery-ui-mouse'),
799 ASENHA_VERSION,
800 false
801 );
802 wp_enqueue_script( 'jquery-ui-sortable' );
803 wp_deregister_script( 'jquery-ui-draggable' );
804 wp_register_script(
805 'jquery-ui-draggable',
806 get_site_url() . '/wp-includes/js/jquery/ui/draggable.min.js',
807 array('jquery-ui-mouse'),
808 ASENHA_VERSION,
809 false
810 );
811 wp_enqueue_script( 'jquery-ui-draggable' );
812 wp_deregister_script( 'jquery-ui-droppable' );
813 wp_register_script(
814 'jquery-ui-droppable',
815 get_site_url() . '/wp-includes/js/jquery/ui/droppable.min.js',
816 array('jquery-ui-draggable'),
817 ASENHA_VERSION,
818 false
819 );
820 wp_enqueue_script( 'jquery-ui-droppable' );
821 // Script to set behaviour and actions of the sortable menu
822 wp_enqueue_script(
823 'asenha-custom-admin-menu',
824 ASENHA_URL . 'assets/js/custom-admin-menu.js',
825 array('jquery-ui-draggable'),
826 ASENHA_VERSION,
827 false
828 );
829 wp_enqueue_style(
830 'asenha-admin-menu-organizer',
831 ASENHA_URL . 'assets/css/admin-menu-organizer.css',
832 array(),
833 ASENHA_VERSION
834 );
835 wp_enqueue_script(
836 'asenha-admin-menu-organizer',
837 ASENHA_URL . 'assets/js/admin-menu-organizer.js',
838 array('asenha-custom-admin-menu'),
839 ASENHA_VERSION,
840 false
841 );
842 wp_localize_script( 'asenha-admin-menu-organizer', 'amoPageVars', array(
843 'saveMenuNonce' => wp_create_nonce( 'save-menu-nonce' ),
844 'resetMenuNonce' => wp_create_nonce( 'reset-menu-nonce' ),
845 ) );
846 }
847 // Utilities >> Email Delivery Log
848 if ( 'tools_page_email-delivery-log' == $hook_suffix ) {
849 wp_enqueue_style( 'jquery-ui-css', ASENHA_URL . 'assets/premium/css/jquery-ui/jquery-ui.min.css' );
850 wp_enqueue_style( 'asenha-email-delivery-log', ASENHA_URL . 'assets/premium/css/email-delivery-log.css' );
851 wp_enqueue_script( 'jquery-ui' );
852 // wp_enqueue_script( 'jquery-ui-datepicker' );
853 wp_enqueue_script( 'jquery-ui-tabs' );
854 wp_enqueue_script( 'asenha-email-delivery-log', ASENHA_URL . 'assets/premium/js/email-delivery-log.js' );
855 $nonce = wp_create_nonce( 'email-delivery-log' . get_current_user_id() );
856 wp_localize_script( 'asenha-email-delivery-log', 'emailLog', array(
857 'nonce' => $nonce,
858 ) );
859 }
860 // Utilities >> Image Sizes Panel∂
861 if ( 'post' == $current_screen->base && 'attachment' == $current_screen->id ) {
862 global $post;
863 // Only enqueue if the attachment is an image
864 if ( property_exists( $post, 'post_mime_type' ) && false !== strpos( $post->post_mime_type, 'image' ) ) {
865 wp_enqueue_style( 'asenha-image-sizes-panel', ASENHA_URL . 'assets/css/image-sizes-panel.css' );
866 }
867 }
868 // Code Snippets Manager
869 if ( 'post' == $current_screen->base && 'asenha_code_snippet' == $current_screen->id || 'edit' == $current_screen->base && 'edit-asenha_code_snippet' == $current_screen->id ) {
870 }
871 // Content Management >> Hide Admin Notices
872 if ( array_key_exists( 'hide_admin_notices', $options ) && $options['hide_admin_notices'] ) {
873 $hide_for_nonadmins = ( isset( $options['hide_admin_notices_for_nonadmins'] ) ? $options['hide_admin_notices_for_nonadmins'] : false );
874 $minimum_capability = 'manage_options';
875 if ( function_exists( 'bwasenha_fs' ) ) {
876 if ( $hide_for_nonadmins && bwasenha_fs()->can_use_premium_code__premium_only() ) {
877 $minimum_capability = 'read';
878 }
879 }
880 if ( current_user_can( $minimum_capability ) ) {
881 wp_enqueue_style(
882 'asenha-jbox',
883 ASENHA_URL . 'assets/css/jBox.all.min.css',
884 array(),
885 ASENHA_VERSION
886 );
887 wp_enqueue_script(
888 'asenha-jbox',
889 ASENHA_URL . 'assets/js/jBox.all.min.js',
890 array(),
891 ASENHA_VERSION,
892 false
893 );
894 wp_enqueue_style(
895 'asenha-hide-admin-notices',
896 ASENHA_URL . 'assets/css/hide-admin-notices.css',
897 array(),
898 ASENHA_VERSION
899 );
900 wp_enqueue_script(
901 'asenha-hide-admin-notices',
902 ASENHA_URL . 'assets/js/hide-admin-notices.js',
903 array('asenha-jbox'),
904 ASENHA_VERSION,
905 false
906 );
907 }
908 }
909 // Utilities >> Multiple User Roles
910 if ( array_key_exists( 'multiple_user_roles', $options ) && $options['multiple_user_roles'] ) {
911 if ( 'user-edit.php' == $hook_suffix || 'user-new.php' == $hook_suffix ) {
912 // Only replace roles dropdown with checkboxes for users that can assign roles to other users, e.g. administrators
913 if ( current_user_can( 'promote_users', get_current_user_id() ) ) {
914 wp_enqueue_script(
915 'asenha-multiple-user-roles',
916 ASENHA_URL . 'assets/js/multiple-user-roles.js',
917 array('jquery'),
918 ASENHA_VERSION,
919 false
920 );
921 }
922 }
923 }
924 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
925 $hide_promo_nudge = false;
926 $is_yearend_promo_period = is_yearend_promo_period();
927 // Pass on ASENHA stats to admin-page.js to determine whether to show support nudge
928 $current_date = date( 'Y-m-d', time() );
929 $show_support_nudge = false;
930 $asenha_stats_localized = array(
931 'firstSaveDate' => '',
932 'lastSaveDate' => '',
933 'saveCount' => 0,
934 'hideUpgradeNudge' => false,
935 'hidePromoNudge' => false,
936 'showSupportNudge' => false,
937 );
938 if ( !empty( $asenha_stats ) ) {
939 $hide_upgrade_nudge = ( isset( $asenha_stats['upgrade_nudge_dismissed'] ) ? $asenha_stats['upgrade_nudge_dismissed'] : false );
940 $hide_promo_nudge = ( isset( $asenha_stats['promo_nudge_dismissed'] ) ? $asenha_stats['promo_nudge_dismissed'] : false );
941 $have_supported = ( isset( $asenha_stats['have_supported'] ) ? $asenha_stats['have_supported'] : false );
942 $changes_saved = ( isset( $_GET['settings-updated'] ) && 'true' == sanitize_text_field( $_GET['settings-updated'] ) ? true : false );
943 $save_count = ( isset( $asenha_stats['save_count'] ) ? $asenha_stats['save_count'] : 0 );
944 // Compensate for redirect from settings-updated=true URL
945 if ( $changes_saved ) {
946 $save_count = $save_count + 1;
947 } else {
948 $save_count = $save_count;
949 }
950 $saves_to_nudge_support = 10;
951 if ( $save_count < $saves_to_nudge_support ) {
952 $save_count_modulo = -1;
953 } else {
954 $save_count_modulo = $save_count % $saves_to_nudge_support;
955 }
956 // User have not supported ASE
957 if ( false === $have_supported ) {
958 // Support nudge have not been dismissed
959 if ( isset( $asenha_stats['support_nudge_dismissed'] ) && false === $asenha_stats['support_nudge_dismissed'] ) {
960 // Show support nudge after every x saves
961 if ( $save_count_modulo >= 0 ) {
962 $show_support_nudge = true;
963 } else {
964 $show_support_nudge = false;
965 }
966 if ( $show_support_nudge && $save_count_modulo >= 0 ) {
967 $asenha_stats['support_nudge_last_shown_date'] = $current_date;
968 $asenha_stats['support_nudge_last_shown_save_count'] = $save_count;
969 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
970 }
971 } else {
972 if ( $save_count_modulo == 0 ) {
973 $support_nudge_last_shown_save_count = ( isset( $asenha_stats['support_nudge_last_shown_save_count'] ) ? $asenha_stats['support_nudge_last_shown_save_count'] : 0 );
974 if ( $save_count > $support_nudge_last_shown_save_count ) {
975 $asenha_stats['support_nudge_dismissed'] = false;
976 update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
977 $show_support_nudge = true;
978 } else {
979 $show_support_nudge = false;
980 }
981 } else {
982 $show_support_nudge = false;
983 }
984 }
985 }
986 $first_save_date = ( isset( $asenha_stats['first_save_date'] ) ? $asenha_stats['first_save_date'] : '' );
987 $last_save_date = ( isset( $asenha_stats['last_save_date'] ) ? $asenha_stats['last_save_date'] : '' );
988 $asenha_stats_localized = array(
989 'firstSaveDate' => $first_save_date,
990 'lastSaveDate' => $last_save_date,
991 'saveCount' => $save_count,
992 'isYearEndPromoPeriod' => $is_yearend_promo_period,
993 'hideUpgradeNudge' => $hide_upgrade_nudge,
994 'hidePromoNudge' => $hide_promo_nudge,
995 'showSupportNudge' => $show_support_nudge,
996 );
997 }
998 wp_localize_script( 'asenha-admin-page', 'asenhaStats', $asenha_stats_localized );
999 }
1000
1001 /**
1002 * Inline CSS for Admin Menu Organizer in all wp-admin pages. Previously loaded externally as part of wp-admin.css file
1003 *
1004 * @since 7.6.11
1005 */
1006 function asenha_admin_menu_organizer_css() {
1007 ?>
1008 <style type="text/css">
1009 /* Admin Interface >> Admin Menu Organizer */
1010 #adminmenuwrap {
1011 height: auto !important;
1012 }
1013
1014 .toplevel_page_wpide #adminmenuwrap {
1015 height: calc(100vh - var(--wpide-admin-bar-height)) !important;
1016 } /* Fix for when in WPIDE plugin's menu / admin page */
1017
1018 /* Hide "Show Less" toggle by default to avoid initial flash before JS runs. */
1019 #toplevel_page_asenha_hide_hidden_menu {
1020 display: none;
1021 }
1022
1023 .current.menu-top.hidden,
1024 .wp-has-current-submenu.hidden {
1025 display: list-item;
1026 }
1027
1028 #adminmenu a.menu-top.hidden,
1029 ul#adminmenu a.wp-has-current-submenu.hidden {
1030 display: block;
1031 }
1032
1033 /*! <fs_premium_only> */
1034 .always-hidden {
1035 display: none !important;
1036 }
1037
1038 #adminmenu .wp-submenu a.hidden {
1039 display: none;
1040 }
1041 /*! </fs_premium_only> */
1042 </style>
1043 <?php
1044 }
1045
1046 /**
1047 * Dequeue scripts that prevents ASE settings page from working properly. Usually from plugins.
1048 *
1049 * @since 6.3.3
1050 */
1051 function asenha_dequeue_scritps() {
1052 if ( is_asenha() ) {
1053 // https://wordpress.org/plugins/user-activity-log/
1054 wp_dequeue_script( 'chats-js' );
1055 wp_dequeue_script( 'custom_wp_admin_js' );
1056 // https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/
1057 wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce' );
1058 wp_dequeue_script( 'print-invoices-packing-slip-labels-for-woocommerce-form-wizard' );
1059 // https://wordpress.org/plugins/wp-reading-progress/
1060 wp_dequeue_script( 'ruigehond006_admin_javascript' );
1061 // WordPress Mentions Légales plugin v1.2.3 by Jean-Baptiste Aramendy - http://jba-development.fr/
1062 wp_dequeue_script( 'jquery-ui' );
1063 wp_dequeue_script( 'wordpress-mentions-legales' );
1064 // https://wordpress.org/plugins/us-weather-widget-willyweather/
1065 wp_dequeue_script( 'self' );
1066 // iThemes Security Pro / Solid Security Pro
1067 wp_dequeue_script( 'itsec-core-admin-notices' );
1068 // WPML
1069 wp_dequeue_script( 'wpml-ate-jobs-sync-ui' );
1070 wp_dequeue_script( 'wpml-purify' );
1071 wp_dequeue_script( 'sitepress-scripts' );
1072 wp_dequeue_script( 'sitepress' );
1073 wp_dequeue_script( 'wpml-dismiss-notice' );
1074 wp_dequeue_script( 'wpml-tm-scripts' );
1075 wp_dequeue_script( 'otgs-installer-components-save-setting' );
1076 wp_dequeue_script( 'installer-dismiss-nag' );
1077 wp_dequeue_script( 'install-recommended_plugin' );
1078 wp_dequeue_script( 'icl-admin-notifier' );
1079 wp_dequeue_script( 'otgsPopoverTooltip' );
1080 // WPML String Translation
1081 wp_dequeue_script( 'wpml-theme-plugin-localization-scan' );
1082 // Asset Cleanup
1083 wp_dequeue_script( 'wpassetcleanup-script' );
1084 }
1085 }
1086
1087 /**
1088 * Enqueue public scripts
1089 *
1090 * @since 3.9.0
1091 */
1092 function asenha_public_scripts( $hook_suffix ) {
1093 // Get all WP Enhancements options, default to empty array in case it's not been created yet
1094 $options = get_option( 'admin_site_enhancements', array() );
1095 // External Permalinks
1096 $enable_external_permalinks = ( array_key_exists( 'enable_external_permalinks', $options ) ? $options['enable_external_permalinks'] : false );
1097 if ( $enable_external_permalinks ) {
1098 wp_enqueue_script(
1099 'asenha-public',
1100 ASENHA_URL . 'assets/js/external-permalinks.js',
1101 array(),
1102 ASENHA_VERSION,
1103 false
1104 );
1105 wp_localize_script( 'asenha-public', 'phpVars', array(
1106 'externalPermalinksEnabled' => $enable_external_permalinks,
1107 ) );
1108 }
1109 // Media Categories
1110 $enable_media_categories = ( array_key_exists( 'enable_media_categories', $options ) ? $options['enable_media_categories'] : false );
1111 if ( $enable_media_categories && !is_admin() && is_user_logged_in() ) {
1112 wp_enqueue_style(
1113 'asenha-media-categories-frontend',
1114 ASENHA_URL . 'assets/css/media-categories-frontend.css',
1115 array(),
1116 ASENHA_VERSION
1117 );
1118 }
1119 // Media Replacement
1120 $enable_media_replacement = ( array_key_exists( 'enable_media_replacement', $options ) ? $options['enable_media_replacement'] : false );
1121 if ( $enable_media_replacement && !is_admin() && is_user_logged_in() ) {
1122 wp_enqueue_style(
1123 'asenha-media-replace-frontend',
1124 ASENHA_URL . 'assets/css/media-replace-frontend.css',
1125 array(),
1126 ASENHA_VERSION
1127 );
1128 }
1129 }
1130
1131 /**
1132 * Add admin bar styles for wp-admin and frontend
1133 *
1134 * @since 6.2.1
1135 */
1136 function asenha_admin_bar_item_js_css() {
1137 if ( is_user_logged_in() ) {
1138 ?>
1139 <!--<script></script>-->
1140 <style>
1141 #wp-admin-bar-user-info .avatar {
1142 object-fit: cover;
1143 }
1144 </style>
1145 <?php
1146 }
1147 }
1148
1149 /**
1150 * Add 'Access now' plugin action link.
1151 *
1152 * @since 1.0.0
1153 */
1154 function asenha_plugin_action_links( $links ) {
1155 $settings_link = '<a href="tools.php?page=' . ASENHA_SLUG . '">' . __( 'Configure', 'admin-site-enhancements' ) . '</a>';
1156 array_unshift( $links, $settings_link );
1157 return $links;
1158 }
1159
1160 /**
1161 * Modify footer text
1162 *
1163 * @since 1.0.0
1164 */
1165 function asenha_footer_text() {
1166 // Show nothing
1167 ?>
1168 <?php
1169 }
1170
1171 /**
1172 * Change WP version number text in footer
1173 *
1174 * @since 4.8.3
1175 */
1176 function asenha_footer_version_text() {
1177 ?>
1178 ASE <a href="https://www.wpase.com/documentation/changelog/" target="_blank">v<?php
1179 echo esc_html( ASENHA_VERSION );
1180 ?></a>
1181 <?php
1182 }
1183
1184 /**
1185 * Check if current screen is this plugin's main page
1186 *
1187 * @since 1.0.0
1188 */
1189 function is_asenha() {
1190 $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] );
1191 // e.g. /wp-admin/index.php?page=page-slug
1192 if ( strpos( $request_uri, 'page=' . ASENHA_SLUG ) !== false ) {
1193 return true;
1194 // Yes, this is the plugin's main page
1195 } else {
1196 return false;
1197 // Nope, this is NOT the plugin's page
1198 }
1199 }
1200
1201 /**
1202 * Mark that user have supported ASE
1203 *
1204 * @since 5.2.7
1205 */
1206 function asenha_have_supported() {
1207 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1208 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1209 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
1210 $asenha_stats['have_supported'] = true;
1211 $asenha_stats['support_nudge_dismissed'] = true;
1212 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1213 if ( $success ) {
1214 echo json_encode( array(
1215 'success' => true,
1216 ) );
1217 } else {
1218 echo json_encode( array(
1219 'success' => false,
1220 ) );
1221 }
1222 }
1223 }
1224 }
1225
1226 /**
1227 * Dismiss support nudge
1228 *
1229 * @since 5.8.2
1230 */
1231 function asenha_dismiss_upgrade_nudge() {
1232 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1233 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1234 $current_date = date( 'Y-m-d', time() );
1235 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
1236 $asenha_stats['upgrade_nudge_dismissed'] = true;
1237 $asenha_stats['upgrade_nudge_dismissed_date'] = $current_date;
1238 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1239 if ( $success ) {
1240 echo json_encode( array(
1241 'success' => true,
1242 ) );
1243 } else {
1244 echo json_encode( array(
1245 'success' => false,
1246 ) );
1247 }
1248 }
1249 }
1250 }
1251
1252 /**
1253 * Dismiss promo nudge
1254 *
1255 * @since 7.5.1
1256 */
1257 function asenha_dismiss_promo_nudge() {
1258 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1259 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1260 $current_date = date( 'Y-m-d', time() );
1261 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
1262 $asenha_stats['promo_nudge_dismissed'] = true;
1263 $asenha_stats['promo_nudge_dismissed_date'] = $current_date;
1264 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1265 if ( $success ) {
1266 echo json_encode( array(
1267 'success' => true,
1268 ) );
1269 } else {
1270 echo json_encode( array(
1271 'success' => false,
1272 ) );
1273 }
1274 }
1275 }
1276 }
1277
1278 /**
1279 * Dismiss support nudge
1280 *
1281 * @since 5.2.7
1282 */
1283 function asenha_dismiss_support_nudge() {
1284 if ( isset( $_REQUEST ) && current_user_can( 'manage_options' ) ) {
1285 if ( wp_verify_nonce( sanitize_text_field( $_REQUEST['nonce'] ), 'asenha-' . get_current_user_id() ) ) {
1286 $asenha_stats = get_option( ASENHA_SLUG_U . '_stats', array() );
1287 $asenha_stats['support_nudge_dismissed'] = true;
1288 $success = update_option( ASENHA_SLUG_U . '_stats', $asenha_stats, false );
1289 if ( $success ) {
1290 echo json_encode( array(
1291 'success' => true,
1292 ) );
1293 } else {
1294 echo json_encode( array(
1295 'success' => false,
1296 ) );
1297 }
1298 }
1299 }
1300 }
1301