Changeset 3414590
- Timestamp:
- 12/08/2025 05:33:02 PM (4 months ago)
- Location:
- go-live-update-urls
- Files:
-
- 10 edited
- 1 copied
-
tags/7.0.7 (copied) (copied from go-live-update-urls/trunk)
-
tags/7.0.7/go-live-update-urls.php (modified) (2 diffs)
-
tags/7.0.7/readme.txt (modified) (2 diffs)
-
tags/7.0.7/src/Core.php (modified) (2 diffs)
-
tags/7.0.7/src/Database.php (modified) (7 diffs)
-
tags/7.0.7/src/Updates.php (modified) (10 diffs)
-
trunk/go-live-update-urls.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Core.php (modified) (2 diffs)
-
trunk/src/Database.php (modified) (7 diffs)
-
trunk/src/Updates.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
go-live-update-urls/tags/7.0.7/go-live-update-urls.php
r3369773 r3414590 6 6 * Author: OnPoint Plugins 7 7 * Author URI: https://onpointplugins.com 8 * Version: 7.0. 68 * Version: 7.0.7 9 9 * Text Domain: go-live-update-urls 10 10 * Domain Path: /languages/ … … 16 16 */ 17 17 18 define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0. 6' );18 define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0.7' ); 19 19 define( 'GO_LIVE_UPDATE_URLS_REQUIRED_PRO_VERSION', '7.1.0' ); 20 20 define( 'GO_LIVE_UPDATE_URLS_URL', plugin_dir_url( __FILE__ ) ); -
go-live-update-urls/tags/7.0.7/readme.txt
r3369773 r3414590 4 4 Tags: search and replace, database, urls, domain, update urls 5 5 Requires at least: 6.2.0 6 Tested up to: 6. 8.26 Tested up to: 6.9.0 7 7 Requires PHP: 7.4.0 8 Stable tag: 7.0. 68 Stable tag: 7.0.7 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 122 122 123 123 == 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 124 131 = 7.0.6 = 125 132 * Tested to WordPress 6.8.2. -
go-live-update-urls/tags/7.0.7/src/Core.php
r3216196 r3414590 85 85 86 86 /** 87 * Quick and dirty update of entire blog87 * Quick and dirty update of the entire blog 88 88 * 89 89 * Mostly used for unit testing and future WP-CLI command … … 107 107 108 108 /** 109 * Display custom action links in pluginslist.109 * Display custom action links in the plugin list. 110 110 * 111 111 * 1. Settings. 112 * 2. Go PRO. 112 * 2. Documentation. 113 * 3. Go PRO. 113 114 * 114 * @param array $actions - Array of actions and their link.115 * @param array<string, string> $actions - Array of actions and their link. 115 116 * 116 * @return array 117 * @return array<string, string> 117 118 */ 118 119 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' ) ); 120 123 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' ) ); 122 125 } 123 126 return $actions; -
go-live-update-urls/tags/7.0.7/src/Database.php
r3159918 r3414590 15 15 16 16 /** 17 * Get list of tables we treat as serialized when updating17 * Get the list of tables we treat as serialized when updating 18 18 * 19 19 * @since 5.0.0 … … 22 22 */ 23 23 public function get_serialized_tables() { 24 global $wpdb;24 $wpdb = $this->get_wpdb(); 25 25 // Default tables with serialized data. 26 26 $serialized_tables = [ … … 68 68 */ 69 69 public function get_core_tables() { 70 global $wpdb;70 $wpdb = $this->get_wpdb(); 71 71 72 72 $tables = [ … … 137 137 */ 138 138 public function get_all_table_names() { 139 global $wpdb;139 $wpdb = $this->get_wpdb(); 140 140 $query = "SELECT TABLE_NAME as TableName FROM information_schema.TABLES WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->esc_like( $wpdb->prefix ) . "%'"; 141 141 … … 227 227 */ 228 228 public function update_column( $table, $column, $old_url, $new_url ): int { 229 global $wpdb;229 $wpdb = $this->get_wpdb(); 230 230 231 231 $count = $this->count_column_urls( $table, $column, $old_url ); … … 244 244 245 245 /** 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. 247 247 * 248 248 * When updating, the serialized data is updated first and this … … 261 261 */ 262 262 public function count_column_urls( $table, $column, $old_url ): int { 263 global $wpdb;263 $wpdb = $this->get_wpdb(); 264 264 265 265 $query = "SELECT SUM( ROUND( ( LENGTH( `{$column}` ) - LENGTH( REPLACE( `{$column}`, %s, '' ) ) ) / LENGTH( %s ) ) ) from `{$table}`"; 266 266 267 267 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']; 268 278 } 269 279 -
go-live-update-urls/tags/7.0.7/src/Updates.php
r3216196 r3414590 10 10 * 11 11 * While no updates to the database are done within this class, 12 * all calls to the methods ,which update the database go through here12 * all calls to the methods which update the database go through here 13 13 * except for serialized data. 14 14 * 15 * This class determines ,which data needs to be updated in which way16 * and makes necessary calls.15 * This class determines which data needs to be updated in which way 16 * and makes the necessary calls. 17 17 * 18 18 * @since 6.1.0 … … 24 24 * @var string 25 25 */ 26 protected $old_url;26 protected string $old_url; 27 27 28 28 /** … … 31 31 * @var string 32 32 */ 33 protected $new_url;33 protected string $new_url; 34 34 35 35 /** … … 38 38 * @var string[] 39 39 */ 40 protected $tables;40 protected array $tables; 41 41 42 42 … … 110 110 * 111 111 * 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 that112 * is using the original domain, we end up with an email address that 113 113 * includes @www We remove the prepended www from email addresses 114 114 * here. … … 133 133 * of the URL. 134 134 * 135 * Actual translation and updating ishandled by each updater.135 * Actual translation and updating handled by each updater. 136 136 * We simply load and call them here. 137 137 * … … 163 163 * of the URL. 164 164 * 165 * Actual counting ishandled by each updater.165 * Actual counting handled by each updater. 166 166 * We simply load and call them here. 167 167 * … … 224 224 /** 225 225 * If the new domain is the old one with a new subdomain like www. 226 * the first round of updates will create double subdomains in226 * The first round of updates will create double subdomains in 227 227 * the database like www.www. 228 228 * 229 * Return the doubled up subdomain if it exists, otherwise null.229 * Return the doubled-up subdomain if it exists, otherwise null. 230 230 * 231 231 * @since 6.1.0 … … 233 233 * @return string|null 234 234 */ 235 public function get_doubled_up_subdomain() {235 public function get_doubled_up_subdomain(): ?string { 236 236 if ( static::is_subdomain( $this->old_url, $this->new_url ) ) { 237 237 return \str_replace( $this->old_url, $this->new_url, $this->new_url ); … … 255 255 * @return string[] 256 256 */ 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(); 259 260 260 261 $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 ) { 264 267 // 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' ); 267 273 } 268 274 -
go-live-update-urls/trunk/go-live-update-urls.php
r3369773 r3414590 6 6 * Author: OnPoint Plugins 7 7 * Author URI: https://onpointplugins.com 8 * Version: 7.0. 68 * Version: 7.0.7 9 9 * Text Domain: go-live-update-urls 10 10 * Domain Path: /languages/ … … 16 16 */ 17 17 18 define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0. 6' );18 define( 'GO_LIVE_UPDATE_URLS_VERSION', '7.0.7' ); 19 19 define( 'GO_LIVE_UPDATE_URLS_REQUIRED_PRO_VERSION', '7.1.0' ); 20 20 define( 'GO_LIVE_UPDATE_URLS_URL', plugin_dir_url( __FILE__ ) ); -
go-live-update-urls/trunk/readme.txt
r3369773 r3414590 4 4 Tags: search and replace, database, urls, domain, update urls 5 5 Requires at least: 6.2.0 6 Tested up to: 6. 8.26 Tested up to: 6.9.0 7 7 Requires PHP: 7.4.0 8 Stable tag: 7.0. 68 Stable tag: 7.0.7 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 122 122 123 123 == 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 124 131 = 7.0.6 = 125 132 * Tested to WordPress 6.8.2. -
go-live-update-urls/trunk/src/Core.php
r3216196 r3414590 85 85 86 86 /** 87 * Quick and dirty update of entire blog87 * Quick and dirty update of the entire blog 88 88 * 89 89 * Mostly used for unit testing and future WP-CLI command … … 107 107 108 108 /** 109 * Display custom action links in pluginslist.109 * Display custom action links in the plugin list. 110 110 * 111 111 * 1. Settings. 112 * 2. Go PRO. 112 * 2. Documentation. 113 * 3. Go PRO. 113 114 * 114 * @param array $actions - Array of actions and their link.115 * @param array<string, string> $actions - Array of actions and their link. 115 116 * 116 * @return array 117 * @return array<string, string> 117 118 */ 118 119 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' ) ); 120 123 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' ) ); 122 125 } 123 126 return $actions; -
go-live-update-urls/trunk/src/Database.php
r3159918 r3414590 15 15 16 16 /** 17 * Get list of tables we treat as serialized when updating17 * Get the list of tables we treat as serialized when updating 18 18 * 19 19 * @since 5.0.0 … … 22 22 */ 23 23 public function get_serialized_tables() { 24 global $wpdb;24 $wpdb = $this->get_wpdb(); 25 25 // Default tables with serialized data. 26 26 $serialized_tables = [ … … 68 68 */ 69 69 public function get_core_tables() { 70 global $wpdb;70 $wpdb = $this->get_wpdb(); 71 71 72 72 $tables = [ … … 137 137 */ 138 138 public function get_all_table_names() { 139 global $wpdb;139 $wpdb = $this->get_wpdb(); 140 140 $query = "SELECT TABLE_NAME as TableName FROM information_schema.TABLES WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->esc_like( $wpdb->prefix ) . "%'"; 141 141 … … 227 227 */ 228 228 public function update_column( $table, $column, $old_url, $new_url ): int { 229 global $wpdb;229 $wpdb = $this->get_wpdb(); 230 230 231 231 $count = $this->count_column_urls( $table, $column, $old_url ); … … 244 244 245 245 /** 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. 247 247 * 248 248 * When updating, the serialized data is updated first and this … … 261 261 */ 262 262 public function count_column_urls( $table, $column, $old_url ): int { 263 global $wpdb;263 $wpdb = $this->get_wpdb(); 264 264 265 265 $query = "SELECT SUM( ROUND( ( LENGTH( `{$column}` ) - LENGTH( REPLACE( `{$column}`, %s, '' ) ) ) / LENGTH( %s ) ) ) from `{$table}`"; 266 266 267 267 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']; 268 278 } 269 279 -
go-live-update-urls/trunk/src/Updates.php
r3216196 r3414590 10 10 * 11 11 * While no updates to the database are done within this class, 12 * all calls to the methods ,which update the database go through here12 * all calls to the methods which update the database go through here 13 13 * except for serialized data. 14 14 * 15 * This class determines ,which data needs to be updated in which way16 * and makes necessary calls.15 * This class determines which data needs to be updated in which way 16 * and makes the necessary calls. 17 17 * 18 18 * @since 6.1.0 … … 24 24 * @var string 25 25 */ 26 protected $old_url;26 protected string $old_url; 27 27 28 28 /** … … 31 31 * @var string 32 32 */ 33 protected $new_url;33 protected string $new_url; 34 34 35 35 /** … … 38 38 * @var string[] 39 39 */ 40 protected $tables;40 protected array $tables; 41 41 42 42 … … 110 110 * 111 111 * 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 that112 * is using the original domain, we end up with an email address that 113 113 * includes @www We remove the prepended www from email addresses 114 114 * here. … … 133 133 * of the URL. 134 134 * 135 * Actual translation and updating ishandled by each updater.135 * Actual translation and updating handled by each updater. 136 136 * We simply load and call them here. 137 137 * … … 163 163 * of the URL. 164 164 * 165 * Actual counting ishandled by each updater.165 * Actual counting handled by each updater. 166 166 * We simply load and call them here. 167 167 * … … 224 224 /** 225 225 * If the new domain is the old one with a new subdomain like www. 226 * the first round of updates will create double subdomains in226 * The first round of updates will create double subdomains in 227 227 * the database like www.www. 228 228 * 229 * Return the doubled up subdomain if it exists, otherwise null.229 * Return the doubled-up subdomain if it exists, otherwise null. 230 230 * 231 231 * @since 6.1.0 … … 233 233 * @return string|null 234 234 */ 235 public function get_doubled_up_subdomain() {235 public function get_doubled_up_subdomain(): ?string { 236 236 if ( static::is_subdomain( $this->old_url, $this->new_url ) ) { 237 237 return \str_replace( $this->old_url, $this->new_url, $this->new_url ); … … 255 255 * @return string[] 256 256 */ 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(); 259 260 260 261 $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 ) { 264 267 // 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' ); 267 273 } 268 274
Note: See TracChangeset
for help on using the changeset viewer.