PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.6
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.6
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
gamipress / integrations / thrive-leads / includes / functions.php

functions.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.6, at integrations/thrive-leads/includes/functions.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions
4 *
5 * @package GamiPress\Thrive_Leads\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_leads_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 if( isset( $_REQUEST['post_type'] ) && in_array( 'thrive_form', $_REQUEST['post_type'] ) ) {
28
29 $results = array();
30
31 $type_forms = get_posts(
32 array(
33 'post_type' => 'tve_form_type',
34 'posts_per_page' => -1,
35 'post_status' => 'any',
36 )
37 );
38
39 foreach ( $type_forms as $parent ) {
40 $forms = tve_leads_get_form_variations( $parent->ID );
41
42 foreach ( $forms as $form ) {
43 $results[ ] = array(
44 'ID' => $form['key'],
45 'post_title' => $form['post_title']
46 );
47 }
48 }
49
50 // Return our results
51 wp_send_json_success( $results );
52 die;
53 }
54
55 }
56 add_action( 'wp_ajax_gamipress_get_posts', 'gamipress_thrive_leads_ajax_get_posts', 5 );
57
58 /**
59 * Get the form title
60 *
61 * @since 1.0.0
62 *
63 * @param int $form_id
64 *
65 * @return string|null
66 */
67 function gamipress_thrive_leads_get_form_title( $form_id ) {
68
69 // Empty title if no ID provided
70 if( absint( $form_id ) === 0 ) {
71 return '';
72 }
73
74 $form = tve_leads_get_form_variation( null, $form_id );
75
76 return $form['post_title'];
77
78 }