id ? true : false ); } /** * Check if we should show the a notice. * * @param string $type The notice type. * @return bool */ public function should_show_notice( $type = 'discount' ) { $notices = get_option( 'kirki_notices', [] ); // Stop here if notice has been dismissed. if ( isset( $notices[ $type . '_notice' ] ) ) { return false; } // Stop here if we're on our settings page. if ( $this->is_settings_page() ) { return false; } // Stop here if current user can't manage options. if ( ! current_user_can( 'manage_options' ) ) { return false; } return true; } /** * Discount notice. */ public function discount_notice() { // Stop here if the notice shouldn't be shown. if ( ! $this->should_show_notice( 'discount' ) ) { return; } ?>

Font Display Issues? Clear the Font Cache in Kirki

New! Easily resolve font display issues by clearing the Font Cache in Kirki. This one-click solution fixes problems caused by domain name changes or site migrations.

Learn more

should_show_notice( 'discount' ) ) { return; } wp_enqueue_style( 'kirki-admin-notice', KIRKI_PLUGIN_URL . '/kirki-packages/settings/dist/admin-notice.css', array(), KIRKI_VERSION ); wp_enqueue_script( 'kirki-discount-notice', KIRKI_PLUGIN_URL . '/kirki-packages/settings/dist/discount-notice.js', array( 'jquery' ), KIRKI_VERSION, true ); } /** * Dismiss discount notice. */ public function dismiss_discount_notice() { $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : ''; if ( ! wp_verify_nonce( $nonce, 'Kirki_Dismiss_Discount_Notice' ) ) { wp_send_json_error( __( 'Invalid nonce', 'kirki' ) ); } if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( "You don't have capability to run this action", 'kirki' ) ); } $notices = get_option( 'kirki_notices', [] ); $notices['discount_notice'] = 1; update_option( 'kirki_notices', $notices ); wp_send_json_success( __( 'Discount notice has been dismissed', 'kirki' ) ); } }