PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 7.6.10
Admin and Site Enhancements (ASE) v7.6.10
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 / classes / class-common-methods.php
admin-site-enhancements / classes Last commit date
class-activation.php 1 year ago class-admin-menu-organizer.php 1 year ago class-auto-publish-posts-with-missed-schedule.php 1 year ago class-avif-upload.php 1 year ago class-change-login-url.php 1 year ago class-cleanup-admin-bar.php 1 year ago class-common-methods.php 1 year ago class-content-duplication.php 1 year ago class-content-order.php 1 year ago class-custom-admin-footer-text.php 1 year ago class-custom-body-class.php 1 year ago class-custom-css.php 1 year ago class-custom-nav-menu-items-in-new-tab.php 1 year ago class-deactivation.php 1 year ago class-disable-comments.php 1 year ago class-disable-dashboard-widgets.php 1 year ago class-disable-feeds.php 1 year ago class-disable-gutenberg.php 1 year ago class-disable-rest-api.php 1 year ago class-disable-smaller-components.php 1 year ago class-disable-updates.php 1 year ago class-disable-xml-rpc.php 1 year ago class-display-system-summary.php 1 year ago class-email-address-obfuscator.php 1 year ago class-email-delivery.php 1 year ago class-enhance-list-tables.php 1 year ago class-external-permalinks.php 1 year ago class-heartbeat-control.php 1 year ago class-hide-admin-bar.php 1 year ago class-hide-admin-notices.php 1 year ago class-image-sizes-panel.php 1 year ago class-image-upload-control.php 1 year ago class-insert-head-body-footer-code.php 1 year ago class-last-login-column.php 1 year ago class-limit-login-attempts.php 1 year ago class-login-id-type.php 1 year ago class-login-logout-menu.php 1 year ago class-maintenance-mode.php 1 year ago class-manage-ads-appads-txt.php 1 year ago class-manage-robots-txt.php 1 year ago class-media-replacement.php 1 year ago class-multiple-user-roles.php 1 year ago class-obfuscate-author-slugs.php 1 year ago class-open-external-links-in-new-tab.php 1 year ago class-password-protection.php 1 year ago class-redirect-after-login.php 1 year ago class-redirect-after-logout.php 1 year ago class-redirect-fourofour.php 1 year ago class-registration-date-column.php 1 year ago class-revisions-control.php 1 year ago class-search-engines-visibility.php 1 year ago class-settings-fields-render.php 1 year ago class-settings-sanitization.php 1 year ago class-settings-sections-fields.php 1 year ago class-show-custom-taxonomy-filters.php 1 year ago class-site-identity-on-login-page.php 1 year ago class-svg-upload.php 1 year ago class-various-admin-ui-enhancements.php 1 year ago class-view-admin-as-role.php 1 year ago class-wider-admin-menu.php 1 year ago class-wp-config-transformer.php 1 year ago
class-common-methods.php
507 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 use WP_Query;
6 /**
7 * Class that provides common methods used throughout the plugin
8 *
9 * @since 2.5.0
10 */
11 class Common_Methods {
12 /**
13 * Get IP of the current visitor/user. In use by at least the Limit Login Attempts feature.
14 * This takes a best guess of the visitor's actual IP address.
15 * Takes into account numerous HTTP proxy headers due to variations
16 * in how different ISPs handle IP addresses in headers between hops.
17 *
18 * @link https://stackoverflow.com/q/1634782
19 * @since 2.5.0
20 */
21 public function get_user_ip_address( $return_type = 'ip', $for_which_module = 'limit-login-attempts' ) {
22 $options = get_option( ASENHA_SLUG_U, array() );
23 $ip_address_header = '';
24 switch ( $for_which_module ) {
25 case 'limit-login-attempts':
26 $ip_address_header = ( isset( $options['limit_login_attempts_header_override'] ) ? trim( $options['limit_login_attempts_header_override'] ) : '' );
27 break;
28 case 'password-protection':
29 $ip_address_header = ( isset( $options['password_protection_header_override'] ) ? trim( $options['password_protection_header_override'] ) : '' );
30 break;
31 }
32 // Attempt to get IP address with the preferred header
33 if ( !empty( $ip_address_header ) && isset( $_SERVER[$ip_address_header] ) ) {
34 // Check if multiple IP addresses exist in var
35 $ip_list = explode( ',', $_SERVER[$ip_address_header] );
36 if ( is_array( $ip_list ) && count( $ip_list ) > 1 ) {
37 foreach ( $ip_list as $ip ) {
38 switch ( $return_type ) {
39 case 'ip':
40 if ( $this->is_ip_valid( trim( $ip ) ) ) {
41 return sanitize_text_field( trim( $ip ) );
42 } else {
43 return '0.0.0.0';
44 // placeholder IP address
45 }
46 break;
47 case 'header':
48 return $ip_address_header . ' (multiple IP addresses)';
49 break;
50 }
51 }
52 } else {
53 switch ( $return_type ) {
54 case 'ip':
55 if ( $this->is_ip_valid( trim( $ip_list[0] ) ) ) {
56 return sanitize_text_field( $ip_list[0] );
57 } else {
58 return '0.0.0.0';
59 // placeholder IP address
60 }
61 break;
62 case 'header':
63 return $ip_address_header;
64 break;
65 }
66 }
67 }
68 // The following request headers can be modified by user or attacker when sending a request, so, will bypass an already blocked IP
69 // 'HTTP_CLIENT_IP', 'CF_CONNECTING_IP', 'HTTP_CF_CONNECTING_IP', 'HTTP_CF_CONNECTING_IP', 'TRUE_CLIENT_IP', 'HTTP_TRUE_CLIENT_IP', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED'
70 // Reported as security vulnerability in ASE <= v7.6.7.1 -- Limit Login Attempt Bypass via IP Spoofing
71 // Return unreliable but unspoofable IP address coming from the $_SERVER global as the default / fallback
72 switch ( $return_type ) {
73 case 'ip':
74 if ( $this->is_ip_valid( trim( $_SERVER['REMOTE_ADDR'] ) ) ) {
75 return sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
76 } else {
77 return '0.0.0.0';
78 // placeholder IP address
79 }
80 break;
81 case 'header':
82 return 'REMOTE_ADDR';
83 break;
84 }
85 }
86
87 /**
88 * Check if the supplied IP address is valid or not
89 *
90 * @param string $ip an IP address
91 * @link https://stackoverflow.com/q/1634782
92 * @return boolean true if supplied address is valid IP, and false otherwise
93 */
94 public function is_ip_valid( $ip ) {
95 if ( empty( $ip ) ) {
96 return false;
97 }
98 // Ref: https://www.php.net/manual/en/filter.filters.validate.php
99 if ( false == filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {
100 return false;
101 } else {
102 return true;
103 }
104 }
105
106 /**
107 * Convert number of seconds into hours, minutes, seconds. In use by at least the Limit Login Attempts feature.
108 *
109 * @since 2.5.0
110 */
111 public function seconds_to_period( $seconds, $conversion_type ) {
112 $period_start = new \DateTime('@0');
113 $period_end = new \DateTime("@{$seconds}");
114 if ( $conversion_type == 'to-days-hours-minutes-seconds' ) {
115 return $period_start->diff( $period_end )->format( '%a days, %h hours, %i minutes and %s seconds' );
116 } elseif ( $conversion_type == 'to-hours-minutes-seconds' ) {
117 return $period_start->diff( $period_end )->format( '%h hours, %i minutes and %s seconds' );
118 } elseif ( $conversion_type == 'to-minutes-seconds' ) {
119 return $period_start->diff( $period_end )->format( '%i minutes and %s seconds' );
120 } else {
121 return $period_start->diff( $period_end )->format( '%a days, %h hours, %i minutes and %s seconds' );
122 }
123 }
124
125 /**
126 * Remove html tags and content inside the tags from a string
127 *
128 * @since 3.0.3
129 */
130 public function strip_html_tags_and_content( $string ) {
131 // Strip HTML tags and content inside them. Ref: https://stackoverflow.com/a/39320168
132 if ( !is_null( $string ) ) {
133 if ( false === strpos( $string, 'fs-submenu-item' ) ) {
134 $string = preg_replace( '@<(\\w+)\\b.*?>.*?</\\1>@si', '', $string );
135 }
136 // Strip any remaining HTML or PHP tags
137 $string = strip_tags( $string );
138 }
139 return $string;
140 }
141
142 /**
143 * Get menu hidden by toggle
144 *
145 * @since 5.1.0
146 */
147 public function get_menu_hidden_by_toggle() {
148 $menu_hidden_by_toggle = array();
149 $options = get_option( ASENHA_SLUG_U, array() );
150 if ( array_key_exists( 'custom_menu_hidden', $options ) ) {
151 $menu_hidden = $options['custom_menu_hidden'];
152 $menu_hidden = explode( ',', $menu_hidden );
153 $menu_hidden_by_toggle = array();
154 foreach ( $menu_hidden as $menu_id ) {
155 $menu_hidden_by_toggle[] = $this->restore_menu_item_id( $menu_id );
156 }
157 }
158 return $menu_hidden_by_toggle;
159 }
160
161 /**
162 * Get user capabilities for which the "Show All/Less" menu toggle should be shown for
163 *
164 * @since 5.1.0
165 */
166 public function get_user_capabilities_to_show_menu_toggle_for() {
167 global $menu, $submenu;
168 $menu_always_hidden = array();
169 $user_capabilities_menus_are_hidden_for = array();
170 $menu_hidden_by_toggle = $this->get_menu_hidden_by_toggle();
171 // indexed array
172 foreach ( $menu as $menu_key => $menu_info ) {
173 foreach ( $menu_hidden_by_toggle as $hidden_menu_id ) {
174 if ( false !== strpos( $menu_info[4], 'wp-menu-separator' ) ) {
175 $menu_item_id = $menu_info[2];
176 } else {
177 $menu_item_id = $menu_info[5];
178 }
179 if ( $menu_item_id == $hidden_menu_id ) {
180 $user_capabilities_menus_are_hidden_for[] = $menu_info[1];
181 }
182 }
183 }
184 $user_capabilities_menus_are_hidden_for = array_unique( $user_capabilities_menus_are_hidden_for );
185 return $user_capabilities_menus_are_hidden_for;
186 // indexed array
187 }
188
189 /**
190 * Transform menu item's ID
191 *
192 * @since 5.1.0
193 */
194 public function transform_menu_item_id( $menu_item_id ) {
195 // Transform e.g. edit.php?post_type=page ==> edit__php___post_type____page
196 $menu_item_id_transformed = str_replace( array(
197 ".",
198 "?",
199 "=/",
200 "=",
201 "&",
202 "/"
203 ), array(
204 "__",
205 "___",
206 "_______",
207 "____",
208 "_____",
209 "______"
210 ), $menu_item_id );
211 return $menu_item_id_transformed;
212 }
213
214 /**
215 * Transform menu item's ID
216 *
217 * @since 5.1.0
218 */
219 public function restore_menu_item_id( $menu_item_id_transformed ) {
220 // Transform e.g. edit__php___post_type____page ==> edit.php?post_type=page
221 $menu_item_id = str_replace( array(
222 "_______",
223 "______",
224 "_____",
225 "____",
226 "___",
227 "__"
228 ), array(
229 "=/",
230 "/",
231 "&",
232 "=",
233 "?",
234 "."
235 ), $menu_item_id_transformed );
236 return $menu_item_id;
237 }
238
239 /**
240 * Sanitize hexedecimal numbers used for colors
241 *
242 * @link https://plugins.trac.wordpress.org/browser/bm-custom-login/trunk/bm-custom-login.php
243 * @param string $color Hex number to sanitize.
244 * @return string
245 */
246 public function sanitize_hex_color( $color ) {
247 if ( '' === $color ) {
248 return '';
249 }
250 // Make sure the color starts with a hash.
251 $color = '#' . ltrim( $color, '#' );
252 // 3 or 6 hex digits, or the empty string.
253 if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
254 return $color;
255 }
256 return null;
257 }
258
259 /**
260 * Get the post ID of the most recent post in a custom post type
261 *
262 * @since 6.4.1
263 */
264 public function get_most_recent_post_id( $post_type ) {
265 $args = array(
266 'post_type' => $post_type,
267 'posts_per_page' => 1,
268 'orderby' => 'date',
269 'order' => 'DESC',
270 );
271 $query = new WP_Query($args);
272 if ( $query->have_posts() ) {
273 $query->the_post();
274 $post_id = get_the_ID();
275 wp_reset_postdata();
276 return $post_id;
277 }
278 return 0;
279 // Return 0 if no posts found
280 }
281
282 /**
283 * Extended ruleset for wp_kses() that includes SVG tag and it's children
284 *
285 * @since 6.8.3
286 */
287 public function get_kses_extended_ruleset() {
288 $kses_defaults = wp_kses_allowed_html( 'post' );
289 // For SVG icons
290 $svg_args = array(
291 'svg' => array(
292 'class' => true,
293 'aria-hidden' => true,
294 'aria-labelledby' => true,
295 'role' => true,
296 'xmlns' => true,
297 'width' => true,
298 'height' => true,
299 'viewbox' => true,
300 'viewBox' => true,
301 ),
302 'g' => array(
303 'fill' => true,
304 'fill-rule' => true,
305 'stroke' => true,
306 'stroke-width' => true,
307 'stroke-linejoin' => true,
308 'stroke-linecap' => true,
309 ),
310 'title' => array(
311 'title' => true,
312 ),
313 'path' => array(
314 'd' => true,
315 'fill' => true,
316 'stroke' => true,
317 'stroke-width' => true,
318 'stroke-linejoin' => true,
319 'stroke-linecap' => true,
320 ),
321 'rect' => array(
322 'width' => true,
323 'height' => true,
324 'x' => true,
325 'y' => true,
326 'rx' => true,
327 'ry' => true,
328 'fill' => true,
329 'stroke' => true,
330 'stroke-width' => true,
331 'stroke-linejoin' => true,
332 'stroke-linecap' => true,
333 ),
334 'circle' => array(
335 'cx' => true,
336 'cy' => true,
337 'r' => true,
338 'stroke' => true,
339 'stroke-width' => true,
340 'stroke-linejoin' => true,
341 'stroke-linecap' => true,
342 ),
343 );
344 $kses_with_extras = array_merge( $kses_defaults, $svg_args );
345 // For embedded PDF viewer
346 $style_script_args = array(
347 'style' => true,
348 'script' => array(
349 'src' => true,
350 ),
351 );
352 return array_merge( $kses_with_extras, $style_script_args );
353 }
354
355 /**
356 * Get the singular label from a $post object
357 *
358 * @since 6.9.3
359 */
360 function get_post_type_singular_label( $post ) {
361 $post_type_singular_label = '';
362 if ( property_exists( $post, 'post_type' ) ) {
363 $post_type_object = get_post_type_object( $post->post_type );
364 if ( is_object( $post_type_object ) && property_exists( $post_type_object, 'label' ) ) {
365 $post_type_singular_label = $post_type_object->labels->singular_name;
366 }
367 }
368 return $post_type_singular_label;
369 }
370
371 function is_in_block_editor() {
372 $current_screen = get_current_screen();
373 if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
374 return true;
375 } else {
376 return false;
377 }
378 }
379
380 /**
381 * Check if WooCommerce is active
382 *
383 * @since 6.9.9
384 */
385 public function is_woocommerce_active() {
386 if ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
387 return true;
388 } else {
389 return false;
390 }
391 }
392
393 /**
394 * Convert HEX color to RGBA
395 *
396 * @link https://stackoverflow.com/a/31934345
397 * @since 7.0.0
398 */
399 public function hex_to_rgba( $hex, $alpha = false ) {
400 $hex = str_replace( '#', '', trim( $hex ) );
401 $length = strlen( $hex );
402 $rgb['r'] = hexdec( ( $length == 6 ? substr( $hex, 0, 2 ) : (( $length == 3 ? str_repeat( substr( $hex, 0, 1 ), 2 ) : 0 )) ) );
403 $rgb['g'] = hexdec( ( $length == 6 ? substr( $hex, 2, 2 ) : (( $length == 3 ? str_repeat( substr( $hex, 1, 1 ), 2 ) : 0 )) ) );
404 $rgb['b'] = hexdec( ( $length == 6 ? substr( $hex, 4, 2 ) : (( $length == 3 ? str_repeat( substr( $hex, 2, 1 ), 2 ) : 0 )) ) );
405 if ( false !== $alpha ) {
406 $rgb['a'] = $alpha;
407 }
408 // Return array of r, g, b and a
409 // return $rgb;
410 // Return rgb(255,255,255) or rgba(255,255,255,.5)
411 return implode( array_keys( $rgb ) ) . '(' . implode( ', ', $rgb ) . ')';
412 }
413
414 /**
415 * Detect if a color is light or dark
416 *
417 * @link https://stackoverflow.com/a/12228730
418 * @since 7.0.0
419 */
420 public function is_color_dark( $hex ) {
421 $hex = str_replace( '#', '', trim( $hex ) );
422 $r = hexdec( $hex[0] . $hex[1] );
423 $g = hexdec( $hex[2] . $hex[3] );
424 $b = hexdec( $hex[4] . $hex[5] );
425 $lightness = (max( $r, $g, $b ) + min( $r, $g, $b )) / 510.0;
426 // HSL algorithm
427 if ( $lightness > 0.8 ) {
428 return false;
429 } else {
430 return true;
431 }
432 }
433
434 /**
435 * Return SVG for small triangle in place of using &#9654; HTMl character
436 * which may be converted to emoticon by the browser or app
437 *
438 * @since 7.2.0
439 */
440 public function get_svg_triangle() {
441 return '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 16 16"><path fill="currentColor" d="M14.222 6.687a1.5 1.5 0 0 1 0 2.629l-10 5.499A1.5 1.5 0 0 1 2 13.5V2.502a1.5 1.5 0 0 1 2.223-1.314z"/></svg>';
442 }
443
444 /**
445 * Get an image URL from an ASE setting field, which could be an internal relative URL or an external URL
446 *
447 * @since 7.2.1
448 */
449 public function get_image_url( $ase_settings_field_name ) {
450 $options = get_option( ASENHA_SLUG_U, array() );
451 if ( isset( $options[$ase_settings_field_name] ) ) {
452 if ( false === strpos( $options[$ase_settings_field_name], 'http' ) && false !== strpos( $options[$ase_settings_field_name], '/uploads/' ) ) {
453 $logo_image = content_url() . $options[$ase_settings_field_name];
454 } else {
455 // $maybe_valid_url = filter_var( $options['admin_logo_image'], FILTER_SANITIZE_URL );
456 $maybe_valid_url = sanitize_url( $options[$ase_settings_field_name], array('http', 'https') );
457 if ( false !== filter_var( $maybe_valid_url, FILTER_VALIDATE_URL ) ) {
458 $logo_image = $maybe_valid_url;
459 } else {
460 $logo_image = '';
461 }
462 }
463 } else {
464 $logo_image = '';
465 }
466 return $logo_image;
467 }
468
469 /**
470 * Get current URL, without query parameters and without trailing slash
471 * e.g. https://www.site.com/some-page
472 *
473 * @return string
474 */
475 public function get_current_url() {
476 $output = '';
477 $url = (( is_ssl() ? 'https://' : 'http://' )) . sanitize_text_field( $_SERVER['HTTP_HOST'] ) . sanitize_text_field( $_SERVER['REQUEST_URI'] );
478 $url_parts = explode( '?', $url, 2 );
479 // limit to max of 2 elements with last element containing the rest of the string
480 if ( isset( $url_parts[0] ) ) {
481 $output = trim( $url_parts[0], '/' );
482 }
483 return ( $output ? urldecode( $output ) : '/' );
484 }
485
486 /**
487 * Get array of elements with value of true
488 *
489 * @since 7.6.10
490 */
491 public function get_array_of_keys_with_true_value( $array_with_true_false_values ) {
492 $array_of_keys_with_true_value = array();
493 if ( is_array( $array_with_true_false_values ) && count( $array_with_true_false_values ) > 0 ) {
494 foreach ( $array_with_true_false_values as $key => $value ) {
495 if ( $value ) {
496 $array_of_keys_with_true_value[] = $key;
497 }
498 }
499 return $array_of_keys_with_true_value;
500 } else {
501 return array();
502 // default, empty array
503 }
504 }
505
506 }
507