EasyDigitalDownloads
3 years ago
Elementor
2 years ago
Integrations
3 years ago
MemberPress
2 years ago
Plugins
2 years ago
Promos
3 years ago
Rules
2 years ago
Shortcodes
2 years ago
WPForms
1 year ago
WooCommerce
1 year ago
Actions.php
1 year ago
Ajax.php
4 years ago
Api.php
1 year ago
ApiAuth.php
4 years ago
ApiKey.php
1 year ago
AssetLoader.php
5 years ago
BaseRestApi.php
3 years ago
Blocks.php
1 year ago
ClassicEditor.php
3 years ago
ConstantContact.php
1 year ago
Debug.php
1 year ago
EasyDigitalDownloads.php
1 year ago
Elementor.php
3 years ago
Inserter.php
3 years ago
InstallSkin.php
5 years ago
InstallSkinCompat.php
5 years ago
MailPoet.php
1 year ago
MemberPress.php
2 years ago
Menu.php
1 year ago
Notifications.php
1 year ago
OmuApi.php
4 years ago
Output.php
1 year ago
Pages.php
1 year ago
Partners.php
1 year ago
Plugins.php
2 years ago
Promos.php
3 years ago
Refresh.php
1 year ago
RestApi.php
1 year ago
RevenueAttribution.php
4 years ago
Review.php
4 years ago
Rules.php
1 year ago
Save.php
2 years ago
Shortcode.php
4 years ago
Sites.php
1 year ago
Support.php
1 year ago
Type.php
3 years ago
Urls.php
1 year ago
Utils.php
1 year ago
Validate.php
2 years ago
WPForms.php
2 years ago
Welcome.php
4 years ago
Widget.php
4 years ago
WooCommerce.php
1 year ago
Wordfence.php
3 years ago
WpErrorException.php
5 years ago
Review.php
75 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Review class. |
| 4 | * |
| 5 | * @since 1.1.4.5 |
| 6 | * |
| 7 | * @package OMAPI |
| 8 | * @author Devin Vinson |
| 9 | */ |
| 10 | |
| 11 | // Exit if accessed directly. |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Review class. |
| 18 | * |
| 19 | * @since 1.1.4.5 |
| 20 | */ |
| 21 | class OMAPI_Review { |
| 22 | /** |
| 23 | * Determine if review message should be shown |
| 24 | * based on backend rules. |
| 25 | * |
| 26 | * @since 2.6.1 |
| 27 | * |
| 28 | * @return bool If it should show the review bar |
| 29 | */ |
| 30 | public function should_show_review() { |
| 31 | $review = get_option( 'omapi_review' ); |
| 32 | |
| 33 | if ( ! is_user_logged_in() || ! OMAPI::get_instance()->can_access( 'review' ) ) { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | // If already dismissed... |
| 38 | if ( ! empty( $review['dismissed'] ) ) { |
| 39 | if ( empty( $review['later'] ) ) { |
| 40 | // Dismissed and no later, so do not show. |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | $delayed_less_than_month_ago = ! empty( $review['later'] ) && $review['time'] + ( 30 * DAY_IN_SECONDS ) > time(); |
| 45 | |
| 46 | if ( $delayed_less_than_month_ago ) { |
| 47 | // Delayed less than a month ago, so do not show. |
| 48 | return false; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Dismiss the review bar |
| 57 | * |
| 58 | * @param bool $later If delay the review for later. |
| 59 | * |
| 60 | * @since 1.1.6.1 |
| 61 | * @since 2.6.1 Avoid using any request variables and receive later as parameter |
| 62 | */ |
| 63 | public function dismiss_review( $later = false ) { |
| 64 | $option = array( |
| 65 | 'time' => time(), |
| 66 | 'dismissed' => true, |
| 67 | 'later' => ! empty( $later ), |
| 68 | ); |
| 69 | |
| 70 | $option['updated'] = update_option( 'omapi_review', $option ); |
| 71 | |
| 72 | return $option; |
| 73 | } |
| 74 | } |
| 75 |