nu_id' => $original_id, 'new_menu_id' => $post_id, ]; set_transient( 'ocdi_import_menu_mapping', $ocdi_menu_mapping, HOUR_IN_SECONDS ); } } /** * Fix issue with WP Navigation block. * * We did this by looping through all the imported posts with the WP Navigation block * and replacing the original menu ID with the new menu ID. * * @since 3.2.0 */ public function fix_imported_wp_navigation() { // Get the `wp_navigation` import mapping. $nav_import_mapping = get_transient( 'ocdi_import_menu_mapping' ); // Get the post IDs that needs to be updated. $posts_nav_block = get_transient( 'ocdi_import_posts_with_nav_block' ); if ( empty( $nav_import_mapping ) || empty( $posts_nav_block ) ) { return; } $replace_pairs = []; foreach ( $nav_import_mapping as $mapping ) { $replace_pairs[ '' ] = ''; } // Loop through each the posts that needs to be updated. foreach ( $posts_nav_block as $post_id ) { $post_nav_block = get_post( $post_id ); if ( empty( $post_nav_block ) || empty( $post_nav_block->post_content ) ) { return; } wp_update_post( [ 'ID' => $post_id, 'post_content' => strtr( $post_nav_block->post_content, $replace_pairs ), ] ); } } /** * Update imported terms count. */ private function update_terms_count() { foreach ( $this->imported_terms as $tax => $terms ) { wp_update_term_count_now( $terms, $tax ); } } /** * Get the import buttons HTML for the successful import page. * * @since 3.2.0 * * @return string */ public function get_import_successful_buttons_html() { /** * Filter the buttons that are displayed on the successful import page. * * @since 3.2.0 * * @param array $buttons { * Array of buttons. * * @type string $label Button label. * @type string $class Button class. * @type string $href Button URL. * @type string $target Button target. Can be `_blank`, `_parent`, `_top`. Default is `_self`. * } */ $buttons = Helpers::apply_filters( 'ocdi/import_successful_buttons', [ [ 'label' => __( 'Theme Settings' , 'one-click-demo-import' ), 'class' => 'button button-primary button-hero', 'href' => admin_url( 'customize.php' ), 'target' => '_blank', ], [ 'label' => __( 'Visit Site' , 'one-click-demo-import' ), 'class' => 'button button-primary button-hero', 'href' => get_home_url(), 'target' => '_blank', ], ] ); if ( empty( $buttons ) || ! is_array( $buttons ) ) { return ''; } ob_start(); foreach ( $buttons as $button ) { if ( empty( $button['href'] ) || empty( $button['label'] ) ) { continue; } $target = '_self'; if ( ! empty( $button['target'] ) && in_array( strtolower( $button['target'] ), [ '_blank', '_parent', '_top' ], true ) ) { $target = $button['target']; } $class = 'button button-primary button-hero'; if ( ! empty( $button['class'] ) ) { $class = $button['class']; } printf( '%4$s', esc_url( $button['href'] ), esc_attr( $class ), esc_attr( $target ), esc_html( $button['label'] ) ); } $buttons_html = ob_get_clean(); return empty( $buttons_html ) ? '' : $buttons_html; } }