Agency Toolkit Activated
Agency Toolkit plugin has been activated. You may visit your options page here.
'Version' ), false );
$plugin_version = $plugin_data['Version'];
define( 'INSPRY_TOOLKIT_CURRENT_VERSION', $plugin_version );
/**
* Turn the backend users summary on by default, once.
*
* It shipped off by default in 1.0.35, and the settings form stores an empty
* value for every unticked box, so a stored "off" almost always means only
* that the form was saved. (The exception, a site that switched it on and off
* again before 1.0.36, is accepted.) The first load of 1.0.36 (or of a new
* install) therefore switches it on and records that it did. From then on the
* checkbox is the only authority: a site that unticks it stays off, through
* this and every later update.
*
* To keep a site off before it updates, store an explicit 0 first
* (wp option update inspry_toolkit_users_summary 0) and do not save the
* toolkit settings form until 1.0.36 is installed: the form stores an empty
* value for an unticked box, never 0, so saving it would replace the 0.
*
* @return void
*/
function inspry_toolkit_apply_users_summary_default() {
// No options table yet while WordPress itself is being installed.
if ( function_exists( 'wp_installing' ) && wp_installing() ) {
return;
}
if ( get_option( 'inspry_toolkit_users_summary_default_applied' ) ) {
return;
}
$current = get_option( 'inspry_toolkit_users_summary' );
$declined = ( 0 === $current || '0' === $current );
if ( ! $declined && 1 != $current ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual -- stored as "1" or 1.
update_option( 'inspry_toolkit_users_summary', 1 );
}
update_option( 'inspry_toolkit_users_summary_default_applied', 1 );
}
// Before the loop below, so the summary loads on this same request.
inspry_toolkit_apply_users_summary_default();
$toolkit_all_options = array_merge(
$toolkit_options,
$toolkit_security_options,
$toolkit_performance_options,
$toolkit_email_notification_options
);
// Loop through options and enable what is enabled
foreach ( $toolkit_all_options as $option ) {
// Check if the option is enabled
if ( get_option( 'inspry_toolkit_' . $option['name'] ) == 1 ) {
// Exclude limit admins file since there is none
if ( $option['name'] != 'limit_admins' ) {
// Include the file that option is located in. Filenames follow the
// WordPress standard of hyphens as word separators; files not yet
// renamed still use the option name verbatim, so fall back to that.
$option_file = plugin_dir_path( __FILE__ ) . 'functions/' .
str_replace( '_', '-', $option['name'] ) . '.php';
if ( ! file_exists( $option_file ) ) {
$option_file = plugin_dir_path( __FILE__ ) . 'functions/' .
$option['name'] . '.php';
}
include $option_file;
}
// Set Default Host In Manage Environment Indicator
if ( $option['name'] == 'manage_environment_indicator' ) {
$dei_host_name = get_option( 'inspry_toolkit_development_environment_host_name' );
if ( $dei_host_name ) {
$default_host = $dei_host_name;
}
// DISPLAY ENVIRONMENT ON ADMIN BAR ITEMS
add_action( 'admin_bar_menu', 'inspry_toolkit_display_production_environment_on_admin_bar', 9999 );
if ( ! function_exists( 'inspry_toolkit_display_production_environment_on_admin_bar' ) ) {
function inspry_toolkit_display_production_environment_on_admin_bar( WP_Admin_Bar $admin_bar ) {
$agency_toolkit_access = get_option( 'inspry_toolkit_development_environment_user_list' );
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
if ( in_array( get_current_user_id(), $agency_toolkit_access ) ) {
$admin_bar->add_menu(
array(
'id' => 'production-environment-indicator',
'parent' => null,
'group' => null,
'title' => 'Production', // you can use img tag with image link. it will show the image icon Instead of the title.
'href' => admin_url(
'admin.php?page=inspry-agency-toolkit'
),
'meta' => array(
'title' => __( 'Production', 'agency-toolkit' ), // This title will show on hover
),
)
);
}
}
}
// Environment Indicator CSS ( Backend/Frontend )
add_action( 'admin_head', 'inspry_toolkit_environment_indicator_custom_css' );
add_action( 'wp_head', 'inspry_toolkit_environment_indicator_custom_css' );
if ( ! function_exists( 'inspry_toolkit_environment_indicator_custom_css' ) ) {
function inspry_toolkit_environment_indicator_custom_css() {
?>