1, 'completed' => 0, 'first_run' => 1 ), '', false ); } $setup_state = get_option( 'sitelang_setup_wizard', array() ); if ( is_array( $setup_state ) && empty( $setup_state['completed'] ) && get_current_user_id() ) { set_transient( 'sitelang_activation_redirect_' . get_current_user_id(), 1, MINUTE_IN_SECONDS ); } } /** * Deactivate plugin. * * @return void */ public static function deactivate() { wp_clear_scheduled_hook( 'sitelang_license_heartbeat' ); flush_rewrite_rules(); } /** * Create mapping table. * * Data model: * - translations are normal WordPress posts/products for native editing. * - this table is the authoritative relation between original and language version. * - post meta mirrors the relation for fast admin queries and compatibility. * * @return void */ public static function create_tables() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table = $wpdb->prefix . 'sitelang_translations'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE {$table} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, original_id bigint(20) unsigned NOT NULL, translation_id bigint(20) unsigned NOT NULL, language_code varchar(20) NOT NULL, content_type varchar(40) NOT NULL, status varchar(30) NOT NULL DEFAULT 'draft', inherit_product_data tinyint(1) NOT NULL DEFAULT 0, created_at datetime NOT NULL, updated_at datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY original_language (original_id, language_code), UNIQUE KEY translation_language (translation_id, language_code), KEY translation_id (translation_id), KEY content_type (content_type) ) {$charset_collate};"; dbDelta( $sql ); } /** * Seed default options. * * @return void */ private static function seed_options() { if ( false === get_option( 'sitelang_languages', false ) ) { add_option( 'sitelang_languages', array(), '', false ); } if ( false === get_option( 'sitelang_settings', false ) ) { add_option( 'sitelang_settings', array( 'default_language' => 'en', 'default_label' => 'English', 'default_native' => 'English', 'default_flag' => 'us', 'switcher_mode' => 'dropdown', 'switcher_show_flag' => 1, 'switcher_show_name' => 0, 'switcher_radius' => 6, 'switcher_custom_hover' => 0, 'switcher_hover_bg' => '#eaf3f5', 'switcher_hover_text' => '#045f78', 'switcher_bg' => '#ffffff', 'switcher_text' => '#1f2937', 'switcher_accent' => '#b68b2d', 'switcher_placement' => 'header-floating', 'hook_enabled' => 0, 'hook_name' => '', 'homepages' => array(), ), '', false ); } } }