| 1 |
<?php |
| 2 |
|
| 3 |
namespace forge12\contactform7\CF7DoubleOptIn { |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Plugin Name: Double Opt-In (Contact Form 7, Avada) - GDPR Ready |
| 10 |
* Plugin URI: https://www.forge12.com/blog/so-verwendest-du-das-double-opt-in-fuer-contact-form-7/ |
| 11 |
* Description: This plugin allows you to add a double OptIn System to your Contact Form 7 & Avada Forms. |
| 12 |
* Text Domain: double-opt-in |
| 13 |
* Domain Path: /languages |
| 14 |
* Version: 3.0.3 |
| 15 |
* Author: Forge12 Interactive GmbH |
| 16 |
* Author URI: https://www.forge12.com |
| 17 |
*/ |
| 18 |
define( 'FORGE12_OPTIN_VERSION', '3.0.3' ); |
| 19 |
define( 'FORGE12_OPTIN_SLUG', 'f12-cf7-doubleoptin' ); |
| 20 |
define( 'FORGE12_OPTIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* Dependencies |
| 25 |
*/ |
| 26 |
require_once( 'core/BaseController.class.php' ); |
| 27 |
|
| 28 |
require_once( 'OnActivation.php' ); |
| 29 |
require_once( 'OnDeactivation.php' ); |
| 30 |
require_once( 'OnUpdate.php' ); |
| 31 |
require_once( 'compatibility/OptInFrontend.class.php' ); |
| 32 |
|
| 33 |
require_once( 'core/Messages.class.php' ); |
| 34 |
require_once( 'core/TemplateHandler.class.php' ); |
| 35 |
require_once( 'core/IPHelper.class.php' ); |
| 36 |
require_once( 'core/SanitizeHelper.class.php' ); |
| 37 |
require_once( 'core/Ajax.class.php' ); |
| 38 |
require_once( 'core/Compatibility.class.php' ); |
| 39 |
require_once( 'core/CleanUp.class.php' ); |
| 40 |
require_once( 'core/HTMLSelect.class.php' ); |
| 41 |
require_once( 'core/UI.class.php' ); |
| 42 |
require_once( 'core/UIPage.class.php' ); |
| 43 |
require_once( 'core/UIPageForm.class.php' ); |
| 44 |
require_once( 'core/OptIn.class.php' ); |
| 45 |
require_once( 'core/OptInLimitFilter.class.php' ); |
| 46 |
require_once( 'core/OptInSearchFilter.class.php' ); |
| 47 |
require_once( 'core/Category.class.php' ); |
| 48 |
require_once( 'core/CategoryOptions.class.php' ); |
| 49 |
require_once( 'core/Pagination.class.php' ); |
| 50 |
require_once( 'core/Support.class.php' ); |
| 51 |
|
| 52 |
/** |
| 53 |
* Class CF7DoubleOptIn |
| 54 |
* Controller for the Custom Links. |
| 55 |
* |
| 56 |
* @package forge12\contactform7 |
| 57 |
*/ |
| 58 |
class CF7DoubleOptIn { |
| 59 |
/** |
| 60 |
* @var CF7DoubleOptIn|Null |
| 61 |
*/ |
| 62 |
private static $_instance = null; |
| 63 |
|
| 64 |
/** |
| 65 |
* @var TemplateHandler|null |
| 66 |
*/ |
| 67 |
private $TemplateHandler = null; |
| 68 |
|
| 69 |
/** |
| 70 |
* Get the singleton instance of CF7DoubleOptIn. |
| 71 |
* |
| 72 |
* @return CF7DoubleOptIn The singleton instance. |
| 73 |
*/ |
| 74 |
public static function getInstance() { |
| 75 |
if ( self::$_instance == null ) { |
| 76 |
self::$_instance = new self(); |
| 77 |
} |
| 78 |
|
| 79 |
return self::$_instance; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Return a list containing the array with all data stored within the form |
| 84 |
* |
| 85 |
* @param int $postID |
| 86 |
* |
| 87 |
* @formatter:off |
| 88 |
* |
| 89 |
* @return { |
| 90 |
* @type int $enable The Status of the OptIn, either 1 for enabled or 0 for disabled. Default: 0 |
| 91 |
* @type string $sender The E-Mail of the sender of the optIn mail |
| 92 |
* @type string $subject The Subject of the OptIn Mail |
| 93 |
* @type string $body The Content of the OptIn Mail |
| 94 |
* @type string $recipient The Field that contains the E-Mail of the Recipient. |
| 95 |
* @type int $page The Post ID of the confirmation page. Default: -1 |
| 96 |
* @type string $conditions Additional condition to dynamically enable / disable the optin. |
| 97 |
* Default: disabled |
| 98 |
* @type string $template The Template used for the OptIn Mail |
| 99 |
* @type int $category The Category the OptIns will be assigned to. |
| 100 |
* } |
| 101 |
* @formatter:on |
| 102 |
*/ |
| 103 |
public function getParameter( $postID ) { |
| 104 |
|
| 105 |
$data = [ |
| 106 |
'enable' => 0, |
| 107 |
'sender' => get_bloginfo( 'admin_email' ), |
| 108 |
'sender_name' => '', |
| 109 |
'subject' => '', |
| 110 |
'body' => '', |
| 111 |
'recipient' => '', |
| 112 |
'page' => - 1, |
| 113 |
'conditions' => 'disabled', |
| 114 |
'template' => '', |
| 115 |
'category' => 0, |
| 116 |
]; |
| 117 |
|
| 118 |
/** |
| 119 |
* DOI Parameter |
| 120 |
* |
| 121 |
* Filters the parameter for the DOI. This hook allows developers |
| 122 |
* to alter DOI fields. |
| 123 |
* |
| 124 |
* @param array $data Additional Fields |
| 125 |
* |
| 126 |
* @since 1.0.0 |
| 127 |
*/ |
| 128 |
$data = apply_filters( 'f12_cf7_doubleoptin_get_parameter', $data ); |
| 129 |
|
| 130 |
if ( ! $postID ) { |
| 131 |
return $data; |
| 132 |
} |
| 133 |
|
| 134 |
$options = get_post_meta( $postID, 'f12-cf7-doubleoptin', true ); |
| 135 |
|
| 136 |
if ( ! $options ) { |
| 137 |
return $data; |
| 138 |
} |
| 139 |
|
| 140 |
return array_merge( $data, $options ); |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Private constructor to prevent direct instantiation. |
| 145 |
*/ |
| 146 |
private function __construct() { |
| 147 |
load_plugin_textdomain( 'double-opt-in', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 148 |
/** |
| 149 |
* DOI INIT |
| 150 |
* |
| 151 |
* Run custom actions after the DOI has been initialized |
| 152 |
* |
| 153 |
* @param CF7DoubleOptIn $this |
| 154 |
* |
| 155 |
* @since 3.0.0 |
| 156 |
*/ |
| 157 |
do_action( 'f12_cf7_doubleoptin_init', $this ); |
| 158 |
|
| 159 |
|
| 160 |
$this->TemplateHandler = TemplateHandler::getInstance(); |
| 161 |
|
| 162 |
$UI = new UI( $this->TemplateHandler, FORGE12_OPTIN_SLUG, 'Forge12 Double Opt-In', 'manage_options' ); |
| 163 |
|
| 164 |
add_action( 'after_setup_theme', array( $this, 'init' ) ); |
| 165 |
|
| 166 |
$Compatibility = new Compatibility( $this ); |
| 167 |
$CleanUp = new CleanUp(); |
| 168 |
|
| 169 |
// Pagination |
| 170 |
Pagination::getInstance(); |
| 171 |
|
| 172 |
// initialize filter |
| 173 |
CategoryOptions::getInstance(); |
| 174 |
OptInLimitFilter::getInstance(); |
| 175 |
OptInSearchFilter::getInstance(); |
| 176 |
|
| 177 |
// Support |
| 178 |
Support::getInstance(); |
| 179 |
} |
| 180 |
|
| 181 |
/** |
| 182 |
* Retrieve the template handler instance. |
| 183 |
* |
| 184 |
* @return TemplateHandler The template handler instance. |
| 185 |
*/ |
| 186 |
public function get_template_handler() { |
| 187 |
return $this->TemplateHandler; |
| 188 |
} |
| 189 |
|
| 190 |
/** |
| 191 |
* @private WordPress Hook |
| 192 |
*/ |
| 193 |
public function init() { |
| 194 |
do_action( 'f12_cf7_doubleoptin_register_implementations' ); |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Return the settings for the optin. |
| 199 |
* |
| 200 |
* @param string $single The Key of the setting to return only the required setting |
| 201 |
* |
| 202 |
* @formatter:off |
| 203 |
* @return { |
| 204 |
* // Returns the Settings for the DOI |
| 205 |
* |
| 206 |
* @type string $optout_subject The Subject for the OptOut Mail |
| 207 |
* @type string $optout_body The Content for the OptOut Mail |
| 208 |
* @type int $optout_page The Post ID for the OptOut Page |
| 209 |
* @type int $support Defines if the Support link will be added to the footer |
| 210 |
* @type int $delete An integer from 1 to 30 |
| 211 |
* @type int $delete_unconfirmed An integer from 1 to 30 |
| 212 |
* @type string $delete_period The time period, either months, days, years |
| 213 |
* @type string $delete_unconfirmed_period The time period, either months, days, years |
| 214 |
* } |
| 215 |
* @formatter:on |
| 216 |
*/ |
| 217 |
public function getSettings( $single = '', $container = null ) { |
| 218 |
$default = array(); |
| 219 |
|
| 220 |
$default = apply_filters( 'f12_cf7_doubleoptin_settings', $default ); |
| 221 |
|
| 222 |
$settings = get_option( 'f12-doi-settings' ); |
| 223 |
|
| 224 |
if ( ! is_array( $settings ) ) { |
| 225 |
$settings = array(); |
| 226 |
} |
| 227 |
|
| 228 |
foreach ( $default as $key => $data ) { |
| 229 |
if ( isset( $settings[ $key ] ) ) { |
| 230 |
if ( is_array( $default[ $key ] ) ) { |
| 231 |
$default[ $key ] = array_merge( $default[ $key ], $settings[ $key ] ); |
| 232 |
} else { |
| 233 |
$default[ $key ] = $settings[ $key ]; |
| 234 |
} |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
$settings = $default; |
| 239 |
|
| 240 |
if ( ! empty( $single ) ) { |
| 241 |
if ( $container != null ) { |
| 242 |
if ( isset( $settings[ $container ] ) && isset( $settings[ $container ][ $single ] ) ) { |
| 243 |
$settings = $settings[ $container ][ $single ]; |
| 244 |
} |
| 245 |
} |
| 246 |
} else { |
| 247 |
if ( isset( $settings[ $single ] ) ) { |
| 248 |
$settings = $settings[ $single ]; |
| 249 |
} |
| 250 |
} |
| 251 |
|
| 252 |
return $settings; |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
CF7DoubleOptIn::getInstance(); |
| 258 |
|
| 259 |
} |