/** * Activate a module. * * @param string $module Module slug. * @param bool $exit Should exit be called after deactivation. * @param bool $redirect Should there be a redirection after activation. * * @return bool|void */ public function activate( $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 ); if ( ! strlen( $module ) ) { return false; } // If it's already active, then don't do it again. $active = $this->get_active(); foreach ( $active as $act ) { if ( $act === $module ) { return true; } } if ( ! $this->is_module( $module ) ) { return false; } // Jetpack plugin only if ( class_exists( 'Jetpack' ) ) { $module_data = $this->get( $module ); $status = new Status(); $state = new CookieState(); if ( ! \Jetpack::is_connection_ready() ) { if ( ! $status->is_offline_mode() && ! $status->is_onboarding() ) { return false; } // If we're not connected but in offline mode, make sure the module doesn't require a connection. if ( $status->is_offline_mode() && $module_data['requires_connection'] ) { return false; } } if ( class_exists( 'Jetpack_Client_Server' ) ) { $jetpack = \Jetpack::init(); // Check and see if the old plugin is active. if ( isset( $jetpack->plugins_to_deactivate[ $module ] ) ) { // Deactivate the old plugins. $deactivated = array(); foreach ( $jetpack->plugins_to_deactivate[ $module ] as $idx => $deactivate_me ) { if ( \Jetpack_Client_Server::deactivate_plugin( $deactivate_me[0], $deactivate_me[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. $deactivated[] = "$module:$idx"; } } if ( $deactivated ) { $state->state( 'deactivated_plugins', implode( ',', $deactivated ) ); wp_safe_redirect( add_query_arg( 'jetpack_restate', 1 ) ); exit; } } } // Protect won't work with mis-configured IPs. if ( 'protect' === $module ) { if ( ! IP_Utils::get_ip() ) { $state->state( 'message', 'protect_misconfigured_ip' ); return false; } } if ( ! Jetpack_Plan::supports( $module ) ) { return false; } // Check the file for fatal errors, a la wp-admin/plugins.php::activate. $errors = new Errors(); $state->state( 'module', $module ); $state->state( 'error', 'module_activation_failed' ); // we'll override this later if the plugin can be included without fatal error. $errors->catch_errors( true ); ob_start(); $module_path = $this->get_path( $module ); if ( file_exists( $module_path ) ) { require $this->get_path( $module ); // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.NotAbsolutePath } $active[] = $module; $this->update_active( $active ); $state->state( 'error', false ); // the override. ob_end_clean(); $errors->catch_errors( false ); } else { // Not a Jetpack plugin. $active[] = $module; $this->update_active( $active ); } if ( $redirect ) { wp_safe_redirect( ( new Paths() )->admin_url( 'page=jetpack' ) ); } if ( $exit ) { exit; } return true; } /** * Deactivate module. * * @param string $module Module slug. * * @return bool */ public function deactivate( $module ) { /** * Fires when a module is deactivated. * * @since 1.9.0 * * @param string $module Module slug. */ do_action( 'jetpack_pre_deactivate_module', $module ); $active = $this->get_active(); $new = array_filter( array_diff( $active, (array) $module ) ); return $this->update_active( $new ); } /** * Generate a module's path from its slug. * * @param string $slug Module slug. */ public function get_path( $slug ) { if ( ! Constants::is_defined( 'JETPACK__PLUGIN_DIR' ) ) { return ''; } /** * Filters the path of a modules. * * @since 7.4.0 * * @param array $return The absolute path to a module's root php file * @param string $slug The module slug */ return apply_filters( 'jetpack_get_module_path', JETPACK__PLUGIN_DIR . "modules/$slug.php", $slug ); } /** * Saves all the currently active modules to options. * Also fires Action hooks for each newly activated and deactivated module. * * @param array $modules Array of active modules to be saved in options. * * @return $success bool true for success, false for failure. */ public function update_active( $modules ) { $current_modules = \Jetpack_Options::get_option( 'active_modules', array() ); $active_modules = $this->get_active(); $new_active_modules = array_diff( $modules, $current_modules ); $new_inactive_modules = array_diff( $active_modules, $modules ); $new_current_modules = array_diff( array_merge( $current_modules, $new_active_modules ), $new_inactive_modules ); $reindexed_modules = array_values( $new_current_modules ); $success = \Jetpack_Options::update_option( 'active_modules', array_unique( $reindexed_modules ) ); // Let's take `pre_update_option_jetpack_active_modules` filter into account // and actually decide for which modules we need to fire hooks by comparing // the 'active_modules' option before and after the update. $current_modules_post_update = \Jetpack_Options::get_option( 'active_modules', array() ); $new_inactive_modules = array_diff( $current_modules, $current_modules_post_update ); $new_inactive_modules = array_unique( $new_inactive_modules ); $new_inactive_modules = array_values( $new_inactive_modules ); $new_active_modules = array_diff( $current_modules_post_update, $current_modules ); $new_active_modules = array_unique( $new_active_modules ); $new_active_modules = array_values( $new_active_modules ); foreach ( $new_active_modules as $module ) { /** * Fires when a specific module is activated. * * @since 1.9.0 * * @param string $module Module slug. * @param boolean $success whether the module was activated. @since 4.2 */ do_action( 'jetpack_activate_module', $module, $success ); /** * Fires when a module is activated. * The dynamic part of the filter, $module, is the module slug. * * @since 1.9.0 * * @param string $module Module slug. */ do_action( "jetpack_activate_module_$module", $module ); } foreach ( $new_inactive_modules as $module ) { /** * Fired after a module has been deactivated. * * @since 4.2.0 * * @param string $module Module slug. * @param boolean $success whether the module was deactivated. */ do_action( 'jetpack_deactivate_module', $module, $success ); /** * Fires when a module is deactivated. * The dynamic part of the filter, $module, is the module slug. * * @since 1.9.0 * * @param string $module Module slug. */ do_action( "jetpack_deactivate_module_$module", $module ); } return $success; } }
Fatal error: Uncaught Error: Class 'Automattic\Jetpack\Modules' not found in /home/healths/public_html/wp-content/plugins/jetpack-social/vendor/automattic/jetpack-plans/src/class-current-plan.php:262 Stack trace: #0 /home/healths/public_html/wp-content/plugins/jetpack-social/vendor/automattic/jetpack-plans/src/class-current-plan.php(370): Automattic\Jetpack\Current_Plan::get() #1 /home/healths/public_html/wp-content/plugins/jetpack-social/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-base.php(1784): Automattic\Jetpack\Current_Plan::supports() #2 /home/healths/public_html/wp-content/plugins/jetpack-social/jetpack_vendor/automattic/jetpack-publicize/src/social-image-generator/class-settings.php(78): Automattic\Jetpack\Publicize\Publicize_Base->has_social_image_generator_feature() #3 /home/healths/public_html/wp-content/plugins/jetpack-social/jetpack_vendor/automattic/jetpack-publicize/src/social-image-generator/class-setup.php(18): Automattic\Jetpack\Publicize\Social_Image_Generator\Settings->is_available( in /home/healths/public_html/wp-content/plugins/jetpack-social/vendor/automattic/jetpack-plans/src/class-current-plan.php on line 262