Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BhargavBhandari90/e0e9f07a9cadc025f56b3c669f3ea67c to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/e0e9f07a9cadc025f56b3c669f3ea67c to your computer and use it in GitHub Desktop.
Set BB groups in elementor Display Conditions
<?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