Plugin Directory

Changeset 3444459


Ignore:
Timestamp:
01/21/2026 11:13:43 PM (2 months ago)
Author:
madebyiman
Message:

Update to version 1.1.1 from GitHub

Location:
smart-renew-tracker
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • smart-renew-tracker/tags/1.1.1/includes/email-notifications.php

    r3444424 r3444459  
    1111    }
    1212
    13     // متد جدید برای دکمه تست
    1413    public function handle_test_email_ajax() {
    15         // چک کردن امنیت
    1614        if ( ! current_user_can( 'manage_options' ) || ! check_ajax_referer( 'smartrt_test_nonce', 'nonce', false ) ) {
    1715            wp_send_json_error( __( 'Permission denied.', 'smart-renew-tracker' ) );
     
    5755
    5856    public function process_notifications() {
    59         // کدهای قبلی متد پروسس...
     57        $alert_days   = get_option( 'smartrt_alert_days', 7 );
     58        $target_email = get_option( 'smartrt_target_email', get_option( 'admin_email' ) );
     59        $today        = current_time( 'timestamp' );
     60
     61        // ۲. کوئری برای پیدا کردن تمام موارد ثبت شده
     62        $query = new \WP_Query( [
     63                'post_type'      => 'smartrt_renewal',
     64                'posts_per_page' => -1,
     65                'post_status'    => 'publish',
     66        ] );
     67
     68        $expiring_items = [];
     69
     70        foreach ( $query->posts as $renewal ) {
     71            $renewal_date = get_post_meta( $renewal->ID, '_smartrt_renewal_date', true );
     72            if ( ! $renewal_date ) continue;
     73
     74            $diff = ceil( ( strtotime( $renewal_date ) - $today ) / DAY_IN_SECONDS );
     75
     76            // اگر مورد در بازه هشدار (مثلاً ۷ روز مانده) باشد
     77            if ( $diff <= $alert_days && $diff >= 0 ) {
     78                $expiring_items[] = [
     79                        'title' => get_the_title( $renewal->ID ),
     80                        'days'  => $diff,
     81                        'date'  => $renewal_date,
     82                        'type'  => get_post_meta( $renewal->ID, '_smartrt_type', true )
     83                ];
     84            }
     85        }
     86
     87        if ( ! empty( $expiring_items ) ) {
     88            $this->send_html_email( $target_email, $expiring_items );
     89        }
    6090    }
    6191}
     92
     93new Email_Notifications();
  • smart-renew-tracker/trunk/includes/email-notifications.php

    r3444424 r3444459  
    1111    }
    1212
    13     // متد جدید برای دکمه تست
    1413    public function handle_test_email_ajax() {
    15         // چک کردن امنیت
    1614        if ( ! current_user_can( 'manage_options' ) || ! check_ajax_referer( 'smartrt_test_nonce', 'nonce', false ) ) {
    1715            wp_send_json_error( __( 'Permission denied.', 'smart-renew-tracker' ) );
     
    5755
    5856    public function process_notifications() {
    59         // کدهای قبلی متد پروسس...
     57        $alert_days   = get_option( 'smartrt_alert_days', 7 );
     58        $target_email = get_option( 'smartrt_target_email', get_option( 'admin_email' ) );
     59        $today        = current_time( 'timestamp' );
     60
     61        // ۲. کوئری برای پیدا کردن تمام موارد ثبت شده
     62        $query = new \WP_Query( [
     63                'post_type'      => 'smartrt_renewal',
     64                'posts_per_page' => -1,
     65                'post_status'    => 'publish',
     66        ] );
     67
     68        $expiring_items = [];
     69
     70        foreach ( $query->posts as $renewal ) {
     71            $renewal_date = get_post_meta( $renewal->ID, '_smartrt_renewal_date', true );
     72            if ( ! $renewal_date ) continue;
     73
     74            $diff = ceil( ( strtotime( $renewal_date ) - $today ) / DAY_IN_SECONDS );
     75
     76            // اگر مورد در بازه هشدار (مثلاً ۷ روز مانده) باشد
     77            if ( $diff <= $alert_days && $diff >= 0 ) {
     78                $expiring_items[] = [
     79                        'title' => get_the_title( $renewal->ID ),
     80                        'days'  => $diff,
     81                        'date'  => $renewal_date,
     82                        'type'  => get_post_meta( $renewal->ID, '_smartrt_type', true )
     83                ];
     84            }
     85        }
     86
     87        if ( ! empty( $expiring_items ) ) {
     88            $this->send_html_email( $target_email, $expiring_items );
     89        }
    6090    }
    6191}
     92
     93new Email_Notifications();
Note: See TracChangeset for help on using the changeset viewer.