p@ p@ p@ p@ p@ p@ @ P@ @ @ 0@ 0@ @ @ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ p@ @ @ p@ О@ @ @ Р@ Р@ @ @ @ @ P@ p@ @ @ @ @ @ P@ 0@ p@ @ @ P@ p@ @ @ @ @ @ P@ 0@ @ @ @ @ @ p@ @ @ P@ p@ @ @ @ @ @ P@ 0@ p@ @ @ P@ p@ @ @ @ @ @ P@ 0@ @ @ @ @ @ @ p@ @ P@ @ 0@ @ @ @ @ p@ p@ @ @ 0@ @ @ p@ @ @ p@ Р@ @ P@ P@ P@ P@ P@ 0@ @ @ @ @ P@ 0@ 0@ p@ @ P@ @ p@ P@ @ p@ @ @ @ P@ @ @ 0@ @ P@ @ @ P@ @ @ @ @ P@ 0@ @ @ @ P@ @ @ @ @ 0@ Ж@ p@ И@ p@ Й@ @ @ 0@ П@ К@ P@ @ @ @ P@ Р@ @ 0@ Ж@ p@ И@ p@ Й@ @ p@ @ @ 0@ Ж@ p@ И@ p@ Й@ p@ Р@ О@ @ @ 0@ Ж@ p@ И@ p@ Й@ П@ @ @ P@ P@ @ @ Р@ @ 0@ @ @ @ P@ P@ @ @ П@ @ @ p@ @ @ @ @ @ @ @ p@ @ @ @ @ @ R p@ @ P@ p@ p@ @ P@ @ @ * * @since 6.14.0 * * @return bool */ public function is_old_plugin_installed(): bool { if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = get_plugins(); return array_key_exists( 'the-events-calendar-category-colors/the-events-calendar-category-colors.php', $plugins ); } /** * Checks if migration has not started. * * @since 6.14.0 * * @return bool */ public function is_migration_not_started(): bool { $migration_status = Status::get_migration_status(); return ( ! isset( $migration_status['status'] ) || $migration_status['status'] === Status::$not_started ); } /** * Checks if the plugin has any category meta values. * * @since 6.14.0 * * @return bool */ public function has_category_meta(): bool { $categories = get_terms( [ 'taxonomy' => Tribe__Events__Main::TAXONOMY, 'hide_empty' => false, 'number' => 1, ] ); if ( empty( $categories ) ) { return false; } // Check for border color meta (primary in new system). return ! empty( get_term_meta( $categories[0]->term_id, Config::META_KEY_PREFIX . Config::META_KEY_MAP['border'], true ) ); } /** * Checks if the plugin has original settings. * * @since 6.14.0 * * @return bool */ public function has_original_settings(): bool { return ! empty( get_option( Config::ORIGINAL_SETTINGS_OPTION ) ); } /** * Deactivates the legacy plugin. * * @since 6.14.0 * * @return void */ public function deactivate_plugin(): void { deactivate_plugins( self::PLUGIN_FILE ); } /** * Handles the migration process when the user clicks the migration button. * * @since 6.14.0 */ public function handle_migration(): void { check_admin_referer( 'tec_start_category_colors_migration' ); if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to perform this action.', 'the-events-calendar' ) ); } $flow = tribe( Migration_Flow::class ); $result = $flow->initialize(); if ( is_wp_error( $result ) ) { // Show error notice. AdminNotices::show( 'tec_category_colors_migration_error', sprintf( '
%s
%s
', __( 'Migration Error', 'the-events-calendar' ), $result->get_error_message() ) ) ->urgency( 'error' ) ->dismissible( true ) ->inline( true ); } else { // Set a one-time user meta flag for the background notice. update_user_meta( get_current_user_id(), '_tec_category_colors_migration_notice', 1 ); } // Redirect back to the same page (no redirect to category page). //phpcs:ignore WordPressVIPMinimum.Security.ExitAfterRedirect.NoExit wp_safe_redirect( wp_get_referer() ?: admin_url() ); tribe_exit(); } /** * Disables the save button for the Category Colors settings tab. * * @since 6.14.0 * * @param array