PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / trunk
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI vtrunk
8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 7.8.6 7.8.5 All 44 releases
gamipress / includes / admin / notices.php

notices.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI trunk, at includes/admin/notices.php

95 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Notices
4 *
5 * @package GamiPress\Admin\Notices
6 * @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gmail.com>
7 * @since 1.5.9
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * GamiPress admin notices
14 *
15 * @since 1.5.9
16 */
17 function gamipress_admin_notices() {
18
19 // Bail if current user is not a site administrator
20 if( ! current_user_can( 'update_plugins' ) ){
21 return;
22 }
23
24 // Check if user checked already hide the review notice
25 if( gamipress_is_network_wide_active() ) {
26 $hide_review_notice = ( $exists = get_site_option( 'gamipress_hide_review_notice' ) ) ? $exists : '';
27 } else {
28 $hide_review_notice = ( $exists = get_option( 'gamipress_hide_review_notice' ) ) ? $exists : '';
29 }
30
31 if( $hide_review_notice !== 'yes' ) {
32
33 // Get the GamiPress installation date
34 if( gamipress_is_network_wide_active() ) {
35 $gamipress_install_date = ( $exists = get_site_option( 'gamipress_install_date' ) ) ? $exists : date( 'Y-m-d H:i:s' );
36 } else {
37 $gamipress_install_date = ( $exists = get_option( 'gamipress_install_date' ) ) ? $exists : date( 'Y-m-d H:i:s' );
38 }
39
40 $now = date( 'Y-m-d h:i:s' );
41 $datetime1 = new DateTime( $gamipress_install_date );
42 $datetime2 = new DateTime( $now );
43
44 // Difference in days between installation date and now
45 $diff_interval = round( ( $datetime2->format( 'U' ) - $datetime1->format( 'U' ) ) / ( 60 * 60 * 24 ) );
46
47 if( $diff_interval >= 7 ) {
48 ?>
49
50 <div class="notice gamipress-review-notice">
51 <p>
52 <?php _e( 'Awesome! You\'ve been using <strong>GamiPress</strong> for a while.', 'gamipress' ); ?><br>
53 <?php _e( 'May I ask you to give it a <strong>5-star rating</strong> on WordPress?', 'gamipress' ); ?><br>
54 <?php _e( 'This will help to spread its popularity and to make this plugin a better one.', 'gamipress' ); ?><br>
55 <br>
56 <?php _e( 'Your help is much appreciated. Thank you very much,', 'gamipress' ); ?><br>
57 <span>~Ruben Garcia</span>
58 </p>
59 <ul>
60 <li><a href="https://wordpress.org/support/plugin/gamipress/reviews/?rate=5#new-post" class="button button-primary" target="_blank" title="<?php _e( 'Yes, I want to rate it!', 'gamipress' ); ?>"><?php _e( 'Yes, I want to rate it!', 'gamipress' ); ?></a></li>
61 <li><a href="javascript:void(0);" class="gamipress-hide-review-notice button" title="<?php _e( 'I already did', 'gamipress' ); ?>"><?php _e( 'I already did', 'gamipress' ); ?></a></li>
62 <li><a href="javascript:void(0);" class="gamipress-hide-review-notice" title="<?php _e( 'No, I don\'t want to rate it', 'gamipress' ); ?>"><small><?php _e( 'No, I don\'t want to rate it', 'gamipress' ); ?></small></a></li>
63 </ul>
64 <span class="dashicons-before dashicons-gamipress"></span>
65 </div>
66
67 <?php
68 }
69
70 }
71
72 }
73 add_action( 'admin_notices', 'gamipress_admin_notices' );
74
75 /**
76 * Ajax handler for hide review notice action
77 *
78 * @since 1.5.9
79 */
80 function gamipress_ajax_hide_review_notice() {
81 // Security check, forces to die if not security passed
82 check_ajax_referer( 'gamipress_admin', 'nonce' );
83
84 if( gamipress_is_network_wide_active() ) {
85 update_site_option( 'gamipress_hide_review_notice', 'yes' );
86 } else {
87 update_option( 'gamipress_hide_review_notice', 'yes' );
88 }
89
90 wp_send_json_success( array( 'success' ) );
91 exit;
92 }
93
94 add_action( 'wp_ajax_gamipress_hide_review_notice', 'gamipress_ajax_hide_review_notice' );
95