function rt_wp_nginx_helper_install() { global $wp_roles, $rt_wp_nginx_helper; if (!current_user_can('activate_plugins')) { return; } $role = get_role('administrator'); if (empty($role)) { update_site_option("rt_wp_nginx_helper_init_check", __('Sorry, you need to be an administrator to use Nginx Helper', "rt_wp_nginx_helper")); return; } $role->add_cap('Nginx Helper | Config'); $role->add_cap('Nginx Helper | Purge cache'); $rt_wp_nginx_helper_get_options = get_site_option('rt_wp_nginx_helper_global_options'); if (empty($rt_wp_nginx_helper_get_options)) { $rt_wp_nginx_helper_get_options = rt_wp_nginx_helper_get_options(); update_site_option("rt_wp_nginx_helper_global_options", $rt_wp_nginx_helper_get_options); } if (is_multisite()) { $blogs = get_blogs_of_user(true); foreach ($blogs as $b) { $rt_wp_nginx_helper_options = get_blog_option($b->userblog_id, 'rt_wp_nginx_helper_options'); if (empty($rt_wp_nginx_helper_options)) { $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options(); update_blog_option($b->userblog_id, "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options); } } } else { $rt_wp_nginx_helper_options = get_option('rt_wp_nginx_helper_options'); if (empty($rt_wp_nginx_helper_options)) { $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options(); update_option("rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options); } } wp_schedule_event(time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily'); }
function update_new_blog_options($blog_id) { global $rt_wp_nginx_purger; include_once RT_WP_NGINX_HELPER_PATH . 'admin/install.php'; $rt_wp_nginx_purger->log("New site added (id {$blog_id})"); $this->update_map(); $rt_wp_nginx_purger->log("New site added to nginx map (id {$blog_id})"); $helper_options = rt_wp_nginx_helper_get_options(); update_blog_option($blog_id, "rt_wp_nginx_helper_options", $helper_options); $rt_wp_nginx_purger->log("Default options updated for the new blog (id {$blog_id})"); }