class-wpml-element-sync-settings-factory.php
923 Bytes
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
<?php
class WPML_Element_Sync_Settings_Factory {
const POST = 'post';
const TAX = 'taxonomy';
const KEY_POST_SYNC_OPTION = 'custom_posts_sync_option';
const KEY_TAX_SYNC_OPTION = 'taxonomies_sync_option';
/**
* @param string $type
*
* @return WPML_Element_Sync_Settings
* @throws Exception
*/
public static function create( $type ) {
/** @var SitePress $sitepress */
global $sitepress;
if ( self::POST === $type ) {
$settings = $sitepress->get_setting( self::KEY_POST_SYNC_OPTION, array() );
} elseif ( self::TAX === $type ) {
$settings = $sitepress->get_setting( self::KEY_TAX_SYNC_OPTION, array() );
} else {
throw new Exception( 'Unknown element type.' );
}
return new WPML_Element_Sync_Settings( $settings );
}
public static function createPost() {
return self::create( self::POST );
}
public static function createTax() {
return self::create( self::TAX );
}
}