Skip to content

Commit

Permalink
fix wpcs linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
antonlukin committed Jul 28, 2024
1 parent 23db192 commit 0e0bc4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion classes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function init_networks() {
'Social_Planner\Network_Facebook' => SOCIAL_PLANNER_DIR . '/networks/class-network-facebook.php',
'Social_Planner\Network_OK' => SOCIAL_PLANNER_DIR . '/networks/class-network-ok.php',
'Social_Planner\Network_Linkedin' => SOCIAL_PLANNER_DIR . '/networks/class-network-linkedin.php',
'Social_Planner\Network_Make' => SOCIAL_PLANNER_DIR . '/networks/class-network-make.php',
'Social_Planner\Network_Make' => SOCIAL_PLANNER_DIR . '/networks/class-network-make.php',
);

/**
Expand Down
31 changes: 12 additions & 19 deletions networks/class-network-make.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function get_fields() {
'required' => true,
),

'title' => array(
'title' => array(
'label' => __( 'Subtitle', 'social-planner' ),
'hint' => __( 'Optional field. Used as an subtitle if there are multiple Make providers.', 'social-planner' ),
),
Expand All @@ -88,14 +88,13 @@ public static function send_message( $message, $settings ) {
return new WP_Error( 'sending', esc_html__( 'WebHook URL parameter is not found', 'social-planner' ) );
}


$response = self::make_request( $message, $settings['webhook_url'] );

if($response["response"]["code"] == 200) {
if ( 200 === $response['response']['code'] ) {
return true;
}

return new WP_Error( 'sending', esc_html__( 'API return error: ', 'social-planner' ).$response->code );
return new WP_Error( 'sending', esc_html__( 'API return error: ', 'social-planner' ) . $response->code );
}

/**
Expand All @@ -104,7 +103,7 @@ public static function send_message( $message, $settings ) {
* @param array $message List of message args.
*/
private static function prepare_message_excerpt( $message ) {
$excerpt = "";
$excerpt = '';

if ( ! empty( $message['excerpt'] ) ) {
$excerpt = $message['excerpt'];
Expand All @@ -123,25 +122,23 @@ private static function prepare_message_excerpt( $message ) {
/**
* Prepare data and send request to remote API.
*
* @param array $message Message data.
* @param string $path Remote API URL path.
* @param string $token Access token from settings.
* @param array $message Message data.
* @param string $webhook_url Remote API URL.
*/
protected static function make_request( $message, $webhook_url ) {
$body = array();
$url = $webhook_url;

$url = $webhook_url;
$excerpt = self::prepare_message_excerpt( $message );
if ( empty( $excerpt ) && empty( $message['poster_id']) ) {

if ( empty( $excerpt ) && empty( $message['poster_id'] ) ) {
return new WP_Error( 'sending', esc_html__( 'Excerpt and poster are both empty', 'social-planner' ) );
}

if ( ! empty( $message['poster_id'] ) ) {
$body["image_url"] = wp_get_attachment_url($message['poster_id']);
$body['image_url'] = wp_get_attachment_url( $message['poster_id'] );
}


$body['content'] = $excerpt;

/**
Expand Down Expand Up @@ -169,17 +166,13 @@ protected static function make_request( $message, $webhook_url ) {
private static function send_request( $url, $body, $headers = null ) {
$args = array(
'user-agent' => 'social-planner/' . SOCIAL_PLANNER_VERSION,
'body' => $body,
'body' => $body,
);

// array_merge($args, $body);

if ( $headers ) {
$args['headers'] = $headers;
}



/**
* Filter request arguments right before sending.
*
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you find a bug or want to add new feature to this plugin, create new [issue](
== Changelog ==

= 1.4.0 =
* Adding new provider for make.
* Adding new provider for make.com.

= 1.3.2 =
* Bump 'Tested up' version and update readme
Expand Down

0 comments on commit 0e0bc4b

Please sign in to comment.