This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,103 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Displays the main Better Search Replace page under Tools -> Better Search Replace.
*
* @link https://bettersearchreplace.com
* @since 1.0.0
*
* @package Better_Search_Replace
* @subpackage Better_Search_Replace/templates
*/
// Prevent direct access.
if ( ! defined( 'BSR_PATH' ) ) exit;
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template partial loaded in BSR admin context; variables are file scope, not WordPress globals.
// phpcs:disable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended -- Tab is sanitized and matched against allowlist; optional tools-screen nonce verified when present.
$allowed_tabs = array( 'bsr_search_replace', 'bsr_settings', 'bsr_help' );
$active_tab = 'bsr_search_replace';
$tab_candidate = '';
if ( isset( $_GET['tab'] ) ) {
$tab_candidate = sanitize_key( wp_unslash( (string) $_GET['tab'] ) );
}
if ( '' !== $tab_candidate ) {
$nonce_ok = true;
if ( isset( $_GET['_wpnonce'] ) ) {
$nonce_ok = wp_verify_nonce( sanitize_text_field( wp_unslash( (string) $_GET['_wpnonce'] ) ), BSR_Utils::TOOLS_SCREEN_NONCE_ACTION );
}
if ( $nonce_ok && in_array( $tab_candidate, $allowed_tabs, true ) ) {
$active_tab = $tab_candidate;
}
}
// phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended
if ( 'bsr_settings' === $active_tab ) {
$action = get_admin_url() . 'options.php';
} else {
$action = get_admin_url() . 'admin-post.php';
}
$tab_urls = array(
'bsr_search_replace' => BSR_Utils::tools_page_url( array( 'tab' => 'bsr_search_replace' ) ),
'bsr_settings' => BSR_Utils::tools_page_url( array( 'tab' => 'bsr_settings' ) ),
'bsr_help' => BSR_Utils::tools_page_url( array( 'tab' => 'bsr_help' ) ),
);
$logo_src = plugin_dir_url( __FILE__ ) . '../assets/svg/logo-bsr.svg';
$icon_src = plugin_dir_url( __FILE__ ) . '../assets/svg/icon-upgrade.svg';
$upgrade = 'https://deliciousbrains.com/better-search-replace/upgrade/?utm_source=insideplugin&utm_medium=web&utm_content=header&utm_campaign=bsr-to-migrate';
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<div class="wrap" style="display: grid;">
<div class="bsr-notice-container">
<h2 class="hidden"></h2>
</div>
<div class="header">
<div class="content">
<a href="<?php echo esc_url( $tab_urls['bsr_search_replace'] ); ?>">
<img src="<?php echo esc_url( $logo_src ); ?>" class="logo" alt="">
</a>
<a href="<?php echo esc_url( $upgrade ); ?>" target="_blank" rel="noopener noreferrer" class="upgrade-notice">
<img src="<?php echo esc_url( $icon_src ); ?>" alt="">
<?php esc_html_e( 'Upgrade now and get 50% off', 'better-search-replace' ); ?>
</a>
</div>
<?php settings_errors(); ?>
<?php BSR_Admin::render_result(); ?>
</div>
<div class="nav-tab-wrapper">
<ul>
<li><a href="<?php echo esc_url( $tab_urls['bsr_search_replace'] ); ?>" class="nav-tab <?php echo esc_attr( 'bsr_search_replace' === $active_tab ? 'nav-tab-active' : '' ); ?>"><?php esc_html_e( 'Search/Replace', 'better-search-replace' ); ?></a></li>
<li><a href="<?php echo esc_url( $tab_urls['bsr_settings'] ); ?>" class="nav-tab <?php echo esc_attr( 'bsr_settings' === $active_tab ? 'nav-tab-active' : '' ); ?>"><?php esc_html_e( 'Settings', 'better-search-replace' ); ?></a></li>
<li><a href="<?php echo esc_url( $tab_urls['bsr_help'] ); ?>" class="nav-tab <?php echo esc_attr( 'bsr_help' === $active_tab ? 'nav-tab-active' : '' ); ?>"><?php esc_html_e( 'Help', 'better-search-replace' ); ?></a></li>
</ul>
</div>
<form class="bsr-action-form" action="<?php echo esc_url( $action ); ?>" method="POST">
<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template partial; file scope of this include.
$bsr_template = BSR_Templates_Helper::get_tab_template( $active_tab );
include $bsr_template;
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
</form>
</div><!-- /.wrap -->
@@ -0,0 +1,89 @@
<?php
/**
* Displays the "System Info" tab.
*
* @link https://bettersearchreplace.com
* @since 1.1
*
* @package Better_Search_Replace
* @subpackage Better_Search_Replace/templates
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Prevent direct access.
if ( ! defined( 'BSR_PATH' ) ) {
exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$bsr_upgrade_url = 'https://deliciousbrains.com/better-search-replace/upgrade/?utm_source=insideplugin&utm_medium=web&utm_content=help-tab&utm_campaign=bsr-to-migrate';
$bsr_github_url = 'https://github.com/deliciousbrains/better-search-replace';
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<div class="ui-sidebar-wrapper">
<div class="inside">
<div class="panel">
<div class="panel-header">
<h3><?php esc_html_e( 'Help & Troubleshooting', 'better-search-replace' ); ?></h3>
</div>
<div class="panel-content">
<div>
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: %s: URL to the upgrade page. */
__( '<a href="%s" style="font-weight:bold;" target="_blank" rel="noopener noreferrer">Upgrade</a> to gain access to premium features and priority email support.', 'better-search-replace' ),
esc_url( $bsr_upgrade_url )
)
);
?>
</p>
<p>
<?php
echo wp_kses_post(
sprintf(
/* translators: %s: URL to the GitHub repository. */
__( 'Found a bug or have a feature request? Please submit an issue on <a href="%s">GitHub</a>!', 'better-search-replace' ),
esc_url( $bsr_github_url )
)
);
?>
</p>
</div>
<!--System Info-->
<div class="row">
<div class="input-text full-width">
<label><strong><?php esc_html_e( 'System Info', 'better-search-replace' ); ?></strong></label>
<textarea readonly="readonly" onclick="this.focus(); this.select()" name="bsr-sysinfo"><?php echo esc_textarea( BSR_Compatibility::get_sysinfo() ); ?></textarea>
</div>
</div>
<div class="row">
<p class="submit">
<input type="hidden" name="action" value="bsr_download_sysinfo" />
<?php wp_nonce_field( 'bsr_download_sysinfo', 'bsr_sysinfo_nonce' ); ?>
<input type="submit" name="bsr-download-sysinfo" id="bsr-download-sysinfo" class="button button-secondary button-sm" value="<?php echo esc_attr__( 'Download System Info', 'better-search-replace' ); ?>">
</p>
</div>
</div>
</div>
</div>
<?php
if ( file_exists( BSR_PATH . 'templates/sidebar.php' ) ) {
include_once BSR_PATH . 'templates/sidebar.php';
}
?>
</div>
@@ -0,0 +1,142 @@
<?php
/**
* Displays the main "Search/Replace" tab.
*
* @link https://bettersearchreplace.com
* @since 1.1
*
* @package Better_Search_Replace
* @subpackage Better_Search_Replace/templates
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Prevent direct/unauthorized access.
if ( ! defined( 'BSR_PATH' ) ) exit;
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$bsr_assets = plugin_dir_url( __FILE__ ) . '../assets/svg/';
$bsr_guid_doc = 'https://wordpress.org/documentation/article/changing-the-site-url/#important-guid-note';
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<div id="bsr-search-replace-wrap" class="postbox">
<div class="ui-sidebar-wrapper">
<div class="inside">
<div id="bsr-search-replace-form" class="form-table">
<!--Hidden and to trigger the dry run notice placement-->
<h2 class="hidden"><?php esc_html_e( 'Dry Run Notice', 'better-search-replace' ); ?></h2>
<!--Search/Replace Panel-->
<div class="panel">
<div class="panel-header">
<h3><?php esc_html_e( 'Search/Replace', 'better-search-replace' ); ?></h3>
<a href="#" class="tooltip">
<img src="<?php echo esc_url( $bsr_assets . 'icon-help.svg' ); ?>" alt="">
</a>
<span class="helper-message left">
<?php esc_html_e( 'Search and replace text in the database, including serialized arrays and objects. Be sure to back up your database before running this process.', 'better-search-replace' ); ?>
</span>
</div>
<div class="panel-content">
<!--Search/Replace Fields-->
<div class="row search-replace">
<div class="input-text full-width">
<label for="search_for"><strong><?php esc_html_e( 'Search for', 'better-search-replace' ); ?></strong></label>
<input id="search_for" class="regular-text" type="text" name="search_for" value="<?php BSR_Admin::prefill_value( 'search_for' ); ?>" />
</div>
<div class="input-text full-width">
<label for="replace_with"><strong><?php esc_html_e( 'Replace with', 'better-search-replace' ); ?></strong></label>
<input id="replace_with" class="regular-text" type="text" name="replace_with" value="<?php BSR_Admin::prefill_value( 'replace_with' ); ?>" />
</div>
</div>
<!--Tables-->
<div class="row">
<div class="col full-width tables">
<label for="select_tables"><strong><?php esc_html_e( 'Select tables', 'better-search-replace' ); ?></strong></label>
<?php BSR_Admin::load_tables(); ?>
<p class="description"><?php esc_html_e( 'Select multiple tables with Ctrl-Click for Windows or Cmd-Click for Mac.', 'better-search-replace' ); ?></p>
</div>
</div>
</div>
</div>
<!--Additional Settings Panel-->
<div class="panel">
<div class="panel-header">
<h3><?php esc_html_e( 'Additional Settings', 'better-search-replace' ); ?></h3>
</div>
<div class="panel-content settings additional-settings">
<!--Case Sensitive-->
<label for="case_insensitive" class="row">
<div class="col">
<input id="case_insensitive" type="checkbox" name="case_insensitive" <?php BSR_Admin::prefill_value( 'case_insensitive', 'checkbox' ); ?> />
</div>
<div class="col">
<label for="case_insensitive"><strong><?php esc_html_e( 'Case-Insensitive', 'better-search-replace' ); ?></strong></label>
<label for="case_insensitive"><span class="description"><?php esc_html_e( 'Searches are case-sensitive by default.', 'better-search-replace' ); ?></span></label>
</div>
</label>
<!--Replace GUIDs-->
<label for="replace_guids" class="row">
<div class="col">
<input id="replace_guids" type="checkbox" name="replace_guids" <?php BSR_Admin::prefill_value( 'replace_guids', 'checkbox' ); ?> />
</div>
<div class="col">
<label for="replace_guids" class="replace_guids"><strong><?php esc_html_e( 'Replace GUIDs', 'better-search-replace' ); ?></strong><a href="<?php echo esc_url( $bsr_guid_doc ); ?>" target="_blank" rel="noopener noreferrer"><img src="<?php echo esc_url( $bsr_assets . 'icon-help.svg' ); ?>" alt=""></a></label>
<label for="replace_guids"><span class="description"><?php esc_html_e( 'If left unchecked, all database columns titled \'guid\' will be skipped.', 'better-search-replace' ); ?></span></label>
</div>
</label>
<!--Dry Run-->
<label for="dry_run" class="row">
<div class="col">
<input id="dry_run" type="checkbox" name="dry_run" checked />
</div>
<div class="col">
<label for="dry_run"><strong><?php esc_html_e( 'Run as dry run', 'better-search-replace' ); ?></strong></label>
<label for="dry_run"><span class="description"><?php esc_html_e( 'If checked, no changes will be made to the database, allowing you to check the results beforehand.', 'better-search-replace' ); ?></span></label>
</div>
</label>
</div>
</div>
<div id="bsr-error-wrap"></div>
<!--Submit Button-->
<div id="bsr-submit-wrap">
<?php wp_nonce_field( 'process_search_replace', 'bsr_nonce' ); ?>
<input type="hidden" name="action" value="bsr_process_search_replace" />
<button id="bsr-submit" type="submit" class="button button-primary button-lg"><?php esc_html_e( 'Run Search/Replace', 'better-search-replace' ); ?>
<img src="<?php echo esc_url( $bsr_assets . 'icon-arrow.svg' ); ?>" alt="">
</button>
</div>
</div>
</div>
<?php
if ( file_exists( BSR_PATH . 'templates/sidebar.php' ) ) {
include_once BSR_PATH . 'templates/sidebar.php';
}
?>
<!-- /.ui-sidebar-wrapper -->
</div>
</div><!-- /#bsr-search-replace-wrap -->
@@ -0,0 +1,68 @@
<?php
/**
* Displays the main "Settings" tab.
*
* @link https://bettersearchreplace.com
* @since 1.1
*
* @package Better_Search_Replace
* @subpackage Better_Search_Replace/templates
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Prevent direct/unauthorized access.
if ( ! defined( 'BSR_PATH' ) ) exit;
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template partial loaded in BSR admin context; variables are file scope, not WordPress globals.
$page_size = get_option( 'bsr_page_size' ) ? absint( get_option( 'bsr_page_size' ) ) : 20000;
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<?php settings_fields( 'bsr_settings_fields' ); ?>
<div class="ui-sidebar-wrapper">
<div class="inside">
<div class="panel">
<div class="panel-header">
<h3><?php esc_html_e( 'Settings', 'better-search-replace' ); ?></h3>
</div>
<div class="panel-content settings">
<!--Max Page Size-->
<div class="row last-row">
<div class="input-text">
<div class="settings-header">
<label><strong><?php esc_html_e( 'Max Page Size', 'better-search-replace' ); ?></strong></label>
<span id="bsr-page-size-value"><?php echo esc_html( (string) absint( $page_size ) ); ?></span>
</div>
<input id="bsr_page_size" type="hidden" name="bsr_page_size" value="<?php echo esc_attr( (string) $page_size ); ?>" />
<p class="description"><?php esc_html_e( 'If you notice timeouts or are unable to backup/import the database, try decreasing this value.', 'better-search-replace' ); ?></p>
<div class="slider-wrapper">
<div id="bsr-page-size-slider" class="bsr-slider"></div>
</div>
</div>
</div>
<!--Submit Button-->
<div class="row panel-footer">
<?php submit_button(); ?>
</div>
</div>
</div>
</div>
<?php
if ( file_exists( BSR_PATH . 'templates/sidebar.php' ) ) {
include_once BSR_PATH . 'templates/sidebar.php';
}
?>
</div>
@@ -0,0 +1,52 @@
<?php
/**
* Upgrade sidebar partial.
*
* @package Better_Search_Replace
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! defined( 'BSR_PATH' ) ) {
exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template partial loaded in BSR admin context; variables are file scope, not WordPress globals.
$birds = plugin_dir_url( __FILE__ ) . '../assets/svg/mdb-birds.svg';
$upgrade_href = 'https://deliciousbrains.com/better-search-replace/upgrade/?utm_source=insideplugin&utm_medium=web&utm_content=sidebar&utm_campaign=bsr-to-migrate';
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<div class="upgrade-sidebar">
<img src="<?php echo esc_url( $birds ); ?>" alt="">
<div class="content">
<h3><?php esc_html_e( 'Upgrade', 'better-search-replace' ); ?></h3>
<p><?php esc_html_e( 'Gain access to more database and migration features', 'better-search-replace' ); ?></p>
<ul>
<li>
<p><?php esc_html_e( 'Preview database changes before they are saved', 'better-search-replace' ); ?></p>
</li>
<li>
<p><?php esc_html_e( 'Use regular expressions for complex string replacements', 'better-search-replace' ); ?></p>
</li>
<li>
<p><?php esc_html_e( 'Migrate full sites including themes, plugins, media, and database', 'better-search-replace' ); ?></p>
</li>
<li>
<p><?php esc_html_e( 'Export and import WordPress databases', 'better-search-replace' ); ?></p>
</li>
<li>
<p><?php esc_html_e( 'Email support', 'better-search-replace' ); ?></p>
</li>
</ul>
<p class="upgrade-offer-text"><?php echo wp_kses_post( __( 'Get up to <span>50% off</span> your first year!', 'better-search-replace' ) ); ?></p>
<div class="button-row">
<a href="<?php echo esc_url( $upgrade_href ); ?>" class="button button-primary button-sm" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Upgrade Now', 'better-search-replace' ); ?></a>
</div>
</div>
</div>