Skip to content

Commit 0c2fdff

Browse files
committed
added performance section
1 parent ce4444b commit 0c2fdff

3 files changed

Lines changed: 73 additions & 37 deletions

File tree

EmbedPress/Elementor/Widgets/Embedpress_Document.php

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,39 @@ public function get_keywords()
8585
return ['embedpress', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'embedpress-document'];
8686
}
8787

88+
/**
89+
* Performance Settings Section
90+
*/
91+
public function init_performance_controls()
92+
{
93+
// Get global lazy load setting
94+
$g_settings = get_option(EMBEDPRESS_PLG_NAME, []);
95+
$lazy_load_default = isset($g_settings['g_lazyload']) && $g_settings['g_lazyload'] == 1 ? 'yes' : '';
96+
97+
$this->start_controls_section(
98+
'embedpress_performance_section',
99+
[
100+
'label' => __('Performance', 'embedpress'),
101+
]
102+
);
103+
104+
$this->add_control(
105+
'enable_lazy_load',
106+
[
107+
'label' => sprintf(__('Enable Lazy Loading %s', 'embedpress'), $this->pro_text),
108+
'type' => \Elementor\Controls_Manager::SWITCHER,
109+
'label_on' => __('Yes', 'embedpress'),
110+
'label_off' => __('No', 'embedpress'),
111+
'return_value' => 'yes',
112+
'default' => $lazy_load_default,
113+
'description' => __('Load iframe only when it enters the viewport for better performance', 'embedpress'),
114+
'classes' => $this->pro_class,
115+
]
116+
);
117+
118+
$this->end_controls_section();
119+
}
120+
88121
protected function register_controls()
89122
{
90123
$class = 'embedpress-pro-control not-active';
@@ -277,24 +310,7 @@ protected function register_controls()
277310

278311
$this->init_branding_controls( 'document');
279312

280-
// Get global lazy load setting
281-
$g_settings = get_option(EMBEDPRESS_PLG_NAME, []);
282-
$lazy_load_default = isset($g_settings['g_lazyload']) && $g_settings['g_lazyload'] == 1 ? 'yes' : '';
283-
284-
$this->add_control(
285-
'enable_lazy_load',
286-
[
287-
'label' => sprintf(__('Enable Lazy Loading %s', 'embedpress'), $this->pro_text),
288-
'type' => \Elementor\Controls_Manager::SWITCHER,
289-
'label_on' => __('Yes', 'embedpress'),
290-
'label_off' => __('No', 'embedpress'),
291-
'return_value' => 'yes',
292-
'default' => $lazy_load_default,
293-
'separator' => 'before',
294-
'description' => __('Load iframe only when it enters the viewport for better performance', 'embedpress'),
295-
'classes' => $this->pro_class,
296-
]
297-
);
313+
298314

299315
$this->end_controls_section();
300316

@@ -451,6 +467,8 @@ protected function register_controls()
451467
$this->end_controls_section();
452468

453469
do_action( 'extend_elementor_controls', $this, '_doc_', $this->pro_text, $this->pro_class);
470+
471+
$this->init_performance_controls();
454472

455473
}
456474

EmbedPress/Elementor/Widgets/Embedpress_Elementor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ protected function register_controls()
442442
do_action('extend_elementor_controls', $this, '_', $this->pro_text, $this->pro_class);
443443

444444
$this->init_performance_controls();
445+
445446
$this->init_style_controls();
446447
$this->init_opensea_color_and_typography();
447448
}

EmbedPress/Elementor/Widgets/Embedpress_Pdf.php

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,40 @@ public function get_keywords()
8888
return ['embedpress', 'pdf', 'doc', 'embedpress-document'];
8989
}
9090

91+
92+
/**
93+
* Performance Settings Section
94+
*/
95+
public function init_performance_controls()
96+
{
97+
// Get global lazy load setting
98+
$g_settings = get_option(EMBEDPRESS_PLG_NAME, []);
99+
$lazy_load_default = isset($g_settings['g_lazyload']) && $g_settings['g_lazyload'] == 1 ? 'yes' : '';
100+
101+
$this->start_controls_section(
102+
'embedpress_performance_section',
103+
[
104+
'label' => __('Performance', 'embedpress'),
105+
]
106+
);
107+
108+
$this->add_control(
109+
'enable_lazy_load',
110+
[
111+
'label' => sprintf(__('Enable Lazy Loading %s', 'embedpress'), $this->pro_text),
112+
'type' => \Elementor\Controls_Manager::SWITCHER,
113+
'label_on' => __('Yes', 'embedpress'),
114+
'label_off' => __('No', 'embedpress'),
115+
'return_value' => 'yes',
116+
'default' => $lazy_load_default,
117+
'description' => __('Load iframe only when it enters the viewport for better performance', 'embedpress'),
118+
'classes' => $this->pro_class,
119+
]
120+
);
121+
122+
$this->end_controls_section();
123+
}
124+
91125
protected function register_controls()
92126
{
93127
$class = 'embedpress-pro-control not-active';
@@ -353,25 +387,6 @@ protected function register_controls()
353387

354388
$this->init_branding_controls('document');
355389

356-
// Get global lazy load setting
357-
$g_settings = get_option(EMBEDPRESS_PLG_NAME, []);
358-
$lazy_load_default = isset($g_settings['g_lazyload']) && $g_settings['g_lazyload'] == 1 ? 'yes' : '';
359-
360-
$this->add_control(
361-
'enable_lazy_load',
362-
[
363-
'label' => sprintf(__('Enable Lazy Loading %s', 'embedpress'), $this->pro_text),
364-
'type' => \Elementor\Controls_Manager::SWITCHER,
365-
'label_on' => __('Yes', 'embedpress'),
366-
'label_off' => __('No', 'embedpress'),
367-
'return_value' => 'yes',
368-
'default' => $lazy_load_default,
369-
'separator' => 'before',
370-
'description' => __('Load iframe only when it enters the viewport for better performance', 'embedpress'),
371-
'classes' => $this->pro_class,
372-
]
373-
);
374-
375390
$this->end_controls_section();
376391

377392

@@ -756,7 +771,9 @@ protected function register_controls()
756771

757772
$this->end_controls_section();
758773

774+
759775
do_action( 'extend_elementor_controls', $this, '_pdf_', $this->pro_text, $this->pro_class);
776+
$this->init_performance_controls();
760777

761778
}
762779

0 commit comments

Comments
 (0)