| @@ -45,8 +45,15 @@ | ||
| 45 | 45 | */ |
| 46 | 46 | private $settings; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | + * KBMigration | |
| 50 | + * | |
| 51 | + * @var KBMigration | |
| 52 | + */ | |
| 53 | + private $kbmigration; | |
| 54 | + | |
| 55 | + /** | |
| 49 | 56 | * Enqueue |
| 50 | 57 | * @var Enqueue |
| 51 | 58 | */ |
| 52 | 59 | private $assets; |
| @@ -56,12 +63,13 @@ | ||
| 56 | 63 | * @var FAQBuilder |
| 57 | 64 | */ |
| 58 | 65 | private $faq_builder; |
| 59 | 66 | |
| 60 | - public function __construct( Container $container, PostType $type, Enqueue $assets, Settings $settings ) { | |
| 67 | + public function __construct( Container $container, PostType $type, Enqueue $assets, Settings $settings, KBMigration $kbmigration ) { | |
| 61 | 68 | $this->container = $container; |
| 62 | 69 | $this->assets = $assets; |
| 63 | 70 | $this->settings = $settings; |
| 71 | + $this->kbmigration = $kbmigration; | |
| 64 | 72 | $this->slug = 'betterdocs-admin'; |
| 65 | 73 | |
| 66 | 74 | add_action( 'init', [ $type, 'register' ], 9 ); |
| 67 | 75 | |
| @@ -102,9 +110,10 @@ | ||
| 102 | 110 | add_filter( 'manage_docs_posts_custom_column', [ $this, 'manage_custom_columns' ], 10, 2 ); |
| 103 | 111 | |
| 104 | 112 | self::$cache_bank = CacheBank::get_instance(); |
| 105 | 113 | try { |
| 106 | - $this->notices(); | |
| 114 | + // $this->notices(); | |
| 115 | + add_action('admin_init', [$this, 'notices']); | |
| 107 | 116 | } catch ( Exception $e ) { |
| 108 | 117 | unset( $e ); |
| 109 | 118 | } |
| 110 | 119 | // Remove OLD notice from 1.0.0 (if other WPDeveloper plugin has notice) |
| @@ -212,15 +221,55 @@ | ||
| 212 | 221 | $notices->add( 'review', $_review_notice, [ |
| 213 | 222 | 'start' => $notices->strtotime( '+10 days' ), |
| 214 | 223 | 'recurrence' => 30, |
| 215 | 224 | 'dismissible' => true |
| 216 | - // 'screens' => [ | |
| 217 | - // 'dashboard', 'plugins', 'themes', 'edit-page', | |
| 218 | - // 'edit-post', 'users', 'tools', 'options-general', | |
| 219 | - // 'nav-menus', 'toplevel_page_betterdocs-admin', 'betterdocs_page_betterdocs-settings', 'betterdocs_page_betterdocs-analytics', 'betterdocs_page_betterdocs-faq', 'edit-doc_tag', 'edit-doc_category' | |
| 220 | - // ] | |
| 221 | 225 | ] ); |
| 222 | 226 | |
| 227 | + if ( $this->kbmigration->existing_plugins && ! in_array( $this->kbmigration->existing_plugins[0][0], $this->kbmigration->migrated_plugins ) ) { | |
| 228 | + $migration_message = sprintf( | |
| 229 | + '<p class="migration-message">%s</p><a class="button button-primary betterdocs-migration-notice" href="%s">%s</a>', | |
| 230 | + __( | |
| 231 | + sprintf( | |
| 232 | + 'Already using %s? Power up your Knowledge Base by migrating all your docs, settings to BetterDocs with just 1 click.', | |
| 233 | + '<strong>' . esc_html($this->kbmigration->existing_plugins[0][1]) . '</strong>', | |
| 234 | + '<strong>' . esc_html($this->kbmigration->existing_plugins[0][1]) . '</strong>' | |
| 235 | + ), | |
| 236 | + 'betterdocs' | |
| 237 | + ), | |
| 238 | + esc_url(admin_url('admin.php?page=betterdocs-settings&tab=tab-migration')), | |
| 239 | + __('Start Migration', 'betterdocs') | |
| 240 | + ); | |
| 241 | + | |
| 242 | + $_migration_notice = [ | |
| 243 | + 'thumbnail' => '', | |
| 244 | + 'html' => $migration_message, | |
| 245 | + 'links' => [ | |
| 246 | + 'maybe_later' => [ | |
| 247 | + 'label' => __( 'Maybe Later', 'betterdocs' ), | |
| 248 | + 'icon_class' => 'dashicons dashicons-calendar-alt', | |
| 249 | + 'attributes' => [ | |
| 250 | + 'data-later' => true, | |
| 251 | + 'class' => 'dismiss-btn' | |
| 252 | + ] | |
| 253 | + ], | |
| 254 | + 'never_show_again' => [ | |
| 255 | + 'label' => __( 'Never show again', 'betterdocs' ), | |
| 256 | + 'icon_class' => 'dashicons dashicons-dismiss', | |
| 257 | + 'attributes' => [ | |
| 258 | + 'data-dismiss' => true | |
| 259 | + ] | |
| 260 | + ] | |
| 261 | + ] | |
| 262 | + ]; | |
| 263 | + | |
| 264 | + $notices->add( 'migration', $_migration_notice, [ | |
| 265 | + 'start' => $notices->time(), | |
| 266 | + 'recurrence' => false, | |
| 267 | + 'dismissible' => true, | |
| 268 | + 'display_if' => current_user_can( 'delete_users' ) | |
| 269 | + ] ); | |
| 270 | + } | |
| 271 | + | |
| 223 | 272 | /** |
| 224 | 273 | * Opt-In Notice |
| 225 | 274 | */ |
| 226 | 275 | if ( $this->insights != null ) { |
| @@ -419,12 +468,13 @@ | ||
| 419 | 468 | 'betterdocs_pro_plugin' => betterdocs()->is_pro_active() |
| 420 | 469 | ] ); |
| 421 | 470 | } |
| 422 | 471 | |
| 423 | - if ( ! in_array( $hook, [ 'toplevel_page_betterdocs-admin', 'betterdocs_page_betterdocs-analytics' ] ) ) { | |
| 472 | + if ( ! in_array( $hook, ['term.php', 'edit-tags.php','toplevel_page_betterdocs-admin', 'betterdocs_page_betterdocs-analytics' ] ) ) { | |
| 424 | 473 | return; |
| 425 | 474 | } |
| 426 | 475 | |
| 476 | + wp_enqueue_script('wp-editor'); //enqueued on betterdocs-term pages to show SEO data from Yoast | |
| 427 | 477 | wp_enqueue_script( 'wp-color-picker' ); |
| 428 | 478 | |
| 429 | 479 | $this->assets->enqueue( 'betterdocs-select2', 'vendor/js/select2.min.js', [] ); |
| 430 | 480 | $this->assets->enqueue( 'betterdocs-sweetalert', 'vendor/js/sweetalert.min.js', [] ); |