1 | <?php |
||
17 | class Domain_Mapping { |
||
18 | |||
19 | /** |
||
20 | * Singleton holder. |
||
21 | * |
||
22 | * @var Domain_Mapping |
||
23 | **/ |
||
24 | private static $instance = null; |
||
25 | |||
26 | /** |
||
27 | * An array of methods that are used to hook the Jetpack sync filters for home_url and site_url to a mapping plugin. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | public static $test_methods = array( |
||
32 | 'hook_wordpress_mu_domain_mapping', |
||
33 | 'hook_wpmu_dev_domain_mapping', |
||
34 | ); |
||
35 | |||
36 | /** |
||
37 | * Singleton constructor. |
||
38 | * |
||
39 | * @return Domain_Mapping|null |
||
40 | */ |
||
41 | public static function init() { |
||
48 | |||
49 | /** |
||
50 | * Class Automattic\Jetpack\Third_Party\Domain_Mapping constructor. |
||
51 | */ |
||
52 | private function __construct() { |
||
55 | |||
56 | /** |
||
57 | * This function is called on the plugins_loaded action and will loop through the $test_methods |
||
58 | * to try and hook a domain mapping plugin to the Jetpack sync filters for the home_url and site_url callables. |
||
59 | */ |
||
60 | public function attempt_to_hook_domain_mapping_plugins() { |
||
71 | |||
72 | /** |
||
73 | * This method will test for a constant and function that are known to be used with Donncha's WordPress MU |
||
74 | * Domain Mapping plugin. If conditions are met, we hook the domain_mapping_siteurl() function to Jetpack sync |
||
75 | * filters for home_url and site_url callables. |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function hook_wordpress_mu_domain_mapping() { |
||
89 | |||
90 | /** |
||
91 | * This method will test for a class and method known to be used in WPMU Dev's domain mapping plugin. If the |
||
92 | * method exists, then we'll hook the swap_to_mapped_url() to our Jetpack sync filters for home_url and site_url. |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function hook_wpmu_dev_domain_mapping() { |
||
107 | |||
108 | /* |
||
109 | * Utility Methods |
||
110 | * |
||
111 | * These methods are very minimal, and in most cases, simply pass on arguments. Why create them you ask? |
||
112 | * So that we can test. |
||
113 | */ |
||
114 | |||
115 | /** |
||
116 | * Checks if a method exists. |
||
117 | * |
||
118 | * @param string $class Class name. |
||
119 | * @param string $method Method name. |
||
120 | * |
||
121 | * @return bool Returns function_exists() without modification. |
||
122 | */ |
||
123 | public function method_exists( $class, $method ) { |
||
126 | |||
127 | /** |
||
128 | * Checks if a class exists. |
||
129 | * |
||
130 | * @param string $class Class name. |
||
131 | * |
||
132 | * @return bool Returns class_exists() without modification. |
||
133 | */ |
||
134 | public function class_exists( $class ) { |
||
137 | |||
138 | /** |
||
139 | * Checks if a function exists. |
||
140 | * |
||
141 | * @param string $function Function name. |
||
142 | * |
||
143 | * @return bool Returns function_exists() without modification. |
||
144 | */ |
||
145 | public function function_exists( $function ) { |
||
148 | |||
149 | /** |
||
150 | * Returns the Domain_Map::utils() instance. |
||
151 | * |
||
152 | * @see https://github.com/wpmudev/domain-mapping/blob/master/classes/Domainmap/Utils.php |
||
153 | * @return Domainmap_Utils |
||
154 | */ |
||
155 | public function get_domain_mapping_utils_instance() { |
||
158 | } |
||
159 | |||
161 |