filename
stringlengths
11
137
content
stringlengths
6
292k
projects/packages/waf/tests/php/unit/test-waf-request.php
<?php /** * Request test suite. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Request; /** * Request test suite. */ class WafRequestTest extends PHPUnit\Framework\TestCase { use \Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; /** * Test for null on CLI. */ public function testIpR...
projects/packages/waf/tests/php/unit/test-waf-runner.php
<?php /** * Standalone bootstrap test suite. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Constants; use Automattic\Jetpack\Waf\Waf_Runner; /** * Runtime test suite. */ final class WafRunnerTest extends PHPUnit\Framework\TestCase { /** * Test define mode */ public function testDe...
projects/packages/waf/tests/php/unit/test-waf-standalone-bootstrap.php
<?php /** * Standalone bootstrap test suite. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Standalone_Bootstrap; /** * Runtime test suite. */ final class WafStandaloneBootstrapTest extends PHPUnit\Framework\TestCase { /** * Test guarding against running outside of WP context. * *...
projects/packages/waf/tests/php/unit/test-waf-operators.php
<?php /** * Adapted from modsecurity tests: https://github.com/SpiderLabs/ModSecurity/tree/caadf97524a4861456be176a8cb91dcbb76b97e4/tests/op * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Operators; /** * Operators test suite. */ final class WafOperatorsTest extends PHPUnit\Framework\Test...
projects/packages/waf/tests/php/unit/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/ */ /** * Include the composer autoloader. */ require_once __DIR__ . '/../../../vendor/autoload.php'; require_once __DIR__ . '/functions-wordpress.php';
projects/packages/waf/tests/php/unit/test-waf-runtime.php
<?php /** * Runtime test suite. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Operators; use Automattic\Jetpack\Waf\Waf_Runtime; use Automattic\Jetpack\Waf\Waf_Transforms; /** * Runtime test suite. */ final class WafRuntimeTest extends PHPUnit\Framework\TestCase { /** * Instance of th...
projects/packages/waf/tests/php/unit/functions-wordpress.php
<?php /** * Functions that mock WordPress core functionality for testing purposes. * * @package automattic/jetpack-waf */ if ( ! function_exists( 'trailingslashit' ) ) { /** * A drop-in for a WordPress core function. * * @param String $string string. * @return String */ function trailingslashit( $stri...
projects/packages/waf/tests/php/unit/test-waf-compatibility.php
<?php /** * Compatibility test suite. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Compatibility; /** * Compatibility test suite. */ class WafCompatibilityTest extends PHPUnit\Framework\TestCase { /** * Test Waf_Compatibility::merge_ip_allow_lists(). */ public function testMergeI...
projects/packages/waf/tests/php/unit/test-waf-runtime-targets.php
<?php /** * Test WAF runtime target matching * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Operators; use Automattic\Jetpack\Waf\Waf_Request; use Automattic\Jetpack\Waf\Waf_Runtime; use Automattic\Jetpack\Waf\Waf_Transforms; /** * Runtime test suite. */ final class WafRuntimeTargetsTest ...
projects/packages/waf/tests/php/unit/test-waf-transforms.php
<?php /** * Adapted from modsecurity tests: https://github.com/SpiderLabs/ModSecurity/tree/caadf97524a4861456be176a8cb91dcbb76b97e4/tests/tfn * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Transforms as GlobalWafTransforms; /** * Transforms test suite. */ final class WafTransformsTest ext...
projects/packages/waf/tests/php/integration/test-waf-activation.php
<?php /** * Activation tests. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Constants; use Automattic\Jetpack\Waf\Waf_Initializer; use Automattic\Jetpack\Waf\Waf_Rules_Manager; use Automattic\Jetpack\Waf\Waf_Runner; use Automattic\Jetpack\Waf\Waf_Standalone_Bootstrap; /** * Integration tests for ...
projects/packages/waf/tests/php/integration/test-waf-runner.php
<?php /** * Runner tests. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Constants; use Automattic\Jetpack\Waf\Waf_Initializer; use Automattic\Jetpack\Waf\Waf_Runner; /** * Integration tests for the firewall runner. */ final class WafRunsTest extends WorDBless\BaseTestCase { /** * Test setup....
projects/packages/waf/tests/php/integration/test-waf-unsupported-environment.php
<?php /** * Unsupported environment tests. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Constants; use Automattic\Jetpack\Modules; use Automattic\Jetpack\Status\Cache; use Automattic\Jetpack\Waf\Waf_Initializer; /** * Integration tests for unsupported environments. */ final class WafUnsupported...
projects/packages/waf/tests/php/integration/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/ */ /** * Include the composer autoloader. */ require_once __DIR__ . '/../../../vendor/autoload.php'; /** * Load WorDBless. */ \WorDBless\Load::load();
projects/packages/waf/tests/php/integration/test-waf-compatibility.php
<?php /** * Compatibility tests. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Waf\Waf_Compatibility; use Automattic\Jetpack\Waf\Waf_Initializer; use Automattic\Jetpack\Waf\Waf_Rules_Manager; use Automattic\Jetpack\Waf\Waf_Runner; /** * Integration tests for the backwards-compatibility of the pac...
projects/packages/waf/tests/php/integration/test-waf-rest-api.php
<?php /** * REST API integration tests. * * @package automattic/jetpack-waf */ use Automattic\Jetpack\Constants; use Automattic\Jetpack\Waf\REST_Controller; use Automattic\Jetpack\Waf\Waf_Rules_Manager; /** * Integration tests for the REST API endpoints registered by the WAF. */ final class WafRestIntegrationTe...
projects/packages/waf/src/functions.php
<?php /** * Utility functions for WAF. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; /** * A wrapper for WordPress's `wp_unslash()`. * * Even though PHP itself dropped the option to add slashes to superglobals a decade ago, * WordPress still does it through some misguided extreme ba...
projects/packages/waf/src/class-waf-cli.php
<?php /** * CLI handler for Jetpack Waf. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use WP_CLI; use WP_CLI_Command; /** * Set up the WAF, change its mode, or generate its rules. */ class CLI extends WP_CLI_Command { /** * View or set the current mode of the WAF. * ## OPTIONS ...
projects/packages/waf/src/class-waf-operators.php
<?php /** * Rule compiler for Jetpack Waf. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; /** * Waf_Operators class */ class Waf_Operators { /** * Returns true if the test string is found at the beginning of the input. * * @param string $input Input. * @param string $test Test...
projects/packages/waf/src/class-waf-constants.php
<?php /** * Class use to define the constants used by the WAF * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\Status\Host; /** * Defines our constants. */ class Waf_Constants { /** * Initializes the constants required for generating the bootstrap, if they have...
projects/packages/waf/src/class-waf-transforms.php
<?php /** * Transforms for Jetpack Waf * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; /** * Waf_Transforms class */ class Waf_Transforms { /** * Decode a Base64-encoded string. This runs the decode without strict mode, to match Modsecurity's 'base64DecodeExt' transform function. ...
projects/packages/waf/src/class-waf-request.php
<?php /** * HTTP request representation specific for the WAF. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; require_once __DIR__ . '/functions.php'; /** * Request representation. * * @template RequestFile as array{ name: string, filename: string } */ class Waf_Request { /** * Th...
projects/packages/waf/src/class-waf-initializer.php
<?php /** * Class use to initialize the WAF module. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\Waf\Brute_Force_Protection\Brute_Force_Protection; use WP_Error; /** * Initializes the module */ class Waf_Initializer { /** * Option for storing whether or no...
projects/packages/waf/src/class-brute-force-protection.php
<?php /** * Class used to define Brute Force Protection. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf\Brute_Force_Protection; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Constants; use Automattic\Jetpack\CookieState; use Automattic\Jetpack\IP\...
projects/packages/waf/src/class-compatibility.php
<?php /** * Class used to manage backwards-compatibility of the package. * * @since 0.8.0 * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Jetpack_Options; /** * Defines methods for ensuring backwards compatibility. */ class Waf_Compatibility { /** * Add compatibilty hooks *...
projects/packages/waf/src/class-rest-controller.php
<?php /** * Class use to register REST API endpoints used by the WAF * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\Connection\REST_Connector; use Automattic\Jetpack\Waf\Brute_Force_Protection\Brute_Force_Protection; use WP_Error; use WP_REST_Server; /** * Define...
projects/packages/waf/src/class-waf-rules-manager.php
<?php /** * Class for generating and working with firewall rule files. * * @since 0.9.0 * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\IP\Utils as IP_Utils; use Jetpack_Options; use WP_Error; /** * Class for generating ...
projects/packages/waf/src/class-waf-runtime.php
<?php /** * Runtime for Jetpack Waf * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\IP\Utils as IP_Utils; require_once __DIR__ . '/functions.php'; // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This class is all about sanitizing i...
projects/packages/waf/src/class-waf-runner.php
<?php /** * Entrypoint for actually executing the WAF. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\Modules; use Automattic\Jetpack\Status\Host; use Automattic\Jetpack\Waf\Brute_Force_Protection\Brute_Force_Protection; /** * Executes the WAF. */ class Waf_Runn...
projects/packages/waf/src/class-waf-standalone-bootstrap.php
<?php /** * Handles generation and deletion of the bootstrap for the standalone WAF mode. * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Composer\InstalledVersions; /** * Handles the bootstrap. */ class Waf_Standalone_Bootstrap { /** * Ensures that constants are initialized if...
projects/packages/waf/src/class-waf-stats.php
<?php /** * Class used to retrieve WAF stats * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Automattic\Jetpack\IP\Utils as IP_Utils; /** * Retrieves WAF stats. */ class Waf_Stats { /** * Get IP allow list count * * @return int The number of valid IP addresses in the allow ...
projects/packages/waf/src/brute-force-protection/class-transient-cleanup.php
<?php /** * Adapted from Purge Transients by Seebz * https://github.com/Seebz/Snippets/tree/master/Wordpress/plugins/purge-transients * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf\Brute_Force_Protection; /** * Transient Cleanup class. */ class Brute_Force_Protection_Transient_Cleanup ...
projects/packages/waf/src/brute-force-protection/class-math-fallback.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Waf\Brute_Force_Protection; if ( ! class_exists( 'Brute_Force_Protection_Math_Authenticate' ) ) { /** * The math captcha fallback if we can't talk to the Protect API */ class Brute_Force_Protection_Math_Authenticat...
projects/packages/waf/src/brute-force-protection/class-shared-functions.php
<?php /** * Class for functions shared by the Brute force protection feature and its related json-endpoints * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf\Brute_Force_Protection; use Automattic\Jetpack\IP\Utils as IP_Utils; use Automattic\Jetpack\Waf\Waf_Rules_Manager; use WP_Error; /** ...
projects/packages/waf/src/brute-force-protection/class-blocked-login-page.php
<?php // phpcs:ignore - WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Waf\Brute_Force_Protection; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Redirect; use Jetpack_Options; use WP_Error; /** * Class Brute_Force_Protection_Blocked_Login_Page * * Instanciated on the...
projects/packages/waf/src/exceptions/class-file-system-exception.php
<?php /** * File system exception. * * @since 0.10.1 * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; /** * Custom exception for WAF file system errors. */ class File_System_Exception extends Waf_Exception { /** * Error slug which maps to WP_Error::$code. * * @var string */ ...
projects/packages/waf/src/exceptions/class-rules-api-exception.php
<?php /** * Rules API exception. * * @since 0.10.1 * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; /** * Custom exception for WAF rules API errors. */ class Rules_API_Exception extends Waf_Exception { /** * Error slug which maps to WP_Error::$code. * * @var string */ const ...
projects/packages/waf/src/exceptions/class-waf-exception.php
<?php /** * Base custom exception for the WAF package. * * @since 0.10.1 * * @package automattic/jetpack-waf */ namespace Automattic\Jetpack\Waf; use Exception; use WP_Error; /** * WAF exception. */ class Waf_Exception extends Exception { /** * Error slug which maps to WP_Error::$code. * * @var strin...
projects/packages/tracking/legacy/class-jetpack-tracks-client.php
<?php // phpcs:ignore /** * Legacy Tracks client stub file. * * @package automattic/jetpack-tracking * @deprecated 1.14.7 * @see automattic/jetpack-connection */ require_once __DIR__ . '/../../jetpack-connection/legacy/class-jetpack-tracks-client.php';
projects/packages/tracking/legacy/class-jetpack-tracks-event.php
<?php // phpcs:ignore /** * Legacy Tracks event stub file. * * @package automattic/jetpack-tracking * @deprecated 1.14.7 * @see automattic/jetpack-connection */ require_once __DIR__ . '/../../jetpack-connection/legacy/class-jetpack-tracks-event.php';
projects/packages/tracking/src/class-tracking.php
<?php // phpcs:ignore /** * Nosara Tracks for Jetpack * * @package automattic/jetpack-tracking * @deprecated 1.14.7 * @see automattic/jetpack-connection */ require_once __DIR__ . '/../../jetpack-connection/src/class-tracking.php';
projects/packages/device-detection/tests/php/test_DeviceDetection.php
<?php /** * Tests for the Automattic\Jetpack\Mobile package. * * @package automattic/jetpack-device-detection * * @phpcs:disable WordPress.Files.FileName */ use Automattic\Jetpack\Device_Detection; use PHPUnit\Framework\TestCase; /** * Tests for the Device_Detection class. */ class Test_Device_Detection exten...
projects/packages/device-detection/tests/php/bootstrap.php
<?php /** * Tests bootstrap. * * @package automattic/jetpack-device-detection */ // @phpcs:disable Squiz.Commenting.FileComment require_once __DIR__ . '/../../vendor/autoload.php';
projects/packages/device-detection/src/functions.php
<?php /** * Utility functions for device detection. * * @package automattic/jetpack-device-detection */ namespace Automattic\Jetpack\Device_Detection; // Check if the function is already defined, in case someone bypassed the autoloader or something // to get the two classes from different copies of the package. i...
projects/packages/device-detection/src/class-device-detection.php
<?php /** * Device detection for Jetpack. * * @package automattic/jetpack-device-detection */ namespace Automattic\Jetpack; require_once __DIR__ . '/functions.php'; require_once __DIR__ . '/class-user-agent-info.php'; use Automattic\Jetpack\Device_Detection\User_Agent_Info; use function Automattic\Jetpack\Device...
projects/packages/device-detection/src/class-user-agent-info.php
<?php /** * User agent detection for Jetpack. * * @package automattic/jetpack-device-detection * * We don't want to rename public members. * @phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase * @phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase *...
projects/packages/admin-ui/tests/php/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/ */ /** * Include the composer autoloader. */ require_once __DIR__ . '/../../vendor/autoload.php'; define( 'WP_DEBUG', true ); \WorDBless\Load::load();
projects/packages/admin-ui/tests/php/test_admin_menu.php
<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase /** * Admin_Menu functionality testing. * * @package automattic/jetpack-admin-ui */ namespace Automattic\Jetpack\Admin_UI; use PHPUnit\Framework\TestCase; /** * Connection Manager functionality testing. */ class Admin_Menu_Test extends TestC...
projects/packages/admin-ui/src/class-admin-menu.php
<?php /** * Admin Menu Registration * * @package automattic/jetpack-admin-ui */ namespace Automattic\Jetpack\Admin_UI; /** * This class offers a wrapper to add_submenu_page and makes sure stand-alone plugin's menu items are always added under the Jetpack top level menu. * If the Jetpack top level was not previo...
projects/packages/licensing/tests/php/class-test-licensing.php
<?php /** * Tests the TOS package. * * @package automattic/jetpack-licensing */ namespace Automattic\Jetpack; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Jetpack_IXR_ClientMulticall; use stdClass; use WorDBless\BaseTestCase; use WP_Error; /** * Class Test_Licensing * * @package Automa...
projects/packages/licensing/tests/php/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/jetpack-licensing */ define( 'JETPACK_MASTER_USER', true ); /** * Include composer autoloader. */ require_once __DIR__ . '/../../vendor/autoload.php'; \WorDBless\Load::load(); // IXR legacy autoloading runs too early conditionally on ABSPATH and WPINC which are d...
projects/packages/licensing/tests/php/class-test-licensing-endpoints.php
<?php /** * Tests the endpoints within the Licensing package. * * @package automattic/jetpack-licensing */ namespace Automattic\Jetpack; use WorDBless\BaseTestCase; /** * Class Test_Licensing * * @package Automattic\Jetpack */ class Test_Licensing_Endpoints extends BaseTestCase { /** * Used to store an i...
projects/packages/licensing/src/class-endpoints.php
<?php /** * A Licensing Endpoints class for Jetpack. * * @package automattic/jetpack-licensing */ namespace Automattic\Jetpack\Licensing; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Licensing; use Automattic\Jetpack\Status\Visit...
projects/packages/licensing/src/class-licensing.php
<?php /** * A Terms of Service class for Jetpack. * * @package automattic/jetpack-licensing */ namespace Automattic\Jetpack; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Licensing\Endpoints; use Jetpack_IXR_ClientMulticall; use Jetpack_Options; use WP_Error; /** * Clas...
projects/packages/sync/tests/php/test-default-filter-settings.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName /** * The Test_Default_Filter_Settings class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use PHPUnit\Framework\TestCase; /** * Unit tests for the Default_Filter_Settings class. * * @package automattic/jetpack-s...
projects/packages/sync/tests/php/data-test-data-settings.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Sync; /** * Data sets for the Test_Data_Settings tests. * * @package automattic/jetpack-sync */ class Data_Test_Data_Settings { /* * For all expected outputs in the test data, the required modules and filters are a...
projects/packages/sync/tests/php/test-package-version.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Sync; use PHPUnit\Framework\TestCase; /** * Unit tests for the Package_Version class. * * @package automattic/jetpack-sync */ class Test_Package_Version extends TestCase { /** * Tests that the sync package versio...
projects/packages/sync/tests/php/test-dedicated-sender.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Sync; use WorDBless\BaseTestCase; use WorDBless\Options as WorDBless_Options; /** * Unit tests for the Dedicated_Sender class. * * @covers Automattic\Jetpack\Sync\Dedicated_Sender * * @package automattic/jetpack-syn...
projects/packages/sync/tests/php/bootstrap.php
<?php /** * Bootstrap. * * @package automattic/jetpack-sync */ /** * Include the Composer autoloader. */ require_once __DIR__ . '/../../vendor/autoload.php'; /** * Include the test data file the the Test_Data_Settings class. */ require_once __DIR__ . '/data-test-data-settings.php'; /** * Load WorDBless */ ...
projects/packages/sync/tests/php/test-actions.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Constants; use WorDBless\BaseTestCase; use WorDBless\Options as WorDBless_Options; /** * Unit tests for the Actions class. * * @package automattic/jetpack-sync */ class Test_Actions exten...
projects/packages/sync/tests/php/test-data-settings.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Sync; use WorDBless\BaseTestCase; /** * Unit tests for the Data_Settings class. * * @package automattic/jetpack-sync */ class Test_Data_Settings extends BaseTestCase { /** * An instance of the Data_Settings class...
projects/packages/sync/tests/php/test-rest-endpoints.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Manager; use Automattic\Jetpack\Connection\REST_Connector; use Automattic\Jetpack\Constants; use Automattic\Jetpack\Sync\Main as Sync_Main; use PHPUnit\Framework\TestCase; use WorDB...
projects/packages/sync/src/class-defaults.php
<?php /** * Jetpack Sync Defaults * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Status; /** * Just some defaults that we share with the server. */ class Defaults { /** * Default Options. * * @var array */ public static $default_options_whitelist = ...
projects/packages/sync/src/class-sender.php
<?php /** * Sync sender. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Manager; use Automattic\Jetpack\Constants; use WP_Error; /** * This class grabs pending actions from the queue and sends them */ class Sender { /** * Name of the option that ...
projects/packages/sync/src/interface-replicastore.php
<?php /** * Sync architecture prototype. * * To run tests: phpunit --testsuite sync --filter New_Sync * * @author Dan Walmsley * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * A high-level interface for objects that store synced WordPress data. * Useful for ensuring that differe...
projects/packages/sync/src/class-replicastore.php
<?php /** * Sync replicastore. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Sync\Replicastore\Table_Checksum; use Automattic\Jetpack\Sync\Replicastore\Table_Checksum_Usermeta; use Automattic\Jetpack\Sync\Replicastore\Table_Checksum_Users; use Exception; use WP_...
projects/packages/sync/src/class-actions.php
<?php /** * A class that defines syncable actions for Jetpack. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Manager as Jetpack_Connection; use Automattic\Jetpack\Constants; use Automattic\Jetpack\Identity_Crisis; use Automattic\Jetpack\Status; use Au...
projects/packages/sync/src/class-functions.php
<?php /** * Utility functions to generate data synced to wpcom * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Urls; use Automattic\Jetpack\Constants; use Automattic\Jetpack\Modules as Jetpack_Modules; /** * Utility functions to generate data synced t...
projects/packages/sync/src/class-utils.php
<?php /** * Sync utils. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * Class for sync utilities. */ class Utils { /** * Retrieve the values of sync items. * * @access public * @static * * @param array $items Array of sync items. * @return array Array of sync item...
projects/packages/sync/src/class-lock.php
<?php /** * Lock class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * Lock class */ class Lock { /** * Prefix of the blog lock transient. * * @access public * * @var string */ const LOCK_PREFIX = 'jp_sync_lock_'; /** * Default Lifetime of the lock. * This i...
projects/packages/sync/src/interface-codec.php
<?php /** * Interface for encoding and decoding sync objects. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * Very simple interface for encoding and decoding input. * This is used to provide compression and serialization to messages. **/ interface Codec_Interface { /** * Ret...
projects/packages/sync/src/class-rest-endpoints.php
<?php /** * Sync package. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Rest_Authentication; use WP_Error; use WP_REST_Server; /** * This class will handle Sync v4 REST Endpoints. * * @since 1.23.1 */ class REST_Endpoints { /** * Items pend...
projects/packages/sync/src/class-main.php
<?php /** * This class hooks the main sync actions. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Sync\Actions as Sync_Actions; use Automattic\Jetpack\Sync\Queue\Queue_Storage_Table; /** * Jetpack Sync main class. */ class Main { /** * Sets up event handl...
projects/packages/sync/src/class-package-version.php
<?php /** * The Package_Version class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * The Package_Version class. */ class Package_Version { const PACKAGE_VERSION = '2.9.0'; const PACKAGE_SLUG = 'sync'; /** * Adds the package slug and version to the package version track...
projects/packages/sync/src/class-rest-sender.php
<?php /** * Sync package. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use WP_Error; /** * This class will handle checkout of Sync queues for REST Endpoints. * * @since 1.23.1 */ class REST_Sender { /** * Items pending send. * * @var array */ public $items = array();...
projects/packages/sync/src/class-queue-buffer.php
<?php /** * Sync queue buffer. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * A buffer of items from the queue that can be checked out. */ class Queue_Buffer { /** * Sync queue buffer ID. * * @access public * * @var int */ public $id; /** * Sync items. * *...
projects/packages/sync/src/class-users.php
<?php /** * Sync for users. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Manager as Jetpack_Connection; use Automattic\Jetpack\Connection\XMLRPC_Async_Call; use Automattic\Jetpack\Roles; /** * Class Users. * * Responsible for syncing user data ch...
projects/packages/sync/src/class-dedicated-sender.php
<?php /** * Dedicated Sender. * * The class is responsible for spawning dedicated Sync requests. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use WP_Error; /** * Class to manage Sync spawning. * The purpose of this class is to provide the means to unblock Sync * from running in ...
projects/packages/sync/src/class-simple-codec.php
<?php /** * Simple codec for encoding and decoding sync objects. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * An implementation of Automattic\Jetpack\Sync\Codec_Interface that uses base64 * algorithm to compress objects serialized using json_encode. */ class Simple_Codec ext...
projects/packages/sync/src/class-queue.php
<?php /** * The class that describes the Queue for the sync package. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Sync\Queue\Queue_Storage_Options; use Automattic\Jetpack\Sync\Queue\Queue_Storage_Table; use WP_Error; /** * A persistent queue that can be flush...
projects/packages/sync/src/class-default-filter-settings.php
<?php /** * The Default Filter Settings class. * * This class provides the default whitelist values for the Sync data filters. * See the DATA_FILTER_DEFAULTS constant for the list of filters. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * The Default_Filter_Settings class */...
projects/packages/sync/src/class-modules.php
<?php /** * Simple wrapper that allows enumerating cached static instances * of sync modules. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Sync\Modules\Module; /** * A class to handle loading of sync modules. */ class Modules { /** * Lists classnames of...
projects/packages/sync/src/class-listener.php
<?php /** * Jetpack's Sync Listener * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\IP\Utils as IP_Utils; use Automattic\Jetpack\Roles; /** * This class monitors actions and logs them to the queue ...
projects/packages/sync/src/class-data-settings.php
<?php /** * The Data Settings class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * The Data_Settings class */ class Data_Settings { /** * The data that must be synced for every synced site. */ const MUST_SYNC_DATA_SETTINGS = array( 'jetpack_sync_modules' =...
projects/packages/sync/src/class-json-deflate-array-codec.php
<?php /** * An implementation of Automattic\Jetpack\Sync\Codec_Interface that uses gzip's DEFLATE * algorithm to compress objects serialized using json_encode. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * An implementation of Automattic\Jetpack\Sync\Codec_Interface that uses ...
projects/packages/sync/src/class-settings.php
<?php /** * Sync settings. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use Automattic\Jetpack\Constants; use Automattic\Jetpack\Sync\Queue\Queue_Storage_Table; /** * Class to manage the sync settings. */ class Settings { /** * Prefix, used for the sync settings option names. ...
projects/packages/sync/src/class-health.php
<?php /** * Health class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; /** * Health class. */ class Health { /** * Prefix of the blog lock transient. * * @access public * * @var string */ const STATUS_OPTION = 'sync_health_status'; /** * Status key in option arra...
projects/packages/sync/src/class-server.php
<?php /** * Sync server. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync; use WP_Error; /** * Simple version of a Jetpack Sync Server - just receives arrays of events and * issues them locally with the 'jetpack_sync_remote_action' action. */ class Server { /** * Codec used to deco...
projects/packages/sync/src/replicastore/class-table-checksum-users.php
<?php /** * Table Checksums Class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Replicastore; use Exception; /** * Class to handle Table Checksums for the Users table. */ class Table_Checksum_Users extends Table_Checksum { /** * Returns the checksum query. All validation of fie...
projects/packages/sync/src/replicastore/class-table-checksum.php
<?php /** * Table Checksums Class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Replicastore; use Automattic\Jetpack\Sync; use Exception; use WP_Error; // TODO add rest endpoints to work with this, hopefully in the same folder. /** * Class to handle Table Checksums. */ class Table_...
projects/packages/sync/src/replicastore/class-table-checksum-usermeta.php
<?php /** * Table Checksums Class. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Replicastore; use Automattic\Jetpack\Connection\Manager; use Automattic\Jetpack\Sync; use Automattic\Jetpack\Sync\Modules; use WP_Error; use WP_User_Query; /** * Class to handle Table Checksums for the U...
projects/packages/sync/src/sync-queue/class-queue-storage-options.php
<?php /** * The class responsible for storing Queue events in the `wp_options` table. * * Used by class Queue. * * @see \Automattic\Jetpack\Sync\Queue * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Queue; /** * `wp_options` storage backend for the Queue. */ class Queue_Storage_Opt...
projects/packages/sync/src/sync-queue/class-queue-storage-table.php
<?php /** * The class responsible for storing Queue events in a custom Sync events table. * * Used by class Queue. * * @see \Automattic\Jetpack\Sync\Queue * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Queue; /** * Custom Sync events table storage backend for the Queue. */ class Q...
projects/packages/sync/src/modules/class-posts.php
<?php /** * Posts sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Constants as Jetpack_Constants; use Automattic\Jetpack\Roles; use Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Sync\Settings; /** * Class to handle sync for posts. ...
projects/packages/sync/src/modules/class-attachments.php
<?php /** * Attachments sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; /** * Class to handle sync for attachments. */ class Attachments extends Module { /** * Sync module name. * * @access public * * @return string */ public function name() { retu...
projects/packages/sync/src/modules/class-full-sync-immediately.php
<?php /** * Full sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Sync\Actions; use Automattic\Jetpack\Sync\Defaults; use Automattic\Jetpack\Sync\Lock; use Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Sync\Settings; /** * This clas...
projects/packages/sync/src/modules/class-woocommerce.php
<?php /** * WooCommerce sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; use WP_Error; /** * Class to handle sync for WooCommerce. */ class WooCommerce extends Module { /** * Whitelist for order item meta we are interested to sync. * * @access private * ...
projects/packages/sync/src/modules/class-wp-super-cache.php
<?php /** * WP_Super_Cache sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; /** * Class to handle sync for WP_Super_Cache. */ class WP_Super_Cache extends Module { /** * Constructor. * * @todo Should we refactor this to use $this->set_defaults() instead? *...
projects/packages/sync/src/modules/class-module.php
<?php /** * A base abstraction of a sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Sync\Functions; use Automattic\Jetpack\Sync\Listener; use Automattic\Jetpack\Sync\Replicastore; use Automattic\Jetpack\Sync\Sender; use Automattic\Jetpack\Sync...
projects/packages/sync/src/modules/class-plugins.php
<?php /** * Plugins sync module. * * @package automattic/jetpack-sync */ namespace Automattic\Jetpack\Sync\Modules; use Automattic\Jetpack\Constants as Jetpack_Constants; /** * Class to handle sync for plugins. */ class Plugins extends Module { /** * Action handler callable. * * @access private * * ...