PluginProbe
Borderless – Addons and Templates for Elementor / 1.6.1
Borderless – Addons and Templates for Elementor v1.6.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / includes / library / inc / ImportActions.php

ImportActions.php in Borderless – Addons and Templates for Elementor 1.6.1, at includes/library/inc/ImportActions.php

90 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace LIBRARY;
4
5 class ImportActions {
6 public function register_hooks() {
7 add_action( 'library/before_content_import_execution', array( $this, 'before_content_import_action' ), 10, 3 );
8
9 add_action( 'library/after_content_import_execution', array( $this, 'before_widget_import_action' ), 10, 3 );
10 add_action( 'library/after_content_import_execution', array( $this, 'widgets_import' ), 20, 3 );
11 add_action( 'library/after_content_import_execution', array( $this, 'redux_import' ), 30, 3 );
12
13 add_action( 'library/customizer_import_execution', array( $this, 'customizer_import' ), 10, 1 );
14
15 add_action( 'library/after_all_import_execution', array( $this, 'after_import_action' ), 10, 3 );
16
17 if ( Helpers::apply_filters( 'library/enable_custom_menu_widget_ids_fix', true ) ) {
18 add_action( 'library/widget_settings_array', array( $this, 'fix_custom_menu_widget_ids' ) );
19 }
20 }
21
22
23 public function fix_custom_menu_widget_ids( $widget ) {
24 if ( ! array_key_exists( 'nav_menu', $widget ) || empty( $widget['nav_menu'] ) || ! is_int( $widget['nav_menu'] ) ) {
25 return $widget;
26 }
27
28 $library = BorderlessLibraryImporter::get_instance();
29 $content_import_data = $library->importer->get_importer_data();
30 $term_ids = $content_import_data['mapping']['term_id'];
31
32 $widget['nav_menu'] = $term_ids[ $widget['nav_menu'] ];
33
34 return $widget;
35 }
36
37
38 public function widgets_import( $selected_import_files, $import_files, $selected_index ) {
39 if ( ! empty( $selected_import_files['widgets'] ) ) {
40 WidgetImporter::import( $selected_import_files['widgets'] );
41 }
42 }
43
44
45 public function redux_import( $selected_import_files, $import_files, $selected_index ) {
46 if ( ! empty( $selected_import_files['redux'] ) ) {
47 ReduxImporter::import( $selected_import_files['redux'] );
48 }
49 }
50
51
52 public function customizer_import( $selected_import_files ) {
53 if ( ! empty( $selected_import_files['customizer'] ) ) {
54 CustomizerImporter::import( $selected_import_files['customizer'] );
55 }
56 }
57
58
59 public function before_content_import_action( $selected_import_files, $import_files, $selected_index ) {
60 $this->do_import_action( 'library/before_content_import', $import_files[ $selected_index ] );
61 }
62
63
64 public function before_widget_import_action( $selected_import_files, $import_files, $selected_index ) {
65 $this->do_import_action( 'library/before_widgets_import', $import_files[ $selected_index ] );
66 }
67
68
69 public function after_import_action( $selected_import_files, $import_files, $selected_index ) {
70 $this->do_import_action( 'library/after_import', $import_files[ $selected_index ] );
71 }
72
73
74 private function do_import_action( $action, $selected_import ) {
75 if ( false !== Helpers::has_action( $action ) ) {
76 $library = BorderlessLibraryImporter::get_instance();
77 $log_file_path = $library->get_log_file_path();
78
79 ob_start();
80 Helpers::do_action( $action, $selected_import );
81 $message = ob_get_clean();
82 $log_added = Helpers::append_to_file(
83 $message,
84 $log_file_path,
85 $action
86 );
87 }
88 }
89 }
90