offset = strtotime('-7 days'); add_action('admin_init', array($this, 'checkInstallationDate')); add_action( 'wp_ajax_' . self::DISMISS_AJAX_ACTION, array( $this, 'dismissNotice' ) ); add_action('admin_head', array($this, 'loadStyle')); add_action('admin_footer', array($this, 'printDismissJS')); } /** * Check if is possible to display admin notice on the current screen * @return bool */ private function allowDisplay() { if ( in_array( get_current_screen()->base, array( 'dashboard', 'post', 'edit' ) ) || strpos( get_current_screen()->base, DGWT_WCAS_SETTINGS_KEY ) !== false ) { return true; } return false; } /** * Display feedback notice * @return null | echo HTML */ public function displayNotice() { global $current_user; if ($this->allowDisplay()) { ?>
' . $current_user->display_name . '', '' . DGWT_WCAS_NAME . '' ); ?>
', '' ); ?>
offset >= $install_date && current_user_can('install_plugins')) { add_action('admin_notices', array($this, 'displayNotice')); } } } /** * Hide admin notice * * @return null */ public function dismissNotice() { update_option( self::HIDE_NOTICE_OPT, true ); wp_send_json_success(); } /** * Print JS for close admin notice */ public function printDismissJS() { if(!$this->allowDisplay()){ return false; } ?> allowDisplay()){ wp_enqueue_style('dgwt-wcas-admin-style'); } } }