PluginProbe
FileBird – WordPress Media Library Folders & File Manager / 6.2.5
FileBird – WordPress Media Library Folders & File Manager v6.2.5
6.5.8 6.5.7 6.5.5 6.5.4 trunk 4.3.1 5.1.6 5.3 5.3.2 5.4.3 5.4.4 5.4.5 5.5 5.5.3 5.5.5 5.5.8 5.5.8.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 6.2.3 6.2.5 6.3 All 36 releases
filebird / includes / Classes / Review.php

Review.php in FileBird – WordPress Media Library Folders & File Manager 6.2.5, at includes/Classes/Review.php

79 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FileBird\Classes;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Review {
7 public function __construct() {
8 add_action( 'wp_ajax_fbv_save_review', array( $this, 'fbv_save_review' ) );
9
10 $option = get_option( 'fbv_review', false );
11 if ( time() >= intval( $option ) && '0' !== $option ) {
12 add_action( 'admin_notices', array( $this, 'give_review' ) );
13 }
14 }
15
16 public function enqueue_scripts() {
17 wp_enqueue_script( 'fbv-review', NJFB_PLUGIN_URL . 'assets/js/review.js', array( 'jquery' ), NJFB_VERSION, false );
18 }
19
20 public function checkNonce( $nonce ) {
21 if ( ! wp_verify_nonce( $nonce, 'fbv_nonce' ) ) {
22 wp_send_json_error( array( 'status' => 'Wrong nonce validate!' ) );
23 exit();
24 }
25 }
26
27 public function hasField( $field, $request ) {
28 return isset( $request[ $field ] ) ? sanitize_text_field( $request[ $field ] ) : null;
29 }
30
31 public function fbv_save_review() {
32 if ( count( $_REQUEST ) ) {
33 $nonce = $this->hasField( 'nonce', $_REQUEST );
34 $field = $this->hasField( 'field', $_REQUEST );
35
36 $this->checkNonce( $nonce );
37
38 if ( 'later' == $field ) {
39 update_option( 'fbv_review', time() + 5 * 60 * 60 * 24 ); //After 3 days show
40 } elseif ( 'alreadyDid' == $field || 'rateNow' == $field ) {
41 update_option( 'fbv_review', 0 );
42 }
43 wp_send_json_success();
44 }
45 wp_send_json_error( array( 'message' => 'Update fail!' ) );
46 }
47
48 public static function update_time_display() {
49 $option = get_option( 'fbv_review', false );
50 if ( '0' !== $option ) {
51 update_option( 'fbv_review', time() + 3 * 60 * 60 * 24 ); //After 3 days show
52 }
53 }
54
55 public function give_review() {
56 if ( function_exists( 'get_current_screen' ) ) {
57 if ( get_current_screen()->id == 'upload' || get_current_screen()->id == 'plugins' ) {
58 $this->enqueue_scripts();
59 ?>
60 <div class="notice notice-success is-dismissible filebird-notice" id="njt-FileBird-review">
61 <h3><?php esc_html_e( 'Give FileBird a review', 'filebird' ); ?></h3>
62 <p>
63 <?php esc_html_e( 'Thank you for choosing FileBird. We hope you love it. Could you take a couple of seconds posting a nice review to share your happy experience?', 'filebird' ); ?>
64 </p>
65 <p>
66 <?php esc_html_e( 'We will be forever grateful. Thank you in advance ;)', 'filebird' ); ?>
67 </p>
68 <p>
69 <a href="javascript:;" data="rateNow"
70 class="button button-primary"><?php esc_html_e( 'Rate now', 'filebird' ); ?></a>
71 <a href="javascript:;" data="later" class="button"><?php esc_html_e( 'Later', 'filebird' ); ?></a>
72 <a href="javascript:;" data="alreadyDid" class="button"><?php esc_html_e( 'No, thanks', 'filebird' ); ?></a>
73 </p>
74 </div>
75 <?php
76 }
77 }
78 }
79 }