C:\xampp\htdocs\landing\wp-content\plugins\mailchimp-for-wp\integrations\custom\class-custom.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php

defined
'ABSPATH' ) or exit;

/**
 * Class MC4WP_Custom_Integration
 * @ignore
 */
class MC4WP_Custom_Integration extends MC4WP_Integration {


    
/**
     * @var string
     */
    
protected $checkbox_name 'mc4wp-subscribe';

    
/**
     * @var string
     */
    
public $name 'Custom';

    
/**
     * @var string
     */
    
public $description 'Integrate with custom third-party forms.';

    
/**
    * Add hooks
    */
    
public function add_hooks() {
        
add_action'init', array( $this'listen' ), 50 );
    }

    
/**
     * Was the integration checkbox checked?
     *
     * @return bool
     */
    
public function checkbox_was_checked() {
        
$data          $this->get_data();
        
$value         = isset( $data$this->checkbox_name ] ) ? $data$this->checkbox_name ] : '';
        
$truthy_values = array( 1'1''yes'true'true''y' );
        return 
in_array$value$truthy_valuestrue );
    }

    
/**
     * Maybe fire a general subscription request
     */
    
public function listen() {
        if ( ! 
$this->checkbox_was_checked() ) {
            return 
false;
        }

        
$data $this->get_data();

        
// don't run for CF7 or Events Manager requests
        // (since they use the same "mc4wp-subscribe" trigger)
        
$disable_triggers = array(
            
'_wpcf7' => '',
            
'action' => 'booking_add',
        );

        foreach ( 
$disable_triggers as $trigger => $trigger_value ) {
            if ( isset( 
$data$trigger ] ) ) {
                
$value $data$trigger ];

                
// do nothing if trigger value is optional
                // or if trigger value matches
                
if ( empty( $trigger_value ) || $value === $trigger_value ) {
                    return 
false;
                }
            }
        }

        
// run!
        
return $this->process();
    }

    
/**
     * Process custom form
     *
     * @return bool|string
     */
    
public function process() {
        
$parser = new MC4WP_Field_Guesser$this->get_data() );
        
$data   $parser->combine( array( 'guessed''namespaced' ) );

        
// do nothing if no email was found
        
if ( empty( $data['EMAIL'] ) ) {
            
$this->get_log()->warningsprintf'%s > Unable to find EMAIL field.'$this->name ) );
            return 
false;
        }

        return 
$this->subscribe$data );
    }

    
/**
     * @return bool
     */
    
public function is_installed() {
        return 
true;
    }

    
/**
     * @return array
     */
    
public function get_ui_elements() {
        return array( 
'lists''double_optin''update_existing''replace_interests' );
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586