PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / floating-buttons / documents / floating-buttons.php

floating-buttons.php in Elementor Website Builder – more than just a page builder 3.23.0-dev3, at modules/floating-buttons/documents/floating-buttons.php

145 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\FloatingButtons\Documents;
4
5 use Elementor\Core\DocumentTypes\PageBase;
6 use Elementor\Modules\Library\Traits\Library as Library_Trait;
7 use Elementor\Modules\FloatingButtons\Module as Floating_Buttons_Module;
8 use Elementor\Modules\PageTemplates\Module as Page_Templates_Module;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13
14 class Floating_Buttons extends PageBase {
15 use Library_Trait;
16
17 public static function get_properties() {
18 $properties = parent::get_properties();
19
20 $properties['support_kit'] = true;
21 $properties['support_site_editor'] = false;
22 $properties['cpt'] = [ Floating_Buttons_Module::CPT_FLOATING_BUTTONS ];
23 $properties['show_navigator'] = false;
24 $properties['allow_adding_widgets'] = false;
25 $properties['support_page_layout'] = false;
26 $properties['library_close_title'] = esc_html__( 'Go To Dashboard', 'elementor' );
27 $properties['publish_button_title'] = esc_html__( 'After publishing this widget, you will be able to set it as visible on the entire site in the Admin Table.', 'elementor' );
28 $properties['allow_closing_remote_library'] = false;
29
30 return $properties;
31 }
32
33 public function print_content() {
34 $plugin = \Elementor\Plugin::$instance;
35
36 if ( $plugin->preview->is_preview_mode( $this->get_main_id() ) ) {
37 // PHPCS - the method builder_wrapper is safe.
38 echo $plugin->preview->builder_wrapper( '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
39 } else {
40 // PHPCS - the method get_content is safe.
41 echo $this->get_content(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
42 }
43 }
44
45 public function get_location() {
46 return self::get_property( 'location' );
47 }
48
49 public static function get_type() {
50 return Floating_Buttons_Module::FLOATING_BUTTONS_DOCUMENT_TYPE;
51 }
52
53 public static function register_post_fields_control( $document ) {}
54
55 public static function register_hide_title_control( $document ) {}
56
57 public function get_name() {
58 return Floating_Buttons_Module::FLOATING_BUTTONS_DOCUMENT_TYPE;
59 }
60
61 public function filter_admin_row_actions( $actions ) {
62 unset( $actions['edit'] );
63 unset( $actions['inline hide-if-no-js'] );
64 $built_with_elementor = parent::filter_admin_row_actions( [] );
65
66 if ( isset( $actions['trash'] ) ) {
67 $delete = $actions['trash'];
68 unset( $actions['trash'] );
69 $actions['trash'] = $delete;
70 }
71
72 if ( 'publish' === $this->get_post()->post_status ) {
73 $actions = $this->set_as_entire_site( $actions );
74 }
75
76 return $built_with_elementor + $actions;
77 }
78
79 public function set_as_entire_site( $actions ) {
80 if ( get_post_meta( $this->get_post()->ID, '_elementor_conditions', true ) ) {
81 $actions['set_as_entire_site'] = sprintf(
82 '<a style="color:red;" href="?post=%s&action=remove_from_entire_site&_wpnonce=%s">%s</a>',
83 $this->get_post()->ID,
84 wp_create_nonce( 'remove_from_entire_site_' . $this->get_post()->ID ),
85 esc_html__( 'Remove From Entire Site', 'elementor' )
86 );
87 } else {
88 $actions['set_as_entire_site'] = sprintf(
89 '<a href="?post=%s&action=set_as_entire_site&_wpnonce=%s">%s</a>',
90 $this->get_post()->ID,
91 wp_create_nonce( 'set_as_entire_site_' . $this->get_post()->ID ),
92 esc_html__( 'Set as Entire Site', 'elementor' )
93 );
94 }
95
96 return $actions;
97 }
98
99 public static function get_title() {
100 return esc_html__( 'Floating Button', 'elementor' );
101 }
102
103 public static function get_plural_title() {
104 return esc_html__( 'Floating Buttons', 'elementor' );
105 }
106
107 public static function get_create_url() {
108 return parent::get_create_url() . '#library';
109 }
110
111 public function save( $data ) {
112 if ( empty( $data['settings']['template'] ) ) {
113 $data['settings']['template'] = Page_Templates_Module::TEMPLATE_CANVAS;
114 }
115
116 return parent::save( $data );
117 }
118
119 public function admin_columns_content( $column_name ) {
120 if ( 'elementor_library_type' === $column_name ) {
121 $this->print_admin_column_type();
122 }
123 }
124
125 public function get_edit_url() {
126 $url = parent::get_edit_url();
127
128 if ( ! $this->get_post()->post_content ) {
129 $url .= '#library';
130 }
131
132 return $url;
133 }
134
135 protected function get_remote_library_config() {
136 $config = [
137 'type' => 'floating_button',
138 'default_route' => 'templates/floating-buttons',
139 'autoImportSettings' => true,
140 ];
141
142 return array_replace_recursive( parent::get_remote_library_config(), $config );
143 }
144 }
145