class-wpml-page-builders-defined.php
2.25 KB
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
<?php
/**
* Class WPML_Page_Builders_Defined
*/
class WPML_Page_Builders_Defined {
private $settings;
public function __construct() {
$this->init_settings();
}
public function has( $page_builder ) {
global $wp_version;
if ( 'gutenberg' === $page_builder ) {
if ( version_compare( $wp_version, '5.0-beta1', '>=' ) ) {
return true;
}
}
if ( ! empty( $this->settings[ $page_builder ]['constant'] ) ) {
return defined( $this->settings[ $page_builder ]['constant'] );
}
if ( ! empty( $this->settings[ $page_builder ]['function'] ) ) {
return function_exists( $this->settings[ $page_builder ]['function'] );
}
}
/**
* @param array $components
*
* @return array
*/
public function add_components( $components ) {
if ( isset( $components['page-builders'] ) ) {
foreach (
array(
'beaver-builder' => 'Beaver Builder',
'elementor' => 'Elementor',
'gutenberg' => 'Gutenberg',
'cornerstone' => 'Cornerstone',
'siteorigin' => 'SiteOrigin',
) as $key => $name
) {
$components['page-builders'][ $key ] = array(
'name' => $name,
'constant' => isset( $this->settings[ $key ]['constant'] ) ? $this->settings[ $key ]['constant'] : null,
'function' => isset( $this->settings[ $key ]['function'] ) ? $this->settings[ $key ]['function'] : null,
'notices-display' => array(
'wpml-translation-editor',
),
);
}
}
return $components;
}
public function init_settings() {
$this->settings = array(
'beaver-builder' => array(
'constant' => 'FL_BUILDER_VERSION',
'factory' => 'WPML_Beaver_Builder_Integration_Factory',
),
'elementor' => array(
'constant' => 'ELEMENTOR_VERSION',
'factory' => 'WPML_Elementor_Integration_Factory',
),
'gutenberg' => array(
'constant' => 'GUTENBERG_VERSION',
'factory' => 'WPML_Gutenberg_Integration_Factory',
),
'cornerstone' => array(
'constant' => 'CS_VERSION',
'factory' => 'WPML_Cornerstone_Integration_Factory',
),
'siteorigin' => array(
'constant' => 'SITEORIGIN_PANELS_VERSION',
'factory' => \WPML\PB\SiteOrigin\Factory::class,
),
);
}
/**
* @return array
*/
public function get_settings() {
return $this->settings;
}
}