Remove shortcode, add button & dialog by hooking into actions

This commit is contained in:
Kelly Dwan 2019-11-20 16:58:18 -05:00
parent a67ef04505
commit 04d1a12296
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
6 changed files with 88 additions and 94 deletions

View file

@ -18,12 +18,18 @@ const SLUG = 'pledge';
const SLUG_PL = 'pledges';
const CPT_ID = FiveForTheFuture\PREFIX . '_' . SLUG;
add_action( 'init', __NAMESPACE__ . '\register', 0 );
add_action( 'admin_menu', __NAMESPACE__ . '\admin_menu' );
// Admin hooks.
add_action( 'init', __NAMESPACE__ . '\register', 0 );
add_action( 'admin_menu', __NAMESPACE__ . '\admin_menu' );
add_action( 'pre_get_posts', __NAMESPACE__ . '\filter_query' );
// List table columns.
add_filter( 'manage_edit-' . CPT_ID . '_columns', __NAMESPACE__ . '\add_list_table_columns' );
add_action( 'manage_' . CPT_ID . '_posts_custom_column', __NAMESPACE__ . '\populate_list_table_columns', 10, 2 );
// Front end hooks.
add_action( 'pledge_footer', __NAMESPACE__ . '\render_manage_link_request' );
add_action( 'wp_footer', __NAMESPACE__ . '\render_js_templates' );
/**
* Register all the things.
*
@ -252,3 +258,28 @@ function filter_query( $query ) {
// see https://github.com/WordPress/five-for-the-future/issues/70#issuecomment-549066883.
$query->set( 'posts_per_page', 100 );
}
/**
* Render the button to toggle the "Request Manage Email" dialog.
*
* @return void
*/
function render_manage_link_request() {
// @todo enable when https://github.com/WordPress/five-for-the-future/issues/6 is done
if ( ! defined( 'WPORG_SANDBOXED' ) || ! WPORG_SANDBOXED ) {
return;
}
require_once FiveForTheFuture\get_views_path() . 'button-request-manage-link.php';
}
/**
* Render JS templates at the end of the page.
*
* @return void
*/
function render_js_templates() {
if ( CPT_ID === get_post_type() ) {
require_once FiveForTheFuture\get_views_path() . 'modal-request-manage-link.php';
}
}