ap_activate_addon( string $addon_name )
Description #
Activate an addon and trigger addon activation hook.
Parameters #
- $addon_namestring (Required) Addon file name.
Source #
File: includes/functions.php
function ap_activate_addon( $addon_name ) { if ( ap_is_addon_active( $addon_name ) ) { return false; } global $ap_addons_activation; $opt = get_option( 'anspress_addons', array() ); $all_addons = ap_get_addons(); $addon_name = wp_normalize_path( $addon_name ); if ( isset( $all_addons[ $addon_name ] ) ) { $opt[ $addon_name ] = true; update_option( 'anspress_addons', $opt ); $file = $all_addons[ $addon_name ]['path']; // Check file exists before requiring. if ( ! file_exists( $file ) ) { return false; } require_once $file; if ( isset( $ap_addons_activation[ $addon_name ] ) ) { call_user_func( $ap_addons_activation[ $addon_name ] ); } do_action( 'ap_addon_activated', $addon_name ); // Fix to drop wpengine cache. if ( class_exists( 'WpeCommon' ) ) { WpeCommon::purge_memcached(); WpeCommon::clear_maxcdn_cache(); WpeCommon::purge_varnish_cache(); } // Delete cache. wp_cache_delete( 'addons', 'anspress' ); // Flush rewrite rules. ap_opt( 'ap_flush', 'true' ); return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/functions.php:1751
Add your comment