wpml-slug-translation-factory.php
1.87 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
<?php
class WPML_Slug_Translation_Factory implements IWPML_Frontend_Action_Loader, IWPML_Backend_Action_Loader, IWPML_AJAX_Action_Loader {
const POST = 'post';
const TAX = 'taxonomy';
const INIT_PRIORITY = -1000;
public function create() {
global $sitepress;
$hooks = array();
$records_factory = new WPML_Slug_Translation_Records_Factory();
$settings_factory = new WPML_ST_Slug_Translation_Settings_Factory();
$post_records = $records_factory->create( self::POST );
$tax_records = $records_factory->createTaxRecords();
$global_settings = $settings_factory->create();
$post_settings = $settings_factory->create( self::POST );
$tax_settings = $settings_factory->createTaxSettings();
$term_link_filter = new WPML_ST_Term_Link_Filter( $tax_records, $sitepress, new WPML_WP_Cache_Factory(), $tax_settings );
$hooks['legacy_class'] = new WPML_Slug_Translation(
$sitepress,
$records_factory,
WPML_Get_LS_Languages_Status::get_instance(),
$term_link_filter,
$global_settings
);
$hooks['rewrite_rules'] = ( new \WPML\ST\SlugTranslation\Hooks\HooksFactory() )->create();
if ( is_admin() ) {
$hooks['ui_save_post'] = new WPML_ST_Slug_Translation_UI_Save(
$post_settings,
$post_records,
$sitepress,
new WPML_WP_Post_Type(),
WPML_ST_Slug_Translation_UI_Save::ACTION_HOOK_FOR_POST
);
$hooks['ui_save_tax'] = new WPML_ST_Slug_Translation_UI_Save(
$tax_settings,
$tax_records,
$sitepress,
new WPML_WP_Taxonomy(),
WPML_ST_Slug_Translation_UI_Save::ACTION_HOOK_FOR_TAX
);
if ( $global_settings->is_enabled() ) {
$hooks['sync_strings'] = new WPML_ST_Slug_Translation_Strings_Sync(
$records_factory,
$settings_factory
);
}
}
$hooks['public-api'] = new WPML_ST_Slug_Translation_API(
$records_factory,
$settings_factory,
$sitepress,
new WPML_WP_API()
);
return $hooks;
}
}