diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
commit | 10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch) | |
tree | b4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/vendor/automattic/jetpack-connection/legacy/class-jetpack-ixr-clientmulticall.php | |
parent | Updating script for Update (diff) | |
download | blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2 blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip |
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/vendor/automattic/jetpack-connection/legacy/class-jetpack-ixr-clientmulticall.php')
-rw-r--r-- | plugins/jetpack/vendor/automattic/jetpack-connection/legacy/class-jetpack-ixr-clientmulticall.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/jetpack/vendor/automattic/jetpack-connection/legacy/class-jetpack-ixr-clientmulticall.php b/plugins/jetpack/vendor/automattic/jetpack-connection/legacy/class-jetpack-ixr-clientmulticall.php new file mode 100644 index 00000000..da71873f --- /dev/null +++ b/plugins/jetpack/vendor/automattic/jetpack-connection/legacy/class-jetpack-ixr-clientmulticall.php @@ -0,0 +1,68 @@ +<?php +/** + * IXR_ClientMulticall + * + * @package automattic/jetpack-connection + * + * @since 1.5 + * @since 7.7 Moved to the jetpack-connection package. + */ + +/** + * A Jetpack implementation of the WordPress core IXR client, capable of multiple calls in a single request. + */ +class Jetpack_IXR_ClientMulticall extends Jetpack_IXR_Client { + /** + * Storage for the IXR calls. + * + * @var array + */ + public $calls = array(); + + /** + * Add a IXR call to the client. + * First argument is the method name. + * The rest of the arguments are the params specified to the method. + */ + public function addCall() { + $args = func_get_args(); + $method_name = array_shift( $args ); + $struct = array( + 'methodName' => $method_name, + 'params' => $args, + ); + $this->calls[] = $struct; + } + + /** + * Perform the IXR multicall request. + * + * @return bool True if request succeeded, false otherwise. + */ + public function query() { + usort( $this->calls, array( $this, 'sort_calls' ) ); + + // Prepare multicall, then call the parent::query() method. + return parent::query( 'system.multicall', $this->calls ); + } + + /** + * Sort the IXR calls. + * Make sure syncs are always done first. + * + * @param array $a First call in the sorting iteration. + * @param array $b Second call in the sorting iteration. + * @return int Result of the sorting iteration. + */ + public function sort_calls( $a, $b ) { + if ( 'jetpack.syncContent' === $a['methodName'] ) { + return -1; + } + + if ( 'jetpack.syncContent' === $b['methodName'] ) { + return 1; + } + + return 0; + } +} |