PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.5
8.0.5 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 All 47 releases
← All changes | integrations/fluentbooking/includes/functions.php +166 -0 7.9.2 → 8.0.5 View file →
@@ -1,0 +1,166 @@
1 +<?php
2 +/**
3 + * Functions
4 + *
5 + * @package GamiPress\FluentBooking\Functions
6 + * @since 1.0.0
7 + */
8 +
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * Overrides GamiPress AJAX Helper for selecting posts
14 + *
15 + * @since 1.0.0
16 + */
17 +function gamipress_fluentbooking_ajax_get_posts() {
18 +
19 + // Security check, forces to die if not security passed
20 + check_ajax_referer( 'gamipress_admin', 'nonce' );
21 +
22 + // Check if user can manage GamiPress
23 + if( ! current_user_can( gamipress_get_manager_capability() ) ) {
24 + wp_send_json_error( __( 'You\'re not allowed to perform this action.', 'gamipress' ) );
25 + }
26 +
27 + global $wpdb;
28 +
29 + $results = array();
30 +
31 + // Pull back the search string
32 + $search = isset( $_REQUEST['q'] ) ? sanitize_text_field( $_REQUEST['q'] ) : '';
33 + $search = $wpdb->esc_like( $search );
34 +
35 + if( isset( $_REQUEST['post_type'] ) && in_array( 'single_meeting', $_REQUEST['post_type'] ) ) {
36 +
37 + // Get the single calendars
38 + $calendars = FluentBooking\App\Models\CalendarSlot::where( 'event_type', 'single' )->get();
39 +
40 + foreach ( $calendars as $calendar ) {
41 +
42 + if( ! empty( $search ) ) {
43 + if( strpos( strtolower( $calendar->title ), strtolower( $search ) ) === false ) {
44 + continue;
45 + }
46 + }
47 +
48 + // Results should meet same structure like posts
49 + $results[] = array(
50 + 'ID' => $calendar->id,
51 + 'post_title' => $calendar->title,
52 + );
53 +
54 + }
55 +
56 + // Return our results
57 + wp_send_json_success( $results );
58 + die;
59 +
60 + } else if( isset( $_REQUEST['post_type'] ) && in_array( 'team_meeting', $_REQUEST['post_type'] ) ) {
61 +
62 + // Get the team calendars
63 + $calendars = FluentBooking\App\Models\CalendarSlot::whereIn( 'event_type', ['collective', 'round_robin'] )->get();
64 +
65 + foreach ( $calendars as $calendar ) {
66 +
67 + if( ! empty( $search ) ) {
68 + if( strpos( strtolower( $calendar->title ), strtolower( $search ) ) === false ) {
69 + continue;
70 + }
71 + }
72 +
73 + // Results should meet same structure like posts
74 + $results[] = array(
75 + 'ID' => $calendar->id,
76 + 'post_title' => $calendar->title,
77 + );
78 +
79 + }
80 +
81 + // Return our results
82 + wp_send_json_success( $results );
83 + die;
84 + } else if( isset( $_REQUEST['post_type'] ) && in_array( 'hosts', $_REQUEST['post_type'] ) ) {
85 +
86 + // Get the meeting hosts
87 + $hosts = FluentBooking\App\Models\Calendar::where( 'type', '!=', 'team' )->get();
88 +
89 + foreach ( $hosts as $host ) {
90 +
91 + if( ! empty( $search ) ) {
92 + if( strpos( strtolower( $host->title ), strtolower( $search ) ) === false ) {
93 + continue;
94 + }
95 + }
96 +
97 + // Results should meet same structure like posts
98 + $results[] = array(
99 + 'ID' => $host->user_id,
100 + 'post_title' => $host->title,
101 + );
102 +
103 + }
104 +
105 + // Return our results
106 + wp_send_json_success( $results );
107 + die;
108 + }
109 +
110 +}
111 +add_action( 'wp_ajax_gamipress_get_posts', 'gamipress_fluentbooking_ajax_get_posts', 5 );
112 +
113 +/**
114 + * Get the meeting title
115 + *
116 + * @since 1.0.0
117 + *
118 + * @param int $event_id ID meeting event
119 + *
120 + * @return string
121 + *
122 + */
123 +function gamipress_fluentbooking_get_meeting_title( $event_id ) {
124 +
125 + // Empty title if no ID provided
126 + if( absint( $event_id ) === 0 ) {
127 + return '';
128 + }
129 +
130 + $result = FluentBooking\App\Models\CalendarSlot::where( 'id', $event_id )->get();
131 +
132 + foreach ( $result as $event ){
133 + $event_title = $event->title;
134 + }
135 +
136 + return $event_title;
137 +
138 +}
139 +
140 +/**
141 + * Get the host title
142 + *
143 + * @since 1.0.0
144 + *
145 + * @param int $host_id ID host
146 + *
147 + * @return string
148 + *
149 + */
150 +function gamipress_fluentbooking_get_host_title( $host_id ) {
151 +
152 + // Empty title if no ID provided
153 + if( absint( $host_id ) === 0 ) {
154 + return '';
155 + }
156 +
157 + $result = FluentBooking\App\Models\Calendar::where( 'type', '!=', 'team' )->where( 'user_id', $host_id )->get();
158 +
159 + foreach ( $result as $host ){
160 + $host_title = $host->title;
161 + }
162 +
163 + return $host_title;
164 +
165 +}
166 +