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/thrive-apprentice/includes/functions.php +73 -0 7.9.3 → 8.0.5 View file →
@@ -1,0 +1,73 @@
1 +<?php
2 +/**
3 + * Functions
4 + *
5 + * @package GamiPress\Thrive_Apprentice\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_thrive_apprentice_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'] ) ? $wpdb->esc_like( sanitize_text_field( $_REQUEST['q'] ) ) : '';
33 +
34 + if( isset( $_REQUEST['post_type'] ) && in_array( 'tva_courses_posts', $_REQUEST['post_type'] ) ) {
35 +
36 + // Get the services
37 + $courses = get_terms(array(
38 + 'taxonomy' => 'tva_courses',
39 + 'hide_empty' => false,
40 + ));
41 +
42 + foreach ( $courses as $course ) {
43 +
44 + // Results should meet same structure like posts
45 + $results[] = array(
46 + 'ID' => $course->term_id,
47 + 'post_title' => $course->name,
48 + );
49 +
50 + }
51 +
52 + // Return our results
53 + wp_send_json_success( $results );
54 + die;
55 +
56 + }
57 +
58 +
59 +}
60 +add_action( 'wp_ajax_gamipress_get_posts', 'gamipress_thrive_apprentice_ajax_get_posts', 5 );
61 +
62 +// Get the service title
63 +function gamipress_thrive_apprentice_get_course_title( $course_id ) {
64 +
65 + $course_id = absint( $course_id );
66 +
67 + if( $course_id === 0 ) return '';
68 +
69 + $course_title = get_term_by('id', $course_id, 'tva_courses');
70 +
71 + return $course_title->name;
72 +
73 +}