. */ // If this file was called directly, abort. if ( ! defined( 'ABSPATH' ) ) { exit; } if ( ! defined( 'WPINC' ) ) { die; } if ( ! function_exists( 'run_better_search_replace' ) ) { // Defines the path to the main plugin file. define( 'BSR_FILE', __FILE__ ); // Defines the path to be used for includes. define( 'BSR_PATH', plugin_dir_path( BSR_FILE ) ); // Defines the URL to the plugin. define( 'BSR_URL', plugin_dir_url( BSR_FILE ) ); // Defines the current version of the plugin. define( 'BSR_VERSION', '1.4.11' ); // Defines the name of the plugin. define( 'BSR_NAME', 'Better Search Replace' ); /** * Get plugin data from plugin header. * * @param string $header * * @return string * @since 1.4.11 */ function bsr_get_plugin_data( $header ) { $data = get_file_data( __FILE__, array( 'Name' => 'Plugin Name', 'RequiresWP' => 'Requires at least', 'RequiresPHP' => 'Requires PHP', ), 'plugin' ); if ( empty( $data[ $header ] ) ) { return ''; } return $data[ $header ]; } /** * Check if WordPress version meets minimum requirement. * * @return bool True if WordPress version is sufficient, false otherwise. * @since 1.4.11 */ function bsr_check_wp_version() { global $wp_version; if ( version_compare( $wp_version, bsr_get_plugin_data( 'RequiresWP' ) ) === -1 ) { add_action( 'admin_notices', 'bsr_wp_version_notice' ); add_action( 'network_admin_notices', 'bsr_wp_version_notice' ); return false; } return true; } /** * Check if PHP version meets minimum requirement. * * @return bool True if PHP version is sufficient, false otherwise. * @since 1.4.11 */ function bsr_check_php_version() { if ( version_compare( PHP_VERSION, bsr_get_plugin_data( 'RequiresPHP' ) ) === -1 ) { add_action( 'admin_notices', 'bsr_php_version_notice' ); add_action( 'network_admin_notices', 'bsr_php_version_notice' ); return false; } return true; } /** * Display admin notice for insufficient WordPress version. * * @since 1.4.11 */ function bsr_wp_version_notice() { global $wp_version; ?>

%1$s requires WordPress %2$s or higher. You are currently running WordPress %3$s. Please upgrade WordPress to activate this plugin.', 'better-search-replace' ), bsr_get_plugin_data( 'Name' ), bsr_get_plugin_data( 'RequiresWP' ), esc_html( $wp_version ) ) ); ?>

%1$s requires PHP %2$s or higher. You are currently running PHP %3$s. Please contact your web host to upgrade PHP to activate this plugin.', 'better-search-replace' ), bsr_get_plugin_data( 'Name' ), bsr_get_plugin_data( 'RequiresPHP' ), esc_html( PHP_VERSION ) ) ); ?>

run(); } } add_action( 'after_setup_theme', 'run_better_search_replace' ); } if ( ! function_exists( 'bsr_enabled_for_user' ) ) { /** * Is the current user allowed to use BSR? * * @return bool */ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Public helper; guarded by function_exists in bootstrap. function bsr_enabled_for_user() { // Allows for overriding the capability required to run the plugin. // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Legacy filter name; public API for capability override. $cap = apply_filters( 'bsr_capability', 'manage_options' ); return current_user_can( $cap ); } } if ( file_exists( BSR_PATH . 'ext/bsr-ext-functions.php' ) ) { require_once BSR_PATH . 'ext/bsr-ext-functions.php'; }