'Permission Denied' ) ); } // Trigger the migration. Spectra_Migrate_Blocks::get_instance()->blocks_migration(); // Update the migration status to 'no' before starting. update_option( 'uag_migration_status', 'yes' ); // Set a new option to know that the migration process has started. update_option( 'uag_migration_progress_status', 'in-progress' ); // Prepare the response. $response = array( 'success' => true, 'data' => array( 'message' => esc_html__( 'Migration started successfully.', 'ultimate-addons-for-gutenberg' ), ), ); // Send JSON response. wp_send_json_success( $response ); } /** * Callback function to display migration log page content. * * @since 2.13.9 * @return void */ public function handle_log_download() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to access this page.', 'ultimate-addons-for-gutenberg' ) ); } $log_file = ABSPATH . 'wp-content/uploads/migration-log.txt'; if ( file_exists( $log_file ) ) { header( 'Content-Description: File Transfer' ); header( 'Content-Type: application/octet-stream' ); header( 'Content-Disposition: attachment; filename="' . basename( $log_file ) . '"' ); header( 'Expires: 0' ); header( 'Cache-Control: must-revalidate' ); header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $log_file ) ); flush(); // Flush system output buffer. readfile( $log_file ); exit; } else { wp_die( esc_html__( 'Log file not found.', 'ultimate-addons-for-gutenberg' ) ); } } /** * Updates the Gutenberg templates pro URL. * This function returns the URL for the pro version of Gutenberg templates. * * @since 2.13.7 * @return string The URL for Spectra Webpage. */ public function update_gutenberg_templates_pro_url() { return \UAGB_Admin_Helper::get_spectra_pro_url( '/pricing/', 'gutenberg-templates', 'dashboard', 'Starter-Template-Backend' ); } /** * Update Old user option using URL Param. * * If any user wants to set the site as old user then just add the URL param as true. * * @since 2.0.1 * @access public */ public function update_old_user_option_by_url_params() { if ( ! current_user_can( 'manage_options' ) ) { return; } $spectra_old_user = isset( $_GET['spectra_old_user'] ) ? sanitize_text_field( $_GET['spectra_old_user'] ) : false; //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $_GET['spectra_old_user'] does not provide nonce. if ( 'yes' === $spectra_old_user ) { update_option( 'uagb-old-user-less-than-2', 'yes' ); } elseif ( 'no' === $spectra_old_user ) { delete_option( 'uagb-old-user-less-than-2' ); } } /** * UAG version rollback. * * Rollback to previous UAG version. * * Fired by `admin_post_uag_rollback` action. * * @since 1.23.0 * @access public */ public function post_uagb_rollback() { if ( ! current_user_can( 'install_plugins' ) ) { wp_die( esc_html__( 'You do not have permission to access this page.', 'ultimate-addons-for-gutenberg' ), esc_html__( 'Rollback to Previous Version', 'ultimate-addons-for-gutenberg' ), array( 'response' => 200, ) ); } check_admin_referer( 'uag_rollback' ); $rollback_versions = UAGB_Admin_Helper::get_instance()->get_rollback_versions(); $update_version = isset( $_GET['version'] ) ? sanitize_text_field( $_GET['version'] ) : ''; if ( empty( $update_version ) || ! in_array( $update_version, $rollback_versions, true ) ) { wp_die( esc_html__( 'Error occurred, The version selected is invalid. Try selecting different version.', 'ultimate-addons-for-gutenberg' ) ); } $plugin_slug = basename( UAGB_FILE, '.php' ); $rollback = new UAGB_Rollback( array( 'version' => $update_version, 'plugin_name' => UAGB_BASE, 'plugin_slug' => $plugin_slug, 'package_url' => sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $update_version ), ) ); $rollback->run(); wp_die( '', esc_html__( 'Rollback to Previous Version', 'ultimate-addons-for-gutenberg' ), array( 'response' => 200, ) ); } /** * Activation Reset */ public function activation_redirect() { $do_redirect = apply_filters( 'uagb_enable_redirect_activation', get_option( '__uagb_do_redirect' ) ); if ( $do_redirect ) { update_option( '__uagb_do_redirect', false ); if ( ! is_multisite() ) { wp_safe_redirect( add_query_arg( array( 'page' => UAGB_SLUG, 'spectra-activation-redirect' => true, ), admin_url( 'admin.php' ) ) ); exit(); } } } /** * Filters and Returns a list of allowed tags and attributes for a given context. * * @param Array $allowedposttags Array of allowed tags. * @param String $context Context type (explicit). * @since 1.8.0 * @return Array */ public function add_data_attributes( $allowedposttags, $context ) { $allowedposttags['a']['data-repeat-notice-after'] = true; return $allowedposttags; } /** * Ask Plugin Rating * * @since 1.8.0 */ public function register_notices() { // Check if assets should be excluded for the current post type. if ( UAGB_Admin_Helper::should_exclude_assets_for_cpt() ) { return; // Early return to prevent loading assets. } if ( ! current_user_can( 'manage_options' ) ) { return; } $image_path = UAGB_URL . 'admin-core/assets/images/uag-logo.svg'; if ( ! get_option( 'uag_migration_status', false ) && 'yes' === get_option( 'uagb-old-user-less-than-2' ) && 'in-progress' !== get_option( 'uag_migration_progress_status', '' ) ) { Astra_Notices::add_notice( array( 'id' => 'uagb-block-migration_status', 'type' => '', 'message' => sprintf( // Translators: %1$s: Spectra logo, %2$s: migration note , %3$s: The closing tag, %4$s: migration description, %5$s: migration button placeholder, %6$s: Learn more button, %7$s: learn more placeholder. '