Plugin Directory

Changeset 3414590


Ignore:
Timestamp:
12/08/2025 05:33:02 PM (4 months ago)
Author:
Mat Lipe
Message:

Update to version 7.0.7 from GitHub

Location:
go-live-update-urls
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • go-live-update-urls/tags/7.0.7/go-live-update-urls.php

    r3369773 r3414590  
    66 * Author: OnPoint Plugins
    77 * Author URI: https://onpointplugins.com
    8  * Version: 7.0.6
     8 * Version: 7.0.7
    99 * Text Domain: go-live-update-urls
    1010 * Domain Path: /languages/
     
    1616 */
    1717
    18 define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0.6' );
     18define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0.7' );
    1919define( 'GO_LIVE_UPDATE_URLS_REQUIRED_PRO_VERSION', '7.1.0' );
    2020define( 'GO_LIVE_UPDATE_URLS_URL', plugin_dir_url( __FILE__ ) );
  • go-live-update-urls/tags/7.0.7/readme.txt

    r3369773 r3414590  
    44Tags: search and replace, database, urls, domain, update urls
    55Requires at least: 6.2.0
    6 Tested up to: 6.8.2
     6Tested up to: 6.9.0
    77Requires PHP: 7.4.0
    8 Stable tag: 7.0.6
     8Stable tag: 7.0.7
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    122122
    123123== Changelog ==
     124= 7.0.7 =
     125* Added a link to documentation in the plugin list.
     126* Introduced a `get_wpdb` method on the `Database` class.
     127* Improved PHPDocs in the Updates class.
     128* Updated NodeJS to version 22.21.1.
     129* Tested to WordPress 6.9.0.
     130
    124131= 7.0.6 =
    125132* Tested to WordPress 6.8.2.
  • go-live-update-urls/tags/7.0.7/src/Core.php

    r3216196 r3414590  
    8585
    8686    /**
    87      * Quick and dirty update of entire blog
     87     * Quick and dirty update of the entire blog
    8888     *
    8989     * Mostly used for unit testing and future WP-CLI command
     
    107107
    108108    /**
    109      * Display custom action links in plugins list.
     109     * Display custom action links in the plugin list.
    110110     *
    111111     * 1. Settings.
    112      * 2. Go PRO.
     112     * 2. Documentation.
     113     * 3. Go PRO.
    113114     *
    114      * @param array $actions - Array of actions and their link.
     115     * @param array<string, string> $actions - Array of actions and their link.
    115116     *
    116      * @return array
     117     * @return array<string, string>
    117118     */
    118119    public function plugin_action_link( array $actions ) {
    119         $actions['settings'] = sprintf( '<a href="%1$s">%2$s</a>', Admin::instance()->get_url(), __( 'Settings', 'go-live-update-urls' ) );
     120        $actions['documentation'] = \sprintf( '<a href="%s" target="_blank">%s</a>',
     121            'https://onpointplugins.com/go-live-update-urls/go-live-update-urls-usage/?utm_source=wp-plugins&utm_campaign=documentation&utm_medium=wp-dash', __( 'Documentation', 'go-live-update-urls' ) );
     122        $actions['settings'] = \sprintf( '<a href="%1$s">%2$s</a>', Admin::instance()->get_url(), __( 'Settings', 'go-live-update-urls' ) );
    120123        if ( ! \defined( 'GO_LIVE_UPDATE_URLS_PRO_VERSION' ) ) {
    121             $actions['go-pro'] = sprintf( '<a href="%1$s" target="_blank" style="color:#3db634;font-weight:700;">%2$s</a>', 'https://onpointplugins.com/product/go-live-update-urls-pro/?utm_source=wp-plugins&utm_campaign=gopro&utm_medium=wp-dash', __( 'Go PRO', 'go-live-update-urls' ) );
     124            $actions['go-pro'] = \sprintf( '<a href="%1$s" target="_blank" style="color:#3db634;font-weight:700;">%2$s</a>', 'https://onpointplugins.com/product/go-live-update-urls-pro/?utm_source=wp-plugins&utm_campaign=gopro&utm_medium=wp-dash', __( 'Go PRO', 'go-live-update-urls' ) );
    122125        }
    123126        return $actions;
  • go-live-update-urls/tags/7.0.7/src/Database.php

    r3159918 r3414590  
    1515
    1616    /**
    17      * Get list of tables we treat as serialized when updating
     17     * Get the list of tables we treat as serialized when updating
    1818     *
    1919     * @since   5.0.0
     
    2222     */
    2323    public function get_serialized_tables() {
    24         global $wpdb;
     24        $wpdb = $this->get_wpdb();
    2525        // Default tables with serialized data.
    2626        $serialized_tables = [
     
    6868     */
    6969    public function get_core_tables() {
    70         global $wpdb;
     70        $wpdb = $this->get_wpdb();
    7171
    7272        $tables = [
     
    137137     */
    138138    public function get_all_table_names() {
    139         global $wpdb;
     139        $wpdb = $this->get_wpdb();
    140140        $query = "SELECT TABLE_NAME as TableName FROM information_schema.TABLES WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->esc_like( $wpdb->prefix ) . "%'";
    141141
     
    227227     */
    228228    public function update_column( $table, $column, $old_url, $new_url ): int {
    229         global $wpdb;
     229        $wpdb = $this->get_wpdb();
    230230
    231231        $count = $this->count_column_urls( $table, $column, $old_url );
     
    244244
    245245    /**
    246      * Count of number of rows in a table which contain the old URL.
     246     * Count of the number of rows in a table which contain the old URL.
    247247     *
    248248     * When updating, the serialized data is updated first and this
     
    261261     */
    262262    public function count_column_urls( $table, $column, $old_url ): int {
    263         global $wpdb;
     263        $wpdb = $this->get_wpdb();
    264264
    265265        $query = "SELECT SUM( ROUND( ( LENGTH( `{$column}` ) - LENGTH( REPLACE( `{$column}`, %s, '' ) ) ) / LENGTH( %s ) ) ) from `{$table}`";
    266266
    267267        return (int) $wpdb->get_var( $wpdb->prepare( $query, [ $old_url, $old_url ] ) );
     268    }
     269
     270
     271    /**
     272     * Access the wpdb object safely.
     273     *
     274     * @return \wpdb
     275     */
     276    public function get_wpdb(): \wpdb {
     277        return $GLOBALS['wpdb'];
    268278    }
    269279
  • go-live-update-urls/tags/7.0.7/src/Updates.php

    r3216196 r3414590  
    1010 *
    1111 * While no updates to the database are done within this class,
    12  * all calls to the methods, which update the database go through here
     12 * all calls to the methods which update the database go through here
    1313 * except for serialized data.
    1414 *
    15  * This class determines, which data needs to be updated in which way
    16  * and makes necessary calls.
     15 * This class determines which data needs to be updated in which way
     16 * and makes the necessary calls.
    1717 *
    1818 * @since 6.1.0
     
    2424     * @var string
    2525     */
    26     protected $old_url;
     26    protected string $old_url;
    2727
    2828    /**
     
    3131     * @var string
    3232     */
    33     protected $new_url;
     33    protected string $new_url;
    3434
    3535    /**
     
    3838     * @var string[]
    3939     */
    40     protected $tables;
     40    protected array $tables;
    4141
    4242
     
    110110     *
    111111     * If we change a domain to a subdomain like www, and an email address
    112      * is using the original domain we end up with an email address that
     112     * is using the original domain, we end up with an email address that
    113113     * includes @www We remove the prepended www from email addresses
    114114     * here.
     
    133133     * of the URL.
    134134     *
    135      * Actual translation and updating is handled by each updater.
     135     * Actual translation and updating handled by each updater.
    136136     * We simply load and call them here.
    137137     *
     
    163163     * of the URL.
    164164     *
    165      * Actual counting is handled by each updater.
     165     * Actual counting handled by each updater.
    166166     * We simply load and call them here.
    167167     *
     
    224224    /**
    225225     * If the new domain is the old one with a new subdomain like www.
    226      * the first round of updates will create double subdomains in
     226     * The first round of updates will create double subdomains in
    227227     * the database like www.www.
    228228     *
    229      * Return the doubled up subdomain if it exists, otherwise null.
     229     * Return the doubled-up subdomain if it exists, otherwise null.
    230230     *
    231231     * @since 6.1.0
     
    233233     * @return string|null
    234234     */
    235     public function get_doubled_up_subdomain() {
     235    public function get_doubled_up_subdomain(): ?string {
    236236        if ( static::is_subdomain( $this->old_url, $this->new_url ) ) {
    237237            return \str_replace( $this->old_url, $this->new_url, $this->new_url );
     
    255255     * @return string[]
    256256     */
    257     protected function get_table_columns( $table ) {
    258         global $wpdb;
     257    protected function get_table_columns( string $table ): array {
     258        $wpdb = Database::instance()->get_wpdb();
     259        $supported_types = Database::instance()->get_column_types();
    259260
    260261        $all = $wpdb->get_results( $wpdb->prepare( "SELECT COLUMN_NAME as name, COLUMN_TYPE as type FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='{$wpdb->dbname}' AND TABLE_NAME=%s", $table ) );
    261         $types = Database::instance()->get_column_types();
    262 
    263         return wp_list_pluck( array_filter( $all, function( $column ) use ( $types ) {
     262        if ( ! \is_array( $all ) ) {
     263            return [];
     264        }
     265
     266        $columns = \array_filter( $all, function( $column ) use ( $supported_types ) {
    264267            // Strip the (\d) from varchar and char with (21) and over.
    265             return \in_array( preg_replace( '/\((\d{3}|[3-9]\d|2[1-9])\d*?\)/', '', $column->type ), $types, true );
    266         } ), 'name' );
     268            $data_type = \preg_replace( '/\((\d{3}|[3-9]\d|2[1-9])\d*?\)/', '', $column->type );
     269            return \in_array( $data_type, $supported_types, true );
     270        } );
     271
     272        return \wp_list_pluck( $columns, 'name' );
    267273    }
    268274
  • go-live-update-urls/trunk/go-live-update-urls.php

    r3369773 r3414590  
    66 * Author: OnPoint Plugins
    77 * Author URI: https://onpointplugins.com
    8  * Version: 7.0.6
     8 * Version: 7.0.7
    99 * Text Domain: go-live-update-urls
    1010 * Domain Path: /languages/
     
    1616 */
    1717
    18 define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0.6' );
     18define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0.7' );
    1919define( 'GO_LIVE_UPDATE_URLS_REQUIRED_PRO_VERSION', '7.1.0' );
    2020define( 'GO_LIVE_UPDATE_URLS_URL', plugin_dir_url( __FILE__ ) );
  • go-live-update-urls/trunk/readme.txt

    r3369773 r3414590  
    44Tags: search and replace, database, urls, domain, update urls
    55Requires at least: 6.2.0
    6 Tested up to: 6.8.2
     6Tested up to: 6.9.0
    77Requires PHP: 7.4.0
    8 Stable tag: 7.0.6
     8Stable tag: 7.0.7
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    122122
    123123== Changelog ==
     124= 7.0.7 =
     125* Added a link to documentation in the plugin list.
     126* Introduced a `get_wpdb` method on the `Database` class.
     127* Improved PHPDocs in the Updates class.
     128* Updated NodeJS to version 22.21.1.
     129* Tested to WordPress 6.9.0.
     130
    124131= 7.0.6 =
    125132* Tested to WordPress 6.8.2.
  • go-live-update-urls/trunk/src/Core.php

    r3216196 r3414590  
    8585
    8686    /**
    87      * Quick and dirty update of entire blog
     87     * Quick and dirty update of the entire blog
    8888     *
    8989     * Mostly used for unit testing and future WP-CLI command
     
    107107
    108108    /**
    109      * Display custom action links in plugins list.
     109     * Display custom action links in the plugin list.
    110110     *
    111111     * 1. Settings.
    112      * 2. Go PRO.
     112     * 2. Documentation.
     113     * 3. Go PRO.
    113114     *
    114      * @param array $actions - Array of actions and their link.
     115     * @param array<string, string> $actions - Array of actions and their link.
    115116     *
    116      * @return array
     117     * @return array<string, string>
    117118     */
    118119    public function plugin_action_link( array $actions ) {
    119         $actions['settings'] = sprintf( '<a href="%1$s">%2$s</a>', Admin::instance()->get_url(), __( 'Settings', 'go-live-update-urls' ) );
     120        $actions['documentation'] = \sprintf( '<a href="%s" target="_blank">%s</a>',
     121            'https://onpointplugins.com/go-live-update-urls/go-live-update-urls-usage/?utm_source=wp-plugins&utm_campaign=documentation&utm_medium=wp-dash', __( 'Documentation', 'go-live-update-urls' ) );
     122        $actions['settings'] = \sprintf( '<a href="%1$s">%2$s</a>', Admin::instance()->get_url(), __( 'Settings', 'go-live-update-urls' ) );
    120123        if ( ! \defined( 'GO_LIVE_UPDATE_URLS_PRO_VERSION' ) ) {
    121             $actions['go-pro'] = sprintf( '<a href="%1$s" target="_blank" style="color:#3db634;font-weight:700;">%2$s</a>', 'https://onpointplugins.com/product/go-live-update-urls-pro/?utm_source=wp-plugins&utm_campaign=gopro&utm_medium=wp-dash', __( 'Go PRO', 'go-live-update-urls' ) );
     124            $actions['go-pro'] = \sprintf( '<a href="%1$s" target="_blank" style="color:#3db634;font-weight:700;">%2$s</a>', 'https://onpointplugins.com/product/go-live-update-urls-pro/?utm_source=wp-plugins&utm_campaign=gopro&utm_medium=wp-dash', __( 'Go PRO', 'go-live-update-urls' ) );
    122125        }
    123126        return $actions;
  • go-live-update-urls/trunk/src/Database.php

    r3159918 r3414590  
    1515
    1616    /**
    17      * Get list of tables we treat as serialized when updating
     17     * Get the list of tables we treat as serialized when updating
    1818     *
    1919     * @since   5.0.0
     
    2222     */
    2323    public function get_serialized_tables() {
    24         global $wpdb;
     24        $wpdb = $this->get_wpdb();
    2525        // Default tables with serialized data.
    2626        $serialized_tables = [
     
    6868     */
    6969    public function get_core_tables() {
    70         global $wpdb;
     70        $wpdb = $this->get_wpdb();
    7171
    7272        $tables = [
     
    137137     */
    138138    public function get_all_table_names() {
    139         global $wpdb;
     139        $wpdb = $this->get_wpdb();
    140140        $query = "SELECT TABLE_NAME as TableName FROM information_schema.TABLES WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->esc_like( $wpdb->prefix ) . "%'";
    141141
     
    227227     */
    228228    public function update_column( $table, $column, $old_url, $new_url ): int {
    229         global $wpdb;
     229        $wpdb = $this->get_wpdb();
    230230
    231231        $count = $this->count_column_urls( $table, $column, $old_url );
     
    244244
    245245    /**
    246      * Count of number of rows in a table which contain the old URL.
     246     * Count of the number of rows in a table which contain the old URL.
    247247     *
    248248     * When updating, the serialized data is updated first and this
     
    261261     */
    262262    public function count_column_urls( $table, $column, $old_url ): int {
    263         global $wpdb;
     263        $wpdb = $this->get_wpdb();
    264264
    265265        $query = "SELECT SUM( ROUND( ( LENGTH( `{$column}` ) - LENGTH( REPLACE( `{$column}`, %s, '' ) ) ) / LENGTH( %s ) ) ) from `{$table}`";
    266266
    267267        return (int) $wpdb->get_var( $wpdb->prepare( $query, [ $old_url, $old_url ] ) );
     268    }
     269
     270
     271    /**
     272     * Access the wpdb object safely.
     273     *
     274     * @return \wpdb
     275     */
     276    public function get_wpdb(): \wpdb {
     277        return $GLOBALS['wpdb'];
    268278    }
    269279
  • go-live-update-urls/trunk/src/Updates.php

    r3216196 r3414590  
    1010 *
    1111 * While no updates to the database are done within this class,
    12  * all calls to the methods, which update the database go through here
     12 * all calls to the methods which update the database go through here
    1313 * except for serialized data.
    1414 *
    15  * This class determines, which data needs to be updated in which way
    16  * and makes necessary calls.
     15 * This class determines which data needs to be updated in which way
     16 * and makes the necessary calls.
    1717 *
    1818 * @since 6.1.0
     
    2424     * @var string
    2525     */
    26     protected $old_url;
     26    protected string $old_url;
    2727
    2828    /**
     
    3131     * @var string
    3232     */
    33     protected $new_url;
     33    protected string $new_url;
    3434
    3535    /**
     
    3838     * @var string[]
    3939     */
    40     protected $tables;
     40    protected array $tables;
    4141
    4242
     
    110110     *
    111111     * If we change a domain to a subdomain like www, and an email address
    112      * is using the original domain we end up with an email address that
     112     * is using the original domain, we end up with an email address that
    113113     * includes @www We remove the prepended www from email addresses
    114114     * here.
     
    133133     * of the URL.
    134134     *
    135      * Actual translation and updating is handled by each updater.
     135     * Actual translation and updating handled by each updater.
    136136     * We simply load and call them here.
    137137     *
     
    163163     * of the URL.
    164164     *
    165      * Actual counting is handled by each updater.
     165     * Actual counting handled by each updater.
    166166     * We simply load and call them here.
    167167     *
     
    224224    /**
    225225     * If the new domain is the old one with a new subdomain like www.
    226      * the first round of updates will create double subdomains in
     226     * The first round of updates will create double subdomains in
    227227     * the database like www.www.
    228228     *
    229      * Return the doubled up subdomain if it exists, otherwise null.
     229     * Return the doubled-up subdomain if it exists, otherwise null.
    230230     *
    231231     * @since 6.1.0
     
    233233     * @return string|null
    234234     */
    235     public function get_doubled_up_subdomain() {
     235    public function get_doubled_up_subdomain(): ?string {
    236236        if ( static::is_subdomain( $this->old_url, $this->new_url ) ) {
    237237            return \str_replace( $this->old_url, $this->new_url, $this->new_url );
     
    255255     * @return string[]
    256256     */
    257     protected function get_table_columns( $table ) {
    258         global $wpdb;
     257    protected function get_table_columns( string $table ): array {
     258        $wpdb = Database::instance()->get_wpdb();
     259        $supported_types = Database::instance()->get_column_types();
    259260
    260261        $all = $wpdb->get_results( $wpdb->prepare( "SELECT COLUMN_NAME as name, COLUMN_TYPE as type FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='{$wpdb->dbname}' AND TABLE_NAME=%s", $table ) );
    261         $types = Database::instance()->get_column_types();
    262 
    263         return wp_list_pluck( array_filter( $all, function( $column ) use ( $types ) {
     262        if ( ! \is_array( $all ) ) {
     263            return [];
     264        }
     265
     266        $columns = \array_filter( $all, function( $column ) use ( $supported_types ) {
    264267            // Strip the (\d) from varchar and char with (21) and over.
    265             return \in_array( preg_replace( '/\((\d{3}|[3-9]\d|2[1-9])\d*?\)/', '', $column->type ), $types, true );
    266         } ), 'name' );
     268            $data_type = \preg_replace( '/\((\d{3}|[3-9]\d|2[1-9])\d*?\)/', '', $column->type );
     269            return \in_array( $data_type, $supported_types, true );
     270        } );
     271
     272        return \wp_list_pluck( $columns, 'name' );
    267273    }
    268274
Note: See TracChangeset for help on using the changeset viewer.