PluginProbe
Additional Terms Lite for WooCommerce / 1.6.3
Additional Terms Lite for WooCommerce v1.6.3
1.7.3 1.7.2.1 trunk 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 All 35 releases
woo-additional-terms / src / Enhancements / Rate.php

Rate.php in Additional Terms Lite for WooCommerce 1.6.3, at src/Enhancements/Rate.php

116 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The plugin rate class.
4 *
5 * @author MyPreview (Github: @mahdiyazdani, @gooklani, @mypreview)
6 *
7 * @since 1.4.1
8 *
9 * @package woo-additional-terms
10 */
11
12 namespace Woo_Additional_Terms\Enhancements;
13
14 use WP_Footer_Rate;
15 use Woo_Additional_Terms\Helper;
16
17 /**
18 * Class Rate.
19 */
20 class Rate {
21
22 /**
23 * Rated (already) option name.
24 *
25 * @since 1.5.2
26 *
27 * @var string
28 */
29 const OPTION_NAME = 'woo_additional_terms_rated';
30
31 /**
32 * Rate transient name.
33 *
34 * @since 1.4.1
35 *
36 * @var string
37 */
38 const TRANSIENT_NAME = 'woo_additional_terms_rate';
39
40
41 /**
42 * Setup hooks and filters.
43 *
44 * @since 1.6.0
45 *
46 * @return void
47 */
48 public function setup() {
49
50 add_action( 'woo_additional_terms_admin_notices', array( $this, 'admin_notice' ) );
51 add_action( 'woocommerce_settings_start', array( $this, 'wp_footer' ) );
52 }
53
54 /**
55 * Display the rate the plugin notice.
56 *
57 * @since 1.4.1
58 *
59 * @return void
60 */
61 public function admin_notice() {
62
63 // Bail early if the rate notice has been dismissed.
64 if (
65 get_option( self::OPTION_NAME )
66 || get_transient( self::TRANSIENT_NAME )
67 ) {
68 return;
69 }
70
71 $usage_timestamp = woo_additional_terms()->service( 'options' )->get_usage_timestamp();
72
73 // If the usage timestamp is empty, add it and bail.
74 if ( empty( $usage_timestamp ) ) {
75 // Add the activation timestamp.
76 woo_additional_terms()->service( 'options' )->add_usage_timestamp();
77
78 return;
79 }
80
81 // Bail early if the plugin recently installed.
82 if ( time() < ( $usage_timestamp + WEEK_IN_SECONDS ) ) {
83 return;
84 }
85
86 // Enqueue the assets.
87 wp_enqueue_style( 'woo-additional-terms-rate' );
88 wp_enqueue_script( 'woo-additional-terms-dismiss' );
89
90 // Display the notice.
91 woo_additional_terms()->service( 'template_manager' )->echo_template(
92 'notices/rate.php',
93 array(
94 'usage_timestamp' => human_time_diff( $usage_timestamp ),
95 )
96 );
97 }
98
99 /**
100 * Ask for a review in the footer of the settings page.
101 *
102 * @since 1.6.0
103 *
104 * @return void
105 */
106 public function wp_footer() {
107
108 new WP_Footer_Rate\Rate(
109 woo_additional_terms()->service( 'file' )->plugin_basename(),
110 woo_additional_terms()->get_slug(),
111 _x( 'Woo Additional Terms', 'plugin name', 'woo-additional-terms' ),
112 Helper\Settings::is_page()
113 );
114 }
115 }
116