PluginProbe
HootKit / trunk
HootKit vtrunk
trunk 2.0.21 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5
hootkit / admin / class-notice.php

class-notice.php in HootKit trunk, at admin/class-notice.php

76 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Add admin notice
4 * This file is loaded at after_setup_theme@96
5 *
6 * @package Hootkit
7 */
8
9 // If this file is called directly, abort.
10 if ( ! defined( 'ABSPATH' ) ) {
11 die;
12 }
13
14 /**
15 * Add notice if not already dismissed
16 *
17 * @since 1.0
18 * @access public
19 * @return void
20 */
21 function hootkit_notices_init( $current_screen ) {
22 if ( !empty( $current_screen->id ) && ( $current_screen->id == 'widgets' || $current_screen->id == 'plugins' ) ) {
23 if ( empty( get_option( 'hootkit-dismiss-review' ) ) ) {
24 $activated = get_option( 'hootkit-activate' );
25 // Add notice if empty for previously activated plugin, or time greater than set time
26 if ( empty( $activated ) || ( is_numeric( $activated ) && $activated + ( 2 * 24 * 60 * 60 ) < time() ) || ( is_array( $activated ) && !empty( $activated['time'] ) && $activated['time'] + ( 2 * 24 * 60 * 60 ) < time() ) ) {
27 add_action( 'admin_notices', 'hootkit_add_notice', 9 );
28 add_action( 'admin_print_footer_scripts', 'hootkit_dismiss_noticescript' );
29 }
30 }
31 }
32 }
33 add_action( 'current_screen', 'hootkit_notices_init' );
34
35 /**
36 * Display admin notice
37 *
38 * @since 1.0
39 * @access public
40 * @return void
41 */
42 function hootkit_add_notice() {
43 ?>
44 <div id="hootkit-review-msg" class="notice notice-info is-dismissible">
45 <?php
46 /* Translators: 1 and 2 are placeholders for HTML p tag, 3 and 4 are placeholders for HTML strong tag, 5 and 6 are placeholders for link markup */
47 printf( esc_html__( '%1$sIf you have enjoyed using %3$sHootKit%4$s, can you do us a BIG favor and %3$s%5$srate it on WordPress here%6$s%4$s. %2$s%1$sIt helps us spread the word, and really boosts our team motivation.%2$s', 'hootkit' ), '<p>', '</p>', '<strong>', '</strong>', '<a href="https://wordpress.org/support/plugin/hootkit/reviews/?filter=5#new-post" target="_blank">', '</a>' );
48 ?>
49 </div>
50 <?php
51 }
52
53 /**
54 * Add dismiss script
55 *
56 * @since 1.0
57 * @access public
58 * @return void
59 */
60 function hootkit_dismiss_noticescript(){
61 ?><script> jQuery(document).ready(function($) { "use strict"; $('#hootkit-review-msg .notice-dismiss').on('click',function(e){ jQuery.ajax({ url : ajaxurl, type : 'post', data : { 'action': 'hootkit_dismiss_notice', 'nonce': '<?php echo wp_create_nonce( 'dismiss-hootkit-review' ); ?>' } }); }); }); </script><?php
62 }
63
64 /**
65 * Ajax callback to set dismissable notice
66 *
67 * @since 1.0
68 * @access public
69 * @return void
70 */
71 function hootkit_dismiss_notice() {
72 check_ajax_referer( 'dismiss-hootkit-review', 'nonce' );
73 update_option( 'hootkit-dismiss-review', 1 );
74 wp_die();
75 }
76 add_action( 'wp_ajax_hootkit_dismiss_notice', 'hootkit_dismiss_notice' );