| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable Settings Hooks. |
| 4 |
* |
| 5 |
* Action/filter hooks used for Charitable Settings API. |
| 6 |
* |
| 7 |
* @package Charitable/Functions/Admin |
| 8 |
* @author David Bisset |
| 9 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 10 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 11 |
* @since 1.8.1.6 |
| 12 |
*/ |
| 13 |
|
| 14 |
// Exit if accessed directly. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Register Charitable tools. |
| 21 |
* |
| 22 |
* @see Charitable_Tools::register_settings() |
| 23 |
*/ |
| 24 |
add_action( 'admin_init', array( Charitable_Tools::get_instance(), 'register_settings' ) ); |
| 25 |
|
| 26 |
/** |
| 27 |
* Add settings to the Tools tab. |
| 28 |
* |
| 29 |
* @since 1.8.1.6 and 1.8.2 |
| 30 |
* |
| 31 |
* @see Charitable_Tools_Settings::add_import_fields() |
| 32 |
*/ |
| 33 |
add_filter( 'charitable_tools_tab_fields_export', array( Charitable_Tools_Settings::get_instance(), 'add_tools_export_fields' ), 5 ); |
| 34 |
add_filter( 'charitable_tools_tab_fields_snippets', array( Charitable_Tools_Settings::get_instance(), 'add_tools_snippets_fields' ), 5 ); |
| 35 |
add_filter( 'charitable_tools_tab_fields_customize', array( Charitable_Tools_Settings::get_instance(), 'add_tools_customize_fields' ), 5 ); |
| 36 |
|
| 37 |
/** |
| 38 |
* Import sub-tab fields. |
| 39 |
* |
| 40 |
* @since 1.8.10 |
| 41 |
*/ |
| 42 |
add_filter( 'charitable_tools_tab_fields_sub_import__charitable', array( Charitable_Tools_Settings::get_instance(), 'add_tools_import_charitable_fields' ), 5 ); |
| 43 |
add_filter( 'charitable_tools_tab_fields_sub_import__givewp', array( Charitable_Tools_Settings::get_instance(), 'add_tools_import_givewp_fields' ), 5 ); |
| 44 |
add_filter( 'charitable_tools_tab_fields_sub_import__givebutter', array( Charitable_Tools_Settings::get_instance(), 'add_tools_import_givebutter_fields' ), 5 ); |
| 45 |
|
| 46 |
/** |
| 47 |
* Add settings to the Misc tab. |
| 48 |
* |
| 49 |
* @since 1.8.9 |
| 50 |
* |
| 51 |
* @see Charitable_Tools_Misc::add_misc_fields() |
| 52 |
*/ |
| 53 |
add_filter( 'charitable_tools_tab_fields_misc', array( Charitable_Tools_Misc::get_instance(), 'add_misc_fields' ), 5 ); |
| 54 |
|
| 55 |
/** |
| 56 |
* Handle bulk removal of donations. |
| 57 |
* |
| 58 |
* @since 1.8.9 |
| 59 |
* |
| 60 |
* @see Charitable_Tools_Misc::bulk_remove_donations() |
| 61 |
*/ |
| 62 |
add_filter( 'charitable_save_tools', array( Charitable_Tools_Misc::get_instance(), 'bulk_remove_donations' ), 10, 3 ); |
| 63 |
|
| 64 |
/** |
| 65 |
* Look for export/import attempts. |
| 66 |
* |
| 67 |
* @see Charitable_Export_Settings::add_export_fields() |
| 68 |
*/ |
| 69 |
add_action( 'admin_init', array( Charitable_Export_Items::get_instance(), 'admin_accept_export_campaign_request' ) ); |
| 70 |
add_action( 'admin_init', array( Charitable_Export_Items::get_instance(), 'admin_accept_export_donations_request' ) ); |
| 71 |
add_action( 'admin_init', array( Charitable_Import_Items::get_instance(), 'admin_accept_import_campaign_request' ) ); |
| 72 |
add_action( 'admin_init', array( Charitable_Import_Items::get_instance(), 'admin_accept_import_donations_request' ) ); |
| 73 |
|
| 74 |
/** |
| 75 |
* Import sub-tab default redirect. |
| 76 |
* |
| 77 |
* @since 1.8.10 |
| 78 |
*/ |
| 79 |
add_action( 'admin_init', array( Charitable_Tools::get_instance(), 'tools_sub_tab_default' ), 5 ); |
| 80 |
|
| 81 |
/** |
| 82 |
* GiveWP and GiveButter CSV import handlers. |
| 83 |
* |
| 84 |
* @since 1.8.10 |
| 85 |
*/ |
| 86 |
add_action( 'admin_init', array( Charitable_Import_Items::get_instance(), 'admin_accept_import_donations_givewp_request' ) ); |
| 87 |
add_action( 'admin_init', array( Charitable_Import_Items::get_instance(), 'admin_accept_import_donations_givebutter_request' ) ); |
| 88 |
|
| 89 |
/** |
| 90 |
* GiveWP migration tool AJAX handlers. |
| 91 |
* |
| 92 |
* @since 1.8.10 |
| 93 |
*/ |
| 94 |
add_action( 'wp_ajax_charitable_givewp_import_start', array( Charitable_GiveWP_Importer::get_instance(), 'ajax_import_start' ) ); |
| 95 |
add_action( 'wp_ajax_charitable_givewp_import_batch', array( Charitable_GiveWP_Importer::get_instance(), 'ajax_import_batch' ) ); |
| 96 |
|
| 97 |
|
| 98 |
/** |
| 99 |
* Add the tools tab settings fields. |
| 100 |
* |
| 101 |
* @since 1.8.1.6 |
| 102 |
* |
| 103 |
* @return array<string,array> |
| 104 |
*/ |
| 105 |
add_action( 'admin_enqueue_scripts', array( Charitable_Intergrations_WPCode::get_instance(), 'enqueue_scripts' ) ); |
| 106 |
add_action( 'admin_enqueue_scripts', array( Charitable_Tools_System_Info::get_instance(), 'enqueue_scripts' ) ); |
| 107 |
|
| 108 |
/** |
| 109 |
* Register AJAX action for email diagnostics. |
| 110 |
* |
| 111 |
* @since 1.8.9.2 |
| 112 |
*/ |
| 113 |
add_action( 'wp_ajax_charitable_email_diagnostics', array( Charitable_Tools_System_Info::get_instance(), 'ajax_email_diagnostics' ) ); |
| 114 |
|
| 115 |
/** |
| 116 |
* Register AJAX action for test email. |
| 117 |
* |
| 118 |
* @since 1.8.9.2 |
| 119 |
*/ |
| 120 |
add_action( 'wp_ajax_charitable_send_test_email', array( Charitable_Tools_System_Info::get_instance(), 'ajax_send_test_email' ) ); |
| 121 |
|
| 122 |
/** |
| 123 |
* Clear error logs via AJAX. |
| 124 |
* |
| 125 |
* @since 1.8.9.2 |
| 126 |
* |
| 127 |
* @see Charitable_Tools_System_Info::ajax_clear_error_logs() |
| 128 |
*/ |
| 129 |
add_action( 'wp_ajax_charitable_clear_error_logs', array( Charitable_Tools_System_Info::get_instance(), 'ajax_clear_error_logs' ) ); |
| 130 |
|
| 131 |
/** |
| 132 |
* Export error logs via AJAX. |
| 133 |
* |
| 134 |
* @since 1.8.9.2 |
| 135 |
* |
| 136 |
* @see Charitable_Tools_System_Info::ajax_export_error_logs() |
| 137 |
*/ |
| 138 |
add_action( 'wp_ajax_charitable_export_error_logs', array( Charitable_Tools_System_Info::get_instance(), 'ajax_export_error_logs' ) ); |
| 139 |
|
| 140 |
/** |
| 141 |
* Register AJAX action for debug log scanner. |
| 142 |
* |
| 143 |
* @since 1.8.9.2 |
| 144 |
* |
| 145 |
* @see Charitable_Tools_System_Info::ajax_debug_log_scan() |
| 146 |
*/ |
| 147 |
add_action( 'wp_ajax_charitable_debug_log_scan', array( Charitable_Tools_System_Info::get_instance(), 'ajax_debug_log_scan' ) ); |
| 148 |
|
| 149 |
/** |
| 150 |
* Capture failed plugin installs/updates into a small ring buffer so the |
| 151 |
* "Recent Plugin Install/Update Errors" section of System Info has data |
| 152 |
* to show. Pure pass-through on success. |
| 153 |
* |
| 154 |
* @since 1.8.10.5 |
| 155 |
*/ |
| 156 |
add_filter( 'upgrader_install_package_result', array( 'Charitable_Tools_System_Info', 'log_install_result' ), 10, 2 ); |
| 157 |
|
| 158 |
add_action( 'admin_enqueue_scripts', array( Charitable_Tools_Misc::get_instance(), 'enqueue_scripts' ) ); |
| 159 |
|
| 160 |
/** |
| 161 |
* Enqueue GiveWP migration tool scripts. |
| 162 |
* |
| 163 |
* @since 1.8.10 |
| 164 |
*/ |
| 165 |
add_action( 'admin_enqueue_scripts', array( Charitable_GiveWP_Importer::get_instance(), 'enqueue_scripts' ) ); |
| 166 |
|
| 167 |
/** |
| 168 |
* Logger AJAX handlers and script enqueue. |
| 169 |
* |
| 170 |
* @since 1.8.11 |
| 171 |
*/ |
| 172 |
add_action( 'wp_ajax_charitable_get_log_record', array( 'Charitable_Log', 'ajax_get_record' ) ); |
| 173 |
add_action( 'wp_ajax_charitable_delete_all_logs', array( 'Charitable_Log', 'ajax_delete_all_logs' ) ); |
| 174 |
add_action( 'wp_ajax_charitable_export_logs_csv', array( 'Charitable_Log', 'ajax_export_csv' ) ); |
| 175 |
add_action( 'wp_ajax_charitable_toggle_logging', array( 'Charitable_Log', 'ajax_toggle_logging' ) ); |
| 176 |
add_action( 'wp_ajax_charitable_save_log_retention', array( 'Charitable_Log', 'ajax_save_retention' ) ); |
| 177 |
add_action( 'admin_enqueue_scripts', array( 'Charitable_Log', 'enqueue_scripts' ) ); |
| 178 |
|