Files
1984-hosting-support/1984-hosting-support.php

110 lines
2.8 KiB
PHP

<?php
/*
* Plugin Name: 1984 Hosting Support
* Version: 1.0
* Author: 1984 ehf
* Author URI: https://1984.hosting
* Description: Support plugin for 1984 Hosting customers.
*/
/**
* The main HostingSupport1984 class
*
* @package HostingSupport1984
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html GNU General Public License v2.0
*
* This is where basic constants such as the version number are pulled from.
* There are other classes that may depend on this file, so only remove it if
* you do not intend to use the plugin.
*/
class HostingSupport1984 {
const HOSTING_SUPPORT_VERSION = '0.4.0';
/**
* Construct a new HostingSupport1984 object
*/
public function __construct() {
// Loading the text domain for a mu-plugin is tricky.
// We need to use admin_init instead of plugins_loaded as we are only
// using the plugin in the admin interface.
add_action(
'admin_init',
array( $this, 'load_textdomain' )
);
// Register the activation hook.
register_activation_hook(
__FILE__,
array( $this, 'activation_hook' )
);
// Run on activation of any plugin.
add_action(
'activated_plugin',
array( $this, 'plugin_activation_hook' )
);
// Run on activation of theme.
add_action(
'switch_theme',
array( $this, 'theme_switch_hook' )
);
}
/**
* Load the 'hosting_support_1984' text domain
*
* @return Boolean
*/
public function load_textdomain() {
return load_plugin_textdomain(
'hostingsupport1984',
false,
'1984-hosting-support/languages'
);
}
/**
* On activation of this plugin, set auto-update option for core,
* plus enable auto-updates for installed plugins and themes.
*/
public function activation_hook() {
// Auto-update WordPress core.
update_site_option( 'auto_update_core_major', 'enabled' );
// Auto-update plugins.
$all_plugins = apply_filters( 'all_plugins', get_plugins() );
update_site_option( 'auto_update_plugins', array_keys( $all_plugins ) );
// Auto-update themes.
$all_themes = wp_get_themes();
update_site_option( 'auto_update_themes', array_keys( $all_themes ) );
}
/**
* On plugin activation, add to auto-updated list of plugins.
*/
public function plugin_activation_hook( $plugin ) {
$auto_updated_plugins = (array) get_site_option( 'auto_update_plugins', array() );
$auto_updated_plugins[] = $plugin;
update_site_option( 'auto_update_plugins', array_unique( $auto_updated_plugins ) );
}
/**
* On theme switch, enable auto-update for all themes.
*/
public function theme_switch_hook( $theme ) {
$all_themes = wp_get_themes();
update_site_option( 'auto_update_themes', array_keys( $all_themes ) );
}
}
$hosting_support_1984 = new HostingSupport1984();
define( 'A1984_HOSTING_SUPPORT_BASE_FILE', __FILE__ );
require_once __DIR__ . '/1984-hosting-support-ui.php';