PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.2
GiveWP – Donation Plugin and Fundraising Platform v2.2.2
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / post-types.php
give / includes Last commit date
admin 7 years ago api 7 years ago deprecated 7 years ago donors 7 years ago emails 7 years ago forms 7 years ago gateways 7 years ago libraries 7 years ago payments 7 years ago actions.php 7 years ago ajax-functions.php 7 years ago class-give-async-process.php 8 years ago class-give-background-updater.php 7 years ago class-give-cache.php 7 years ago class-give-cli-commands.php 8 years ago class-give-comment.php 7 years ago class-give-cron.php 8 years ago class-give-db-donor-meta.php 8 years ago class-give-db-donors.php 7 years ago class-give-db-form-meta.php 8 years ago class-give-db-logs-meta.php 8 years ago class-give-db-logs.php 7 years ago class-give-db-meta.php 7 years ago class-give-db-payment-meta.php 7 years ago class-give-db-sequential-ordering.php 7 years ago class-give-db-sessions.php 7 years ago class-give-db.php 8 years ago class-give-donate-form.php 8 years ago class-give-donor-wall-widget.php 7 years ago class-give-donor.php 7 years ago class-give-email-access.php 7 years ago class-give-html-elements.php 7 years ago class-give-license-handler.php 7 years ago class-give-logging.php 8 years ago class-give-readme-parser.php 8 years ago class-give-roles.php 8 years ago class-give-scripts.php 7 years ago class-give-session.php 7 years ago class-give-stats.php 8 years ago class-give-template-loader.php 8 years ago class-give-tooltips.php 8 years ago class-give-translation.php 8 years ago class-notices.php 7 years ago country-functions.php 8 years ago currency-functions.php 7 years ago error-tracking.php 8 years ago filters.php 7 years ago formatting.php 7 years ago import-functions.php 7 years ago install.php 7 years ago login-register.php 8 years ago misc-functions.php 7 years ago plugin-compatibility.php 8 years ago post-types.php 8 years ago price-functions.php 7 years ago process-donation.php 7 years ago shortcodes.php 7 years ago template-functions.php 8 years ago user-functions.php 7 years ago
post-types.php
476 lines
1 <?php
2 /**
3 * Post Type Functions
4 *
5 * @package Give
6 * @subpackage Functions
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Registers and sets up the Donation Forms (give_forms) custom post type
19 *
20 * @since 1.0
21 * @return void
22 */
23 function give_setup_post_types() {
24
25 // Give Forms single post and archive options.
26 $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) );
27 $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) );
28
29 // Enable/Disable give_forms links if form is saving.
30 if ( Give_Admin_Settings::is_saving_settings() ) {
31 if ( isset( $_POST['forms_singular'] ) ) {
32 $give_forms_singular = give_is_setting_enabled( give_clean( $_POST['forms_singular'] ) );
33 flush_rewrite_rules();
34 }
35
36 if ( isset( $_POST['forms_archives'] ) ) {
37 $give_forms_archives = give_is_setting_enabled( give_clean( $_POST['forms_archives'] ) );
38 flush_rewrite_rules();
39 }
40 }
41
42 $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
43 // Support for old 'GIVE_FORMS_SLUG' constant
44 if ( defined( 'GIVE_FORMS_SLUG' ) ) {
45 $give_forms_slug = GIVE_FORMS_SLUG;
46 }
47
48 $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
49 'slug' => $give_forms_slug,
50 'with_front' => false,
51 );
52
53 $give_forms_labels = apply_filters( 'give_forms_labels', array(
54 'name' => __( 'Donation Forms', 'give' ),
55 'singular_name' => __( 'Form', 'give' ),
56 'add_new' => __( 'Add Form', 'give' ),
57 'add_new_item' => __( 'Add New Donation Form', 'give' ),
58 'edit_item' => __( 'Edit Donation Form', 'give' ),
59 'new_item' => __( 'New Form', 'give' ),
60 'all_items' => __( 'All Forms', 'give' ),
61 'view_item' => __( 'View Form', 'give' ),
62 'search_items' => __( 'Search Forms', 'give' ),
63 'not_found' => __( 'No forms found.', 'give' ),
64 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ),
65 'parent_item_colon' => '',
66 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ),
67 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ),
68 ) );
69
70 // Default give_forms supports.
71 $give_form_supports = array(
72 'title',
73 'thumbnail',
74 'excerpt',
75 'revisions',
76 'author',
77 );
78
79 // Has the user disabled the excerpt?
80 if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) {
81 unset( $give_form_supports[2] );
82 }
83
84 // Has user disabled the featured image?
85 if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
86 unset( $give_form_supports[1] );
87 remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
88 }
89
90 $give_forms_args = array(
91 'labels' => $give_forms_labels,
92 'public' => $give_forms_singular,
93 'show_ui' => true,
94 'show_in_menu' => true,
95 'show_in_rest' => true,
96 'query_var' => true,
97 'rewrite' => $give_forms_rewrite,
98 'map_meta_cap' => true,
99 'capability_type' => 'give_form',
100 'has_archive' => $give_forms_archives,
101 'menu_icon' => 'dashicons-give',
102 'hierarchical' => false,
103 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ),
104 );
105 register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
106
107 /** Donation Post Type */
108 $payment_labels = array(
109 'name' => _x( 'Donations', 'post type general name', 'give' ),
110 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ),
111 'add_new' => __( 'Add New', 'give' ),
112 'add_new_item' => __( 'Add New Donation', 'give' ),
113 'edit_item' => __( 'Edit Donation', 'give' ),
114 'new_item' => __( 'New Donation', 'give' ),
115 'all_items' => __( 'All Donations', 'give' ),
116 'view_item' => __( 'View Donation', 'give' ),
117 'search_items' => __( 'Search Donations', 'give' ),
118 'not_found' => __( 'No donations found.', 'give' ),
119 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ),
120 'parent_item_colon' => '',
121 'menu_name' => __( 'Donations', 'give' ),
122 );
123
124 $payment_args = array(
125 'labels' => apply_filters( 'give_payment_labels', $payment_labels ),
126 'public' => false,
127 'query_var' => false,
128 'rewrite' => false,
129 'map_meta_cap' => true,
130 'capability_type' => 'give_payment',
131 'supports' => array( 'title' ),
132 'can_export' => true,
133 );
134 register_post_type( 'give_payment', $payment_args );
135
136 }
137
138 add_action( 'init', 'give_setup_post_types', 1 );
139
140
141 /**
142 * Give Setup Taxonomies
143 *
144 * Registers the custom taxonomies for the give_forms custom post type
145 *
146 * @since 1.0
147 * @return void
148 */
149 function give_setup_taxonomies() {
150
151 $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
152
153 /** Categories */
154 $category_labels = array(
155 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ),
156 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ),
157 'search_items' => __( 'Search Categories', 'give' ),
158 'all_items' => __( 'All Categories', 'give' ),
159 'parent_item' => __( 'Parent Category', 'give' ),
160 'parent_item_colon' => __( 'Parent Category:', 'give' ),
161 'edit_item' => __( 'Edit Category', 'give' ),
162 'update_item' => __( 'Update Category', 'give' ),
163 'add_new_item' => __( 'Add New Category', 'give' ),
164 'new_item_name' => __( 'New Category Name', 'give' ),
165 'menu_name' => __( 'Categories', 'give' ),
166 );
167
168 $category_args = apply_filters( 'give_forms_category_args', array(
169 'hierarchical' => true,
170 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ),
171 'show_ui' => true,
172 'query_var' => 'give_forms_category',
173 'rewrite' => array(
174 'slug' => $slug . '/category',
175 'with_front' => false,
176 'hierarchical' => true,
177 ),
178 'capabilities' => array(
179 'manage_terms' => 'manage_give_form_terms',
180 'edit_terms' => 'edit_give_form_terms',
181 'assign_terms' => 'assign_give_form_terms',
182 'delete_terms' => 'delete_give_form_terms',
183 ),
184 )
185 );
186
187 /** Tags */
188 $tag_labels = array(
189 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ),
190 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ),
191 'search_items' => __( 'Search Tags', 'give' ),
192 'all_items' => __( 'All Tags', 'give' ),
193 'parent_item' => __( 'Parent Tag', 'give' ),
194 'parent_item_colon' => __( 'Parent Tag:', 'give' ),
195 'edit_item' => __( 'Edit Tag', 'give' ),
196 'update_item' => __( 'Update Tag', 'give' ),
197 'add_new_item' => __( 'Add New Tag', 'give' ),
198 'new_item_name' => __( 'New Tag Name', 'give' ),
199 'menu_name' => __( 'Tags', 'give' ),
200 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ),
201 );
202
203 $tag_args = apply_filters( 'give_forms_tag_args', array(
204 'hierarchical' => false,
205 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ),
206 'show_ui' => true,
207 'query_var' => 'give_forms_tag',
208 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
209 'capabilities' => array(
210 'manage_terms' => 'manage_give_form_terms',
211 'edit_terms' => 'edit_give_form_terms',
212 'assign_terms' => 'assign_give_form_terms',
213 'delete_terms' => 'delete_give_form_terms',
214 ),
215 )
216 );
217
218 // Does the user want category?
219 $enable_category = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) );
220
221 // Does the user want tag?
222 $enable_tag = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) );
223
224 // Enable/Disable category and tag if form is saving.
225 if ( Give_Admin_Settings::is_saving_settings() ) {
226 if ( isset( $_POST['categories'] ) ) {
227 $enable_category = give_is_setting_enabled( give_clean( $_POST['categories'] ) );
228 flush_rewrite_rules();
229 }
230
231 if ( isset( $_POST['tags'] ) ) {
232 $enable_tag = give_is_setting_enabled( give_clean( $_POST['tags'] ) );
233 flush_rewrite_rules();
234 }
235 }
236
237 if ( $enable_category ) {
238 register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
239 register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
240 }
241
242 if ( $enable_tag ) {
243 register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
244 register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
245 }
246 }
247
248 add_action( 'init', 'give_setup_taxonomies', 0 );
249
250
251 /**
252 * Get Default Form Labels
253 *
254 * @since 1.0
255 * @return array $defaults Default labels
256 */
257 function give_get_default_form_labels() {
258 $defaults = array(
259 'singular' => __( 'Form', 'give' ),
260 'plural' => __( 'Forms', 'give' ),
261 );
262
263 return apply_filters( 'give_default_form_name', $defaults );
264 }
265
266 /**
267 * Get Singular Forms Label
268 *
269 * @since 1.0
270 *
271 * @param bool $lowercase
272 *
273 * @return string $defaults['singular'] Singular label
274 */
275 function give_get_forms_label_singular( $lowercase = false ) {
276 $defaults = give_get_default_form_labels();
277
278 return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
279 }
280
281 /**
282 * Get Plural Forms Label
283 *
284 * @since 1.0
285 * @return string $defaults['plural'] Plural label
286 */
287 function give_get_forms_label_plural( $lowercase = false ) {
288 $defaults = give_get_default_form_labels();
289
290 return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
291 }
292
293 /**
294 * Change default "Enter title here" input
295 *
296 * @since 1.0
297 *
298 * @param string $title Default title placeholder text
299 *
300 * @return string $title New placeholder text
301 */
302 function give_change_default_title( $title ) {
303 // If a frontend plugin uses this filter (check extensions before changing this function)
304 if ( ! is_admin() ) {
305 $title = __( 'Enter form title here', 'give' );
306
307 return $title;
308 }
309
310 $screen = get_current_screen();
311
312 if ( 'give_forms' == $screen->post_type ) {
313 $title = __( 'Enter form title here', 'give' );
314 }
315
316 return $title;
317 }
318
319 add_filter( 'enter_title_here', 'give_change_default_title' );
320
321 /**
322 * Registers Custom Post Statuses which are used by the Payments
323 *
324 * @since 1.0
325 * @return void
326 */
327 function give_register_post_type_statuses() {
328 // Payment Statuses
329 register_post_status( 'refunded', array(
330 'label' => __( 'Refunded', 'give' ),
331 'public' => true,
332 'exclude_from_search' => false,
333 'show_in_admin_all_list' => true,
334 'show_in_admin_status_list' => true,
335 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ),
336 ) );
337 register_post_status( 'failed', array(
338 'label' => __( 'Failed', 'give' ),
339 'public' => true,
340 'exclude_from_search' => false,
341 'show_in_admin_all_list' => true,
342 'show_in_admin_status_list' => true,
343 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ),
344 ) );
345 register_post_status( 'revoked', array(
346 'label' => __( 'Revoked', 'give' ),
347 'public' => true,
348 'exclude_from_search' => false,
349 'show_in_admin_all_list' => true,
350 'show_in_admin_status_list' => true,
351 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ),
352 ) );
353 register_post_status( 'cancelled', array(
354 'label' => __( 'Cancelled', 'give' ),
355 'public' => true,
356 'exclude_from_search' => false,
357 'show_in_admin_all_list' => true,
358 'show_in_admin_status_list' => true,
359 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ),
360 ) );
361 register_post_status( 'abandoned', array(
362 'label' => __( 'Abandoned', 'give' ),
363 'public' => true,
364 'exclude_from_search' => false,
365 'show_in_admin_all_list' => true,
366 'show_in_admin_status_list' => true,
367 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ),
368 ) );
369 register_post_status( 'processing', array(
370 'label' => _x( 'Processing', 'Processing payment status', 'give' ),
371 'public' => true,
372 'exclude_from_search' => false,
373 'show_in_admin_all_list' => true,
374 'show_in_admin_status_list' => true,
375 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' )
376 ) );
377
378 register_post_status( 'preapproval', array(
379 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ),
380 'public' => true,
381 'exclude_from_search' => false,
382 'show_in_admin_all_list' => true,
383 'show_in_admin_status_list' => true,
384 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ),
385 ) );
386
387 }
388
389 add_action( 'init', 'give_register_post_type_statuses' );
390
391 /**
392 * Updated Messages
393 *
394 * Returns an array of with all updated messages.
395 *
396 * @since 1.0
397 *
398 * @param array $messages Post updated message
399 *
400 * @return array $messages New post updated messages
401 */
402 function give_updated_messages( $messages ) {
403 global $post, $post_ID;
404
405 if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) {
406
407 $messages['give_forms'] = array(
408 1 => __( 'Form updated.', 'give' ),
409 4 => __( 'Form updated.', 'give' ),
410 6 => __( 'Form published.', 'give' ),
411 7 => __( 'Form saved.', 'give' ),
412 8 => __( 'Form submitted.', 'give' ),
413 );
414
415 } else {
416
417 $messages['give_forms'] = array(
418 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
419 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
420 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
421 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
422 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
423 );
424
425 }
426
427 return $messages;
428 }
429
430 add_filter( 'post_updated_messages', 'give_updated_messages' );
431
432 /**
433 * Ensure post thumbnail support is turned on
434 */
435 function give_add_thumbnail_support() {
436 if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
437 return;
438 }
439
440 if ( ! current_theme_supports( 'post-thumbnails' ) ) {
441 add_theme_support( 'post-thumbnails' );
442 }
443
444 add_post_type_support( 'give_forms', 'thumbnail' );
445 }
446
447 add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
448
449 /**
450 * Give Sidebars
451 *
452 * This option adds Give sidebars; registered late so it display last in list
453 */
454 function give_widgets_init() {
455
456 // Single Give Forms (disabled if single turned off in settings)
457 if (
458 give_is_setting_enabled( give_get_option( 'forms_singular' ) )
459 && give_is_setting_enabled( give_get_option( 'form_sidebar' ) )
460 ) {
461
462 register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
463 'name' => __( 'Give Single Form Sidebar', 'give' ),
464 'id' => 'give-forms-sidebar',
465 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
466 'before_widget' => '<div id="%1$s" class="widget %2$s">',
467 'after_widget' => '</div>',
468 'before_title' => '<h3 class="widgettitle widget-title">',
469 'after_title' => '</h3>',
470 ) ) );
471
472 }
473 }
474
475 add_action( 'widgets_init', 'give_widgets_init', 999 );
476