settings
5 years ago
globals.php
5 years ago
import-export.php
5 years ago
notices.php
5 years ago
welcome.php
5 years ago
notices.php
79 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Handles additional widget tab options |
| 4 | * run on __construct function |
| 5 | */ |
| 6 | |
| 7 | // Exit if accessed directly |
| 8 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 9 | |
| 10 | |
| 11 | /** |
| 12 | * Admin Messages |
| 13 | * @return void |
| 14 | */ |
| 15 | if( !function_exists( 'widgetopts_admin_notices' ) ): |
| 16 | function widgetopts_admin_notices() { |
| 17 | if( !current_user_can( 'update_plugins' ) ) |
| 18 | return; |
| 19 | |
| 20 | //show rating notice to page that matters most |
| 21 | global $pagenow; |
| 22 | if( !in_array( $pagenow, array( 'widgets.php', 'options-general.php' ) ) ){ |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | if( $pagenow == 'options-general.php' && function_exists( 'get_current_screen' ) ){ |
| 27 | $screen = get_current_screen(); |
| 28 | if( isset( $screen->base ) && $screen->base != 'settings_page_widgetopts_plugin_settings' ){ |
| 29 | return; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | $install_date = get_option( 'widgetopts_installDate' ); |
| 34 | $saved = get_option( 'widgetopts_RatingDiv' ); |
| 35 | $display_date = date( 'Y-m-d h:i:s' ); |
| 36 | $datetime1 = new DateTime( $install_date ); |
| 37 | $datetime2 = new DateTime( $display_date ); |
| 38 | $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' ) ) / (60*60*24)); |
| 39 | if( 'yes' != $saved && $diff_intrval >= 7 ){ |
| 40 | echo '<div class="widgetopts_notice updated" style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);"> |
| 41 | <p>Awesome, you\'ve been using <strong>Widget Options</strong> for more than 1 week. <br> May i ask you to give it a <strong>5-star rating</strong> on WordPress? </br> |
| 42 | This will help to spread its popularity and to make this plugin a better one. |
| 43 | <br><br>Your help is much appreciated. Thank you very much,<br> ~ Widget Options Team |
| 44 | <ul> |
| 45 | <li><a href="https://wordpress.org/support/view/plugin-reviews/widget-options" class="thankyou" target="_blank" title="Ok, you deserved it" style="font-weight:bold;">'. __( 'Ok, you deserved it', 'widget-options' ) .'</a></li> |
| 46 | <li><a href="javascript:void(0);" class="widgetopts_bHideRating" title="I already did" style="font-weight:bold;">'. __( 'I already did', 'widget-options' ) .'</a></li> |
| 47 | <li><a href="javascript:void(0);" class="widgetopts_bHideRating" title="No, not good enough" style="font-weight:bold;">'. __( 'No, not good enough, i do not like to rate it!', 'widget-options' ) .'</a></li> |
| 48 | </ul> |
| 49 | </div> |
| 50 | <script> |
| 51 | jQuery( document ).ready(function( $ ) { |
| 52 | |
| 53 | jQuery(\'.widgetopts_bHideRating\').click(function(){ |
| 54 | var data={\'action\':\'widgetopts_hideRating\'} |
| 55 | jQuery.ajax({ |
| 56 | |
| 57 | url: "'. admin_url( 'admin-ajax.php' ) .'", |
| 58 | type: "post", |
| 59 | data: data, |
| 60 | dataType: "json", |
| 61 | async: !0, |
| 62 | success: function(e) { |
| 63 | if (e=="success") { |
| 64 | jQuery(\'.widgetopts_notice\').slideUp(\'slow\'); |
| 65 | |
| 66 | } |
| 67 | } |
| 68 | }); |
| 69 | }) |
| 70 | |
| 71 | }); |
| 72 | </script> |
| 73 | '; |
| 74 | } |
| 75 | } |
| 76 | add_action( 'admin_notices', 'widgetopts_admin_notices' ); |
| 77 | endif; |
| 78 | ?> |
| 79 |