PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.8
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.8
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / integrations / buddypress / includes / components / gamipress-points-bp-component.php

gamipress-points-bp-component.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.8, at integrations/buddypress/includes/components/gamipress-points-bp-component.php

98 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * GamiPress Points BuddyPress Component
4 *
5 * @package GamiPress\BuddyPress\GamiPress_Points_BP_Component
6 * @since 1.0.8
7 */
8
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 if( ! class_exists( 'GamiPress_Points_BP_Component' ) ) {
13
14 /**
15 * Class GamiPress_Points_BP_Component
16 *
17 * @since 1.0.8
18 */
19 class GamiPress_Points_BP_Component extends BP_Component {
20
21 function __construct() {
22 parent::start(
23 'gamipress-points',
24 __( 'GamiPress Points', 'gamipress' ),
25 BP_PLUGIN_DIR
26 );
27
28 }
29
30 // Globals
31 public function setup_globals( $args = '' ) {
32 $points_tab_title = gamipress_bp_get_option( 'points_tab_title', __( 'Points', 'gamipress' ) );
33 $points_tab_slug = gamipress_bp_get_option( 'points_tab_slug', '' );
34
35 // If empty slug generate it from the title
36 if( empty( $points_tab_slug ) ) {
37 $points_tab_slug = sanitize_title( $points_tab_title );
38 }
39
40 parent::setup_globals( array(
41 'has_directory' => true,
42 'root_slug' => $points_tab_slug,
43 'slug' => $points_tab_slug,
44 ) );
45 }
46
47 // BuddyPress actions
48 public function setup_actions() {
49 parent::setup_actions();
50 }
51
52 // Member Profile Menu
53 public function setup_nav( $main_nav = '', $sub_nav = '' ) {
54
55 if ( ! is_user_logged_in() && ! bp_displayed_user_id() )
56 return;
57
58 if( ! (bool) gamipress_bp_get_option( 'points_tab', false ) ) {
59 return;
60 }
61
62 $points_types_to_show = gamipress_bp_tab_get_points_types();
63
64 if( empty( $points_types_to_show ) ) {
65 return;
66 }
67
68 /**
69 * Filter to programmatically decide if tab should be displayed
70 *
71 * @param bool $show
72 * @param int $displayed_user_id
73 *
74 * @return bool
75 */
76 if( ! (bool) apply_filters( 'gamipress_bp_member_points_tab', true, bp_displayed_user_id() ) ) {
77 return;
78 }
79
80 $tab_title = gamipress_bp_get_option( 'points_tab_title', __( 'Points', 'gamipress' ) );
81
82 $sub_nav = '';
83
84 // Add to the main navigation
85 $main_nav = array(
86 'name' => $tab_title,
87 'slug' => $this->slug,
88 'position' => 100,
89 'screen_function' => 'gamipress_bp_points_tab',
90 'default_subnav_slug' => $this->slug
91 );
92
93 parent::setup_nav( $main_nav, $sub_nav );
94 }
95
96 }
97
98 }