id ) {
return;
}
?>
Permalink Settings and enable an option other than Plain.', 'glotpress' );
$long_notice = sprintf( $long_notice, admin_url( 'options-permalink.php' ) );
gp_display_disabled_admin_notice( $short_notice, $long_notice );
}
/*
* Check the permalink structure, if we don't have one (aka the rewrite engine is disabled)
* return without running any more code as the user will not be able to access GlotPress
* any errors and show an admin notice.
*/
if ( ! get_option( 'permalink_structure' ) ) {
add_action( 'admin_notices', 'gp_unsupported_permalink_structure_admin_notice', 10, 2 );
// Bail out now so no additional code is run.
return;
}
require_once GP_PATH . 'gp-settings.php';
/**
* Perform necessary actions on activation.
*
* @since 1.0.0
*/
function gp_activate_plugin() {
$admins = GP::$permission->find_one( array( 'action' => 'admin' ) );
if ( ! $admins ) {
GP::$permission->create(
array(
'user_id' => get_current_user_id(),
'action' => 'admin',
)
);
}
}
register_activation_hook( GP_PLUGIN_FILE, 'gp_activate_plugin' );
/**
* Run the plugin de-activation code.
*
* @since 1.0.0
*
* @param bool $network_wide Whether the plugin is deactivated for all sites in the network
* or just the current site.
*/
function gp_deactivate_plugin( $network_wide ) {
/*
* Flush the rewrite rule option so it will be re-generated next time the plugin is activated.
* If network deactivating, ensure we flush the option on every site.
*/
if ( $network_wide ) {
$sites = get_sites();
foreach ( $sites as $site ) {
switch_to_blog( $site->blog_id );
update_option( 'gp_rewrite_rule', '' );
restore_current_blog();
}
} else {
update_option( 'gp_rewrite_rule', '' );
}
}
register_deactivation_hook( GP_PLUGIN_FILE, 'gp_deactivate_plugin' );