PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.0.2
GiveWP – Donation Plugin and Fundraising Platform v2.0.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 8 years ago api 8 years ago deprecated 8 years ago donors 8 years ago emails 8 years ago forms 8 years ago gateways 8 years ago libraries 8 years ago payments 8 years ago actions.php 8 years ago ajax-functions.php 8 years ago class-give-async-process.php 8 years ago class-give-background-updater.php 8 years ago class-give-cache.php 8 years ago class-give-cli-commands.php 8 years ago class-give-cron.php 8 years ago class-give-db-donor-meta.php 8 years ago class-give-db-donors.php 8 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 8 years ago class-give-db-meta.php 8 years ago class-give-db-payment-meta.php 8 years ago class-give-db.php 8 years ago class-give-donate-form.php 8 years ago class-give-donor.php 8 years ago class-give-email-access.php 8 years ago class-give-gravatars.php 8 years ago class-give-html-elements.php 8 years ago class-give-license-handler.php 8 years ago class-give-logging.php 8 years ago class-give-roles.php 8 years ago class-give-session.php 8 years ago class-give-stats.php 8 years ago class-give-template-loader.php 9 years ago class-give-tooltips.php 8 years ago class-give-translation.php 8 years ago class-notices.php 8 years ago country-functions.php 8 years ago currency-functions.php 8 years ago error-tracking.php 8 years ago filters.php 8 years ago formatting.php 8 years ago import-functions.php 8 years ago install.php 8 years ago login-register.php 8 years ago misc-functions.php 8 years ago plugin-compatibility.php 8 years ago post-types.php 8 years ago price-functions.php 8 years ago process-donation.php 8 years ago scripts.php 8 years ago shortcodes.php 8 years ago template-functions.php 8 years ago user-functions.php 8 years ago
post-types.php
475 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 'query_var' => true,
96 'rewrite' => $give_forms_rewrite,
97 'map_meta_cap' => true,
98 'capability_type' => 'give_form',
99 'has_archive' => $give_forms_archives,
100 'menu_icon' => 'dashicons-give',
101 'hierarchical' => false,
102 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ),
103 );
104 register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
105
106 /** Donation Post Type */
107 $payment_labels = array(
108 'name' => _x( 'Donations', 'post type general name', 'give' ),
109 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ),
110 'add_new' => __( 'Add New', 'give' ),
111 'add_new_item' => __( 'Add New Donation', 'give' ),
112 'edit_item' => __( 'Edit Donation', 'give' ),
113 'new_item' => __( 'New Donation', 'give' ),
114 'all_items' => __( 'All Donations', 'give' ),
115 'view_item' => __( 'View Donation', 'give' ),
116 'search_items' => __( 'Search Donations', 'give' ),
117 'not_found' => __( 'No donations found.', 'give' ),
118 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ),
119 'parent_item_colon' => '',
120 'menu_name' => __( 'Donations', 'give' ),
121 );
122
123 $payment_args = array(
124 'labels' => apply_filters( 'give_payment_labels', $payment_labels ),
125 'public' => false,
126 'query_var' => false,
127 'rewrite' => false,
128 'map_meta_cap' => true,
129 'capability_type' => 'give_payment',
130 'supports' => array( 'title' ),
131 'can_export' => true,
132 );
133 register_post_type( 'give_payment', $payment_args );
134
135 }
136
137 add_action( 'init', 'give_setup_post_types', 1 );
138
139
140 /**
141 * Give Setup Taxonomies
142 *
143 * Registers the custom taxonomies for the give_forms custom post type
144 *
145 * @since 1.0
146 * @return void
147 */
148 function give_setup_taxonomies() {
149
150 $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
151
152 /** Categories */
153 $category_labels = array(
154 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ),
155 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ),
156 'search_items' => __( 'Search Categories', 'give' ),
157 'all_items' => __( 'All Categories', 'give' ),
158 'parent_item' => __( 'Parent Category', 'give' ),
159 'parent_item_colon' => __( 'Parent Category:', 'give' ),
160 'edit_item' => __( 'Edit Category', 'give' ),
161 'update_item' => __( 'Update Category', 'give' ),
162 'add_new_item' => __( 'Add New Category', 'give' ),
163 'new_item_name' => __( 'New Category Name', 'give' ),
164 'menu_name' => __( 'Categories', 'give' ),
165 );
166
167 $category_args = apply_filters( 'give_forms_category_args', array(
168 'hierarchical' => true,
169 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ),
170 'show_ui' => true,
171 'query_var' => 'give_forms_category',
172 'rewrite' => array(
173 'slug' => $slug . '/category',
174 'with_front' => false,
175 'hierarchical' => true,
176 ),
177 'capabilities' => array(
178 'manage_terms' => 'manage_give_form_terms',
179 'edit_terms' => 'edit_give_form_terms',
180 'assign_terms' => 'assign_give_form_terms',
181 'delete_terms' => 'delete_give_form_terms',
182 ),
183 )
184 );
185
186 /** Tags */
187 $tag_labels = array(
188 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ),
189 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ),
190 'search_items' => __( 'Search Tags', 'give' ),
191 'all_items' => __( 'All Tags', 'give' ),
192 'parent_item' => __( 'Parent Tag', 'give' ),
193 'parent_item_colon' => __( 'Parent Tag:', 'give' ),
194 'edit_item' => __( 'Edit Tag', 'give' ),
195 'update_item' => __( 'Update Tag', 'give' ),
196 'add_new_item' => __( 'Add New Tag', 'give' ),
197 'new_item_name' => __( 'New Tag Name', 'give' ),
198 'menu_name' => __( 'Tags', 'give' ),
199 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ),
200 );
201
202 $tag_args = apply_filters( 'give_forms_tag_args', array(
203 'hierarchical' => false,
204 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ),
205 'show_ui' => true,
206 'query_var' => 'give_forms_tag',
207 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
208 'capabilities' => array(
209 'manage_terms' => 'manage_give_form_terms',
210 'edit_terms' => 'edit_give_form_terms',
211 'assign_terms' => 'assign_give_form_terms',
212 'delete_terms' => 'delete_give_form_terms',
213 ),
214 )
215 );
216
217 // Does the user want category?
218 $enable_category = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) );
219
220 // Does the user want tag?
221 $enable_tag = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) );
222
223 // Enable/Disable category and tag if form is saving.
224 if ( Give_Admin_Settings::is_saving_settings() ) {
225 if ( isset( $_POST['categories'] ) ) {
226 $enable_category = give_is_setting_enabled( give_clean( $_POST['categories'] ) );
227 flush_rewrite_rules();
228 }
229
230 if ( isset( $_POST['tags'] ) ) {
231 $enable_tag = give_is_setting_enabled( give_clean( $_POST['tags'] ) );
232 flush_rewrite_rules();
233 }
234 }
235
236 if ( $enable_category ) {
237 register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
238 register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
239 }
240
241 if ( $enable_tag ) {
242 register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
243 register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
244 }
245 }
246
247 add_action( 'init', 'give_setup_taxonomies', 0 );
248
249
250 /**
251 * Get Default Form Labels
252 *
253 * @since 1.0
254 * @return array $defaults Default labels
255 */
256 function give_get_default_form_labels() {
257 $defaults = array(
258 'singular' => __( 'Form', 'give' ),
259 'plural' => __( 'Forms', 'give' ),
260 );
261
262 return apply_filters( 'give_default_form_name', $defaults );
263 }
264
265 /**
266 * Get Singular Forms Label
267 *
268 * @since 1.0
269 *
270 * @param bool $lowercase
271 *
272 * @return string $defaults['singular'] Singular label
273 */
274 function give_get_forms_label_singular( $lowercase = false ) {
275 $defaults = give_get_default_form_labels();
276
277 return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
278 }
279
280 /**
281 * Get Plural Forms Label
282 *
283 * @since 1.0
284 * @return string $defaults['plural'] Plural label
285 */
286 function give_get_forms_label_plural( $lowercase = false ) {
287 $defaults = give_get_default_form_labels();
288
289 return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
290 }
291
292 /**
293 * Change default "Enter title here" input
294 *
295 * @since 1.0
296 *
297 * @param string $title Default title placeholder text
298 *
299 * @return string $title New placeholder text
300 */
301 function give_change_default_title( $title ) {
302 // If a frontend plugin uses this filter (check extensions before changing this function)
303 if ( ! is_admin() ) {
304 $title = __( 'Enter form title here', 'give' );
305
306 return $title;
307 }
308
309 $screen = get_current_screen();
310
311 if ( 'give_forms' == $screen->post_type ) {
312 $title = __( 'Enter form title here', 'give' );
313 }
314
315 return $title;
316 }
317
318 add_filter( 'enter_title_here', 'give_change_default_title' );
319
320 /**
321 * Registers Custom Post Statuses which are used by the Payments
322 *
323 * @since 1.0
324 * @return void
325 */
326 function give_register_post_type_statuses() {
327 // Payment Statuses
328 register_post_status( 'refunded', array(
329 'label' => __( 'Refunded', 'give' ),
330 'public' => true,
331 'exclude_from_search' => false,
332 'show_in_admin_all_list' => true,
333 'show_in_admin_status_list' => true,
334 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ),
335 ) );
336 register_post_status( 'failed', array(
337 'label' => __( 'Failed', 'give' ),
338 'public' => true,
339 'exclude_from_search' => false,
340 'show_in_admin_all_list' => true,
341 'show_in_admin_status_list' => true,
342 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ),
343 ) );
344 register_post_status( 'revoked', array(
345 'label' => __( 'Revoked', 'give' ),
346 'public' => true,
347 'exclude_from_search' => false,
348 'show_in_admin_all_list' => true,
349 'show_in_admin_status_list' => true,
350 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ),
351 ) );
352 register_post_status( 'cancelled', array(
353 'label' => __( 'Cancelled', 'give' ),
354 'public' => true,
355 'exclude_from_search' => false,
356 'show_in_admin_all_list' => true,
357 'show_in_admin_status_list' => true,
358 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ),
359 ) );
360 register_post_status( 'abandoned', array(
361 'label' => __( 'Abandoned', 'give' ),
362 'public' => true,
363 'exclude_from_search' => false,
364 'show_in_admin_all_list' => true,
365 'show_in_admin_status_list' => true,
366 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ),
367 ) );
368 register_post_status( 'processing', array(
369 'label' => _x( 'Processing', 'Processing payment status', 'give' ),
370 'public' => true,
371 'exclude_from_search' => false,
372 'show_in_admin_all_list' => true,
373 'show_in_admin_status_list' => true,
374 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' )
375 ) );
376
377 register_post_status( 'preapproval', array(
378 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ),
379 'public' => true,
380 'exclude_from_search' => false,
381 'show_in_admin_all_list' => true,
382 'show_in_admin_status_list' => true,
383 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ),
384 ) );
385
386 }
387
388 add_action( 'init', 'give_register_post_type_statuses' );
389
390 /**
391 * Updated Messages
392 *
393 * Returns an array of with all updated messages.
394 *
395 * @since 1.0
396 *
397 * @param array $messages Post updated message
398 *
399 * @return array $messages New post updated messages
400 */
401 function give_updated_messages( $messages ) {
402 global $post, $post_ID;
403
404 if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) {
405
406 $messages['give_forms'] = array(
407 1 => __( 'Form updated.', 'give' ),
408 4 => __( 'Form updated.', 'give' ),
409 6 => __( 'Form published.', 'give' ),
410 7 => __( 'Form saved.', 'give' ),
411 8 => __( 'Form submitted.', 'give' ),
412 );
413
414 } else {
415
416 $messages['give_forms'] = array(
417 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
418 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
419 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
420 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
421 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
422 );
423
424 }
425
426 return $messages;
427 }
428
429 add_filter( 'post_updated_messages', 'give_updated_messages' );
430
431 /**
432 * Ensure post thumbnail support is turned on
433 */
434 function give_add_thumbnail_support() {
435 if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
436 return;
437 }
438
439 if ( ! current_theme_supports( 'post-thumbnails' ) ) {
440 add_theme_support( 'post-thumbnails' );
441 }
442
443 add_post_type_support( 'give_forms', 'thumbnail' );
444 }
445
446 add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
447
448 /**
449 * Give Sidebars
450 *
451 * This option adds Give sidebars; registered late so it display last in list
452 */
453 function give_widgets_init() {
454
455 // Single Give Forms (disabled if single turned off in settings)
456 if (
457 give_is_setting_enabled( give_get_option( 'forms_singular' ) )
458 && give_is_setting_enabled( give_get_option( 'form_sidebar' ) )
459 ) {
460
461 register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
462 'name' => __( 'Give Single Form Sidebar', 'give' ),
463 'id' => 'give-forms-sidebar',
464 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
465 'before_widget' => '<div id="%1$s" class="widget %2$s">',
466 'after_widget' => '</div>',
467 'before_title' => '<h3 class="widgettitle widget-title">',
468 'after_title' => '</h3>',
469 ) ) );
470
471 }
472 }
473
474 add_action( 'widgets_init', 'give_widgets_init', 999 );
475