abstracts
3 months ago
admin
3 months ago
frontend
1 month ago
integrations
1 month ago
v3
3 months ago
vendor
6 days ago
views
8 months ago
class-simplesalestax.php
6 days ago
class-sst-addresses.php
1 month ago
class-sst-ajax.php
3 months ago
class-sst-assets.php
6 months ago
class-sst-blocks-integration.php
1 month ago
class-sst-blocks.php
1 year ago
class-sst-certificates.php
6 days ago
class-sst-install.php
6 months ago
class-sst-logger.php
5 months ago
class-sst-marketplaces.php
6 months ago
class-sst-order-controller.php
3 months ago
class-sst-order.php
1 month ago
class-sst-origin-address.php
8 months ago
class-sst-product.php
3 months ago
class-sst-rate-limit.php
5 months ago
class-sst-settings.php
3 months ago
class-sst-shipping.php
3 years ago
class-sst-taxcloud-v3-api.php
3 months ago
class-sst-taxcloud-v3.php
3 months ago
class-sst-tic.php
2 years ago
class-sst-updater.php
3 years ago
sst-compatibility-functions.php
4 months ago
sst-functions.php
6 days ago
sst-message-functions.php
3 years ago
sst-update-functions.php
11 months ago
sst-message-functions.php
59 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Message functions. |
| 4 | * |
| 5 | * Functions for displaying admin notices. |
| 6 | * |
| 7 | * @author Simple Sales Tax |
| 8 | * @package SST |
| 9 | * @since 5.0 |
| 10 | */ |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Do not all direct access. |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Queue a message for display. |
| 18 | * |
| 19 | * @param string $content Message content. |
| 20 | * @param string $type Type of message. Can be 'error' or 'updated' (default: 'error'). |
| 21 | * |
| 22 | * @since 5.0 |
| 23 | */ |
| 24 | function sst_add_message( $content, $type = 'error' ) { |
| 25 | $all_messages = get_option( 'sst_messages' ); |
| 26 | |
| 27 | if ( ! is_array( $all_messages ) ) { |
| 28 | $all_messages = array(); |
| 29 | } |
| 30 | |
| 31 | $all_messages[] = array( |
| 32 | 'content' => $content, |
| 33 | 'type' => $type, |
| 34 | ); |
| 35 | |
| 36 | update_option( 'sst_messages', $all_messages ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Print queued messages. |
| 41 | * |
| 42 | * @since 5.0 |
| 43 | */ |
| 44 | function sst_print_messages() { |
| 45 | $all_messages = get_option( 'sst_messages' ); |
| 46 | |
| 47 | if ( ! is_array( $all_messages ) ) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | foreach ( $all_messages as $message ) { |
| 52 | printf( "<div class='%s'><p>%s</p></div>", esc_attr( $message['type'] ), esc_html( $message['content'] ) ); |
| 53 | } |
| 54 | |
| 55 | update_option( 'sst_messages', array() ); |
| 56 | } |
| 57 | |
| 58 | add_action( 'admin_notices', 'sst_print_messages' ); |
| 59 |