PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 2.1.5
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v2.1.5
5.6.2 5.6.3 5.6.1 5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 3.0.60 3.0.61 3.0.62 All 38 releases
double-opt-in / core / Compatibility.class.php

Compatibility.class.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 2.1.5, at core/Compatibility.class.php

75 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace forge12\contactform7\CF7DoubleOptIn {
4 if(!defined('ABSPATH')){
5 exit;
6 }
7
8 /**
9 * Class Compatibility
10 */
11 class Compatibility
12 {
13 /**
14 * @var array<string, string>
15 */
16 private $components = array();
17
18 /**
19 * UI constructor.
20 * @param $slug
21 */
22 public function __construct()
23 {
24 $this->load(dirname(dirname(__FILE__)) . '/compatibility', 0);
25
26 add_action('after_setup_theme', function(){
27 add_action('f12_cf7_doubleoptin_ui_after_load_compatibilities', array($this, 'registerComponents'), 10, 1);
28 do_action('f12_cf7_doubleoptin_ui_after_load_compatibilities', $this);
29 });
30 }
31
32 public function registerComponents($Compatibility)
33 {
34 foreach ($this->components as $component) {
35 if (isset($component['name']) && isset($component['path'])) {
36 require_once($component['path']);
37 new $component['name']();
38 }
39 }
40 }
41
42 private function addComponent($name, $path)
43 {
44 $this->components[] = array(
45 'name' => $name,
46 'path' => $path
47 );
48 }
49
50 private function load($directory, $lvl)
51 {
52 if (is_dir($directory)) {
53 $handle = opendir($directory);
54
55 if (!$handle) {
56 return;
57 }
58
59 while (false !== ($entry = readdir($handle))) {
60 if ($entry != '.' && $entry != '..') {
61 if (is_dir($directory . '/' . $entry) && $lvl == 0) {
62 $this->load($directory . '/' . $entry, $lvl + 1);
63 } else {
64 if (preg_match('!Controller([a-zA-Z_0-9]+)\.class\.php!', $entry, $matches)) {
65 if (isset($matches[1])) {
66 $this->addComponent('\\'.__NAMESPACE__.'\Controller' . $matches[1], $directory . '/' . $entry);
67 }
68 }
69 }
70 }
71 }
72 }
73 }
74 }
75 }