PluginProbe
Photo Gallery by Re Gallery: Responsive Image Gallery with AI SEO / trunk
Photo Gallery by Re Gallery: Responsive Image Gallery with AI SEO vtrunk
1.20.14 1.20.13 1.20.12 1.20.11 1.20.10 1.20.9 1.20.8 1.20.7 1.20.6 1.20.5 1.20.4 1.20.3 1.20.2 1.20.1 1.20.0 1.19.2 1.19.1 1.19.0 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 All 135 releases
regallery / builders / elementor / elementor.php

elementor.php in Photo Gallery by Re Gallery: Responsive Image Gallery with AI SEO trunk, at builders/elementor/elementor.php

120 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class REACG_Elementor extends \Elementor\Widget_Base {
4 /**
5 * Get widget name.
6 *
7 * @return string
8 */
9 public function get_name() {
10 return 'reacg-elementor';
11 }
12
13 /**
14 * Get widget title.
15 *
16 * @return string
17 */
18 public function get_title() {
19 return REACG_NICENAME;
20 }
21
22 /**
23 * Get widget icon.
24 *
25 * @return string
26 */
27 public function get_icon() {
28 return 'reacg-elementor-icon';
29 }
30
31 /**
32 * Get widget category.
33 *
34 * @return string[]
35 */
36 public function get_categories() {
37 return [ 'basic' ];
38 }
39
40 /**
41 * Register widget controls.
42 *
43 * @return void
44 */
45 protected function register_controls() {
46 $this->start_controls_section(
47 'reacg_general',
48 [
49 'label' => __('Basic', 'regallery'),
50 ]
51 );
52
53 $edit_link = add_query_arg(array( 'post_type' => REACG_CUSTOM_POST_TYPE ), admin_url('edit.php'));
54 $this->add_control(
55 'post_id',
56 [
57 'label_block' => TRUE,
58 'show_label' => FALSE,
59 /* translators: 1: opening anchor tag, 2: closing anchor tag */
60 'description' => sprintf(__('Add/edit galleries %1$shere%2$s.', 'regallery'), '<a target="_blank" href="' . $edit_link . '">', '</a>'),
61 'type' => \Elementor\Controls_Manager::SELECT,
62 'default' => 0,
63 'options' => REACGLibrary::get_shortcodes(FALSE, TRUE, FALSE),
64 ]
65 );
66 $this->add_control(
67 'enable_options',
68 [
69 'label' => __('Enable options section', 'regallery'),
70 'label_block' => FALSE,
71 'type' => \Elementor\Controls_Manager::SWITCHER,
72 'label_yes' => __('Yes', 'regallery'),
73 'label_no' => __('No', 'regallery'),
74 'default' => 'no',
75 'description' => __( 'The options will be visible only in editor mode.', 'regallery' ),
76 ]
77 );
78
79 $this->end_controls_section();
80 }
81
82 /**
83 * Render widget output on the frontend.
84 *
85 * @return void
86 */
87 protected function render() {
88 $settings = $this->get_settings_for_display();
89 $post_id = intval($settings["post_id"]);
90
91 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Intentional output of trusted HTML and JS generated by the plugin.
92 echo REACGLibrary::get_rest_routs($post_id);
93
94 if ( is_admin() ) {
95 $enable_options = $settings["enable_options"] === "yes" ? 1 : 0;
96 echo '<script type="text/javascript">';
97 // Get inserted widget container by ID.
98 echo 'var widget_cont = document.querySelector(".elementor-element-' . esc_js($this->get_id()) . '");';
99 // Get the gallery container.
100 echo 'var cont = widget_cont ? widget_cont.querySelector("#reacg-root' . esc_js($post_id) . '") : null;';
101 // Enable/disable options section depends on Elementor widget setting.
102 echo 'if (cont) {';
103 echo 'cont.setAttribute("data-options-section", "' . esc_js($enable_options) . '");';
104 echo 'cont.setAttribute("data-plugin-version", "' . esc_js(REACG_VERSION) . '");';
105 echo 'cont.setAttribute("data-gallery-timestamp", Date.now());';
106 echo 'cont.setAttribute("data-options-timestamp", Date.now());';
107 echo '}';
108 // Load the gallery.
109 echo 'var reacgLoadApp = document.getElementById("reacg-loadApp");';
110 echo 'if (reacgLoadApp) {';
111 echo 'reacgLoadApp.setAttribute("data-id", "reacg-root' . esc_js($post_id) . '");';
112 echo 'reacgLoadApp.click();';
113 echo '}';
114 // Open Elementor widget settings after the gallery load.
115 echo 'if (widget_cont) { widget_cont.querySelector(".elementor-editor-widget-settings").click(); }';
116 echo '</script>';
117 }
118 }
119 }
120