PluginProbe
Hello Plus / 1.2.0
Hello Plus v1.2.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / theme / components / theme-overrides.php

theme-overrides.php in Hello Plus 1.2.0, at modules/theme/components/theme-overrides.php

89 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HelloPlus\Modules\Theme\Components;
4
5 use HelloPlus\Includes\Utils;
6 use HelloPlus\Modules\Admin\Classes\Menu\Pages\Setup_Wizard;
7 use HelloPlus\Modules\TemplateParts\Documents\{
8 Ehp_Document_Base,
9 Ehp_Footer,
10 Ehp_Header
11 };
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly
15 }
16
17 class Theme_Overrides {
18
19 public function admin_config( array $config ): array {
20 if ( ! Setup_Wizard::has_site_wizard_been_completed() ) {
21 return $config;
22 }
23
24 $config['siteParts']['siteParts'] = [];
25
26 $header = Ehp_Header::get_active_document();
27 $footer = Ehp_Footer::get_active_document();
28 $elementor_active = Utils::is_elementor_active();
29 $edit_with_elementor = $elementor_active ? '&action=elementor' : '';
30
31 if ( $header ) {
32 $config['siteParts']['siteParts'][] = [
33 'title' => __( 'Header', 'hello-plus' ),
34 'link' => get_edit_post_link( $header[0], 'admin' ) . $edit_with_elementor,
35 ];
36 }
37
38 if ( $footer ) {
39 $config['siteParts']['siteParts'][] = [
40 'title' => __( 'Footer', 'hello-plus' ),
41 'link' => get_edit_post_link( $footer[0], 'admin' ) . $edit_with_elementor,
42 ];
43 }
44
45 return $config;
46 }
47
48 public function localize_settings( $data ) {
49 $data['close_modal_redirect_hello_plus'] = admin_url( 'admin.php?page=' . Utils::get_theme_slug() );
50
51 return $data;
52 }
53
54 public function display_default_header( bool $display ): bool {
55 return $this->display_default_header_footer( $display, 'header' );
56 }
57
58 public function display_default_footer( bool $display ): bool {
59 return $this->display_default_header_footer( $display, 'footer' );
60 }
61
62 protected function display_default_header_footer( bool $display, string $location ): bool {
63 if ( ! Utils::elementor()->preview->is_preview_mode() ) {
64 return $display;
65 }
66
67 $preview_post_id = filter_input( INPUT_GET, 'elementor-preview', FILTER_VALIDATE_INT );
68 $document = Utils::elementor()->documents->get( $preview_post_id );
69
70 if ( $document instanceof Ehp_Document_Base && $document::LOCATION === $location ) {
71 return false;
72 }
73
74 return $display;
75 }
76
77 public function __construct() {
78 add_filter( 'hello-plus-theme/settings/header_footer', '__return_false' );
79 add_filter( 'hello-plus-theme/settings/hello_theme', '__return_false' );
80 add_filter( 'hello-plus-theme/settings/hello_style', '__return_false' );
81 add_filter( 'hello-plus-theme/customizer/enable', Setup_Wizard::has_site_wizard_been_completed() ? '__return_false' : '__return_true' );
82 add_filter( 'hello-plus-theme/rest/admin-config', [ $this, 'admin_config' ] );
83 add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
84
85 add_filter( 'hello-plus-theme/display-default-header', [ $this, 'display_default_header' ] );
86 add_filter( 'hello-plus-theme/display-default-footer', [ $this, 'display_default_footer' ] );
87 }
88 }
89