catch_errors() public static méthode

Catches PHP errors. Must be used in conjunction with output buffering.
public static catch_errors ( boolean $catch )
$catch boolean True to start catching, False to stop.
 public static function activate_module($module, $exit = true, $redirect = true)
 {
     do_action('jetpack_pre_activate_module', $module, $exit);
     $jetpack = Jetpack::init();
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     $module_data = Jetpack::get_module($module);
     if (!Jetpack::is_active()) {
         if (!Jetpack::is_development_mode()) {
             return false;
         }
         // If we're not connected but in development mode, make sure the module doesn't require a connection
         if (Jetpack::is_development_mode() && $module_data['requires_connection']) {
             return false;
         }
     }
     // Check and see if the old plugin is active
     if (isset($jetpack->plugins_to_deactivate[$module])) {
         // Deactivate the old plugin
         if (Jetpack_Client_Server::deactivate_plugin($jetpack->plugins_to_deactivate[$module][0], $jetpack->plugins_to_deactivate[$module][1])) {
             // If we deactivated the old plugin, remembere that with ::state() and redirect back to this page to activate the module
             // We can't activate the module on this page load since the newly deactivated old plugin is still loaded on this page load.
             Jetpack::state('deactivated_plugins', $module);
             wp_safe_redirect(add_query_arg('jetpack_restate', 1));
             exit;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     do_action('jetpack_activate_module', $module);
     $active[] = $module;
     Jetpack_Options::update_option('active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     if ($redirect) {
         wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
     }
     if ($exit) {
         exit;
     }
 }
 function activate_module($module)
 {
     $jetpack = Jetpack::init();
     if (!Jetpack::is_active()) {
         return false;
     }
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     // Check and see if the old plugin is active
     if (isset($jetpack->plugins_to_deactivate[$module])) {
         // Deactivate the old plugin
         if (Jetpack_Client_Server::deactivate_plugin($jetpack->plugins_to_deactivate[$module][0], $jetpack->plugins_to_deactivate[$module][1])) {
             // If we deactivated the old plugin, remembere that with ::state() and redirect back to this page to activate the module
             // We can't activate the module on this page load since the newly deactivated old plugin is still loaded on this page load.
             Jetpack::state('deactivated_plugins', $module);
             wp_safe_redirect(add_query_arg('jetpack_restate', 1));
             exit;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     wp_safe_redirect(Jetpack::admin_url());
     if ('sharedaddy' == $module && version_compare(PHP_VERSION, '5', '<')) {
         exit;
     }
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     do_action("jetpack_activate_module_{$module}");
     $active[] = $module;
     Jetpack::update_option('active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     exit;
 }
 public static function activate_module($module, $exit = true, $redirect = true)
 {
     /**
      * Fires before a module is activated.
      *
      * @since 2.6.0
      *
      * @param string $module Module slug.
      * @param bool $exit Should we exit after the module has been activated. Default to true.
      * @param bool $redirect Should the user be redirected after module activation? Default to true.
      */
     do_action('jetpack_pre_activate_module', $module, $exit, $redirect);
     $jetpack = Jetpack::init();
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     $module_data = Jetpack::get_module($module);
     if (!Jetpack::is_active()) {
         if (!Jetpack::is_development_mode()) {
             return false;
         }
         // If we're not connected but in development mode, make sure the module doesn't require a connection
         if (Jetpack::is_development_mode() && $module_data['requires_connection']) {
             return false;
         }
     }
     // Check and see if the old plugin is active
     if (isset($jetpack->plugins_to_deactivate[$module])) {
         // Deactivate the old plugin
         if (Jetpack_Client_Server::deactivate_plugin($jetpack->plugins_to_deactivate[$module][0], $jetpack->plugins_to_deactivate[$module][1])) {
             // If we deactivated the old plugin, remembere that with ::state() and redirect back to this page to activate the module
             // We can't activate the module on this page load since the newly deactivated old plugin is still loaded on this page load.
             Jetpack::state('deactivated_plugins', $module);
             wp_safe_redirect(add_query_arg('jetpack_restate', 1));
             exit;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     /** This action is documented in class.jetpack.php */
     do_action('jetpack_activate_module', $module);
     $active[] = $module;
     Jetpack_Options::update_option('active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     // A flag for Jump Start so it's not shown again. Only set if it hasn't been yet.
     if ('new_connection' === Jetpack_Options::get_option('jumpstart')) {
         Jetpack_Options::update_option('jumpstart', 'jetpack_action_taken');
         //Jump start is being dismissed send data to MC Stats
         $jetpack->stat('jumpstart', 'manual,' . $module);
         $jetpack->do_stats('server_side');
     }
     if ($redirect) {
         wp_safe_redirect(Jetpack::admin_url('page=jetpack'));
     }
     if ($exit) {
         exit;
     }
     return true;
 }
 function activate_module($module)
 {
     if (!Jetpack::is_active()) {
         return false;
     }
     if (!strlen($module)) {
         return false;
     }
     if (!Jetpack::is_module($module)) {
         return false;
     }
     // If it's already active, then don't do it again
     $active = Jetpack::get_active_modules();
     foreach ($active as $act) {
         if ($act == $module) {
             return true;
         }
     }
     // Check the file for fatal errors, a la wp-admin/plugins.php::activate
     Jetpack::state('module', $module);
     Jetpack::state('error', 'module_activation_failed');
     // we'll override this later if the plugin can be included without fatal error
     wp_redirect(Jetpack::admin_url());
     if ('sharedaddy' == $module && version_compare(PHP_VERSION, '5', '<')) {
         exit;
     }
     Jetpack::catch_errors(true);
     ob_start();
     require Jetpack::get_module_path($module);
     $active[] = $module;
     update_option('jetpack_active_modules', array_unique($active));
     Jetpack::state('error', false);
     // the override
     Jetpack::state('message', 'module_activated');
     Jetpack::state('module', $module);
     ob_end_clean();
     Jetpack::catch_errors(false);
     exit;
 }