| 1 |
<?php |
| 2 |
/** |
| 3 |
* The [give_goal] Shortcode Generator class |
| 4 |
* |
| 5 |
* @package Give/Admin/Shortcodes |
| 6 |
* @copyright Copyright (c) 2016, GiveWP |
| 7 |
* @license https://opensource.org/licenses/gpl-license GNU Public License |
| 8 |
* @since 1.3.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Exit if accessed directly. |
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Class Give_Shortcode_Donation_Form_Goal |
| 18 |
*/ |
| 19 |
class Give_Shortcode_Donation_Form_Goal extends Give_Shortcode_Generator { |
| 20 |
|
| 21 |
/** |
| 22 |
* Class constructor |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
|
| 26 |
$this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
| 27 |
$this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
| 28 |
|
| 29 |
parent::__construct( 'give_goal' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Define the shortcode attribute fields |
| 34 |
* |
| 35 |
* @since 4.0.0 Replace "new form" with "new campaign form" link |
| 36 |
* |
| 37 |
* @return array |
| 38 |
*/ |
| 39 |
public function define_fields() { |
| 40 |
|
| 41 |
$create_form_link = sprintf( |
| 42 |
/* translators: %s: create new form URL */ |
| 43 |
__('<a href="%s">Create</a> a new Campaign Form.', 'give'), |
| 44 |
admin_url('edit.php?post_type=give_forms&page=give-campaigns&new=campaign') |
| 45 |
); |
| 46 |
|
| 47 |
return [ |
| 48 |
[ |
| 49 |
'type' => 'post', |
| 50 |
'query_args' => [ |
| 51 |
'post_type' => 'give_forms', |
| 52 |
'meta_key' => '_give_goal_option', |
| 53 |
'meta_value' => 'enabled', |
| 54 |
], |
| 55 |
'name' => 'id', |
| 56 |
'tooltip' => esc_attr__('Select a Campaign Form', 'give'), |
| 57 |
'placeholder' => '- ' . esc_attr__('Select a Campaign Form', 'give') . ' -', |
| 58 |
'required' => [ |
| 59 |
'alert' => esc_html__('You must first select a Campaign Form!', 'give'), |
| 60 |
'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', |
| 61 |
esc_html__('No campaign forms found.', 'give'), $create_form_link), |
| 62 |
], |
| 63 |
], |
| 64 |
[ |
| 65 |
'type' => 'container', |
| 66 |
'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
| 67 |
], |
| 68 |
[ |
| 69 |
'type' => 'listbox', |
| 70 |
'name' => 'show_text', |
| 71 |
'label' => esc_attr__( 'Show Text:', 'give' ), |
| 72 |
'tooltip' => esc_attr__( 'This text displays the amount of revenue raised compared to the goal.', 'give' ), |
| 73 |
'options' => [ |
| 74 |
'true' => esc_html__( 'Show', 'give' ), |
| 75 |
'false' => esc_html__( 'Hide', 'give' ), |
| 76 |
], |
| 77 |
], |
| 78 |
[ |
| 79 |
'type' => 'listbox', |
| 80 |
'name' => 'show_bar', |
| 81 |
'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
| 82 |
'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
| 83 |
'options' => [ |
| 84 |
'true' => esc_html__( 'Show', 'give' ), |
| 85 |
'false' => esc_html__( 'Hide', 'give' ), |
| 86 |
], |
| 87 |
], |
| 88 |
[ |
| 89 |
'type' => 'docs_link', |
| 90 |
'text' => esc_html__( 'Learn more about the Goal Shortcode', 'give' ), |
| 91 |
'link' => 'http://docs.givewp.com/shortcode-give-goal', |
| 92 |
], |
| 93 |
]; |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* @since 4.3.0 use init action |
| 99 |
*/ |
| 100 |
add_action( 'init', static function () { |
| 101 |
new Give_Shortcode_Donation_Form_Goal(); |
| 102 |
}); |
| 103 |
|