| 1 |
<?php |
| 2 |
/** |
| 3 |
* The [give_goal] Shortcode Generator class |
| 4 |
* |
| 5 |
* @package Give/Admin/Shortcodes |
| 6 |
* @copyright Copyright (c) 2016, WordImpress |
| 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 |
* @return array |
| 36 |
*/ |
| 37 |
public function define_fields() { |
| 38 |
|
| 39 |
$create_form_link = sprintf( |
| 40 |
/* translators: %s: create new form URL */ |
| 41 |
__( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
| 42 |
admin_url( 'post-new.php?post_type=give_forms' ) |
| 43 |
); |
| 44 |
|
| 45 |
return array( |
| 46 |
array( |
| 47 |
'type' => 'post', |
| 48 |
'query_args' => array( |
| 49 |
'post_type' => 'give_forms', |
| 50 |
'meta_key' => '_give_goal_option', |
| 51 |
'meta_value' => 'enabled', |
| 52 |
), |
| 53 |
'name' => 'id', |
| 54 |
'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
| 55 |
'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
| 56 |
'required' => array( |
| 57 |
'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
| 58 |
'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
| 59 |
), |
| 60 |
), |
| 61 |
array( |
| 62 |
'type' => 'container', |
| 63 |
'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
| 64 |
), |
| 65 |
array( |
| 66 |
'type' => 'listbox', |
| 67 |
'name' => 'show_text', |
| 68 |
'label' => esc_attr__( 'Show Text:', 'give' ), |
| 69 |
'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
| 70 |
'options' => array( |
| 71 |
'true' => esc_html__( 'Show', 'give' ), |
| 72 |
'false' => esc_html__( 'Hide', 'give' ), |
| 73 |
), |
| 74 |
), |
| 75 |
array( |
| 76 |
'type' => 'listbox', |
| 77 |
'name' => 'show_bar', |
| 78 |
'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
| 79 |
'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
| 80 |
'options' => array( |
| 81 |
'true' => esc_html__( 'Show', 'give' ), |
| 82 |
'false' => esc_html__( 'Hide', 'give' ), |
| 83 |
), |
| 84 |
), |
| 85 |
); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
new Give_Shortcode_Donation_Form_Goal; |