| @@ -16,16 +16,18 @@ | ||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Registers and sets up the Donation Forms (give_forms) custom post type |
| 19 | 19 | * |
| 20 | + * @since 4.0.0 updated menu_name to GiveWP | |
| 20 | 21 | * @since 1.0 |
| 22 | + * | |
| 21 | 23 | * @return void |
| 22 | 24 | */ |
| 23 | 25 | function give_setup_post_types() { |
| 24 | 26 | |
| 25 | 27 | // 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 | + $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular', 'enabled' ) ); | |
| 29 | + $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives', 'enabled' ) ); | |
| 28 | 30 | |
| 29 | 31 | // Enable/Disable give_forms links if form is saving. |
| 30 | 32 | if ( Give_Admin_Settings::is_saving_settings() ) { |
| 31 | 33 | if ( isset( $_POST['forms_singular'] ) ) { |
| @@ -44,38 +46,41 @@ | ||
| 44 | 46 | if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
| 45 | 47 | $give_forms_slug = GIVE_FORMS_SLUG; |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( | |
| 50 | + $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : [ | |
| 49 | 51 | 'slug' => $give_forms_slug, |
| 50 | 52 | 'with_front' => false, |
| 53 | + ]; | |
| 54 | + | |
| 55 | + $give_forms_labels = apply_filters( | |
| 56 | + 'give_forms_labels', | |
| 57 | + [ | |
| 58 | + 'name' => __( 'Donation Forms', 'give' ), | |
| 59 | + 'singular_name' => __( 'Form', 'give' ), | |
| 60 | + 'add_new' => __( 'Add Form', 'give' ), | |
| 61 | + 'add_new_item' => __( 'Add New Donation Form', 'give' ), | |
| 62 | + 'edit_item' => __( 'Edit Donation Form', 'give' ), | |
| 63 | + 'new_item' => __( 'New Form', 'give' ), | |
| 64 | + 'all_items' => __( 'All Forms', 'give' ), | |
| 65 | + 'view_item' => __( 'View Form', 'give' ), | |
| 66 | + 'search_items' => __( 'Search Forms', 'give' ), | |
| 67 | + 'not_found' => __( 'No forms found.', 'give' ), | |
| 68 | + 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ), | |
| 69 | + 'parent_item_colon' => '', | |
| 70 | + 'menu_name' => apply_filters( 'give_menu_name', 'GiveWP'), | |
| 71 | + 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ), | |
| 72 | + ] | |
| 51 | 73 | ); |
| 52 | 74 | |
| 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 | 75 | // Default give_forms supports. |
| 71 | - $give_form_supports = array( | |
| 76 | + $give_form_supports = [ | |
| 72 | 77 | 'title', |
| 73 | 78 | 'thumbnail', |
| 74 | 79 | 'excerpt', |
| 75 | 80 | 'revisions', |
| 76 | 81 | 'author', |
| 77 | - ); | |
| 82 | + ]; | |
| 78 | 83 | |
| 79 | 84 | // Has the user disabled the excerpt? |
| 80 | 85 | if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
| 81 | 86 | unset( $give_form_supports[2] ); |
| @@ -86,27 +91,27 @@ | ||
| 86 | 91 | unset( $give_form_supports[1] ); |
| 87 | 92 | remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
| 88 | 93 | } |
| 89 | 94 | |
| 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 | - ); | |
| 95 | + $give_forms_args = [ | |
| 96 | + 'labels' => $give_forms_labels, | |
| 97 | + 'public' => $give_forms_singular, | |
| 98 | + 'show_ui' => true, | |
| 99 | + 'show_in_menu' => true, | |
| 100 | + 'show_in_rest' => true, | |
| 101 | + 'query_var' => true, | |
| 102 | + 'rewrite' => $give_forms_rewrite, | |
| 103 | + 'map_meta_cap' => true, | |
| 104 | + 'capability_type' => 'give_form', | |
| 105 | + 'has_archive' => $give_forms_archives, | |
| 106 | + 'menu_icon' => 'dashicons-give', | |
| 107 | + 'hierarchical' => false, | |
| 108 | + 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), | |
| 109 | + ]; | |
| 105 | 110 | register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
| 106 | 111 | |
| 107 | 112 | /** Donation Post Type */ |
| 108 | - $payment_labels = array( | |
| 113 | + $payment_labels = [ | |
| 109 | 114 | 'name' => _x( 'Donations', 'post type general name', 'give' ), |
| 110 | 115 | 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
| 111 | 116 | 'add_new' => __( 'Add New', 'give' ), |
| 112 | 117 | 'add_new_item' => __( 'Add New Donation', 'give' ), |
| @@ -118,11 +123,11 @@ | ||
| 118 | 123 | 'not_found' => __( 'No donations found.', 'give' ), |
| 119 | 124 | 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ), |
| 120 | 125 | 'parent_item_colon' => '', |
| 121 | 126 | 'menu_name' => __( 'Donations', 'give' ), |
| 122 | - ); | |
| 127 | + ]; | |
| 123 | 128 | |
| 124 | - $payment_args = array( | |
| 129 | + $payment_args = [ | |
| 125 | 130 | 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
| 126 | 131 | 'public' => false, |
| 127 | 132 | 'query_var' => false, |
| 128 | 133 | 'rewrite' => false, |
| @@ -127,13 +132,13 @@ | ||
| 127 | 132 | 'query_var' => false, |
| 128 | 133 | 'rewrite' => false, |
| 129 | 134 | 'map_meta_cap' => true, |
| 130 | 135 | 'capability_type' => 'give_payment', |
| 131 | - 'supports' => array( 'title' ), | |
| 136 | + 'supports' => [ 'title' ], | |
| 132 | 137 | 'can_export' => true, |
| 133 | - ); | |
| 138 | + ]; | |
| 139 | + | |
| 134 | 140 | register_post_type( 'give_payment', $payment_args ); |
| 135 | - | |
| 136 | 141 | } |
| 137 | 142 | |
| 138 | 143 | add_action( 'init', 'give_setup_post_types', 1 ); |
| 139 | 144 | |
| @@ -142,10 +147,10 @@ | ||
| 142 | 147 | * Give Setup Taxonomies |
| 143 | 148 | * |
| 144 | 149 | * Registers the custom taxonomies for the give_forms custom post type |
| 145 | 150 | * |
| 151 | + * @return void | |
| 146 | 152 | * @since 1.0 |
| 147 | - * @return void | |
| 148 | 153 | */ |
| 149 | 154 | function give_setup_taxonomies() { |
| 150 | 155 | |
| 151 | 156 | $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
| @@ -150,9 +155,9 @@ | ||
| 150 | 155 | |
| 151 | 156 | $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
| 152 | 157 | |
| 153 | 158 | /** Categories */ |
| 154 | - $category_labels = array( | |
| 159 | + $category_labels = [ | |
| 155 | 160 | 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
| 156 | 161 | 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
| 157 | 162 | 'search_items' => __( 'Search Categories', 'give' ), |
| 158 | 163 | 'all_items' => __( 'All Categories', 'give' ), |
| @@ -162,31 +167,34 @@ | ||
| 162 | 167 | 'update_item' => __( 'Update Category', 'give' ), |
| 163 | 168 | 'add_new_item' => __( 'Add New Category', 'give' ), |
| 164 | 169 | 'new_item_name' => __( 'New Category Name', 'give' ), |
| 165 | 170 | 'menu_name' => __( 'Categories', 'give' ), |
| 166 | - ); | |
| 171 | + ]; | |
| 167 | 172 | |
| 168 | - $category_args = apply_filters( 'give_forms_category_args', array( | |
| 173 | + $category_args = apply_filters( | |
| 174 | + 'give_forms_category_args', | |
| 175 | + [ | |
| 169 | 176 | 'hierarchical' => true, |
| 170 | 177 | 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
| 171 | 178 | 'show_ui' => true, |
| 179 | + 'show_in_rest' => true, | |
| 172 | 180 | 'query_var' => 'give_forms_category', |
| 173 | - 'rewrite' => array( | |
| 181 | + 'rewrite' => [ | |
| 174 | 182 | 'slug' => $slug . '/category', |
| 175 | 183 | 'with_front' => false, |
| 176 | 184 | 'hierarchical' => true, |
| 177 | - ), | |
| 178 | - 'capabilities' => array( | |
| 185 | + ], | |
| 186 | + 'capabilities' => [ | |
| 179 | 187 | 'manage_terms' => 'manage_give_form_terms', |
| 180 | 188 | 'edit_terms' => 'edit_give_form_terms', |
| 181 | 189 | 'assign_terms' => 'assign_give_form_terms', |
| 182 | 190 | 'delete_terms' => 'delete_give_form_terms', |
| 183 | - ), | |
| 184 | - ) | |
| 191 | + ], | |
| 192 | + ] | |
| 185 | 193 | ); |
| 186 | 194 | |
| 187 | 195 | /** Tags */ |
| 188 | - $tag_labels = array( | |
| 196 | + $tag_labels = [ | |
| 189 | 197 | 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
| 190 | 198 | 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
| 191 | 199 | 'search_items' => __( 'Search Tags', 'give' ), |
| 192 | 200 | 'all_items' => __( 'All Tags', 'give' ), |
| @@ -197,23 +205,30 @@ | ||
| 197 | 205 | 'add_new_item' => __( 'Add New Tag', 'give' ), |
| 198 | 206 | 'new_item_name' => __( 'New Tag Name', 'give' ), |
| 199 | 207 | 'menu_name' => __( 'Tags', 'give' ), |
| 200 | 208 | 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ), |
| 201 | - ); | |
| 209 | + ]; | |
| 202 | 210 | |
| 203 | - $tag_args = apply_filters( 'give_forms_tag_args', array( | |
| 211 | + $tag_args = apply_filters( | |
| 212 | + 'give_forms_tag_args', | |
| 213 | + [ | |
| 204 | 214 | 'hierarchical' => false, |
| 205 | 215 | 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
| 206 | 216 | 'show_ui' => true, |
| 217 | + 'show_in_rest' => true, | |
| 207 | 218 | 'query_var' => 'give_forms_tag', |
| 208 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), | |
| 209 | - 'capabilities' => array( | |
| 219 | + 'rewrite' => [ | |
| 220 | + 'slug' => $slug . '/tag', | |
| 221 | + 'with_front' => false, | |
| 222 | + 'hierarchical' => true, | |
| 223 | + ], | |
| 224 | + 'capabilities' => [ | |
| 210 | 225 | 'manage_terms' => 'manage_give_form_terms', |
| 211 | 226 | 'edit_terms' => 'edit_give_form_terms', |
| 212 | 227 | 'assign_terms' => 'assign_give_form_terms', |
| 213 | 228 | 'delete_terms' => 'delete_give_form_terms', |
| 214 | - ), | |
| 215 | - ) | |
| 229 | + ], | |
| 230 | + ] | |
| 216 | 231 | ); |
| 217 | 232 | |
| 218 | 233 | // Does the user want category? |
| 219 | 234 | $enable_category = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
| @@ -234,14 +249,14 @@ | ||
| 234 | 249 | } |
| 235 | 250 | } |
| 236 | 251 | |
| 237 | 252 | if ( $enable_category ) { |
| 238 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); | |
| 253 | + register_taxonomy( 'give_forms_category', [ 'give_forms' ], $category_args ); | |
| 239 | 254 | register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
| 240 | 255 | } |
| 241 | 256 | |
| 242 | 257 | if ( $enable_tag ) { |
| 243 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); | |
| 258 | + register_taxonomy( 'give_forms_tag', [ 'give_forms' ], $tag_args ); | |
| 244 | 259 | register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
| 245 | 260 | } |
| 246 | 261 | } |
| 247 | 262 | |
| @@ -250,16 +265,16 @@ | ||
| 250 | 265 | |
| 251 | 266 | /** |
| 252 | 267 | * Get Default Form Labels |
| 253 | 268 | * |
| 269 | + * @return array $defaults Default labels | |
| 254 | 270 | * @since 1.0 |
| 255 | - * @return array $defaults Default labels | |
| 256 | 271 | */ |
| 257 | 272 | function give_get_default_form_labels() { |
| 258 | - $defaults = array( | |
| 273 | + $defaults = [ | |
| 259 | 274 | 'singular' => __( 'Form', 'give' ), |
| 260 | 275 | 'plural' => __( 'Forms', 'give' ), |
| 261 | - ); | |
| 276 | + ]; | |
| 262 | 277 | |
| 263 | 278 | return apply_filters( 'give_default_form_name', $defaults ); |
| 264 | 279 | } |
| 265 | 280 | |
| @@ -265,13 +280,12 @@ | ||
| 265 | 280 | |
| 266 | 281 | /** |
| 267 | 282 | * Get Singular Forms Label |
| 268 | 283 | * |
| 269 | - * @since 1.0 | |
| 270 | - * | |
| 271 | 284 | * @param bool $lowercase |
| 272 | 285 | * |
| 273 | 286 | * @return string $defaults['singular'] Singular label |
| 287 | + * @since 1.0 | |
| 274 | 288 | */ |
| 275 | 289 | function give_get_forms_label_singular( $lowercase = false ) { |
| 276 | 290 | $defaults = give_get_default_form_labels(); |
| 277 | 291 | |
| @@ -280,10 +294,10 @@ | ||
| 280 | 294 | |
| 281 | 295 | /** |
| 282 | 296 | * Get Plural Forms Label |
| 283 | 297 | * |
| 298 | + * @return string $defaults['plural'] Plural label | |
| 284 | 299 | * @since 1.0 |
| 285 | - * @return string $defaults['plural'] Plural label | |
| 286 | 300 | */ |
| 287 | 301 | function give_get_forms_label_plural( $lowercase = false ) { |
| 288 | 302 | $defaults = give_get_default_form_labels(); |
| 289 | 303 | |
| @@ -292,13 +306,12 @@ | ||
| 292 | 306 | |
| 293 | 307 | /** |
| 294 | 308 | * Change default "Enter title here" input |
| 295 | 309 | * |
| 296 | - * @since 1.0 | |
| 297 | - * | |
| 298 | 310 | * @param string $title Default title placeholder text |
| 299 | 311 | * |
| 300 | 312 | * @return string $title New placeholder text |
| 313 | + * @since 1.0 | |
| 301 | 314 | */ |
| 302 | 315 | function give_change_default_title( $title ) { |
| 303 | 316 | // If a frontend plugin uses this filter (check extensions before changing this function) |
| 304 | 317 | if ( ! is_admin() ) { |
| @@ -320,70 +333,91 @@ | ||
| 320 | 333 | |
| 321 | 334 | /** |
| 322 | 335 | * Registers Custom Post Statuses which are used by the Payments |
| 323 | 336 | * |
| 337 | + * @return void | |
| 324 | 338 | * @since 1.0 |
| 325 | - * @return void | |
| 326 | 339 | */ |
| 327 | 340 | function give_register_post_type_statuses() { |
| 328 | 341 | // 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 | - ) ); | |
| 342 | + register_post_status( | |
| 343 | + 'refunded', | |
| 344 | + [ | |
| 345 | + 'label' => __( 'Refunded', '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( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), | |
| 351 | + ] | |
| 352 | + ); | |
| 353 | + register_post_status( | |
| 354 | + 'failed', | |
| 355 | + [ | |
| 356 | + 'label' => __( 'Failed', 'give' ), | |
| 357 | + 'public' => true, | |
| 358 | + 'exclude_from_search' => false, | |
| 359 | + 'show_in_admin_all_list' => true, | |
| 360 | + 'show_in_admin_status_list' => true, | |
| 361 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), | |
| 362 | + ] | |
| 363 | + ); | |
| 364 | + register_post_status( | |
| 365 | + 'revoked', | |
| 366 | + [ | |
| 367 | + 'label' => __( 'Revoked', 'give' ), | |
| 368 | + 'public' => true, | |
| 369 | + 'exclude_from_search' => false, | |
| 370 | + 'show_in_admin_all_list' => true, | |
| 371 | + 'show_in_admin_status_list' => true, | |
| 372 | + 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), | |
| 373 | + ] | |
| 374 | + ); | |
| 375 | + register_post_status( | |
| 376 | + 'cancelled', | |
| 377 | + [ | |
| 378 | + 'label' => __( 'Cancelled', '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( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), | |
| 384 | + ] | |
| 385 | + ); | |
| 386 | + register_post_status( | |
| 387 | + 'abandoned', | |
| 388 | + [ | |
| 389 | + 'label' => __( 'Abandoned', 'give' ), | |
| 390 | + 'public' => true, | |
| 391 | + 'exclude_from_search' => false, | |
| 392 | + 'show_in_admin_all_list' => true, | |
| 393 | + 'show_in_admin_status_list' => true, | |
| 394 | + 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), | |
| 395 | + ] | |
| 396 | + ); | |
| 397 | + register_post_status( | |
| 398 | + 'processing', | |
| 399 | + [ | |
| 400 | + 'label' => _x( 'Processing', 'Processing payment status', 'give' ), | |
| 401 | + 'public' => true, | |
| 402 | + 'exclude_from_search' => false, | |
| 403 | + 'show_in_admin_all_list' => true, | |
| 404 | + 'show_in_admin_status_list' => true, | |
| 405 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' ), | |
| 406 | + ] | |
| 407 | + ); | |
| 377 | 408 | |
| 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 | - ) ); | |
| 409 | + register_post_status( | |
| 410 | + 'preapproval', | |
| 411 | + [ | |
| 412 | + 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ), | |
| 413 | + 'public' => true, | |
| 414 | + 'exclude_from_search' => false, | |
| 415 | + 'show_in_admin_all_list' => true, | |
| 416 | + 'show_in_admin_status_list' => true, | |
| 417 | + 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ), | |
| 418 | + ] | |
| 419 | + ); | |
| 386 | 420 | |
| 387 | 421 | } |
| 388 | 422 | |
| 389 | 423 | add_action( 'init', 'give_register_post_type_statuses' ); |
| @@ -392,13 +426,12 @@ | ||
| 392 | 426 | * Updated Messages |
| 393 | 427 | * |
| 394 | 428 | * Returns an array of with all updated messages. |
| 395 | 429 | * |
| 396 | - * @since 1.0 | |
| 397 | - * | |
| 398 | 430 | * @param array $messages Post updated message |
| 399 | 431 | * |
| 400 | 432 | * @return array $messages New post updated messages |
| 433 | + * @since 1.0 | |
| 401 | 434 | */ |
| 402 | 435 | function give_updated_messages( $messages ) { |
| 403 | 436 | global $post, $post_ID; |
| 404 | 437 | |
| @@ -403,25 +436,25 @@ | ||
| 403 | 436 | global $post, $post_ID; |
| 404 | 437 | |
| 405 | 438 | if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
| 406 | 439 | |
| 407 | - $messages['give_forms'] = array( | |
| 440 | + $messages['give_forms'] = [ | |
| 408 | 441 | 1 => __( 'Form updated.', 'give' ), |
| 409 | 442 | 4 => __( 'Form updated.', 'give' ), |
| 410 | 443 | 6 => __( 'Form published.', 'give' ), |
| 411 | 444 | 7 => __( 'Form saved.', 'give' ), |
| 412 | 445 | 8 => __( 'Form submitted.', 'give' ), |
| 413 | - ); | |
| 446 | + ]; | |
| 414 | 447 | |
| 415 | 448 | } else { |
| 416 | 449 | |
| 417 | - $messages['give_forms'] = array( | |
| 450 | + $messages['give_forms'] = [ | |
| 418 | 451 | 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
| 419 | 452 | 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
| 420 | 453 | 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
| 421 | 454 | 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
| 422 | 455 | 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
| 423 | - ); | |
| 456 | + ]; | |
| 424 | 457 | |
| 425 | 458 | } |
| 426 | 459 | |
| 427 | 460 | return $messages; |
| @@ -458,17 +491,22 @@ | ||
| 458 | 491 | give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
| 459 | 492 | && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
| 460 | 493 | ) { |
| 461 | 494 | |
| 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 | - ) ) ); | |
| 495 | + register_sidebar( | |
| 496 | + apply_filters( | |
| 497 | + 'give_forms_single_sidebar', | |
| 498 | + [ | |
| 499 | + 'name' => __( 'GiveWP Single Form Sidebar', 'give' ), | |
| 500 | + 'id' => 'give-forms-sidebar', | |
| 501 | + 'description' => __( 'Widgets in this area will be shown on the single GiveWP forms aside area. This sidebar will not display for embedded forms.', 'give' ), | |
| 502 | + 'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
| 503 | + 'after_widget' => '</div>', | |
| 504 | + 'before_title' => '<h3 class="widgettitle widget-title">', | |
| 505 | + 'after_title' => '</h3>', | |
| 506 | + ] | |
| 507 | + ) | |
| 508 | + ); | |
| 471 | 509 | |
| 472 | 510 | } |
| 473 | 511 | } |
| 474 | 512 | |
| @@ -477,16 +515,15 @@ | ||
| 477 | 515 | |
| 478 | 516 | /** |
| 479 | 517 | * Remove "Quick Edit" for the give_forms CPT. |
| 480 | 518 | * |
| 481 | - * @since 2.3.0 | |
| 482 | - * | |
| 483 | 519 | * @param array $actions |
| 484 | 520 | * @param null $post |
| 485 | 521 | * |
| 486 | 522 | * @return array |
| 523 | + * @since 2.3.0 | |
| 487 | 524 | */ |
| 488 | -function give_forms_disable_quick_edit( $actions = array(), $post = null ) { | |
| 525 | +function give_forms_disable_quick_edit( $actions = [], $post = null ) { | |
| 489 | 526 | |
| 490 | 527 | // Abort if the post type is not "give_forms". |
| 491 | 528 | if ( ! is_post_type_archive( 'give_forms' ) ) { |
| 492 | 529 | return $actions; |
| @@ -502,4 +539,49 @@ | ||
| 502 | 539 | |
| 503 | 540 | } |
| 504 | 541 | |
| 505 | 542 | add_filter( 'post_row_actions', 'give_forms_disable_quick_edit', 10, 2 ); |
| 543 | + | |
| 544 | +/** | |
| 545 | + * Removes the screen options pull down. It is reset later in a different position. | |
| 546 | + * | |
| 547 | + * @param bool $display_boolean Whether to display screen options. | |
| 548 | + * @param WP_Screen $wp_screen_object The screen object. | |
| 549 | + * | |
| 550 | + * @return bool Whether to display screen options. | |
| 551 | + * @since 2.5.0 | |
| 552 | + */ | |
| 553 | +function give_remove_screen_options( $display_boolean, $wp_screen_object ) { | |
| 554 | + | |
| 555 | + if ( false !== strpos( $wp_screen_object->id, 'give' ) ) { | |
| 556 | + return false; | |
| 557 | + } | |
| 558 | + | |
| 559 | + // Don't mess with other screens. | |
| 560 | + return $display_boolean; | |
| 561 | +} | |
| 562 | + | |
| 563 | +// add_filter( 'screen_options_show_screen', 'give_remove_screen_options', 10, 2 ); | |
| 564 | + | |
| 565 | +/** | |
| 566 | + * Renders the screen options back after admin bar to ensure it pushes down the banner rather than overlaps them as is default in WordPress. | |
| 567 | + * | |
| 568 | + * @since 2.5.0 | |
| 569 | + */ | |
| 570 | +function give_render_screen_options() { | |
| 571 | + if ( ! is_admin() ) { | |
| 572 | + return; | |
| 573 | + } | |
| 574 | + | |
| 575 | + $current_screen = get_current_screen(); | |
| 576 | + | |
| 577 | + if ( empty( $current_screen ) ) { | |
| 578 | + return; | |
| 579 | + } | |
| 580 | + | |
| 581 | + if ( false !== strpos( $current_screen->id, 'give' ) ) { | |
| 582 | + // Render Screen Options above the banner. | |
| 583 | + $current_screen->render_screen_meta(); | |
| 584 | + } | |
| 585 | +} | |
| 586 | + | |
| 587 | +add_action( 'wp_after_admin_bar_render', 'give_render_screen_options' ); | |