wpseo_activate

Run single site / network-wide activation of the plugin.

Description

wpseo_activate( (bool) $networkwide = false ); 

Parameters (1)

0. $networkwide — Optional. (bool) => false
Whether the plugin is being activated network-wide.

Usage

  1. if ( !function_exists( 'wpseo_activate' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/wp-seo-main.php'; 
  3.  
  4. // Whether the plugin is being activated network-wide. 
  5. $networkwide = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpseo_activate($networkwide); 
  9.  

Defined (2)

The function is defined in the following location(s).

/wp-seo-main.php  
  1. function wpseo_activate( $networkwide = false ) { 
  2. if ( ! is_multisite() || ! $networkwide ) { 
  3. _wpseo_activate(); 
  4. else { 
  5. /** Multi-site network activation - activate the plugin for all blogs */ 
  1. function _wpseo_activate() { 
  2. require_once( WPSEO_PATH . 'inc/wpseo-functions.php' ); 
  3. require_once( WPSEO_PATH . 'inc/class-wpseo-installation.php' ); 
  4.  
  5. wpseo_load_textdomain(); // Make sure we have ourtranslationsavailable for the defaults. 
  6.  
  7.  
  8. WPSEO_Options::get_instance(); 
  9. if ( ! is_multisite() ) { 
  10. WPSEO_Options::initialize(); 
  11. else { 
  12. WPSEO_Options::maybe_set_multisite_defaults( true ); 
  13. WPSEO_Options::ensure_options_exist(); 
  14.  
  15. if ( is_multisite() && ms_is_switched() ) { 
  16. delete_option( 'rewrite_rules' ); 
  17. else { 
  18. $wpseo_rewrite = new WPSEO_Rewrite(); 
  19. $wpseo_rewrite->schedule_flush(); 
  20.  
  21.  
  22. // Clear cache so the changes are obvious. 
  23. WPSEO_Utils::clear_cache(); 
  24.  
  25. do_action( 'wpseo_activate' );