mainfile = $mainfile; $this->domain = $domain; $this->prefix = $prefix; if ( array_search( $this->domain, $this->ignored_domains ) !== false ) { return; } foreach ( $this->ignored_domains as $ignored_domain ) { if ( strpos( $ignored_domain, '*' ) !== false ) { $ignored_domain = str_replace( '*', '', $ignored_domain ); if ( strpos( $this->domain, $ignored_domain ) !== false ) { return; } } } // Add the hooks register_activation_hook( $mainfile, [ $this, 'show_meowapps_create_rating_date' ] ); if ( is_admin() ) { $rating_date = $this->create_rating_date(); if ( time() > $rating_date ) { add_action( 'admin_notices', [ $this, 'admin_notices_rating' ] ); add_filter( 'safe_style_css', function ( $styles ) { $styles[] = 'display'; return $styles; } ); } } } public function show_meowapps_create_rating_date() { delete_option( 'meowapps_hide_meowapps' ); $this->create_rating_date(); } public function create_rating_date() { $rating_date = get_option( $this->prefix . '_rating_date' ); if ( empty( $rating_date ) ) { $two_weeks = strtotime( '+2 weeks' ); $three_weeks = strtotime( '+3 weeks' ); $rating_date = mt_rand( $two_weeks, $three_weeks ); update_option( $this->prefix . '_rating_date', $rating_date, false ); } return $rating_date; } public function admin_notices_rating() { if ( isset( $_POST[$this->prefix . '_remind_me'] ) ) { $two_weeks = strtotime( '+2 weeks' ); $six_weeks = strtotime( '+6 weeks' ); $future_date = mt_rand( $two_weeks, $six_weeks ); update_option( $this->prefix . '_rating_date', $future_date, false ); return; } else if ( isset( $_POST[$this->prefix . '_never_remind_me'] ) ) { $twenty_years = strtotime( '+5 years' ); update_option( $this->prefix . '_rating_date', $twenty_years, false ); return; } else if ( isset( $_POST[$this->prefix . '_did_it'] ) ) { $twenty_years = strtotime( '+100 years' ); update_option( $this->prefix . '_rating_date', $twenty_years, false ); return; } $rating_date = get_option( $this->prefix . '_rating_date' ); $html = wp_kses_post( '
'; // Translators: %1$s is a plugin nicename, %2$s is a short url (slug) $url = 'https://wordpress.org/support/plugin/' . $esc_short_url . '/reviews/?rate=5#new-post'; $html .= sprintf( __( '
If you have a minute, can you write a little review for me? That would really bring me joy and motivation! 💫
Don\'t hesitate to share your feature requests with the review, I always check them and try my best.