ceu_config_setup_after
Fires after the core configuration options have been set up.
add_action( 'ceu_config_setup_after', $callback, 10, 1 );
Description
Fires after plugin constants are defined but before admin initialization. Developers can use this hook to perform custom setup actions or modify plugin configuration before the core administration features are loaded, ensuring access to defined constants.
Usage
add_action( 'ceu_config_setup_after', 'your_function_name', 10, 1 );
Examples
add_action( 'ceu_config_setup_after', 'my_ceu_handle_config_setup_complete', 10, 0 );
/**
* Example function to demonstrate handling the 'ceu_config_setup_after' action hook.
* This function would typically be used to perform additional setup or actions
* after the core plugin configuration has been completed.
*
* For instance, it could be used to initialize custom post types,
* register shortcodes, or perform other plugin-specific setup tasks
* that depend on the plugin's core configuration being in place.
*/
function my_ceu_handle_config_setup_complete() {
// Check if we are in the WordPress admin area before attempting admin-specific actions.
if ( is_admin() ) {
// Example: Enqueue a custom admin script after the plugin configuration is done.
// Replace 'my-custom-admin-script' with the actual script handle.
// Replace 'path/to/your/admin-script.js' with the actual path to your script.
wp_enqueue_script(
'my-custom-admin-script',
plugin_dir_url( __FILE__ ) . 'assets/js/my-admin-script.js',
array( 'jquery' ), // Dependencies
'1.0.0', // Version
true // Load in footer
);
// Example: Add a custom admin notice if a certain option is set.
$my_option = get_option( 'my_ceu_custom_setting' );
if ( $my_option === 'enabled' ) {
add_action( 'admin_notices', 'my_ceu_display_custom_admin_notice' );
}
}
// Example: Register a custom post type if it hasn't been registered yet.
// This is a simplified example; a real implementation would likely have more robust checks.
if ( ! post_type_exists( 'my_custom_cpt' ) ) {
register_post_type( 'my_custom_cpt', array(
'labels' => array(
'name' => __( 'Custom Items', 'my-text-domain' ),
'singular_name' => __( 'Custom Item', 'my-text-domain' ),
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
) );
}
}
/**
* Example function to display a custom admin notice.
*/
function my_ceu_display_custom_admin_notice() {
?>
<div class="notice notice-success is-dismissible">
<p><?php esc_html_e( 'Your custom CEU plugin setup is complete and the special setting is active!', 'my-text-domain' ); ?></p>
</div>
<?php
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/config.php:79
public function configure_plugin_before_boot( $plugin_name, $prefix, $version, $file, $debug ) {
$this->define_constants( $plugin_name, $prefix, $version, $file, $debug );
do_action( 'ceu_define_constants_after' );
register_activation_hook( Utilities::get_plugin_file(), array(
$this,
'activation',
) );
register_deactivation_hook( Utilities::get_plugin_file(), array(
$this,
'deactivation',
) );
add_action( 'admin_init', array(
$this,
'uncanny_ceu_plugin_redirect',
) );
do_action( 'ceu_config_setup_after' );
}