Plugin Directory

Changeset 3259459


Ignore:
Timestamp:
03/20/2025 10:56:13 PM (13 months ago)
Author:
bitspecter
Message:

Delete unnecessary functions

Location:
bitspecter-suite/trunk/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bitspecter-suite/trunk/includes/Branding/BitspecterSuiteBranding.php

    r3229325 r3259459  
    1010    public function __construct()
    1111    {
    12         // Hooks
    1312        $this->init_hooks();
    1413    }
  • bitspecter-suite/trunk/includes/Hardening/BitspecterSuiteHardening.php

    r3229325 r3259459  
    2424        add_action('init', [$this, 'removeUnnecessaryFeatures']);
    2525        add_action('init', [$this, 'removeUnnecessaryWpHeadItems']);
    26         add_action('init', [$this, 'disableRestApi']);
    2726        add_action('init', [$this, 'disableFileEditor']);
    2827        add_action('init', [$this, 'blockXmlRpcRequests']);
     
    3029        add_action('init', [$this, 'blockAuthorScan']);
    3130
     31        add_filter('rest_endpoints', [$this, 'disableUserEndpoints']);
     32
    3233        // Header and error handling
    3334        add_action('send_headers', [$this, 'addSecurityHeaders']);
    34         add_action('wp_login_failed', [$this, 'blockBruteForce']);
    3535        add_filter('login_errors', [$this, 'hideLoginErrors']);
    36 
    37         // REST API modifications
    38         add_filter('rest_endpoints', [$this, 'disableUserEndpoints']);
    39         add_filter('rest_authentication_errors', [$this, 'disableRestApiForGuests']);
    40 
    41         // File upload restrictions
    42         add_filter('upload_mimes', [$this, 'addCustomMimeTypes']);
    43         add_filter('upload_mimes', [$this, 'restrictFileUploads']);
    4436    }
    4537
     
    8981    }
    9082
    91     public function disableRestApi(): void
    92     {
    93         add_filter('rest_enabled', '__return_false');
    94         add_filter('rest_jsonp_enabled', '__return_false');
    95     }
    96 
    9783    public function disableUserEndpoints($endpoints): array
    9884    {
     
    10692            define('DISALLOW_FILE_EDIT', true);
    10793        }
    108     }
    109 
    110     public function restrictFileUploads($mimes): array
    111     {
    112         $restricted_mimes = ['exe' => 'application/x-msdownload', 'php' => 'text/x-php', 'js' => 'application/javascript', 'html' => 'text/html'];
    113         foreach ($restricted_mimes as $ext => $mime) {
    114             unset($mimes[$ext]);
    115         }
    116         return $mimes;
    117     }
    118 
    119     public function addCustomMimeTypes($mimes): array
    120     {
    121         $mimes['svg'] = 'image/svg+xml';
    122         return $mimes;
    12394    }
    12495
     
    147118    }
    148119
    149     public function blockBruteForce($username): void
    150     {
    151         $ip = isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) : '';
    152         $failedAttemptsKey = 'bitspecter_suite_login_failed_'.$ip;
    153 
    154         $failedAttempts = get_transient($failedAttemptsKey) ?: 0;
    155         $failedAttempts++;
    156 
    157         set_transient($failedAttemptsKey, $failedAttempts, 3600);
    158 
    159         if ($failedAttempts >= 5) {
    160             wp_die(esc_html__('You have been temporarily blocked due to too many login attempts. Try again later.', 'bitspecter-suite'));
    161         }
    162     }
    163120
    164121    public function enforceHttps(): void
     
    186143        }
    187144    }
    188 
    189     public function disableRestApiForGuests($access): mixed
    190     {
    191         if (! is_user_logged_in()) {
    192             return new \WP_Error('rest_forbidden', esc_html__('REST API access is restricted to logged-in users.', 'bitspecter-suite'), ['status' => 403]);
    193         }
    194         return $access;
    195     }
    196145}
  • bitspecter-suite/trunk/includes/Optimization/BitspecterSuiteOptimization.php

    r3229325 r3259459  
    2323    public function removeUnnecessaryFeatures(): void
    2424    {
    25         // Odebrání z WP hlavičky
    2625        remove_action('wp_head', 'wp_generator');
    2726        remove_action('wp_head', 'wp_resource_hints', 2);
     
    3130        remove_action('wp_head', 'wp_shortlink_wp_head');
    3231
    33         // Zakázání embeddingu
    3432        remove_action('wp_head', 'wp_oembed_add_discovery_links');
    3533        remove_action('wp_head', 'wp_oembed_add_host_js');
    3634        add_filter('embed_oembed_discover', '__return_false');
    3735
    38         // Odebrání RSS feedů, pokud nejsou potřeba
    3936        remove_action('wp_head', 'feed_links', 2);
    4037        remove_action('wp_head', 'feed_links_extra', 3);
    4138    }
    4239
    43     /**
    44      * Optimalizace načítání skriptů a stylů
    45      */
     40
    4641    public function optimizeScriptsAndStyles(): void
    4742    {
    48         // Zakázání block library CSS pro starší verze WordPressu
    4943        if (! is_admin()) {
    5044            wp_dequeue_style('wp-block-library');
    5145            wp_dequeue_style('wp-block-library-theme');
    52             wp_dequeue_style('wc-block-style'); // WooCommerce block CSS
     46            wp_dequeue_style('wc-block-style');
    5347        }
    5448    }
     
    5751     * Zakázání načítání emoji
    5852     */
    59     public function disableEmojis()
     53    public function disableEmojis(): void
    6054    {
    6155        remove_action('wp_head', 'print_emoji_detection_script', 7);
Note: See TracChangeset for help on using the changeset viewer.