*/ namespace RankMath\Wizard; use RankMath\KB; use RankMath\Admin\Importers\Detector; defined( 'ABSPATH' ) || exit; /** * Step class. */ class Import implements Wizard_Step { /** * Render step body. * * @param object $wizard Wizard class instance. * * @return void */ public function render( $wizard ) { ?>

cmb->show_form(); ?>
0%
detect(); $count = 0; foreach ( $plugins as $slug => $plugin ) { $checked = 'checked'; $multi_checked = 'multicheck-checked'; $choices = array_keys( $plugin['choices'] ); if ( ( array_key_exists( 'seopress', $plugins ) && ( in_array( $slug, [ 'yoast', 'yoast-premium', 'aioseo' ], true ) ) ) || ( array_key_exists( 'yoast', $plugins ) || array_key_exists( 'yoast-premium', $plugins ) ) && 'aioseo' === $slug ) { $checked = ''; $multi_checked = ''; $choices = []; } $field_args = [ 'id' => 'import_from_' . $slug, 'type' => 'group', 'description' => '', 'before_group' => 0 === $count ? '

' . esc_html__( 'Input Data From:', 'rank-math' ) . '

' : '', 'repeatable' => false, 'options' => [ 'group_title' => $plugin['name'], 'sortable' => false, 'closed' => true, ], ]; $group_id = $wizard->cmb->add_field( $field_args ); $is_active = is_plugin_active( $plugin['file'] ); $wizard->cmb->add_group_field( $group_id, [ 'id' => $slug . '_meta', 'type' => 'multicheck', 'repeatable' => false, 'desc' => $this->get_choice_description( $slug, $plugin, $is_active ), 'options' => $plugin['choices'], 'default' => $choices, 'dep' => [ [ 'import_from', $slug ] ], 'classes' => 'nob nopb cmb-multicheck-inline with-description ' . $multi_checked . ' ' . $is_active, 'attributes' => [ 'data-active' => $is_active ], ]); $count++; } } /** * Save handler for step. * * @param array $values Values to save. * @param object $wizard Wizard class instance. * * @return bool */ public function save( $values, $wizard ) { return true; } /** * Get description for choice field. * * @param string $slug Plugin slug. * @param array $plugin Plugin info array. * @param boolean $is_active Is plugin active. * * @return string */ private function get_choice_description( $slug, $plugin, $is_active ) { /* translators: 1 is plugin name */ $desc = 'aio-rich-snippet' === $slug ? esc_html__( 'Import meta data from the %1$s plugin.', 'rank-math' ) : esc_html__( 'Import settings and meta data from the %1$s plugin.', 'rank-math' ); /* translators: 2 is link to Knowledge Base article */ $desc .= __( 'The process may take a few minutes if you have a large number of posts or pages Learn more about the import process here.', 'rank-math' ); if ( $is_active ) { /* translators: 1 is plugin name */ $desc .= '
' . __( ' %1$s plugin will be disabled automatically moving forward to avoid conflicts. It is thus recommended to import the data you need now.', 'rank-math' ); } return sprintf( wp_kses_post( $desc ), $plugin['name'], KB::get( 'seo-import' ) ); } }