Plugin Directory

Changeset 2814435


Ignore:
Timestamp:
11/08/2022 03:41:26 PM (3 years ago)
Author:
vandestouwe
Message:

Version 2.7.2 Add_Filter added to allow for bulk sending of emails

Location:
subscribe-to-category
Files:
661 added
3 edited

Legend:

Unmodified
Added
Removed
  • subscribe-to-category/trunk/classes/class-stc-subscribe.php

    r2768920 r2814435  
    153153        add_action( 'updated_post_meta', array( $this, 'stc_gutenberg_addon_updated_post_meta' ), 10, 4 );
    154154               
     155                add_filter( 'stc_filter_wp_mail', array( $this, 'stc_wp_mail_filtering' ), 10, 4);
     156
    155157                add_filter('manage_notifications_posts_columns', array( $this, 'set_notification_table_columns'));
    156158                add_action('manage_notifications_posts_custom_column' , array( $this, 'custom_notifications_column'), 10, 2 );
    157159                add_filter('manage_stc_posts_columns', array( $this, 'set_book_table_columns'));
    158160                add_action('manage_stc_posts_custom_column' , array( $this, 'custom_stc_column'), 10, 2 );
    159 
     161               
    160162                add_action('wp_ajax_stc_get_results', array($this, 'stc_get_results_callback'));
    161163                add_action('wp_ajax_nopriv_stc_get_results', array($this, 'stc_get_results_callback'));
     
    170172                if (isset($this->settings['enable_sms_notification']) && '1' === $this->settings['enable_sms_notification']) $this->textmagic = STC_SMSNotification::get_instance();
    171173                if (isset($this->settings['enable_sms_notification']) && '1' === $this->settings['enable_sms_notification']) $this->api_textmagic = $this->textmagic->configTextMagic();               
     174        }
     175       
     176        public function stc_wp_mail_filtering($email_address, $email_subject, $message, $headers) {
     177//            unset($email['email']);
     178            $a = "ajkswljs";
     179            return "";
    172180        }
    173181       
     
    19231931                                        // get the requested search areas
    19241932                                        $search_areas = explode(',', str_replace(', ', ',',get_post_meta($subscriber->ID, "_stc_subscriber_search_areas", true)));
    1925                                         $position = false;
    19261933                                        $reason = "";
     1934                                        $reason_p1 = "";
     1935                                        $reason_p2 = "";
    19271936                                       
    19281937                                        if (count($subscriber->categories) == 0){
     
    19401949                                                }
    19411950                                        } else {
     1951                                                // check if we have a hit on at least one Taxonomie
    19421952                                                foreach ( $subscriber->categories as $key=>$categories ) {
    1943                                                         // add compare signs for in_array().
    1944                                                         $cat_name = get_term($categories, "")->name;
    1945                                                         $categories = ':' . $categories . ':';
    1946                                                         if ( in_array( $categories, $post_cat_compare ) ) {
     1953                                                        if ( in_array( ':' . $categories . ':', $post_cat_compare ) ) {
    19471954                                                                if (isset($this->settings['enable_taxonomy_hierarchy']) && $this->settings['enable_taxonomy_hierarchy'] === "1") {
    19481955                                                                        $tax_label = get_taxonomy(get_term($categories, "")->taxonomy)->label;
    19491956                                                                        // translators: Taxonomy Group: "term1->term2" found
    1950                                                                         $reason_p1 = sprintf(esc_html__('%s: "%s" found', 'subscribe-to-category'), $tax_label, rtrim(get_term_parents_list($categories,get_term($categories, "")->taxonomy, array('separator' => '->', 'link' => false)),'->'));
     1957                                                                        $reason_p1 = sprintf(esc_html__('%s: "%s" found.', 'subscribe-to-category'), $tax_label, rtrim(get_term_parents_list($categories,get_term($categories, "")->taxonomy, array('separator' => '->', 'link' => false)),'->'));
    19511958                                                                } else {
    19521959                                                                        $reason_p1 = sprintf(esc_html__('Term: "%s" found.', 'subscribe-to-category'), get_term($categories, "")->name);
    19531960                                                                }
    1954                                                                 $reason_p1 = sprintf(esc_html__('Taxonomy: "%s" and ', 'subscribe-to-category'), $cat_name);
    1955                                                                 $reason = "";
    1956                                                                 // can we also find a matching keyword?
    1957                                                                 if ($this->FindKeywords($post, $keywords, $search_areas, $reason)) {
    1958                                                                         $emails[ $i ]['subscriber_id'] = $subscriber->ID;
    1959                                                                         $emails[ $i ]['mobile_phone'] = $subscriber->mobile_phone;
    1960                                                                         $emails[ $i ]['mobile_phone_status'] = $subscriber->mobile_phone_status;
    1961                                                                         $emails[ $i ]['hash'] = get_post_meta( $subscriber->ID, '_stc_hash', true );
    1962                                                                         $emails[ $i ]['email'] = $subscriber->post_title;
    1963                                                                         $emails[ $i ]['post_id'] = $post->ID;
    1964                                                                         $emails[ $i ]['reason'] = $reason_p1 . $reason;
    1965                                                                         $emails[ $i ]['merged'] = false;
    1966                                                                         $i++;
    1967                                                                         break;
    1968                                                                 }
     1961                                                                break;
    19691962                                                        }
     1963                                                }
     1964                                                $this->FindKeywords($post, $keywords, $search_areas, $reason_p2);
     1965                                               
     1966                                                if ($reason_p1 <> "" && $reason_p2 <> "") { $reason = $reason_p1 . " & " . $reason_p2; }
     1967                                                else if ($reason_p1 <> "" && $reason_p2 == "") {$reason = $reason_p1;}
     1968                                                else if ($reason_p2 <> "" && $reason_p1 == "") {$reason = $reason_p2;}
     1969                                                else {$reason = "";}
     1970
     1971                                                if ($reason <> "") {
     1972                                                        // make an email entry for this subscriber
     1973                                                        $emails[ $i ]['subscriber_id'] = $subscriber->ID;
     1974                                                        $emails[ $i ]['mobile_phone'] = $subscriber->mobile_phone;
     1975                                                        $emails[ $i ]['mobile_phone_status'] = $subscriber->mobile_phone_status;
     1976                                                        $emails[ $i ]['hash'] = get_post_meta( $subscriber->ID, '_stc_hash', true );
     1977                                                        $emails[ $i ]['email'] = $subscriber->post_title;
     1978                                                        $emails[ $i ]['post_id'] = $post->ID;
     1979                                                        $emails[ $i ]['reason'] = $reason;
     1980                                                        $emails[ $i ]['merged'] = false;
     1981                                                        $i++;
    19701982                                                }
    19711983                                        }
     
    20582070                                }
    20592071                               
    2060                                 wp_mail( $email['email'], $email_subject, $message, $headers );
    2061 
     2072                                // filter gives result back and we need that to leave the sending of mails to a provider
     2073                                $filter_answer = apply_filters( 'stc_filter_wp_mail', $email['email'], $email_subject, $message, $headers);
     2074                               
     2075                                if ($filter_answer == $email['email']) {
     2076                                    wp_mail( $email['email'], $email_subject, $message, $headers );
     2077                                }
    20622078                                // sleep 2 seconds once every 25 email to prevent blacklisting.
    20632079                                if ( $i == $this->sleep_flag ) {
  • subscribe-to-category/trunk/readme.txt

    r2768920 r2814435  
    33Tags: subscribe to post, subscribe category, subscribe to taxonomy, subscribe to news, subscribe
    44Requires at least: WP 5.0
    5 Tested up to: 6.0
     5Tested up to: 6.1
    66Requires PHP: 7.0
    7 Stable tag: 2.7.1
     7Stable tag: 2.7.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6969add_filter( 'stc_message_unsubscribe_html', 'my_stc_message_unsubscribe_html', 10, 3 );
    7070add_filter( 'stc_message_subscribe_html', 'my_stc_message_subscribe_html', 10, 3 );
     71
     72// Parameters: $email_adress, $email_subject, $email_contents, $email headers
     73// Return: $email_address if email address still needs to be send by STC else an empty ""
     74add_filter( 'stc_filter_wp_mail', 'my_stc_filter_wp_mail', 10, 4 );
    7175
    7276// HOOKS
     
    151155
    152156== Changelog ==
     157= 2.7.2.
     158* added add_filter feature for users that want to send bulk emails
     159* small bug fixes
     160
    153161= 2.7.1.
    154162* fixed double "WP" call for $_GET receiving subscribe notification url.
     
    426434
    427435== Upgrade Notice ==
    428 * solved bug in {{search_reason}}
    429 * added {{post_excerpt}} and {{post_featured_image}}
    430 * enhanced and improved STC Basic e-Mail Template V2.1 (delete older versions)
     436* Aditional add_filter/hook function to allow bulk sending of email notifications. This will avoid STC tripping out while sending bulk emails.
  • subscribe-to-category/trunk/subscribe-to-category.php

    r2768920 r2814435  
    44  Plugin URI: https://vandestouwe.com/stcmanual
    55  Description: Lets your visitor subscribe to posts for one or several categories.
    6   Version: 2.7.1
     6  Version: 2.7.2
    77  Author: Daniel Söderström / Sidney van de Stouwe
    88  Author URI: https://vandestouwe.com
     
    1919}
    2020
    21 define( 'STC_VERSION', '2.7.1' );
     21define( 'STC_VERSION', '2.7.2' );
    2222define( 'STC_SLUG', 'stc' );
    2323define( 'STC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.