/var/www/html_us/wp-content/plugins/revslider/admin/includes/newsletter.class.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
 * @author    ThemePunch <[email protected]>
 * @link      https://www.themepunch.com/
 * @copyright 2024 ThemePunch
 * @version   1.0.0
 */
 
if(!defined('ABSPATH')) exit();

if(!
class_exists('ThemePunch_Newsletter')) {
     
    class 
ThemePunch_Newsletter {
    
        protected static 
$remote_url    'http://newsletter.themepunch.com/';
        protected static 
$subscribe        'subscribe.php';
        protected static 
$unsubscribe    'unsubscribe.php';
        
        public function 
__construct(){
            
        }
        
        
        
/**
         * Subscribe to the ThemePunch Newsletter
         * @since: 1.0.0
         **/
        
public static function subscribe($email){
            global 
$wp_version;
            
            
$request wp_safe_remote_post(self::$remote_url.self::$subscribe, array(
                
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
                
'timeout' => 15,
                
'body' => array(
                    
'email' => urlencode($email)
                )
            ));
            
            if(!
is_wp_error($request)) {
                if(
$response json_decode($request['body'], true)) {
                    if(
is_array($response)) {
                        
$data $response;
                        
                        return 
$data;
                    }else{
                        return 
false;
                    }
                }
            }
        }
        
        
        
/**
         * Unsubscribe to the ThemePunch Newsletter
         * @since: 1.0.0
         **/
        
public static function unsubscribe($email){
            global 
$wp_version;
            
            
$request wp_safe_remote_post(self::$remote_url.self::$unsubscribe, array(
                
'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url'),
                
'timeout' => 15,
                
'body' => array(
                    
'email' => urlencode($email)
                )
            ));
            
            if(!
is_wp_error($request)) {
                if(
$response json_decode($request['body'], true)) {
                    if(
is_array($response)) {
                        
$data $response;
                        
                        return 
$data;
                    }else{
                        return 
false;
                    }
                }
            }
        }
        
    }
}