| 1 |
<?php |
| 2 |
/** |
| 3 |
* GamiPress 1.5.0 compatibility functions |
| 4 |
* |
| 5 |
* @package GamiPress\1.5.0 |
| 6 |
* @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> |
| 7 |
* @since 1.5.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Filter our step titles to link to achievements and achievement type archives |
| 14 |
* |
| 15 |
* @deprecated |
| 16 |
* |
| 17 |
* @see gamipress_format_requirement_title_with_post_link() |
| 18 |
* |
| 19 |
* @since 1.0.0 |
| 20 |
* |
| 21 |
* @param string $title Our step title |
| 22 |
* @param object $step Our step's post object |
| 23 |
* |
| 24 |
* @return string Our potentially updated title |
| 25 |
*/ |
| 26 |
function gamipress_step_link_title_to_achievement( $title = '', $step = null ) { |
| 27 |
|
| 28 |
// Grab our step requirements |
| 29 |
$step_requirements = gamipress_get_step_requirements( $step->ID ); |
| 30 |
|
| 31 |
// Setup a URL to link to a specific achievement or an achievement type |
| 32 |
if ( ! empty( $step_requirements['achievement_post'] ) ) |
| 33 |
$url = get_permalink( $step_requirements['achievement_post'] ); |
| 34 |
// elseif ( ! empty( $step_requirements['achievement_type'] ) ) |
| 35 |
// $url = get_post_type_archive_link( $step_requirements['achievement_type'] ); |
| 36 |
|
| 37 |
// If we have a URL, update the title to link to it |
| 38 |
if ( isset( $url ) && ! empty( $url ) ) |
| 39 |
$title = '<a href="' . esc_url( $url ) . '">' . $title . '</a>'; |
| 40 |
|
| 41 |
return $title; |
| 42 |
} |
| 43 |
//add_filter( 'gamipress_step_title_display', 'gamipress_step_link_title_to_achievement', 10, 2 ); |
| 44 |
|
| 45 |
/** |
| 46 |
* Filter our points awards titles to link to achievements and achievement type archives |
| 47 |
* |
| 48 |
* @deprecated |
| 49 |
* |
| 50 |
* @see gamipress_format_requirement_title_with_post_link() |
| 51 |
* |
| 52 |
* @since 1.0.0 |
| 53 |
* |
| 54 |
* @param string $title Our points award title |
| 55 |
* @param object $points_award Our points award's post object |
| 56 |
* @return string Our potentially updated title |
| 57 |
*/ |
| 58 |
function gamipress_points_award_link_title_to_achievement( $title = '', $points_award = null ) { |
| 59 |
|
| 60 |
// Grab our points award requirements |
| 61 |
$points_award_requirements = gamipress_get_points_award_requirements( $points_award->ID ); |
| 62 |
|
| 63 |
// Setup a URL to link to a specific achievement or an achievement type |
| 64 |
if ( ! empty( $points_award_requirements['achievement_post'] ) ) |
| 65 |
$url = get_permalink( $points_award_requirements['achievement_post'] ); |
| 66 |
// elseif ( ! empty( $points_award_requirements['achievement_type'] ) ) |
| 67 |
// $url = get_post_type_archive_link( $points_award_requirements['achievement_type'] ); |
| 68 |
|
| 69 |
// If we have a URL, update the title to link to it |
| 70 |
if ( isset( $url ) && ! empty( $url ) ) |
| 71 |
$title = '<a href="' . esc_url( $url ) . '">' . $title . '</a>'; |
| 72 |
|
| 73 |
return $title; |
| 74 |
} |
| 75 |
//add_filter( 'gamipress_points_award_title_display', 'gamipress_points_award_link_title_to_achievement', 10, 2 ); |
| 76 |
|
| 77 |
/** |
| 78 |
* Filter our points deducts titles to link to achievements and achievement type archives |
| 79 |
* |
| 80 |
* @deprecated |
| 81 |
* |
| 82 |
* @see gamipress_format_requirement_title_with_post_link() |
| 83 |
* |
| 84 |
* @since 1.3.7 |
| 85 |
* |
| 86 |
* @param string $title Our points deduct title |
| 87 |
* @param object $points_deduct Our points deduct's post object |
| 88 |
* @return string Our potentially updated title |
| 89 |
*/ |
| 90 |
function gamipress_points_deduct_link_title_to_achievement( $title = '', $points_deduct = null ) { |
| 91 |
|
| 92 |
// Grab our points deduct requirements |
| 93 |
$points_deduct_requirements = gamipress_get_points_deduct_requirements( $points_deduct->ID ); |
| 94 |
|
| 95 |
// Setup a URL to link to a specific achievement or an achievement type |
| 96 |
if ( ! empty( $points_deduct_requirements['achievement_post'] ) ) |
| 97 |
$url = get_permalink( $points_deduct_requirements['achievement_post'] ); |
| 98 |
// elseif ( ! empty( $points_deduct_requirements['achievement_type'] ) ) |
| 99 |
// $url = get_post_type_archive_link( $points_deduct_requirements['achievement_type'] ); |
| 100 |
|
| 101 |
// If we have a URL, update the title to link to it |
| 102 |
if ( isset( $url ) && ! empty( $url ) ) |
| 103 |
$title = '<a href="' . esc_url( $url ) . '">' . $title . '</a>'; |
| 104 |
|
| 105 |
return $title; |
| 106 |
} |
| 107 |
//add_filter( 'gamipress_points_deduct_title_display', 'gamipress_points_deduct_link_title_to_achievement', 10, 2 ); |
| 108 |
|
| 109 |
/** |
| 110 |
* Filter our step titles to link to achievements and achievement type archives |
| 111 |
* |
| 112 |
* @deprecated |
| 113 |
* |
| 114 |
* @see gamipress_format_requirement_title_with_post_link() |
| 115 |
* |
| 116 |
* @since 1.3.1 |
| 117 |
* |
| 118 |
* @param string $title Our rank requirement title |
| 119 |
* @param object $rank_requirement Our rank requirement's post object |
| 120 |
* |
| 121 |
* @return string Our potentially updated title |
| 122 |
*/ |
| 123 |
function gamipress_rank_requirement_link_title_to_achievement( $title = '', $rank_requirement = null ) { |
| 124 |
|
| 125 |
// Grab our rank requirement requirements |
| 126 |
$requirements = gamipress_get_rank_requirement_requirements( $rank_requirement->ID ); |
| 127 |
|
| 128 |
// Setup a URL to link to a specific achievement or an achievement type |
| 129 |
if ( ! empty( $requirements['achievement_post'] ) ) |
| 130 |
$url = get_permalink( $requirements['achievement_post'] ); |
| 131 |
// elseif ( ! empty( $requirements['achievement_type'] ) ) |
| 132 |
// $url = get_post_type_archive_link( $requirements['achievement_type'] ); |
| 133 |
|
| 134 |
// If we have a URL, update the title to link to it |
| 135 |
if ( isset( $url ) && ! empty( $url ) ) |
| 136 |
$title = '<a href="' . esc_url( $url ) . '">' . $title . '</a>'; |
| 137 |
|
| 138 |
return $title; |
| 139 |
} |
| 140 |
//add_filter( 'gamipress_rank_requirement_title_display', 'gamipress_rank_requirement_link_title_to_achievement', 10, 2 ); |