Disable_Section
Mon May 23 2022 08:32:26 GMT+0000 (Coordinated Universal Time)
Saved by
@itaiki
/**
* Class Elementor_Disable_Section
*/
class Elementor_Disable_Section {
public function __construct() {
// Add hooks only if elementor is loaded
add_action( 'elementor/init', [ $this, 'add_hooks' ] );
}
public function add_hooks() {
// Add our custom control section to Section panel
add_action( 'elementor/element/section/section_typo/after_section_end', [ $this, 'add_section_controls' ], 10, 2 );
// Filter if the section was set as disabled
add_filter( 'elementor/frontend/section/should_render', [ $this, 'should_render' ], 10, 2 );
}
/**
* should_render
* This is the magic method that actually disables the section
* render if it was set as disabled.
*/
public function should_render( $should_render, $section ) {
$is_disabled = $section->get_settings( 'is_disabled' );
if ( ! empty( $is_disabled ) && 'yes' === $is_disabled ) {
return false;
}
return $should_render;
}
/**
* add_section_controls
* Used to add our "Disable" control to section panel
*/
public function add_section_controls( $section, $args ) {
$section->start_controls_section(
'section_disable',
[
'label' => 'ביטול טעינת אזור בכל המכשירים',
'tab' => \Elementor\Controls_Manager::TAB_ADVANCED,
]
);
$section->add_control(
'is_disabled',
[
'label' => 'השבתת אזור',
'type' => \Elementor\Controls_Manager::SWITCHER,
]
);
$section->end_controls_section();
}
};
new Elementor_Disable_Section();
content_copyCOPY
Comments