get_results( "SHOW TABLES LIKE 'anycomment_email_queue';", 'ARRAY_A' ); $isTableCreated = ! empty( $res ) && count( $res ) == 1; return $isTableCreated; } /** * {@inheritdoc} */ public function up() { /** * Modify VK API options */ $option = get_option( 'anycomment-social', true ); if ( isset( $option['social_vk_toggle_field'] ) ) { $option['social_vkontakte_toggle_field'] = $option['social_vk_toggle_field']; unset( $option['social_vk_toggle_field'] ); } if ( isset( $option['social_vk_app_id_field'] ) ) { $option['social_vkontakte_app_id_field'] = $option['social_vk_app_id_field']; unset( $option['social_vk_app_id_field'] ); } if ( isset( $option['social_vk_app_secret_field'] ) ) { $option['social_vkontakte_app_secret_field'] = $option['social_vk_app_secret_field']; unset( $option['social_vk_app_secret_field'] ); } update_option( 'anycomment-social', $option ); global $wpdb; $charset_collate = $wpdb->get_charset_collate(); $table = 'anycomment_email_queue'; /** * Create email queue table */ $sql = "CREATE TABLE `$table` ( `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `user_ID` bigint(20) UNSIGNED NOT NULL, `post_ID` bigint(20) UNSIGNED NOT NULL, `comment_ID` bigint(20) UNSIGNED NOT NULL, `content` LONGTEXT COLLATE utf8_unicode_ci NOT NULL, `ip` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `user_agent` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `sent_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`ID`), KEY `user_ID` (`user_ID`), KEY `post_ID` (`post_ID`), KEY `comment_ID` (`comment_ID`) ) $charset_collate"; return ( $wpdb->query( $sql ) !== false ) ? true : false; } /** * {@inheritdoc} */ public function down() { $option = get_option( 'anycomment-social' ); $option['social_vk_toggle_field'] = $option['social_vkontakte_toggle_field']; $option['social_vk_app_id_field'] = $option['social_vkontakte_app_id_field']; $option['social_vk_app_secret_field'] = $option['social_vkontakte_app_secret_field']; unset( $option['social_vkontakte_toggle_field'] ); unset( $option['social_vkontakte_app_id_field'] ); unset( $option['social_vkontakte_app_secret_field'] ); $isVkOptionUpdated = update_option( 'anycomment-social', $option ); /** * Drop email queue table if exist, will be ignored when not exists */ global $wpdb; $sql = "DROP TABLE IF EXISTS anycomment_email_queue;"; $wpdb->query( $sql ); return $isVkOptionUpdated; } } // eof;