diff --git a/plugins/wporg-5ftf/includes/pledge-form.php b/plugins/wporg-5ftf/includes/pledge-form.php index 18d2a03..69d7596 100755 --- a/plugins/wporg-5ftf/includes/pledge-form.php +++ b/plugins/wporg-5ftf/includes/pledge-form.php @@ -14,7 +14,6 @@ defined( 'WPINC' ) || die(); // Todo make this into simple optionless blocks instead? add_shortcode( '5ftf_pledge_form_new', __NAMESPACE__ . '\render_form_new' ); add_shortcode( '5ftf_pledge_form_manage', __NAMESPACE__ . '\render_form_manage' ); -add_shortcode( '5ftf_pledge_form_manage_link', __NAMESPACE__ . '\render_manage_link_request' ); /** * Render the form(s) for creating new pledges. @@ -175,19 +174,6 @@ function render_form_manage() { return ob_get_clean(); } - -/** - * Render the `render_manage_link_request` shortcode. - */ -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() . 'form-pledge-request-manage-link.php'; -} - /** * Process a submission from the Manage Existing Pledge form. * diff --git a/plugins/wporg-5ftf/includes/pledge.php b/plugins/wporg-5ftf/includes/pledge.php index 1acf7ef..fd75c06 100755 --- a/plugins/wporg-5ftf/includes/pledge.php +++ b/plugins/wporg-5ftf/includes/pledge.php @@ -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'; + } +} diff --git a/plugins/wporg-5ftf/views/button-request-manage-link.php b/plugins/wporg-5ftf/views/button-request-manage-link.php new file mode 100644 index 0000000..d546764 --- /dev/null +++ b/plugins/wporg-5ftf/views/button-request-manage-link.php @@ -0,0 +1,13 @@ + +
- -
- -- -
- - -