PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.5.4
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.5.4
4.3.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 All 165 releases
← All changes | Inc/Classes/Tweaks.php +45 -165 4.3.24.0.5.4 View file →
@@ -1,11 +1,11 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc\Classes;
3 +namespace WPAdminify\Inc\Classes;
4 4
5 -use PXLBSAdminify\Inc\Utils;
6 -use PXLBSAdminify\Inc\Admin\AdminSettings;
7 -use PXLBSAdminify\Inc\Admin\AdminSettingsModel;
5 +use WPAdminify\Inc\Utils;
6 +use WPAdminify\Inc\Admin\AdminSettings;
7 +use WPAdminify\Inc\Admin\AdminSettingsModel;
8 8
9 9 // no direct access allowed
10 10 if (!defined('ABSPATH')) {
11 11 exit;
@@ -57,9 +57,9 @@
57 57
58 58 $this->security_attachments();
59 59
60 60 if(!empty($this->performance['performance_enable'])){
61 - $this->performances();
61 + $this->adminify_performances();
62 62 }
63 63
64 64 // Add Custom Default Gravatar Image
65 65 if (!empty($this->custom_gravatar) && array_key_exists('enable', $this->custom_gravatar)) {
@@ -64,10 +64,8 @@
64 64 // Add Custom Default Gravatar Image
65 65 if (!empty($this->custom_gravatar) && array_key_exists('enable', $this->custom_gravatar)) {
66 66 // Add Custom Default Gravatar Image
67 67 add_filter('avatar_defaults', [$this, 'add_custom_gravatar_image'], 99);
68 - // ...and serve it from this site rather than through gravatar.com.
69 - add_filter('get_avatar_data', [$this, 'serve_custom_gravatar_locally'], 99);
70 68 }
71 69
72 70 // If Admin bar Editor Plugin not Installed
73 71 if (! class_exists('\JewelTheme\AdminBarEditor\AdminBarEditor')) {
@@ -74,9 +72,9 @@
74 72 if (!empty($this->options['white_label']['wordpress']['remove_howdy_msg']) || !empty($this->options['white_label']['wordpress']['change_howdy_text'])) {
75 73 // Change Howdy Text
76 74 // add_action('admin_bar_menu', [$this, 'remove_from_admin_bar'], 999);
77 75 // add_action('admin_bar_menu', [$this, 'clear_node_title'], 999);
78 - add_filter('admin_bar_menu', [$this, 'change_howdy_text'], 9999);
76 + add_filter('admin_bar_menu', [$this, 'adminify_change_howdy_text'], 9999);
79 77 }
80 78 }
81 79
82 80
@@ -161,10 +159,9 @@
161 159
162 160 public function url_redirection(){
163 161 global $wp_query;
164 162 $wp_query->set_404();
165 - wp_safe_redirect(esc_url(home_url()), 301);
166 - exit;
163 + wp_redirect(esc_url(home_url()), 301);
167 164 }
168 165
169 166 public function redirect_to_home(){
170 167 $post_archives_data = $this->security_posts['post_archives_data'];
@@ -215,10 +212,10 @@
215 212 public function security_attachments(){
216 213
217 214 // Add Featured Image or Post Thumbnail to RSS Feed
218 215 if (!empty($this->security_media['thumbnails_rss_feed'])) {
219 - add_filter('the_excerpt_rss', [$this, 'rss_post_thumbnail']);
220 - add_filter('the_content_feed', [$this, 'rss_post_thumbnail']);
216 + add_filter('the_excerpt_rss', [$this, 'jltwp_adminify_rss_post_thumbnail']);
217 + add_filter('the_content_feed', [$this, 'jltwp_adminify_rss_post_thumbnail']);
221 218 }
222 219
223 220 }
224 221
@@ -403,9 +400,9 @@
403 400
404 401 /*
405 402 * Change Howdy Text
406 403 */
407 - public function change_howdy_text($wp_admin_bar)
404 + public function adminify_change_howdy_text($wp_admin_bar)
408 405 {
409 406 // Remove Howdy Message entirely
410 407 if (!empty($this->options['white_label']['wordpress']['remove_howdy_msg'])) {
411 408
@@ -438,9 +435,9 @@
438 435
439 436 if (isset($my_account->title)) {
440 437
441 438 // Replace the "Howdy" text with "Welcome"
442 - $changed_howdy_text = str_replace('Howdy', Utils::kses_custom($this->options['white_label']['wordpress']['change_howdy_text']), $my_account->title);
439 + $changed_howdy_text = str_replace('Howdy', Utils::wp_kses_custom($this->options['white_label']['wordpress']['change_howdy_text']), $my_account->title);
443 440
444 441 // Update the node with the new title
445 442 $wp_admin_bar->add_node([
446 443 'id' => 'my-account',
@@ -541,147 +538,23 @@
541 538 */
542 539 $wp_admin_bar->remove_node('wp-logo');
543 540 }
544 541
545 - /**
546 - * The avatar images an administrator configured in the plugin settings.
547 - *
548 - * Keyed by URL, because that is the identifier WordPress stores in the
549 - * `avatar_default` option and hands back to `get_avatar()` later.
550 - *
551 - * @return array<string,string> Avatar URL => label.
552 - */
553 - private function custom_gravatar_images()
554 - {
555 - $images = [];
556 -
557 - if ( empty( $this->custom_gravatar['image'] ) || ! is_array( $this->custom_gravatar['image'] ) ) {
558 - return $images;
559 - }
560 -
561 - foreach ( $this->custom_gravatar['image'] as $value ) {
562 - if ( empty( $value['avatar_image']['url'] ) ) {
563 - continue;
564 - }
565 -
566 - $avatar_url = esc_url_raw( $value['avatar_image']['url'] );
567 - $images[ $avatar_url ] = ! empty( $value['avatar_name'] )
568 - ? sanitize_text_field( $value['avatar_name'] )
569 - : __( 'Custom Gravatar', 'adminify' );
570 - }
571 -
572 - return $images;
573 - }
574 -
575 542 // Custom Avatars
576 543 public function add_custom_gravatar_image($avatar_defaults)
577 544 {
578 - // Register the avatar images configured by the administrator in the plugin settings.
579 - return array_merge( (array) $avatar_defaults, $this->custom_gravatar_images() );
580 - }
545 + // if (!empty($this->custom_gravatar) && array_key_exists('image', $this->custom_gravatar)) {
546 + // foreach ($this->custom_gravatar['image'] as $key => $value) {
547 + // $avatar_url = esc_url_raw($value['avatar_image']['url']);
548 + // $avatar_defaults[$avatar_url] = $value['avatar_name'];
549 + // }
550 + // }
551 + $custom_avatar_url = 'https://scontent.fzyl2-2.fna.fbcdn.net/v/t39.30808-6/348970682_781621106945149_5992028158112526767_n.jpg?_nc_cat=100&ccb=1-7&_nc_sid=cc71e4&_nc_ohc=gUNSZF2ODw8Q7kNvgG5T48V&_nc_ht=scontent.fzyl2-2.fna&oh=00_AYDLLCAW7eyeRQakH_Fy9R57hYPAekMNIcEHLGi12watcA&oe=66906465'; // Replace with your custom avatar URL
552 + $avatar_defaults[$custom_avatar_url] = 'Custom Gravatar'; // Text to display in the avatar dropdown
581 553
582 - /**
583 - * Serve a custom default avatar from this site instead of through gravatar.com.
584 - *
585 - * Core hands the chosen default to Gravatar as the `d=` query arg, which means
586 - * gravatar.com has to fetch the image from THIS server before it can serve it
587 - * back. That only works when the URL is publicly resolvable: on a local install,
588 - * a staging site behind HTTP auth, or an intranet, Gravatar cannot reach it and
589 - * every avatar that falls back to the default comes out broken.
590 - *
591 - * Gravatar precedence is preserved: a user who genuinely has a Gravatar still
592 - * gets theirs, because the custom image is only substituted once
593 - * email_has_gravatar() has established there is nothing to fall back FROM. That
594 - * keeps "Default Avatar" meaning what WordPress says it means.
595 - *
596 - * @param array $args Avatar data, after processing.
597 - * @return array
598 - */
599 - public function serve_custom_gravatar_locally( $args )
600 - {
601 - if ( empty( $args['default'] ) || ! is_string( $args['default'] ) ) {
602 - return $args;
603 - }
604 -
605 - $images = $this->custom_gravatar_images();
606 -
607 - if ( ! isset( $images[ $args['default'] ] ) ) {
608 - return $args;
609 - }
610 -
611 - // `force_default` means the caller asked for the default image specifically -
612 - // the radio list on Settings > Discussion renders every option that way - so
613 - // there is nothing to look up.
614 - if ( empty( $args['force_default'] ) && $this->email_has_gravatar( $args['url'] ) ) {
615 - return $args;
616 - }
617 -
618 - // `found_avatar` is deliberately untouched: it only decides whether
619 - // get_avatar() adds the `avatar-default` class, which is correct here.
620 - $args['url'] = $args['default'];
621 -
622 - return $args;
554 + return $avatar_defaults;
623 555 }
624 556
625 - /**
626 - * Whether the address behind a gravatar.com URL actually has an avatar there.
627 - *
628 - * `d=404` is Gravatar's documented way of asking the question: instead of serving
629 - * a fallback image it answers 404 when the address is unknown. The answer is
630 - * cached per hash, so a busy comment thread costs one request per new address
631 - * rather than one per avatar rendered.
632 - *
633 - * The hash is read back out of the URL core just built rather than recomputed,
634 - * which avoids re-implementing its resolution of user IDs, comments, posts,
635 - * WP_User objects and raw hashes - and means a URL another plugin has already
636 - * pointed somewhere else is left alone.
637 - *
638 - * @param string $avatar_url The avatar URL core built.
639 - * @return bool True when the address has a Gravatar, or when it is not safe to say.
640 - */
641 - private function email_has_gravatar( $avatar_url )
642 - {
643 - if ( empty( $avatar_url ) || ! is_string( $avatar_url ) ) {
644 - return true;
645 - }
646 -
647 - $path = wp_parse_url( $avatar_url, PHP_URL_PATH );
648 - $hash = $path ? basename( $path ) : '';
649 -
650 - // SHA-256 in current core (hash('sha256', ...) in get_avatar_data), MD5 in
651 - // older releases. Anything else is not a gravatar.com avatar URL - another
652 - // plugin has already pointed it elsewhere - and is none of our business.
653 - if ( ! preg_match( '/^[a-f0-9]{32}$|^[a-f0-9]{64}$/i', $hash ) ) {
654 - return true;
655 - }
656 -
657 - $cache_key = 'adminify_has_gravatar_' . $hash;
658 - $cached = get_transient( $cache_key );
659 -
660 - if ( false !== $cached ) {
661 - return '1' === $cached;
662 - }
663 -
664 - $response = wp_remote_head(
665 - 'https://secure.gravatar.com/avatar/' . $hash . '?d=404&s=1',
666 - array( 'timeout' => 3 )
667 - );
668 -
669 - if ( is_wp_error( $response ) ) {
670 - // Offline, blocked, or too slow. Show the custom image rather than a URL
671 - // gravatar.com may not be able to resolve either, and ask again soon -
672 - // a temporary outage should not pin a real Gravatar out of view for a week.
673 - set_transient( $cache_key, '0', 15 * MINUTE_IN_SECONDS );
674 - return false;
675 - }
676 -
677 - $has_gravatar = 200 === (int) wp_remote_retrieve_response_code( $response );
678 -
679 - set_transient( $cache_key, $has_gravatar ? '1' : '0', WEEK_IN_SECONDS );
680 -
681 - return $has_gravatar;
682 - }
683 -
684 557 // Check Last Login Column
685 558 public function last_login_column_info( $user_login )
686 559 {
687 560 $user = get_user_by( 'login', $user_login );
@@ -749,9 +622,9 @@
749 622 *
750 623 * @param array $rules WordPress rewrite rules.
751 624 * @return array Rewrite rules without embeds rules.
752 625 */
753 - public function disable_embeds_rewrites($rules)
626 + public function adminify_disable_embeds_rewrites($rules)
754 627 {
755 628 foreach ($rules as $rule => $rewrite) {
756 629 if (false !== strpos($rewrite, 'embed=true')) {
757 630 unset($rules[$rule]);
@@ -776,18 +649,18 @@
776 649 } else {
777 650 $target = esc_url(home_url());
778 651 }
779 652
780 - $target = apply_filters('pxlbsadminify_redirect_target', $target);
781 - $status = apply_filters('pxlbsadminify_redirect_status', $this->redirect_status);
653 + $target = apply_filters('wp_adminify_redirect_target', $target);
654 + $status = apply_filters('wp_adminify_redirect_status', $this->redirect_status);
782 655
783 - wp_safe_redirect($target, $status);
784 - exit;
656 + wp_redirect($target, $status);
657 + die();
785 658 }
786 659
787 660
788 661 /* Add Featured Image or Post Thumbnail to RSS Feed */
789 - public function rss_post_thumbnail($content)
662 + public function jltwp_adminify_rss_post_thumbnail($content)
790 663 {
791 664 global $post;
792 665 if (has_post_thumbnail($post->ID)) {
793 666 $content = '<p>' . get_the_post_thumbnail($post->ID) .
@@ -807,12 +680,12 @@
807 680 $u_modified_time = get_the_modified_time('U');
808 681
809 682 if ($u_modified_time >= $u_time + 86400) {
810 683 $custom_content = sprintf(
811 - '<div class="wp-adminify-last-updated"><strong><span>%1$s</span></strong><span>%2$s %3$s</span></div>',
812 - esc_html__('Last Updated on', 'adminify'),
813 - esc_html(get_the_modified_time('F jS, Y')),
814 - esc_html(get_the_modified_time('h:i a'))
684 + __('<div class="wp-adminify-last-updated"><strong><span>%1$s</span></strong><span>%2$s %3$s</span></div>', 'adminify'),
685 + esc_html__('Last Updated on ', 'adminify'),
686 + get_the_modified_time('F jS, Y'),
687 + get_the_modified_time('h:i a')
815 688 );
816 689 return $custom_content . $content;
817 690 }
818 691
@@ -866,9 +739,9 @@
866 739 }
867 740
868 741
869 742 /** Remove Dashicons from Admin Bar for non logged in users **/
870 - public function remove_dashicons()
743 + public function jltwp_adminify_remove_dashicons()
871 744 {
872 745 global $pagenow;
873 746
874 747 if (!is_user_logged_in()) {
@@ -873,9 +746,9 @@
873 746
874 747 if (!is_user_logged_in()) {
875 748
876 749 // This retrieves the /path/file.php?param=val part of the URL
877 - $current_request_uri = isset($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '';
750 + $current_request_uri = sanitize_text_field($_SERVER['REQUEST_URI']);
878 751
879 752 // for homepage
880 753 if (empty($current_request_uri)) {
881 754 wp_dequeue_style('dashicons');
@@ -896,8 +769,15 @@
896 769 }
897 770 }
898 771
899 772
773 + /** Control Interval Heartbeat API **/
774 + public function control_heartbeat_api($settings)
775 + {
776 + $settings['interval'] = 60;
777 + return $settings;
778 + }
779 +
900 780 /** Remove Query Strings from Scripts/Styles **/
901 781 public function remove_script_versions($src)
902 782 {
903 783 if( !empty($src) ) {
@@ -906,9 +786,9 @@
906 786 }
907 787 }
908 788
909 789 /** Browser Cache Expires & GZIP Compression **/
910 - public function htaccess()
790 + public function jltwp_adminify_htaccess()
911 791 {
912 792 // We get the main WordPress .htaccess filepath.
913 793 $ruta_htaccess = get_home_path() . '.htaccess'; // https://codex.wordpress.org/Function_Reference/get_home_path !
914 794
@@ -939,9 +819,9 @@
939 819 $lineas[] = 'AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf';
940 820 $lineas[] = 'AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf';
941 821 $lineas[] = '</IfModule>';
942 822
943 - insert_with_markers($ruta_htaccess, 'Adminify by Jewel Theme', $lineas); // https://developer.wordpress.org/reference/functions/insert_with_markers/ !
823 + insert_with_markers($ruta_htaccess, 'WP Adminify by Jewel Theme', $lineas); // https://developer.wordpress.org/reference/functions/insert_with_markers/ !
944 824 }
945 825
946 826
947 827 /**
@@ -950,9 +830,9 @@
950 830 * @access public
951 831 * @since 1.0.0
952 832 * @return void
953 833 */
954 - public function performances()
834 + public function adminify_performances()
955 835 {
956 836 $performance_data = $this->performance['performance_data'];
957 837
958 838 // Remove jQuery Migrate
@@ -958,9 +838,9 @@
958 838 // Remove jQuery Migrate
959 839
960 840 // Remove Dashicons from Frontend
961 841 if (!empty($performance_data) && in_array('dashicons', $performance_data)) {
962 - add_action('wp_print_styles', [$this, 'remove_dashicons'], 100);
842 + add_action('wp_print_styles', [$this, 'jltwp_adminify_remove_dashicons'], 100);
963 843 }
964 844
965 845 /** Remove Version Query Strings from Scripts/Styles */
966 846 if (!empty($performance_data) && in_array('version_strings', $performance_data)) {
@@ -999,9 +879,9 @@
999 879 }
1000 880
1001 881 /** Browser Cache Expires & GZIP Compression */
1002 882 if (in_array('cache_gzip_compression', $performance_data)) {
1003 - register_activation_hook(__FILE__, [$this, 'htaccess']);
883 + register_activation_hook(__FILE__, [$this, 'jltwp_adminify_htaccess']);
1004 884 }
1005 885
1006 886
1007 887 // Remove Gravatar Query Strings
@@ -1027,9 +907,9 @@
1027 907
1028 908 /** Secure method for Defer Parsing of JavaScript moving ALL JS from Header to Footer **/
1029 909 public function defer_parsing_of_js($tag, $handle)
1030 910 {
1031 - $skip = apply_filters('pxlbsadminify_defer_skip', false, $tag, $handle);
911 + $skip = apply_filters('wp_adminify_defer_skip', false, $tag, $handle);
1032 912
1033 913 if ($skip) {
1034 914 return $tag;
1035 915 }