Created
February 25, 2019 18:06
-
-
Save macbookandrew/bb528a7de6bf922464d76515532b92c6 to your computer and use it in GitHub Desktop.
Returns false if goal is disabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Give - <code>get_goal()</code> fix | |
* Plugin URI: https://luminfire.com | |
* Description: Forces <code>get_goal()</code> to return false if goal is disabled for the form. | |
* Version: 1.0.0 | |
* Author: LuminFire (Andrew Minion) | |
* Author URI: https://luminfire.com/ | |
* | |
* @package give-get-goal-fix | |
*/ | |
// Exit if accessed directly. | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
/** | |
* Checks to see if goal is enabled and if not, returns false. | |
* | |
* @param string $goal Goal amount. | |
* @param int $form_id Donation form ID. | |
* | |
* @return mixed Goal amount or false. | |
*/ | |
add_filter( | |
'give_get_set_goal', | |
function( $goal, $form_id ) { | |
$goal_enabled = get_post_meta( $form_id, '_give_goal_option', true ); | |
if ( 'disabled' === $goal_enabled ) { | |
return false; | |
} | |
return $goal; | |
}, | |
10, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment