| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable Admin Campaign Hooks. |
| 4 |
* |
| 5 |
* Action/filter hooks used for setting up donations in the admin. |
| 6 |
* |
| 7 |
* @package Charitable/Functions/Admin |
| 8 |
* @author David Bisset |
| 9 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 10 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 11 |
* @since 1.5.0 |
| 12 |
* @version 1.6.24 |
| 13 |
*/ |
| 14 |
|
| 15 |
// Exit if accessed directly. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
$registry = charitable()->registry(); |
| 21 |
$registry->register_object( Charitable_Campaign_Meta_Boxes::get_instance() ); |
| 22 |
|
| 23 |
/** |
| 24 |
* Sets the placeholder text of the campaign title field. |
| 25 |
* |
| 26 |
* @see Charitable_Campaign_Meta_Boxes::campaign_enter_title() |
| 27 |
*/ |
| 28 |
add_filter( 'enter_title_here', array( $registry->get( 'campaign_meta_boxes' ), 'campaign_enter_title' ), 10, 2 ); |
| 29 |
|
| 30 |
/** |
| 31 |
* Display fields at the very top of the page. |
| 32 |
* |
| 33 |
* @see Charitable_Campaign_Meta_Boxes::campaign_form_top() |
| 34 |
*/ |
| 35 |
add_action( 'edit_form_after_title', array( $registry->get( 'campaign_meta_boxes' ), 'campaign_form_top' ) ); |
| 36 |
|
| 37 |
/** |
| 38 |
* Prevent meta box sorting for campaigns. |
| 39 |
*/ |
| 40 |
add_filter( 'get_user_option_meta-box-order_' . Charitable::CAMPAIGN_POST_TYPE, '__return_false' ); |
| 41 |
|
| 42 |
/** |
| 43 |
* Campaign Metaboxes. |
| 44 |
* |
| 45 |
* @see Charitable_Campaign_Meta_Boxes::add_meta_boxes() |
| 46 |
* @see Charitable_Campaign_Meta_Boxes::campaign_donation_options_metabox() |
| 47 |
* @see Charitable_Campaign_Meta_Boxes::wrap_editor() |
| 48 |
*/ |
| 49 |
add_action( 'add_meta_boxes_' . Charitable::CAMPAIGN_POST_TYPE, array( $registry->get( 'campaign_meta_boxes' ), 'add_meta_boxes' ) ); |
| 50 |
|
| 51 |
/** |
| 52 |
* Save the campaign. |
| 53 |
* |
| 54 |
* @see Charitable_Campaign_Meta_Boxes::save_campaign() |
| 55 |
* @see Charitable_Campaign_Meta_Boxes::set_default_post_content() |
| 56 |
*/ |
| 57 |
add_action( 'save_post_' . Charitable::CAMPAIGN_POST_TYPE, array( $registry->get( 'campaign_meta_boxes' ), 'save_campaign' ), 10, 2 ); |
| 58 |
add_filter( 'wp_insert_post_data', array( $registry->get( 'campaign_meta_boxes' ), 'set_default_post_content' ) ); |
| 59 |
|
| 60 |
/** |
| 61 |
* Set up admin messages & notifications displayed based on actions taken. |
| 62 |
* |
| 63 |
* @see Charitable_Campaign_Meta_Boxes::post_messages() |
| 64 |
* @see Charitable_Campaign_Meta_Boxes::bulk_messages() |
| 65 |
*/ |
| 66 |
add_filter( 'post_updated_messages', array( $registry->get( 'campaign_meta_boxes' ), 'post_messages' ) ); |
| 67 |
|
| 68 |
/** |
| 69 |
* Set the table columns for campaigns. |
| 70 |
* |
| 71 |
* @see Charitable_Campaign_List_Table::dashboard_columns() |
| 72 |
*/ |
| 73 |
add_filter( 'manage_edit-campaign_columns', array( Charitable_Campaign_List_Table::get_instance(), 'dashboard_columns' ), 11 ); |
| 74 |
|
| 75 |
/** |
| 76 |
* Set the content of each column item. |
| 77 |
* |
| 78 |
* @see Charitable_Campaign_List_Table::dashboard_column_item() |
| 79 |
*/ |
| 80 |
add_filter( 'manage_campaign_posts_custom_column', array( Charitable_Campaign_List_Table::get_instance(), 'dashboard_column_item' ), 11, 2 ); |
| 81 |
|
| 82 |
/** |
| 83 |
* Set up admin messages & notifications for bulk actions. |
| 84 |
* |
| 85 |
* @see Charitable_Campaign_List_Table::bulk_messages() |
| 86 |
*/ |
| 87 |
add_filter( 'bulk_post_updated_messages', array( Charitable_Campaign_List_Table::get_instance(), 'bulk_messages' ), 10, 2 ); |
| 88 |
|
| 89 |
/** |
| 90 |
* Add date-based filters above the campaigns table. |
| 91 |
* |
| 92 |
* @see Charitable_Campaign_List_Table::add_filters() |
| 93 |
*/ |
| 94 |
add_action( 'restrict_manage_posts', array( Charitable_Campaign_List_Table::get_instance(), 'add_filters' ), 99 ); |
| 95 |
|
| 96 |
/** |
| 97 |
* Add the export button above the campaigns table. |
| 98 |
* |
| 99 |
* @see Charitable_Campaign_List_Table::add_export() |
| 100 |
*/ |
| 101 |
add_action( 'manage_posts_extra_tablenav', array( Charitable_Campaign_List_Table::get_instance(), 'add_export' ) ); |
| 102 |
|
| 103 |
/** |
| 104 |
* Insert modal forms in the footer. |
| 105 |
* |
| 106 |
* @see Charitable_Campaign_List_Table::modal_forms() |
| 107 |
*/ |
| 108 |
add_action( 'admin_footer', array( Charitable_Campaign_List_Table::get_instance(), 'modal_forms' ) ); |
| 109 |
|
| 110 |
/** |
| 111 |
* Load scripts to include on the campaigns table. |
| 112 |
* |
| 113 |
* @see Charitable_Campaign_List_Table::load_scripts() |
| 114 |
*/ |
| 115 |
add_action( 'admin_enqueue_scripts', array( Charitable_Campaign_List_Table::get_instance(), 'load_scripts' ), 11 ); |
| 116 |
|
| 117 |
/** |
| 118 |
* Add custom filters to the query that returns the campaigns to be displayed. |
| 119 |
* |
| 120 |
* @see Charitable_Campaign_List_Table::filter_request_query() |
| 121 |
*/ |
| 122 |
add_filter( 'request', array( Charitable_Campaign_List_Table::get_instance(), 'filter_request_query' ) ); |