# gamipress/7.9.8/integrations/thrive-apprentice/includes/functions.php

GamiPress – Gamification plugin to reward points, badges &amp; ranks in WordPress, now with AI, version 7.9.8. 74 lines.

- Page: https://pluginprobe.com/plugins/gamipress/7.9.8/code/integrations/thrive-apprentice/includes/functions.php
- Raw: https://pluginprobe.com/plugins/gamipress/7.9.8/raw/integrations/thrive-apprentice/includes/functions.php
- Modified: 2026-07-13T13:39:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gamipress/7.9.8/code/integrations/thrive-apprentice/includes/functions.php#L10-L20`.

```php
<?php
/**
 * Functions
 *
 * @package GamiPress\Thrive_Apprentice\Functions
 * @since 1.0.0
 */

// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;

/**
 * Overrides GamiPress AJAX Helper for selecting posts
 *
 * @since 1.0.0
 */
function gamipress_thrive_apprentice_ajax_get_posts() {

    // Security check, forces to die if not security passed
    check_ajax_referer( 'gamipress_admin', 'nonce' );

    // Check if user can manage GamiPress
    if( ! current_user_can( gamipress_get_manager_capability() ) ) {
        wp_send_json_error( __( 'You\'re not allowed to perform this action.', 'gamipress' ) );
    }

    global $wpdb;

    $results = array();

    // Pull back the search string
    $search = isset( $_REQUEST['q'] ) ? $wpdb->esc_like( sanitize_text_field( $_REQUEST['q'] ) ) : '';

    if( isset( $_REQUEST['post_type'] ) && in_array( 'tva_courses_posts', $_REQUEST['post_type'] ) ) {

        // Get the services
        $courses = get_terms(array(
            'taxonomy' => 'tva_courses',
            'hide_empty' => false,
        ));

        foreach ( $courses as $course ) {

            // Results should meet same structure like posts
            $results[] = array(
                'ID' => $course->term_id,
                'post_title' => $course->name,
            );

        }

        // Return our results
        wp_send_json_success( $results );
        die;

    }


}
add_action( 'wp_ajax_gamipress_get_posts', 'gamipress_thrive_apprentice_ajax_get_posts', 5 );

// Get the service title
function gamipress_thrive_apprentice_get_course_title( $course_id ) {

    $course_id = absint( $course_id );

    if( $course_id === 0 ) return '';

    $course_title = get_term_by('id', $course_id, 'tva_courses');

    return $course_title->name;

}

```
