Skip to content

Commit

Permalink
Merge pull request #411 from 10up/enhancement/30
Browse files Browse the repository at this point in the history
ClassifAI NUX
  • Loading branch information
dkotter authored Apr 28, 2023
2 parents b5ac7b6 + bf50c93 commit ae7f106
Show file tree
Hide file tree
Showing 31 changed files with 23,076 additions and 282 deletions.
Binary file added assets/img/classifai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/onboarding-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/onboarding-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions classifai.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function classifai_define( $name, $value ) {
}

require_once __DIR__ . '/config.php';
classifai_define( 'CLASSIFAI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );

/**
* Loads the CLASSIFAI PHP autoloader if possible.
Expand Down
32 changes: 26 additions & 6 deletions includes/Classifai/Admin/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ public function can_register() {
*/
public function register() {
add_action( 'classifai_activation_hook', [ $this, 'add_activation_notice' ] );
add_action( 'admin_notices', [ $this, 'maybe_render_notices' ] );
add_action( 'admin_notices', [ $this, 'maybe_render_notices' ], 0 );
}

/**
* Respond to the activation hook.
*/
public function maybe_render_notices() {
$registration_settings = get_option( 'classifai_settings' );
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';

if (
'classifai_settings' === get_current_screen()->parent_base &&
'classifai' === $page &&
( ! isset( $registration_settings['valid_license'] ) || ! $registration_settings['valid_license'] )
) {
$notice_url = 'https://classifaiplugin.com/#cta';
Expand All @@ -48,10 +50,28 @@ public function maybe_render_notices() {

$needs_setup = get_transient( 'classifai_activation_notice' );
if ( $needs_setup ) {
printf(
'<div class="notice notice-warning"><p><a href="%s">' . esc_html__( 'ClassifAI requires setup', 'classifai' ) . '</a></p></div>',
esc_url( admin_url( 'admin.php?page=classifai_settings' ) )
);
if ( Onboarding::is_onboarding_completed() ) {
delete_transient( 'classifai_activation_notice' );
return;
}

// Prevent showing the default WordPress "Plugin Activated" notice.
unset( $_GET['activate'] ); // phpcs:ignore WordPress.Security.NonceVerification
?>
<div data-notice="plugin-activation" class="notice notice-success is-dismissible">
<div id="classifai-activation-notice">
<div class="classifai-logo">
<img src="<?php echo esc_url( CLASSIFAI_PLUGIN_URL . 'assets/img/classifai.png' ); ?>" alt="<?php esc_attr_e( 'ClassifAI', 'classifai' ); ?>" />
</div>
<h3 class="classifai-activation-message">
<?php esc_html_e( 'Congratulations, the ClassifAI plugin is now activated.', 'classifai' ); ?>
</h3>
<a class="classifai-button" href="<?php echo esc_url( admin_url( 'admin.php?page=classifai_setup' ) ); ?>">
<?php esc_html_e( 'Start setup', 'classifai' ); ?>
</a>
</div>
</div>
<?php
delete_transient( 'classifai_activation_notice' );
}
}
Expand Down
Loading

0 comments on commit ae7f106

Please sign in to comment.