class-wpel-activation.php
3 years ago
class-wpel-deactivate.php
3 years ago
class-wpel-uninstall.php
3 years ago
class-wpel-activation.php
71 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class WPEL_Activation |
| 4 | * |
| 5 | * @package WPEL |
| 6 | * @category WordPress Plugin |
| 7 | * @version 2.3 |
| 8 | * @link https://www.webfactoryltd.com/ |
| 9 | * @license Dual licensed under the MIT and GPLv2+ licenses |
| 10 | */ |
| 11 | final class WPEL_Activation extends FWP_Register_Hook_Base_1x0x0 |
| 12 | { |
| 13 | |
| 14 | /** |
| 15 | * @var string |
| 16 | */ |
| 17 | protected $hook_type = 'activation'; |
| 18 | |
| 19 | /** |
| 20 | * Activate network |
| 21 | * @return void |
| 22 | */ |
| 23 | protected function network_procedure() |
| 24 | { |
| 25 | $network_already_set = get_site_option( 'wpel-network-settings' ); |
| 26 | |
| 27 | if ( $network_already_set ) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | // network default settings |
| 32 | $network_values = WPEL_Network_Fields::get_instance()->get_default_values(); |
| 33 | $network_admin_values = WPEL_Network_Admin_Fields::get_instance()->get_default_values(); |
| 34 | |
| 35 | update_site_option( 'wpel-network-settings', $network_values ); |
| 36 | update_site_option( 'wpel-network-admin-settings', $network_admin_values ); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Activate site |
| 41 | * @return void |
| 42 | */ |
| 43 | protected function site_procedure() |
| 44 | { |
| 45 | $site_already_set = get_option( 'wpel-external-link-settings' ); |
| 46 | |
| 47 | if ( $site_already_set ) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | // get default values |
| 52 | $external_link_values = WPEL_External_Link_Fields::get_instance()->get_default_values(); |
| 53 | $internal_link_values = WPEL_Internal_Link_Fields::get_instance()->get_default_values(); |
| 54 | $excluded_link_values = WPEL_Excluded_Link_Fields::get_instance()->get_default_values(); |
| 55 | $exceptions_link_values = WPEL_Exceptions_Fields::get_instance()->get_default_values(); |
| 56 | $admin_link_values = WPEL_Admin_Fields::get_instance()->get_default_values(); |
| 57 | |
| 58 | // update new values |
| 59 | update_option( 'wpel-external-link-settings', $external_link_values ); |
| 60 | update_option( 'wpel-internal-link-settings', $internal_link_values ); |
| 61 | update_option( 'wpel-excluded-link-settings', $excluded_link_values ); |
| 62 | update_option( 'wpel-exceptions-settings', $exceptions_link_values ); |
| 63 | update_option( 'wpel-admin-settings', $admin_link_values ); |
| 64 | |
| 65 | // update meta data |
| 66 | $plugin_data = get_plugin_data( WPEL_Plugin::get_plugin_file() ); |
| 67 | update_option( 'wpel-version', $plugin_data[ 'Version' ] ); |
| 68 | } |
| 69 | |
| 70 | } |
| 71 |