Created
August 23, 2022 17:32
-
-
Save BhargavBhandari90/e0e9f07a9cadc025f56b3c669f3ea67c to your computer and use it in GitHub Desktop.
Set BB groups in elementor Display Conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( | |
'elementor/theme/register_conditions', | |
function( $conditions_manager ) { | |
class Page_Template_Condition extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base { | |
public static function get_type() { | |
return 'singular'; | |
} | |
public static function get_priority() { | |
return 30; | |
} | |
public function get_name() { | |
return 'bb_group'; | |
} | |
public function get_label() { | |
return __( 'BB Group' ); | |
} | |
public function check( $args ) { | |
return bp_is_group() && $args['id'] == bp_get_current_group_id(); | |
} | |
protected function _register_controls() { | |
$groups = groups_get_groups( array( 'per_page' => 999 ) ); | |
$groups = wp_list_pluck( $groups['groups'], 'name', 'id' ); | |
$this->add_control( | |
'page_template', | |
array( | |
'section' => 'settings', | |
'label' => __( 'BB Group' ), | |
'type' => \Elementor\Controls_Manager::SELECT, | |
'options' => $groups, | |
) | |
); | |
} | |
} | |
$conditions_manager->get_condition( 'singular' )->register_sub_condition( new Page_Template_Condition() ); | |
}, | |
100 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment