[ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Install/Upgrade routines for the database. 4 * 5 * @package GlotPress 6 * @since 1.0.0 7 */ 8 9 /** 10 * Runs the install/upgrade of the database. 11 * 12 * @since 1.0.0 13 */ 14 function gp_upgrade_db() { 15 global $wpdb; 16 17 $gp_db_version = get_option( 'gp_db_version' ); 18 19 if ( $gp_db_version && $gp_db_version < 980 ) { 20 $wpdb->query( "ALTER TABLE {$wpdb->gp_translation_sets} DROP INDEX project_id_slug_locale, DROP INDEX locale_slug;" ); 21 $wpdb->query( "ALTER TABLE {$wpdb->gp_originals} DROP INDEX singular_plural_context;" ); 22 $wpdb->query( "ALTER TABLE {$wpdb->gp_meta} DROP INDEX object_type__meta_key, DROP INDEX object_type__object_id__meta_key;" ); 23 } 24 25 dbDelta( implode( "\n", gp_schema_get() ) ); 26 27 if ( $gp_db_version ) { 28 gp_upgrade_data( $gp_db_version ); 29 } 30 31 update_option( 'gp_db_version', GP_DB_VERSION ); 32 } 33 34 /** 35 * Updates existing data in the database during an upgrade. 36 * 37 * @since 1.0.0 38 * 39 * @param int $db_version The current version of the database before the upgrade. 40 */ 41 function gp_upgrade_data( $db_version ) { 42 global $wpdb; 43 44 if ( $db_version < 950 ) { 45 $wpdb->query( "UPDATE {$wpdb->gp_projects} SET `path` = SUBSTRING(`path`, 1, CHAR_LENGTH(`path`) - 1) WHERE `path` LIKE '%/';" ); 46 } 47 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Nov 23 01:01:06 2024 | Cross-referenced by PHPXref 0.7.1 |