past_date = strtotime( '-'.get_option('bard_random_number').'days' ); if ( current_user_can('administrator') ) { if ( empty(get_option('bard_rating_dismiss_notice', false)) && empty(get_option('bard_rating_already_rated', false)) ) { add_action( 'admin_init', [$this, 'check_theme_install_time'] ); } } if ( is_admin() ) { add_action( 'admin_head', [$this, 'enqueue_scripts' ] ); } add_action( 'wp_ajax_bard_rating_dismiss_notice', [$this, 'bard_rating_dismiss_notice'] ); add_action( 'wp_ajax_bard_rating_already_rated', [$this, 'bard_rating_already_rated'] ); add_action( 'wp_ajax_bard_rating_need_help', [$this, 'bard_rating_need_help'] ); add_action( 'wp_ajax_bard_rating_maybe_later', [$this, 'bard_rating_maybe_later'] ); } public function check_theme_install_time() { $install_date = get_option('bard_activation_time'); if ( false !== $install_date && $this->past_date >= $install_date ) { add_action( 'admin_notices', [$this, 'render_rating_notice' ]); } } public function bard_rating_maybe_later() { update_option('bard_random_number', 10); update_option('bard_activation_time', strtotime('now')); } public function bard_rating_dismiss_notice() { update_option( 'bard_rating_dismiss_notice', true ); } function bard_rating_already_rated() { update_option( 'bard_rating_already_rated' , true ); } public function bard_rating_need_help() { // Reset Activation Time if user Needs Help update_option('bard_random_number', 10); update_option( 'bard_activation_time', strtotime('now') ); } public function render_rating_notice() { global $pagenow; if ( is_admin() ) { echo '

Thank you for using Bard Theme to build this website!

Could you please do us a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.

OK, you deserve it! Maybe Later I Already did I need support! NO, not good enough

'; } } public function enqueue_scripts() { echo " "; } } if ( 'Bard' === wp_get_theme()->get('Name')) { new BardRatingNotice(); }