Plugin Directory

Changeset 3002205


Ignore:
Timestamp:
11/27/2023 01:29:38 PM (2 years ago)
Author:
eurisko
Message:

v2.3.4 (Nov 27, 2023)

  • Added admin notice.
Location:
reviews-sorted/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • reviews-sorted/trunk/README.txt

    r2996967 r3002205  
    55Tested up to: 6.3.2
    66Requires PHP: 7.2
    7 Stable tag: 2.3.3
     7Stable tag: 2.3.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7474== Changelog ==
    7575
     76= v2.3.4 (Nov 27, 2023) =
     77* Added admin notice.
     78
    7679= v2.3.3 (Nov 06, 2023) =
    7780* Remove the decimal point to show review percentage.
  • reviews-sorted/trunk/reviews-sorted.php

    r2996967 r3002205  
    66 * Author: Reviews Sorted
    77 * Author URI: https://reviewssorted.com/
    8  * Version: 2.3.3
     8 * Version: 2.3.4
    99 * Text Domain: reviews-sorted
    1010 * Domain Path: /languages
     
    154154    }
    155155}
     156
     157/**
     158* Check if the website has collected 10 reviews and display notice in Dashboard
     159**/
     160function review_sorted_check_ten_reviews_collected() {
     161
     162    global $pagenow;
     163    if ( $pagenow == 'index.php' ) {
     164
     165        $RS_Review = new ReviewsSortedFeedback();
     166       
     167        $data    = $RS_Review->get_total();
     168       
     169        $reviews_count = isset( $data['totalReviews'] ) ? $data['totalReviews'] : 0;
     170       
     171        if( $reviews_count >= 10 ) {
     172            add_action( 'admin_notices', 'review_sorted_ten_reviews_admin_notice' );
     173        }
     174    }
     175}
     176add_action( 'admin_init', 'review_sorted_check_ten_reviews_collected', 999 );
     177
     178/**
     179* Display Admin Notice after the website has collected 10 reviews
     180**/
     181function review_sorted_ten_reviews_admin_notice() {
     182
     183    $current_user = wp_get_current_user();
     184    if( !empty( $current_user->user_firstname ) || !empty( $current_user->user_lastname ) ){
     185        $firstname = !empty( $current_user->user_firstname ) ? $current_user->user_firstname : '';
     186        $lastname .= !empty( $current_user->user_lastname ) ? $current_user->user_lastname : '';
     187        $name = trim( $firstname." ".$lastname );
     188    } else if ( !empty( $current_user->display_name ) ){
     189        $name = trim( $current_user->display_name );
     190    } else {
     191        $name = trim( $current_user->user_login );
     192    }
     193
     194    printf( __( "<div class='notice notice-success is-dismissible'><p>Hi<b> %s </b><br>Congratulations on collecting 10 reviews,<br>We hope our plugin has been helpful. If you're enjoying this plugin, please help us by leaving a positive review on the WordPress plugin repository.  It helps us to grow and continue to create a better platform.<br>Thanks - Mike</p></div>", "reviews-sorted" ), $name );
     195}
Note: See TracChangeset for help on using the changeset viewer.