| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template management panel. |
| 4 |
* |
| 5 |
* @package Charitable |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.8.0 |
| 10 |
* @version 1.8.9.1 |
| 11 |
* @version 1.8.9.7 |
| 12 |
*/ |
| 13 |
|
| 14 |
// Exit if accessed directly. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! class_exists( 'Charitable_Builder_Panel_Template' ) ) : |
| 20 |
|
| 21 |
/** |
| 22 |
* Charitable campaign builder template panel. |
| 23 |
* |
| 24 |
* @since 1.8.0 |
| 25 |
*/ |
| 26 |
class Charitable_Builder_Panel_Template extends Charitable_Builder_Panel { |
| 27 |
|
| 28 |
/** |
| 29 |
* Form data and settings. |
| 30 |
* |
| 31 |
* @since 1.8.0 |
| 32 |
* |
| 33 |
* @var array |
| 34 |
*/ |
| 35 |
public $campaign_data; |
| 36 |
|
| 37 |
/** |
| 38 |
* All systems go. |
| 39 |
* |
| 40 |
* @since 1.8.0 |
| 41 |
*/ |
| 42 |
public function init() { |
| 43 |
|
| 44 |
// Define panel information. |
| 45 |
$this->name = esc_html__( 'Template', 'charitable' ); |
| 46 |
$this->slug = 'template'; |
| 47 |
$this->icon = 'panel_template.svg'; |
| 48 |
$this->order = 10; |
| 49 |
$this->sidebar = false; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Enqueue assets for the template panel. |
| 54 |
* |
| 55 |
* @since 1.8.0 |
| 56 |
*/ |
| 57 |
public function enqueues() { |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Output the panel primary content, which is a UI of campaign templates to select. |
| 62 |
* |
| 63 |
* @since 1.8.0 |
| 64 |
* @version 1.8.9.1 |
| 65 |
* @version 1.8.9.7 |
| 66 |
*/ |
| 67 |
public function panel_content() { |
| 68 |
|
| 69 |
$builder_template = new Charitable_Campaign_Builder_Templates(); |
| 70 |
|
| 71 |
// attempt to prefill name and email fields. |
| 72 |
$current_user = wp_get_current_user(); |
| 73 |
$name = ( $current_user ) ? charitable_get_creator_data() : false; |
| 74 |
$email = ! empty( $current_user->user_email ) ? $current_user->user_email : false; |
| 75 |
|
| 76 |
?> |
| 77 |
|
| 78 |
<div class="charitable-preview-wrap"> |
| 79 |
|
| 80 |
<!-- start feedback form --> |
| 81 |
|
| 82 |
<div class="charitable-feedback-form-container"> |
| 83 |
|
| 84 |
<div id="charitable-feedback-form" class="charitable-form charitable-feedback-form"> |
| 85 |
|
| 86 |
<div class="charitable-feedback-form-header"> |
| 87 |
<div class="charitable-feedback-form-title"><?php echo esc_html__( 'Give Feedback', 'charitable' ); ?></div> |
| 88 |
<div class="charitable-templates-close-icon">×</div> |
| 89 |
</div> |
| 90 |
|
| 91 |
<div class="charitable-feedback-form-interior"> |
| 92 |
|
| 93 |
<input type="hidden" class="charitable-feedback-form-type" value="templates" /> |
| 94 |
|
| 95 |
<div class="charitable-form-row charitable-feedback-form-row"> |
| 96 |
<label><?php echo esc_html__( 'Name', 'charitable' ); ?> <span class="charitable-feedback-form-required">*</span></label> |
| 97 |
<input name="charitable-feedback-form-name" type="text" class="charitable-feedback-form-name" value="<?php echo esc_html( $name ); ?>" /> |
| 98 |
</div> |
| 99 |
<div class="charitable-form-row charitable-feedback-form-row"> |
| 100 |
<label><?php echo esc_html__( 'Email', 'charitable' ); ?> <span class="charitable-feedback-form-required">*</span></label> |
| 101 |
<input name="charitable-feedback-form-email" type="email" class="charitable-feedback-form-email" value="<?php echo esc_html( $email ); ?>" /> |
| 102 |
</div> |
| 103 |
<div class="charitable-form-row charitable-feedback-form-row"> |
| 104 |
<label><?php echo esc_html__( 'Let us know which template you think missing here and can be a good addition?', 'charitable' ); ?><span class="charitable-feedback-form-required">*</span></label> |
| 105 |
<textarea name="charitable-feedback-form-feedback" class="charitable-feedback-form-feedback"></textarea> |
| 106 |
</div> |
| 107 |
<div class="charitable-form-row charitable-feedback-form-row"> |
| 108 |
<p class="charitable-feedback-form-required">* = <?php echo esc_html__( 'Required', 'charitable' ); ?></p> |
| 109 |
</div> |
| 110 |
<div class="charitable-form-row charitable-feedback-form-row"> |
| 111 |
<a class="button-link"><?php echo esc_html__( 'Send Request', 'charitable' ); ?></a> |
| 112 |
</div> |
| 113 |
<i class="charitable-loading-spinner charitable-loading-black charitable-loading-inline charitable-hidden"></i> |
| 114 |
|
| 115 |
</div> |
| 116 |
|
| 117 |
<div class="charitable-feedback-form-interior-confirmation"> |
| 118 |
|
| 119 |
<!-- confirmation --> |
| 120 |
<div id="charitable-feedback-form-confirmation" class="charitable-form charitable-feedback-form charitable-form-confirmation charitable-hidden"> |
| 121 |
<h2><?php echo esc_html__( 'Thank You!', 'charitable' ); ?></h2> |
| 122 |
<p><?php echo esc_html__( 'Your feedback has been sent to our team. Stay tuned to our updates on', 'charitable' ); ?> <a href="https://wpcharitable.com" target="_blank">wpcharitable.com</a>.</p> |
| 123 |
</div> |
| 124 |
|
| 125 |
</div> |
| 126 |
|
| 127 |
</div> |
| 128 |
|
| 129 |
</div> |
| 130 |
|
| 131 |
|
| 132 |
<div class="charitable-template-preview"> |
| 133 |
|
| 134 |
<div class="charitable-setup-title"> |
| 135 |
<?php echo esc_html__( 'Select A Template', 'charitable' ); ?> <span class="charitable-setup-title-after"></span> |
| 136 |
</div> |
| 137 |
|
| 138 |
<p class="charitable-setup-desc secondary-text"> |
| 139 |
<?php |
| 140 |
|
| 141 |
// determine if the user already has a template selected for a campaign, or is starting fresh. |
| 142 |
$template_label = isset( $this->campaign_data['template_label'] ) ? esc_attr( $this->campaign_data['template_label'] ) : false; |
| 143 |
|
| 144 |
if ( $template_label ) : |
| 145 |
|
| 146 |
echo wp_kses_post( |
| 147 |
sprintf( |
| 148 |
/* translators: 1: Template ID */ |
| 149 |
__( 'You are currently using the <strong class="template-name">"%1$s"</strong> template. Changing a template now might result in losing fields and data. Proceed carefully.', 'charitable' ), |
| 150 |
esc_html( $template_label ) |
| 151 |
) |
| 152 |
); |
| 153 |
|
| 154 |
else : |
| 155 |
|
| 156 |
echo wp_kses_post( |
| 157 |
sprintf( |
| 158 |
/* translators: 1: Site URL */ |
| 159 |
__( 'To speed up the process you can select from one of our pre-made templates or start from scratch <a href="%1$s" class="charitable-trigger-blank">with our simple column templates</a>. Have a suggestion for a new template? <a href="#" class="send-feedback">We would love to hear it</a>!', 'charitable' ), |
| 160 |
esc_url( admin_url() ) |
| 161 |
) |
| 162 |
); |
| 163 |
|
| 164 |
endif; |
| 165 |
|
| 166 |
echo $builder_template->output_templates_panel(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 167 |
|
| 168 |
?> |
| 169 |
</p> |
| 170 |
|
| 171 |
</div> |
| 172 |
|
| 173 |
</div> |
| 174 |
|
| 175 |
<?php |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
endif; |
| 180 |
|
| 181 |
new Charitable_Builder_Panel_Template(); |
| 182 |
|