Skip to content

Commit

Permalink
Add new filter around the remote post query args
Browse files Browse the repository at this point in the history
  • Loading branch information
Darin Kotter committed Oct 29, 2021
1 parent 7b3c323 commit def546f
Showing 1 changed file with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,6 @@ public function remote_get( $args = array() ) {
}
}

/**
* Filter the remote_get query arguments
*
* @since 1.0
* @hook dt_remote_get_query_args
*
* @param {array} $query_args The existing query arguments.
* @param {array} $args The arguments originally passed to `remote_get`.
* @param {object} $this The authentication class.
*
* @return {array} The existing query arguments.
*/
$query_args = apply_filters( 'dt_remote_get_query_args', $query_args, $args, $this );

// When running a query for the Pull screen with excluded items, make a POST request instead
if ( empty( $id ) && isset( $args['post__not_in'] ) && isset( $args['dt_pull_list'] ) ) {
$query_args['post_type'] = isset( $post_type ) ? $post_type : 'post';
Expand Down Expand Up @@ -257,6 +243,20 @@ public function remote_get( $args = array() ) {
$args_str .= 'per_page=' . (int) $posts_per_page;
}

/**
* Filter the remote_get query arguments
*
* @since 1.0
* @hook dt_remote_get_query_args
*
* @param {array} $query_args The existing query arguments.
* @param {array} $args The arguments originally passed to `remote_get`.
* @param {object} $this The authentication class.
*
* @return {array} The existing query arguments.
*/
$query_args = apply_filters( 'dt_remote_get_query_args', $query_args, $args, $this );

foreach ( $query_args as $arg_key => $arg_value ) {
if ( is_array( $arg_value ) ) {
foreach ( $arg_value as $arg_value_value ) {
Expand Down Expand Up @@ -402,6 +402,7 @@ public function remote_post( $url = '', $args = array() ) {
/**
* Filter the timeout used when calling `remote_post`
*
* @since 1.6.7
* @hook dt_remote_post_timeout
*
* @param int $timeout The timeout to use for the remote post. Default `45`.
Expand All @@ -410,7 +411,18 @@ public function remote_post( $url = '', $args = array() ) {
* @return int The timeout to use for the remote_post call.
*/
'timeout' => apply_filters( 'dt_remote_post_timeout', 45, $args ),
'body' => $args,
/**
* Filter the remote_post query arguments
*
* @since 1.6.7
* @hook dt_remote_post_query_args
*
* @param {array} $args The request arguments.
* @param {WordPressExternalConnection} $this The current connection object.
*
* @return {array} The query arguments.
*/
'body' => apply_filters( 'dt_remote_post_query_args', $args, $this ),
)
)
);
Expand Down

0 comments on commit def546f

Please sign in to comment.