| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 2 |
|
| 3 |
/** |
| 4 |
* Activate the plugin |
| 5 |
* |
| 6 |
* @copyright Copyright (C) 2018, Echo Plugins |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Activate this plugin i.e. setup tables, data etc. |
| 11 |
* NOT invoked on plugin updates |
| 12 |
* |
| 13 |
* @param bool $network_wide - If the plugin is being network-activated |
| 14 |
*/ |
| 15 |
function epda_activate_plugin( $network_wide=false ) { |
| 16 |
global $wpdb; |
| 17 |
|
| 18 |
if ( is_multisite() && $network_wide ) { |
| 19 |
foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
| 20 |
switch_to_blog( $blog_id ); |
| 21 |
epda_activate_plugin_do(); |
| 22 |
restore_current_blog(); |
| 23 |
} |
| 24 |
} else { |
| 25 |
epda_activate_plugin_do(); |
| 26 |
} |
| 27 |
} |
| 28 |
register_activation_hook( EPDA_Scroll_Down_Arrow::$plugin_file, 'epda_activate_plugin' ); |
| 29 |
|
| 30 |
function epda_activate_plugin_do() { |
| 31 |
|
| 32 |
// true if the plugin was activated for the first time since installation |
| 33 |
$plugin_version = get_option( 'epda_version' ); |
| 34 |
if ( empty( $plugin_version ) ) { |
| 35 |
|
| 36 |
// prepare Down Arrow config |
| 37 |
$config = epda_get_instance()->da_config_obj->get_config(); |
| 38 |
epda_get_instance()->da_config_obj->update_configuration( $config ); |
| 39 |
|
| 40 |
EPDA_Utilities::save_wp_option( 'epda_version', EPDA_Scroll_Down_Arrow::$version ); |
| 41 |
} |
| 42 |
|
| 43 |
// check config |
| 44 |
$result = epda_get_instance()->da_config_obj->get_config( true ); |
| 45 |
if ( is_wp_error( $result ) ) { |
| 46 |
// prepare Down Arrow config |
| 47 |
$config = epda_get_instance()->da_config_obj->get_config(); |
| 48 |
epda_get_instance()->da_config_obj->update_configuration( $config ); |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
set_transient( '_epda_plugin_activated', true, 3600 ); |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* User deactivates this plugin so refresh the permalinks |
| 58 |
*/ |
| 59 |
function epda_deactivation() { |
| 60 |
} |
| 61 |
register_deactivation_hook( EPDA_Scroll_Down_Arrow::$plugin_file, 'epda_deactivation' ); |
| 62 |
|