add_actions(); $this->add_filters(); } /** * Retrieve the singleton instance of the class. * @return self The single instance of the class. */ public static function get_instance(): ?Plugin { if( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Handles the deactivation process of the plugin, which includes restoring files, * cleaning up markers, and optionally deleting backup files. * This method performs the following actions: * - Restores all files from backup. * - Cleans up any remaining markers left by the plugin. * - Deletes backup files if the operation is successful (optional step). * - Logs errors in case any process during deactivation fails. * @return void */ /** * Registers WordPress actions for the admin interface. * @return void */ private function add_actions(): void { add_action( 'admin_menu', [ $this, 'admin_menu' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); add_action( 'wp_ajax_adminease_save_settings', [ $this, 'ajax_save_settings' ] ); } /** * Adds custom filters for the plugin. * @return void */ private function add_filters(): void { add_filter( 'plugin_action_links_' . ADMINEASE_BASENAME, [ $this, 'action_links' ] ); add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 4 ); } /** * Adds the admin menu for the plugin. * @return void */ public function admin_menu(): void { add_menu_page( ADMINEASE_NAME, ADMINEASE_NAME, 'manage_options', // This already handles permissions ADMINEASE_SLUG, function() { // Additional permission check if needed if( !current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Insufficient permissions to access this page.', 'adminease' ) ); } include ADMINEASE_DIR . 'partials/dashboard.php'; }, plugins_url( 'assets/img/favicon.svg', ADMINEASE_FILE ), 2 ); } /** * Enqueue admin-specific styles and scripts. * Enqueues required CSS and JavaScript files for the WordPress admin area. * Additionally, localizes JavaScript variables for AJAX interactions and internationalization. * @return void */ public function admin_enqueue_scripts(): void { $screen = get_current_screen(); wp_enqueue_style( ADMINEASE_SLUG . '-global', plugins_url( 'assets/css/adminease-global.css', ADMINEASE_FILE ), [], ADMINEASE_VERSION ); $additional_css = apply_filters( 'adminease_global_inline_css', '' ); if( !empty( $additional_css ) ) { // WordPress's recommended approach for CSS sanitization $sanitized_css = wp_strip_all_tags( $additional_css ); // Additional security: Remove potentially dangerous CSS constructs $sanitized_css = preg_replace( '/javascript\s*:/i', '', $sanitized_css ); $sanitized_css = preg_replace( '/expression\s*\(/i', '', $sanitized_css ); $sanitized_css = preg_replace( '/@import\s+/i', '', $sanitized_css ); wp_add_inline_style( ADMINEASE_SLUG . '-global', $sanitized_css ); } if( $screen->id === 'toplevel_page_' . ADMINEASE_SLUG ) { wp_enqueue_style( ADMINEASE_SLUG, plugins_url( 'assets/css/adminease.css', ADMINEASE_FILE ), [], ADMINEASE_VERSION ); wp_enqueue_style( 'flexboxgrid', plugins_url( 'assets/css/flexboxgrid.min.css', ADMINEASE_FILE ), [], ADMINEASE_VERSION ); wp_enqueue_style( 'choices', plugins_url( 'assets/css/choices.min.css', ADMINEASE_FILE ), [], '11.1.0' ); wp_enqueue_script( 'choices', plugins_url( 'assets/js/choices.min.js', ADMINEASE_FILE ), [ 'jquery' ], '11.1.0', true ); wp_enqueue_script( ADMINEASE_SLUG, plugins_url( 'assets/js/adminease.js', ADMINEASE_FILE ), [ 'jquery', 'choices' ], ADMINEASE_VERSION, true ); wp_localize_script( ADMINEASE_SLUG, 'adminEaseAjaxObj', [ 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'isMobile' => wp_is_mobile(), 'security' => [ 'saveSettings' => wp_create_nonce( 'save_settings' ), ], 'i18n' => [ 'selectChoicesPlaceholder' => esc_html__( 'Select countries', 'adminease' ), 'selectChoicesLoadingText' => esc_html__( 'Loading...', 'adminease' ), 'selectChoicesNoResultsText' => esc_html__( 'No results found', 'adminease' ), 'selectChoicesNoChoicesText' => esc_html__( 'No choices to choose from', 'adminease' ), 'selectChoicesItemSelectText' => esc_html__( 'Press to select', 'adminease' ), 'selectChoicesUniqueItemText' => esc_html__( 'Only unique values can be added', 'adminease' ), 'selectChoicesCustomAddItemText' => esc_html__( 'Only values matching specific conditions can be added', 'adminease' ), 'svgUploadSuccess' => esc_html__( 'SVG uploaded and sanitized successfully!', 'adminease' ), 'svgUploadSuccessDescription' => esc_html__( 'Your SVG file has been professionally sanitized for security.', 'adminease' ), 'svgSanitizedLabel' => esc_html__( '✓ Sanitized', 'adminease' ), ], ] ); } } /** * Handles saving settings via AJAX. * This method verifies the security nonce and user permissions, processes the provided data, * sanitizes the settings, and updates the options in the database. Responds with a JSON success or error message. * @return void */ public function ajax_save_settings(): void { if( !isset( $_POST['security'] ) || !wp_verify_nonce( sanitize_key( wp_unslash( $_POST['security'] ) ), 'save_settings' ) ) { wp_send_json_error( new \WP_Error( 'security', esc_html__( 'Security check failed', 'adminease' ) ) ); } if( !current_user_can( 'manage_options' ) ) { wp_send_json_error( new \WP_Error( 'permissions', esc_html__( 'You do not have sufficient permissions to perform this action', 'adminease' ) ) ); } // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Data is validated elsewhere in the method parse_str( $_POST['data'], $parsed_data ); if( empty( $parsed_data['adminease'] ) ) { wp_send_json_error( new \WP_Error( 'data', esc_html__( 'No data was provided', 'adminease' ) ) ); } $sanitized_settings = $this->wp_recursive_sanitize( $parsed_data['adminease'] ); $sanitized_settings = $this->validate_settings( $sanitized_settings ); if( is_wp_error( $sanitized_settings ) ) { wp_send_json_error( $sanitized_settings ); } update_option( 'adminease_settings', $sanitized_settings ); self::$settings = $sanitized_settings; do_action( 'adminease_settings_saved', $sanitized_settings ); wp_send_json_success( [ 'message' => esc_html__( 'Settings saved successfully', 'adminease' ) ] ); } /** * Retrieves the settings or a specific section of settings. * * @param string $section Optional. The section of settings to retrieve. Defaults to an empty string. * * @return mixed Returns the entire settings array if no section is specified, or the specific section of settings if provided. If the section does not exist, an empty array is returned. */ public static function get_settings( string $section = '' ) { if( !empty( $section ) ) { return self::$settings[ $section ] ?? []; } return self::$settings; } /** * Recursively sanitize all types of values. * * @param mixed $value The value to sanitize. * * @return mixed The sanitized value. */ private function wp_recursive_sanitize( $value ) { if( is_array( $value ) ) { foreach( $value as $key => $item ) { $value[ $key ] = $this->wp_recursive_sanitize( $item ); } return $value; } else if( is_bool( $value ) ) { return (bool) $value; } else if( is_int( $value ) ) { return intval( $value ); } else if( is_float( $value ) ) { return floatval( $value ); } else if( is_string( $value ) ) { return sanitize_text_field( $value ); } else { return $value; } } /** * Validates and ensures the settings provided are consistent and adhere to predefined rules. * * @param array $sanitized_settings An array of sanitized settings, including memory limit configurations. * * @return array|\WP_Error Returns the sanitized settings if validation passes. Returns a WP_Error object if there is a validation error. */ public function validate_settings( array $sanitized_settings ) { foreach( $sanitized_settings as $key => $fields ) { switch( $key ) { case 'performance': { $memory_limit = $this->parse_memory_limit( $fields['wp_memory_limit'] ); $max_memory_limit = $this->parse_memory_limit( $fields['wp_max_memory_limit'] ); if( $max_memory_limit < $memory_limit && 0 !== $max_memory_limit ) { return new \WP_Error( 'wp_max_memory_limit', esc_html__( 'Maximum memory limit cannot be smaller than memory limit', 'adminease' ) ); } if( 'other' === $fields['number_posts_revisions'] && '' === $fields['number_posts_revisions_other'] ) { return new \WP_Error( 'number_posts_revisions_other', esc_html__( 'Number of revisions cannot be empty', 'adminease' ) ); } break; } case 'users': { if( !empty( $sanitized_settings['users']['force_strong_passwords'] ) && ( empty( $sanitized_settings['users']['password_minimum_length'] ) || $sanitized_settings['users']['password_minimum_length'] < 8 ) ) { return new \WP_Error( 'password_minimum_length', esc_html__( 'Password minimum length must be larger than 8 characters.', 'adminease' ) ); } if( !empty( $sanitized_settings['users']['force_strong_passwords'] ) && ( empty( $sanitized_settings['users']['password_maximum_length'] ) || $sanitized_settings['users']['password_maximum_length'] > 64 ) ) { return new \WP_Error( 'password_minimum_length', esc_html__( 'Password maximum length must be smaller than 64 characters.', 'adminease' ) ); } if( !empty( $sanitized_settings['users']['auto_logout_user'] ) && empty( $sanitized_settings['users']['auto_logout_user_time'] ) ) { return new \WP_Error( 'auto_logout_user_time', esc_html__( 'Auto-logout user after X seconds cannot be empty', 'adminease' ) ); } break; } } } return $sanitized_settings; } /** * Parses a memory limit value and converts it into megabytes. * * @param string $value The memory limit value, potentially including a unit (e.g., 'M', 'G'). * * @return int The memory value converted to megabytes. */ private function parse_memory_limit( string $value ): int { $value = trim( $value ); $unit = strtoupper( substr( $value, -1 ) ); $number = (int) $value; switch( $unit ) { case 'G': return $number * 1024; // Convert to MB default: return $number; // Assume MB if no unit } } /** * Add a settings link to plugin action links. * * @param array $links Existing plugin action links. * * @return array Modified plugin action links. */ public function action_links( $links ): array { $link = '' . esc_html__( 'Settings', 'adminease' ) . ''; return array_merge( [ $link ], $links ); } /** * Retrieves an array of plugin fields based on the provided settings key. * This method defines various configurable fields for managing * updates, security, and other aspects of the plugin. Each field contains * information about its type, ID, name, value, and other relevant attributes. * * @param string $key Optional. The specific key within the settings array to retrieve. * Defaults to an empty string, which returns all fields. * * @return array An array of fields grouped into categories, * where each category contains its title and a list of field definitions. */ public static function get_plugin_fields( string $key = '' ): array { $settings = self::get_settings(); $block_specific_countries_description = Features\BlockSpecificCountries::$is_blocking_countries_enabled ? wp_kses( sprintf( /* translators: %1$s: Line break, %2$s: Link to upgrade to Pro version */ __( 'Select countries to block.%1$s Would you like to allow specific IP addresses and allow bots like GoogleBot? %2$s', 'adminease' ), '
', '' . __( 'Upgrade to Pro', 'adminease' ) . '' ), [ 'a' => [ 'href' => [], 'target' => [], ], 'br' => [], ] ) : __( 'Unfortunately your server does not support this feature.', 'adminease' ); $fields = [ 'updates-and-maintenance' => [ 'title' => __( 'Updates and Maintenance', 'adminease' ), 'fields' => [ [ 'type' => 'switch', 'id' => 'disable-auto-update-core', 'name' => 'adminease[updates-and-maintenance][disable_auto_update_core]', 'value' => $settings['updates-and-maintenance']['disable_auto_update_core'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto update core', 'adminease' ), 'description' => __( 'WordPress has a built-in feature that can automatically update itself to the latest version. This helps keep your website secure and up to date without needing to do anything manually. However, some people prefer to disable automatic updates so they can test new versions first or avoid unexpected changes. You can easily turn this option on or off depending on how much control you want over updates.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-auto-update-plugin', 'name' => 'adminease[updates-and-maintenance][disable_auto_update_plugin]', 'value' => $settings['updates-and-maintenance']['disable_auto_update_plugin'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto update plugins', 'adminease' ), 'description' => __( 'WordPress also lets you automatically update your plugins to keep your site secure and running smoothly. This means you don’t have to manually check for updates—WordPress will do it for you. It’s a great way to save time and protect your site from security risks. However, some users prefer to disable auto-updates for plugins so they can test each update first, especially on websites with custom setups or many plugins. You can turn plugin auto-updates on or off individually from your WordPress dashboard.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-auto-update-theme', 'name' => 'adminease[updates-and-maintenance][disable_auto_update_theme]', 'value' => $settings['updates-and-maintenance']['disable_auto_update_theme'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto update themes', 'adminease' ), 'description' => __( "WordPress gives you the option to automatically update your themes, just like plugins. This helps ensure your site stays secure and compatible with the latest features. When auto-updates are enabled for a theme, WordPress will install new versions as they’re released, without requiring manual action. However, if you've made custom changes to your theme files, automatic updates could overwrite them. That’s why some users prefer to turn off auto-updates for themes and update them manually after testing. You can easily enable or disable theme auto-updates from the Appearance > Themes section in your dashboard.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-auto-update-translation', 'name' => 'adminease[updates-and-maintenance][disable_auto_update_translation]', 'value' => $settings['updates-and-maintenance']['disable_auto_update_translation'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto update translations', 'adminease' ), 'description' => __( 'WordPress also supports automatic updates for translations, which include language files for the WordPress core, themes, and plugins. These updates help keep your site’s content accurate and fully translated in your chosen language. Translation files are usually small and safe to update, so WordPress enables these auto-updates by default. Most users leave this feature on, as it improves the user experience without affecting the site’s design or functionality. If needed, advanced users can disable translation auto-updates through code or a plugin, but in most cases, it’s best to keep them enabled.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-auto-core-update-send-email', 'name' => 'adminease[updates-and-maintenance][disable_auto_core_update_send_email]', 'value' => $settings['updates-and-maintenance']['disable_auto_core_update_send_email'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto core update send email', 'adminease' ), 'description' => __( "When WordPress automatically updates its core software, it sends an email notification to the site administrator. This email lets you know that the update was successful and includes details about what was updated. It’s a helpful way to stay informed about changes to your site, especially if you're not logging in regularly. While you can disable these emails with custom code, they’re useful for keeping track of important updates and ensuring everything is working as expected.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-auto-theme-update-send-email', 'name' => 'adminease[updates-and-maintenance][disable_auto_theme_update_send_email]', 'value' => $settings['updates-and-maintenance']['disable_auto_theme_update_send_email'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto theme update send email', 'adminease' ), 'description' => __( "When a theme is automatically updated in WordPress, the site administrator receives an email notification with details about the update. This helps you stay informed about changes to your theme, especially if you’re using auto-updates. The email includes the theme name and version, so you know exactly what was updated. It’s a useful feature for tracking updates and making sure your site looks and functions as expected after the change.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-auto-plugin-update-send-email', 'name' => 'adminease[updates-and-maintenance][disable_auto_plugin_update_send_email]', 'value' => $settings['updates-and-maintenance']['disable_auto_plugin_update_send_email'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable auto plugin update send email', 'adminease' ), 'description' => __( "When a plugin is automatically updated in WordPress, the site administrator gets an email notification with information about the update. This email lists which plugin was updated and its new version, helping you keep track of changes to your site. These notifications are especially useful for monitoring plugin activity, ensuring everything still works correctly, and spotting potential issues early.", 'adminease' ), ], ], ], 'security' => [ 'title' => __( 'Security', 'adminease' ), 'fields' => [ [ 'type' => 'switch', 'id' => 'disable-file-edit', 'name' => 'adminease[security][disable_file_edit]', 'value' => $settings['security']['disable_file_edit'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable file edit', 'adminease' ), 'description' => __( "WordPress includes a built-in code editor that lets administrators edit theme and plugin files directly from the admin panel. While convenient, this feature can be risky—especially if someone gains access to your dashboard or makes accidental changes. Disabling file editing helps protect your site’s code from unwanted modifications. It’s a common security best practice and can be done easily by adding a single line of code to your wp-config.php file.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-xmlrpc', 'name' => 'adminease[security][disable_xmlrpc]', 'value' => $settings['security']['disable_xmlrpc'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable XML-RPC', 'adminease' ), 'description' => __( "

XML-RPC is a feature in WordPress that allows external apps and services to connect to your site—for example, to publish posts remotely or manage content via mobile apps. However, it's also a common target for brute force and DDoS attacks. If you're not using any tools that require XML-RPC, it's a good idea to disable it to improve your site's security.

If you need XML-RPC access from specific locations, you can add their IP addresses. One IP address per line, supporting both IPv4 and IPv6 formats.

Examples:
IPv4: 192.168.1.1
IPv6: 2001:db8:85a3::8a2e:370:7334

Important: When XML-RPC is disabled, only requests from these IPs will be allowed, while all other requests will be denied. Leave empty to block all access to xmlrpc.php.

", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-rest-api', 'name' => 'adminease[security][disable_rest_api]', 'value' => $settings['security']['disable_rest_api'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable REST API', 'adminease' ), 'description' => __( "The WordPress REST API allows external applications and services to interact with your website’s data, such as posts, users, and settings. While it’s useful for developers building custom features or apps, it can also expose sensitive information—especially on sites that don’t need it. Disabling the REST API helps reduce potential security risks and protect user privacy. You can disable it completely or restrict access to logged-in users using code or a security plugin.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-embeds', 'name' => 'adminease[security][disable_embeds]', 'value' => $settings['security']['disable_embeds'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable embeds', 'adminease' ), 'description' => __( "WordPress automatically converts URLs from sites like YouTube or Twitter into embedded content, such as videos or tweets. This feature, called embeds, can make pages heavier and sometimes expose your site to unnecessary external requests. Disabling embeds helps improve performance, reduce privacy concerns, and prevent other sites from embedding your content without permission. You can disable embeds using a few lines of code or a lightweight plugin.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'hide-wordpress-version', 'name' => 'adminease[security][hide_wordpress_version]', 'value' => $settings['security']['hide_wordpress_version'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Hide WordPress version', 'adminease' ), 'description' => __( "By default, WordPress includes its version number in your site's source code, RSS feeds, and sometimes in script URLs. While this seems harmless, it can give attackers clues about potential vulnerabilities if you're running an outdated version. Hiding the WordPress version helps improve your site's security by making it less obvious which version you're using. This can be done with a simple code snippet added to your theme or a security plugin.", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'block-access-sensitive-files', 'name' => 'adminease[security][block_access_sensitive_files]', 'value' => $settings['security']['block_access_sensitive_files'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Block access to sensitive files', 'adminease' ), 'description' => __( 'Block access to configuration files, development files, backups, logs, and version control files', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'cors-header', 'name' => 'adminease[security][cors_header]', 'value' => $settings['security']['cors_header'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'CORS Header', 'adminease' ), 'description' => __( "Allow Cross-Origin Resource Sharing. Add the 'Access-Control-Allow-Origin:' header to responses", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-pingbacks', 'name' => 'adminease[security][disable_pingbacks]', 'value' => $settings['security']['disable_pingbacks'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable pingbacks', 'adminease' ), 'description' => __( 'Pingbacks allow other WordPress websites to automatically leave comments under your posts when these websites link to these posts. Pingbacks can be abused to use your website for DDoS attacks on other sites. This security option turns off XML-RPC pingbacks for your whole website and also disables pingbacks for previously created posts with pingbacks enabled.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'block-author-scans', 'name' => 'adminease[security][block_author_scans]', 'value' => $settings['security']['block_author_scans'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Block author scans', 'adminease' ), 'description' => __( 'Author scans are looking to find usernames of registered users (especially WordPress admin) and brute-force attack the login page of your website to gain access. This security option prevents such scans from exposing these usernames. Note: depending on the permalink configuration on your website this option might prevent visitors from accessing pages that list all articles written by a particular author.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'block-directory-browsing', 'name' => 'adminease[security][block_directory_browsing]', 'value' => $settings['security']['block_directory_browsing'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Block directory browsing', 'adminease' ), 'description' => __( 'If directory browsing is turned on, hackers can obtain various information about your website that can potentially compromise its security. Directory browsing is usually turned off by default, but if it is turned on, this security option can block it.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-script-concatenation', 'name' => 'adminease[security][disable_script_concatenation]', 'value' => $settings['security']['disable_script_concatenation'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable scripts concatenation in WordPress admin panel', 'adminease' ), 'description' => __( "This security option turns off concatenation of scripts running in the WordPress admin panel, preventing your website from being affected by certain DoS attacks. Turning off concatenation of scripts might slightly affect the performance of WordPress admin panel, but it should not affect visitors' experience on your WordPress website.", 'adminease' ), ], [ 'type' => 'select', 'id' => 'block-specific-countries', 'name' => 'adminease[security][block_specific_countries][]', 'value' => $settings['security']['block_specific_countries'] ?? '', 'options' => self::get_countries_iso(), 'label_class' => 'adminease-label', 'input_class' => 'form-control adminease-choices', 'label' => __( 'Block specific countries', 'adminease' ), 'field_description' => $block_specific_countries_description, 'attributes' => [ 'multiple' => 'multiple', 'data-allow_clear' => true, 'data-allow_select_all' => true, 'disabled' => !Features\BlockSpecificCountries::$is_blocking_countries_enabled, ], ], ], ], 'performance' => [ 'title' => __( 'Performance', 'adminease' ), 'fields' => [ [ 'type' => 'select', 'id' => 'empty-trash-days', 'name' => 'adminease[performance][empty_trash_days]', 'value' => $settings['performance']['empty_trash_days'] ?? '', 'options' => [ '' => __( 'Select', 'adminease' ), '0' => __( 'Disable Trash (Delete Permanently)', 'adminease' ), '1' => __( '1 Day', 'adminease' ), '7' => __( '7 Days', 'adminease' ), '14' => __( '14 Days', 'adminease' ), '30' => __( '30 Days (Default)', 'adminease' ), '60' => __( '60 Days', 'adminease' ), '90' => __( '90 Days', 'adminease' ), '180' => __( '180 Days', 'adminease' ), '365' => __( '365 Days', 'adminease' ), ], 'input_class' => 'form-control adminease-choices', 'label_class' => 'adminease-label', 'label' => __( 'Empty Trash Days', 'adminease' ), 'description' => __( 'Controls how many days WordPress keeps deleted content in trash before permanently deleting it. Set to "Disable Trash" to permanently delete items immediately without using trash.', 'adminease' ), 'field_description' => __( 'By default, WordPress keeps deleted posts, pages, and comments in the trash for 30 days. After that, they are permanently deleted.', 'adminease' ), 'placeholder' => __( 'Select', 'adminease' ), 'attributes' => [ 'data-allow_clear' => true, ], ], [ 'type' => 'select', 'id' => 'wp-memory-limit', 'name' => 'adminease[performance][wp_memory_limit]', 'value' => $settings['performance']['wp_memory_limit'] ?? '', 'options' => [ '' => __( 'Select', 'adminease' ), '40M' => '40M', '64M' => '64M', '128M' => '128M', '256M' => '256M', '512M' => '512M', '1G' => '1G', '2G' => '2G', '4G' => '4G', '8G' => '8G', '16G' => '16G', '32G' => '32G', ], 'input_class' => 'form-control adminease-choices', 'label_class' => 'adminease-label', 'label' => __( 'WP Memory Limit', 'adminease' ), 'description' => __( 'The WP Memory Limit is the maximum amount of memory that WordPress is allowed to use for running themes, plugins, and core functions. If your site runs out of memory, you may see errors or experience performance issues. Increasing the memory limit can help improve stability—especially on sites with advanced features or many plugins.', 'adminease' ), 'field_description' => __( 'The default memory limit in WordPress is initially 32MB, but WordPress attempts to increase this to 40MB for single sites and 64MB for multisite installations.
WordPress defaults to a maximum memory limit of 40MB for a single site and 64MB for a WordPress Multisite network.', 'adminease' ), 'placeholder' => __( 'Select', 'adminease' ), 'attributes' => [ 'data-allow_clear' => true, ], ], [ 'type' => 'select', 'id' => 'wp-max-memory-limit', 'name' => 'adminease[performance][wp_max_memory_limit]', 'value' => $settings['performance']['wp_max_memory_limit'] ?? '', 'options' => [ '' => __( 'Select', 'adminease' ), '40M' => '40M', '64M' => '64M', '128M' => '128M', '256M' => '256M', '512M' => '512M', '1G' => '1G', '2G' => '2G', '4G' => '4G', '8G' => '8G', '16G' => '16G', '32G' => '32G', ], 'label_class' => 'adminease-label', 'input_class' => 'form-control adminease-choices', 'label' => __( 'WP Max Memory Limit', 'adminease' ), 'description' => __( 'The WP Max Memory Limit is the highest amount of memory WordPress can use when performing administrative tasks, such as updates, backups, or running large imports. It’s usually set higher than the regular memory limit to ensure smooth operation in the admin area. If this limit is too low, some tasks may fail or time out.', 'adminease' ), 'field_description' => __( 'WordPress defaults to a maximum memory limit of 40MB for a single site and 64MB for a WordPress Multisite network.', 'adminease' ), 'placeholder' => __( 'Select', 'adminease' ), 'attributes' => [ 'data-allow_clear' => true, ], ], [ 'type' => 'number', 'id' => 'max-execution-time', 'name' => 'adminease[performance][max_execution_time]', 'value' => $settings['performance']['max_execution_time'] ?? '', 'label_class' => 'adminease-label', 'input_class' => 'form-control', 'label' => __( 'Max Execution Time', 'adminease' ), 'description' => __( 'The Max Execution Time is like a stopwatch for your server. It sets the maximum time a PHP script is allowed to run before the server cuts it off. If a process—like importing a large file or running a heavy plugin—takes too long, it can get interrupted, causing errors or incomplete actions. By default, many servers set this to 30 seconds, which might not be enough for complex tasks. If you’re seeing timeout errors or white screens, it’s a sign this limit needs to be increased.', 'adminease' ), 'attributes' => [ 'min' => -1, 'max' => 3600, 'step' => 1, ], ], [ 'type' => 'select', 'id' => 'number-posts-revisions', 'name' => 'adminease[performance][number_posts_revisions]', 'value' => $settings['performance']['number_posts_revisions'] ?? '', 'options' => [ '' => __( 'Select', 'adminease' ), 'keep' => __( 'Keep every revision', 'adminease' ), 'dont-keep' => __( "Don't keep any revisions", 'adminease' ), 'other' => __( 'Insert number', 'adminease' ), ], 'label_class' => 'adminease-label', 'input_class' => 'form-control adminease-choices', 'label' => __( 'Post revisions', 'adminease' ), 'description' => __( '

Post revisions in WordPress are automatically saved versions of your posts and pages, created every time you update or save content. This feature lets you undo changes, compare versions, and restore earlier draftsif needed, providing a safety net against mistakes or accidental deletions.

If you change the number of allowed revisions (for example, by setting a limit in wp-config.php)this only affects new revisions going forward. Existing posts will still keep all their current revisions unless you manually delete the extra ones. Limiting revisions does not automatically remove old ones; you must clean them up separately if you want to reduce database size.

', 'adminease' ), 'placeholder' => __( 'Select', 'adminease' ), 'attributes' => [ 'data-allow_clear' => true, ], 'child_fields' => [ [ 'type' => 'number', 'id' => 'number-posts-revisions-other', 'name' => 'adminease[performance][number_posts_revisions_other]', 'value' => $settings['performance']['number_posts_revisions_other'] ?? '', 'label_class' => 'adminease-label', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child m-t-10', 'label' => __( 'Number of post revisions', 'adminease' ), 'field_description' => __( 'Any number greater than 0 (for example, 3): WordPress will only keep that many old versions for each post. (For example, if you set it to 3, only your 3 most recent edits are saved. Older versions are deleted automatically when you make new edits.)', 'adminease' ), 'attributes' => [ 'min' => '-1', 'step' => 1, ], ], ], ], [ 'type' => 'number', 'id' => 'autosave-interval', 'name' => 'adminease[performance][autosave_interval]', 'value' => $settings['performance']['autosave_interval'] ?? '', 'label_class' => 'adminease-label', 'input_class' => 'form-control', 'label' => __( 'Autosave Interval', 'adminease' ), 'description' => __( "The Autosave Interval is how often WordPress automatically saves your posts and pages while you're editing them. This feature helps prevent data loss if your browser crashes or you accidentally close the tab. By default, WordPress autosaves every 60 seconds (1 minute). You can change this interval to save more frequently or less often, depending on your needs.", 'adminease' ), 'field_description' => __( 'By default, WordPress autosaves every 60 seconds.', 'adminease' ), 'attributes' => [ 'min' => 5, 'max' => 3600, 'step' => 5, ], ], [ 'type' => 'switch', 'id' => 'disable-wp-cron', 'name' => 'adminease[performance][disable_wp_cron]', 'value' => $settings['performance']['disable_wp_cron'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable WP Cron', 'adminease' ), 'description' => __( "The WordPress Cron (WP-Cron) system is what handles scheduled tasks like publishing scheduled posts, checking for updates, or sending emails. By default, WP-Cron runs every time someone visits your site—which can lead to performance issues on busy or low-traffic websites. Disabling WP-Cron allows you to take control and replace it with a real server-side cron job that runs at set intervals. This improves reliability and efficiency, especially on larger or more dynamic sites.", 'adminease' ), ], ], ], 'notifications-and-emails' => [ 'title' => __( 'Notifications & Emails', 'adminease' ), 'fields' => [ [ 'type' => 'switch', 'id' => 'disable-new-user-admin-notification-email', 'name' => 'adminease[notifications-and-emails][disable_new_user_admin_notification_email]', 'value' => $settings['notifications-and-emails']['disable_new_user_admin_notification_email'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable new user admin notification email', 'adminease' ), 'description' => __( 'The New User Admin Notification Email is a message sent to the site administrator whenever a new user registers on the website. It includes the new user’s username and email address, helping you keep track of user activity and detect unwanted registrations. While useful, some site owners choose to disable this notification—especially on busy sites or when using custom user management tools—to reduce inbox clutter.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-user-password-change-admin-notification-email', 'name' => 'adminease[notifications-and-emails][disable_user_password_change_admin_notification_email]', 'value' => $settings['notifications-and-emails']['disable_user_password_change_admin_notification_email'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable user password change admin notification email', 'adminease' ), 'description' => __( 'The User Password Change Admin Notification Email is sent to the site administrator when any user changes their password. This alert helps you monitor account activity and quickly spot suspicious behavior—like unexpected password changes. While it adds a layer of security awareness, some admins may choose to disable it to avoid unnecessary notifications on high-traffic sites.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'disable-comment-admin-notification-email', 'name' => 'adminease[notifications-and-emails][disable_comment_admin_notification_email]', 'value' => $settings['notifications-and-emails']['disable_comment_admin_notification_email'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable comment admin notification email', 'adminease' ), 'description' => __( 'The Comment Admin Notification Email is sent to the site administrator whenever a new comment is posted on the site. It includes the comment content, author details, and a direct link to moderate or reply. This feature helps you stay on top of user engagement and quickly catch spam or inappropriate comments.', 'adminease' ), ], ], ], 'users' => [ 'title' => __( 'Users', 'adminease' ), 'fields' => [ [ 'type' => 'switch', 'id' => 'disable-user-registration', 'name' => 'adminease[users][disable_user_registration]', 'value' => $settings['users']['disable_user_registration'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable user registration', 'adminease' ), 'description' => __( 'Disabling user registration in WordPress using PHP gives you stronger control over who can create accounts on your site. This approach removes access to the default WordPress registration form (wp-login.php?action=register) and blocks programmatic registration attempts. If any third-party plugin tries to register users via WordPress core functions, it will trigger an error message instead of creating an account. This method is ideal for preventing spam, hardening site security, and fully locking down user sign-ups at the code level.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'force-strong-passwords', 'name' => 'adminease[users][force_strong_passwords]', 'value' => $settings['users']['force_strong_passwords'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Force strong passwords', 'adminease' ), 'description' => __( '

Enforcing the use of strong passwords in WordPress helps protect your site from brute force attacks and unauthorized access. By requiring users to create passwords with a mix of uppercase and lowercase letters, numbers, and special characters, you ensure better account security for both administrators and regular users.

When enforced via PHP, this rule applies across the entire site—during registration, password resets, and profile updates. Weak passwords are rejected, and users are prompted to choose a stronger one. This level of control helps standardize security practices and ensures even third-party plugins follow your password policy.

', 'adminease' ), 'child_fields' => [ [ 'type' => 'number', 'id' => 'minimum-length', 'name' => 'adminease[users][password_minimum_length]', 'value' => $settings['users']['password_minimum_length'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'Minimum length', 'adminease' ), 'field_description' => __( 'e.g., 8 or more characters', 'adminease' ), 'attributes' => [ 'min' => 8, 'max' => 64, 'step' => 1, ], ], [ 'type' => 'number', 'id' => 'maximum-length', 'name' => 'adminease[users][password_maximum_length]', 'value' => $settings['users']['password_maximum_length'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'Maximum length', 'adminease' ), 'field_description' => __( 'e.g., 8 or more characters', 'adminease' ), 'attributes' => [ 'min' => 8, 'max' => 64, 'step' => 1, ], ], [ 'type' => 'switch', 'id' => 'minimum-uppercase-letters', 'name' => 'adminease[users][password_minimum_uppercase_letters]', 'value' => $settings['users']['password_minimum_uppercase_letters'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'At least one uppercase letter', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'minimum-lowercase-letters', 'name' => 'adminease[users][password_minimum_lowercase_letters]', 'value' => $settings['users']['password_minimum_lowercase_letters'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'At least one lowercase letter', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'minimum-numbers', 'name' => 'adminease[users][password_minimum_numbers]', 'value' => $settings['users']['password_minimum_numbers'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'At least one number', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'minimum-special-characters', 'name' => 'adminease[users][password_minimum_special_characters]', 'value' => $settings['users']['password_minimum_special_characters'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'At least one special character', 'adminease' ), ], ], ], [ 'type' => 'switch', 'id' => 'auto-logout-user', 'name' => 'adminease[users][auto_logout_user]', 'value' => $settings['users']['auto_logout_user'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Auto-logout user', 'adminease' ), 'description' => __( "The Login Session Timeout setting controls how long a user stays logged in before WordPress automatically logs them out. For example, if it’s set to 30 minutes, a user will need to log in again after that time—even if they’re still active. This helps improve your site's security by limiting how long login sessions remain open. You can choose a shorter timeout for better protection or a longer one for convenience.", 'adminease' ), 'child_fields' => [ [ 'type' => 'number', 'id' => 'auto-logout-user-time', 'name' => 'adminease[users][auto_logout_user_time]', 'value' => $settings['users']['auto_logout_user_time'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'Auto-logout user after X seconds', 'adminease' ), 'field_description' => __( 'Set login session limit in seconds.', 'adminease' ), ], ], ], ], ], 'debug' => [ 'title' => __( 'Debug', 'adminease' ), 'fields' => [ [ 'type' => 'switch', 'id' => 'wp-debug', 'name' => 'adminease[debug][wp_debug]', 'value' => $settings['debug']['wp_debug'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'WP Debug', 'adminease' ), 'description' => __( 'The WP_DEBUG setting in WordPress is used to turn on debugging mode. When enabled, it displays PHP errors, warnings, and notices directly on your site—helping developers and site owners identify problems during development or troubleshooting. It’s especially useful when plugins or themes aren’t working as expected. However, it should never be left on in a live site as it can expose sensitive information to visitors.', 'adminease' ), 'child_fields' => [ [ 'type' => 'switch', 'id' => 'wp-debug-log', 'name' => 'adminease[debug][wp_debug_log]', 'value' => $settings['debug']['wp_debug_log'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'WP Debug Log', 'adminease' ), 'description' => __( 'Enable WP Debug Log.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'wp-debug-display', 'name' => 'adminease[debug][wp_debug_display]', 'value' => $settings['debug']['wp_debug_display'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'wrapper_class' => 'form-group-child', 'label' => __( 'WP Debug Display', 'adminease' ), 'description' => __( 'Enable WP Debug Display.', 'adminease' ), ], ], ], ], ], 'media' => [ 'title' => __( 'Media', 'adminease' ), 'fields' => [ [ 'type' => 'number', 'id' => 'upload-max-file-size', 'name' => 'adminease[media][upload_max_file_size]', 'value' => $settings['media']['upload_max_file_size'] ?? '', 'label_class' => 'adminease-label', 'input_class' => 'form-control', 'label' => __( 'Upload Max File Size', 'adminease' ), 'description' => __( 'The Upload Max File Size setting in WordPress controls the maximum size of files that can be uploaded to your site. This limit is set by your server configuration, but you can adjust it in WordPress to allow larger files like high-resolution images, videos, or documents. If you try to upload a file larger than this limit, WordPress will display an error message and prevent the upload.', 'adminease' ), 'field_description' => __( 'Set the maximum file size allowed for uploads in megabytes (MB). Enter a numeric value only (e.g., "64" for 64MB, "128" for 128MB). Leave empty to use server default. This affects the upload_max_filesize PHP setting.', 'adminease' ), 'attributes' => [ 'placeholder' => __( 'e.g., 64', 'adminease' ), 'min' => '1', 'max' => '2048', 'step' => '1', 'pattern' => '[0-9]+', 'inputmode' => 'numeric', ], ], [ 'type' => 'switch', 'id' => 'allow-svg-upload', 'name' => 'adminease[media][allow_svg_upload]', 'value' => $settings['media']['allow_svg_upload'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Allow SVG Upload', 'adminease' ), 'description' => __( 'Enable SVG file uploads to the WordPress media library with built-in security validation. SVG files are automatically scanned for malicious content including JavaScript, dangerous elements, and external references.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'media-library-infinite-scrolling', 'name' => 'adminease[media][media_library_infinite_scrolling]', 'value' => $settings['media']['media_library_infinite_scrolling'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Media Library Infinite Scrolling', 'adminease' ), 'description' => __( 'The Media Library Infinite Scrolling feature in WordPress allows you to browse through your media files without having to click through multiple pages. Instead of traditional pagination, it automatically loads more items as you scroll down, providing a smoother and more efficient way to manage large media libraries.', 'adminease' ), ], ], ], 'misc' => [ 'title' => __( 'Misc', 'adminease' ), 'fields' => [ [ 'type' => 'switch', 'id' => 'drag-and-drop-ordering', 'name' => 'adminease[misc][drag_and_drop_ordering]', 'value' => $settings['misc']['drag_and_drop_ordering'] ?? '', 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Drag and drop ordering', 'adminease' ), 'description' => __( "Rearrange items on your site exactly how you want—just click, drag, and drop! Instantly organize posts or taxonomies with a simple, intuitive interface. No coding, no hassle—just smooth, visual control over your site’s order. Make your WordPress experience truly yours!", 'adminease' ), ], [ 'type' => 'switch', 'id' => 'hide-admin-bar', 'name' => 'adminease[misc][hide_admin_bar]', 'value' => $settings['misc']['hide_admin_bar'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Hide Admin Bar', 'adminease' ), 'description' => __( 'Hide the WordPress admin bar for specific user roles. This helps create a cleaner frontend experience for non-administrative users while maintaining admin functionality where needed.', 'adminease' ), 'child_fields' => [ [ 'type' => 'select', 'id' => 'hide-admin-bar-user-roles', 'name' => 'adminease[misc][hide_admin_bar_user_roles][]', 'value' => $settings['misc']['hide_admin_bar_user_roles'] ?? [], 'options' => Plugin::get_user_roles_options(), 'label_class' => 'adminease-label', 'input_class' => 'form-control adminease-choices', 'wrapper_class' => 'form-group-child', 'label' => __( 'User roles to hide admin bar for', 'adminease' ), 'field_description' => __( 'Select which user roles should have the admin bar hidden. Leave empty to hide for all non-admin users.', 'adminease' ), 'attributes' => [ 'multiple' => 'multiple', 'data-allow_clear' => true, 'data-allow_select_all' => true, ], ], ], ], [ 'type' => 'switch', 'id' => 'disable-gutenberg', 'name' => 'adminease[misc][disable_gutenberg]', 'value' => $settings['misc']['disable_gutenberg'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Disable Gutenberg', 'adminease' ), 'description' => __( 'Disable the Gutenberg block editor and revert to the classic editor for all post types. This is useful for users who prefer the classic editing experience or have compatibility issues with Gutenberg.', 'adminease' ), ], [ 'type' => 'switch', 'id' => 'taxonomy-meta-box', 'name' => 'adminease[misc][taxonomy_meta_box]', 'value' => $settings['misc']['taxonomy_meta_box'] ?? false, 'label_class' => 'adminease-switch', 'input_class' => 'form-control', 'label' => __( 'Enable Lazy Loading for Taxonomy Terms', 'adminease' ), 'description' => __( 'Improve performance on the post edit screen by loading taxonomy terms (like categories or tags) dynamically via AJAX. This is especially useful when you have a large number of terms, as it prevents WordPress from loading them all at once, reducing page load time and memory usage. Enable this option to activate a searchable, paginated dropdown that loads terms on demand.', 'adminease' ), 'field_description' => __( 'Will work when Gutenberg is disabled.', 'adminease' ), ], ], ], ]; $fields = apply_filters( 'adminease_settings_fields', $fields ); return $fields[ $key ] ?? $fields; } /** * Returns a list of countries with their ISO 3166-1 alpha-2 codes as keys and their corresponding country names as values. * @return array An associative array where the keys are ISO 3166-1 alpha-2 country codes and the values are the respective country names. */ public static function get_countries_iso(): array { return [ 'AF' => 'Afghanistan', 'AX' => 'Aland Islands', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua and Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', 'BO' => 'Bolivia', 'BQ' => 'Bonaire, Sint Eustatius and Saba', 'BA' => 'Bosnia and Herzegovina', 'BW' => 'Botswana', 'BV' => 'Bouvet Island', 'BR' => 'Brazil', 'IO' => 'British Indian Ocean Territory', 'BN' => 'Brunei Darussalam', 'BG' => 'Bulgaria', 'BF' => 'Burkina Faso', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CM' => 'Cameroon', 'CA' => 'Canada', 'CV' => 'Cape Verde', 'KY' => 'Cayman Islands', 'CF' => 'Central African Republic', 'TD' => 'Chad', 'CL' => 'Chile', 'CN' => 'China', 'CX' => 'Christmas Island', 'CC' => 'Cocos (Keeling) Islands', 'CO' => 'Colombia', 'KM' => 'Comoros', 'CG' => 'Congo', 'CD' => 'Congo, Democratic Republic of the', 'CK' => 'Cook Islands', 'CR' => 'Costa Rica', 'CI' => 'Côte d\'Ivoire', 'HR' => 'Croatia', 'CU' => 'Cuba', 'CW' => 'Curaçao', 'CY' => 'Cyprus', 'CZ' => 'Czechia', 'DK' => 'Denmark', 'DJ' => 'Djibouti', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'EC' => 'Ecuador', 'EG' => 'Egypt', 'SV' => 'El Salvador', 'GQ' => 'Equatorial Guinea', 'ER' => 'Eritrea', 'EE' => 'Estonia', 'ET' => 'Ethiopia', 'FK' => 'Falkland Islands (Malvinas)', 'FO' => 'Faroe Islands', 'FJ' => 'Fiji', 'FI' => 'Finland', 'FR' => 'France', 'GF' => 'French Guiana', 'PF' => 'French Polynesia', 'TF' => 'French Southern Territories', 'GA' => 'Gabon', 'GM' => 'Gambia', 'GE' => 'Georgia', 'DE' => 'Germany', 'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'GL' => 'Greenland', 'GD' => 'Grenada', 'GP' => 'Guadeloupe', 'GU' => 'Guam', 'GT' => 'Guatemala', 'GG' => 'Guernsey', 'GN' => 'Guinea', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HT' => 'Haiti', 'HM' => 'Heard Island and McDonald Islands', 'VA' => 'Holy See', 'HN' => 'Honduras', 'HK' => 'Hong Kong', 'HU' => 'Hungary', 'IS' => 'Iceland', 'IN' => 'India', 'ID' => 'Indonesia', 'IR' => 'Iran', 'IQ' => 'Iraq', 'IE' => 'Ireland', 'IM' => 'Isle of Man', 'IL' => 'Israel', 'IT' => 'Italy', 'JM' => 'Jamaica', 'JP' => 'Japan', 'JE' => 'Jersey', 'JO' => 'Jordan', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', 'KI' => 'Kiribati', 'KP' => 'Korea (Democratic People\'s Republic of)', 'KR' => 'Korea (Republic of)', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => 'Lao People\'s Democratic Republic', 'LV' => 'Latvia', 'LB' => 'Lebanon', 'LS' => 'Lesotho', 'LR' => 'Liberia', 'LY' => 'Libya', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'MO' => 'Macao', 'MG' => 'Madagascar', 'MW' => 'Malawi', 'MY' => 'Malaysia', 'MV' => 'Maldives', 'ML' => 'Mali', 'MT' => 'Malta', 'MH' => 'Marshall Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania', 'MU' => 'Mauritius', 'YT' => 'Mayotte', 'MX' => 'Mexico', 'FM' => 'Micronesia (Federated States of)', 'MD' => 'Moldova', 'MC' => 'Monaco', 'MN' => 'Mongolia', 'ME' => 'Montenegro', 'MS' => 'Montserrat', 'MA' => 'Morocco', 'MZ' => 'Mozambique', 'MM' => 'Myanmar', 'NA' => 'Namibia', 'NR' => 'Nauru', 'NP' => 'Nepal', 'NL' => 'Netherlands', 'NC' => 'New Caledonia', 'NZ' => 'New Zealand', 'NI' => 'Nicaragua', 'NE' => 'Niger', 'NG' => 'Nigeria', 'NU' => 'Niue', 'NF' => 'Norfolk Island', 'MK' => 'North Macedonia', 'MP' => 'Northern Mariana Islands', 'NO' => 'Norway', 'OM' => 'Oman', 'PK' => 'Pakistan', 'PW' => 'Palau', 'PS' => 'Palestine, State of', 'PA' => 'Panama', 'PG' => 'Papua New Guinea', 'PY' => 'Paraguay', 'PE' => 'Peru', 'PH' => 'Philippines', 'PN' => 'Pitcairn', 'PL' => 'Poland', 'PT' => 'Portugal', 'PR' => 'Puerto Rico', 'QA' => 'Qatar', 'RE' => 'Réunion', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'BL' => 'Saint Barthélemy', 'SH' => 'Saint Helena, Ascension and Tristan da Cunha', 'KN' => 'Saint Kitts and Nevis', 'LC' => 'Saint Lucia', 'MF' => 'Saint Martin (French part)', 'PM' => 'Saint Pierre and Miquelon', 'VC' => 'Saint Vincent and the Grenadines', 'WS' => 'Samoa', 'SM' => 'San Marino', 'ST' => 'Sao Tome and Principe', 'SA' => 'Saudi Arabia', 'SN' => 'Senegal', 'RS' => 'Serbia', 'SC' => 'Seychelles', 'SL' => 'Sierra Leone', 'SG' => 'Singapore', 'SX' => 'Sint Maarten (Dutch part)', 'SK' => 'Slovakia', 'SI' => 'Slovenia', 'SB' => 'Solomon Islands', 'SO' => 'Somalia', 'ZA' => 'South Africa', 'GS' => 'South Georgia and the South Sandwich Islands', 'SS' => 'South Sudan', 'ES' => 'Spain', 'LK' => 'Sri Lanka', 'SD' => 'Sudan', 'SR' => 'Suriname', 'SJ' => 'Svalbard and Jan Mayen', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania, United Republic of', 'TH' => 'Thailand', 'TL' => 'Timor-Leste', 'TG' => 'Togo', 'TK' => 'Tokelau', 'TO' => 'Tonga', 'TT' => 'Trinidad and Tobago', 'TN' => 'Tunisia', 'TR' => 'Turkey', 'TM' => 'Turkmenistan', 'TC' => 'Turks and Caicos Islands', 'TV' => 'Tuvalu', 'UG' => 'Uganda', 'UA' => 'Ukraine', 'AE' => 'United Arab Emirates', 'GB' => 'United Kingdom', 'US' => 'United States', 'UM' => 'United States Minor Outlying Islands', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan', 'VU' => 'Vanuatu', 'VE' => 'Venezuela', 'VN' => 'Viet Nam', 'VG' => 'Virgin Islands (British)', 'VI' => 'Virgin Islands (U.S.)', 'WF' => 'Wallis and Futuna', 'EH' => 'Western Sahara', 'YE' => 'Yemen', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', ]; } /** * Get available user roles as options for select fields. * @return array Array of user roles with role name as key and display name as value. */ public static function get_user_roles_options(): array { global $wp_roles; if( !isset( $wp_roles ) ) { $wp_roles = new \WP_Roles(); } $roles = array(); foreach( $wp_roles->roles as $role_key => $role_data ) { $roles[ $role_key ] = translate_user_role( $role_data['name'] ); } return $roles; } /** * Modifies the row meta displayed for the plugin on the plugins page. * * @param array $plugin_meta Array of the plugin's metadata. * @param string $plugin_file Path to the plugin file, relative to the plugins directory. * @param array $plugin_data Array of plugin data. * @param string $status Plugin status (e.g., 'active', 'inactive'). * * @return array Modified array of plugin metadata. */ public function plugin_row_meta( array $plugin_meta, string $plugin_file, array $plugin_data, string $status ): array { if( in_array( $plugin_file, [ 'adminease/adminease.php', 'adminease-pro/adminease-pro.php' ] ) ) { $plugin_meta[1] = 'By PrecisionWP'; // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage } if( 'adminease/adminease.php' === $plugin_file ) { $plugin_meta[] = '' . esc_attr__( 'Upgrade to Pro', 'adminease' ) . ''; } return $plugin_meta; } }