mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-15 14:55:44 +03:00
Plugin: Refactor to use as foundation for planned pledge workflows (#23)
This starts to address several items in the roadmap, but probably doesn't fully address any of them. It takes the plugin code that was written several months ago, before the scope of this project was fully sorted out, and refactors it to be a starting point for the roadmap. * Adds template files for form inputs that can be used to both create new pledges and manage existing pledges * Does some validation and sanitization work on form submissions * Adds a custom post status for deactivated pledges
This commit is contained in:
parent
7a355b8314
commit
ded645fabc
15 changed files with 613 additions and 323 deletions
|
@ -16,10 +16,22 @@ const SLUG = 'pledge';
|
|||
const SLUG_PL = 'pledges';
|
||||
const CPT_ID = FiveForTheFuture\PREFIX . '_' . SLUG;
|
||||
|
||||
add_action( 'init', __NAMESPACE__ . '\register_custom_post_type', 0 );
|
||||
add_action( 'init', __NAMESPACE__ . '\register', 0 );
|
||||
|
||||
/**
|
||||
* Register the post type.
|
||||
* Register all the things.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function register() {
|
||||
register_custom_post_type();
|
||||
register_custom_post_status();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the post type(s).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function register_custom_post_type() {
|
||||
$labels = array(
|
||||
|
@ -49,7 +61,7 @@ function register_custom_post_type() {
|
|||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title', 'thumbnail', 'author', 'revisions' ),
|
||||
'supports' => array( 'title', 'thumbnail' ),
|
||||
'hierarchical' => false,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
|
@ -71,3 +83,22 @@ function register_custom_post_type() {
|
|||
|
||||
register_post_type( CPT_ID, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the post status(es).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function register_custom_post_status() {
|
||||
register_post_status(
|
||||
FiveForTheFuture\PREFIX . '-deactivated',
|
||||
array(
|
||||
'label' => __( 'Deactivated', 'wporg' ),
|
||||
'label_count' => _n_noop( 'Deactivated <span class="count">(%s)</span>', 'Deactivated <span class="count">(%s)</span>', 'wporg' ),
|
||||
'public' => false,
|
||||
'internal' => false,
|
||||
'protected' => true,
|
||||
CPT_ID => true, // Custom parameter to streamline its use with the Pledge CPT.
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue