Plugin Directory

Changeset 3095264


Ignore:
Timestamp:
05/30/2024 03:59:42 PM (22 months ago)
Author:
kp4coder
Message:

Send data using API, Security Update

Location:
sync-post-with-other-site/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sync-post-with-other-site/trunk/SyncPostWithOtherSite.php

    r3063897 r3095264  
    22/*
    33Plugin Name: Sync Post With Other Site
    4 Plugin URI: https://syncpostwithothersite.in/
     4Plugin URI: https://kp4coder.com/
    55Description: Allows user to sync post with multiple websites.
    6 Version: 1.5.1
     6Version: 1.6
    77Author: kp4coder
    8 Author URI: https://syncpostwithothersite.in/author/
     8Author URI: https://kp4coder.com/
    99Domain Path: /languages
    1010Text Domain: sps_text_domain
     
    5252
    5353global $sps_version;
    54 $sps_version = '1.5.1';
     54$sps_version = '1.6';
    5555
    5656class SyncPostWithOtherSite {
  • sync-post-with-other-site/trunk/includes/sps_sync.class.php

    r2972270 r3095264  
    1515            add_action( "save_post", array( $this, "sps_save_post" ), 10 , 3 );
    1616
    17             add_action( "init", array( $this, "sps_get_request" ) );
    18 
    1917            add_action( "spsp_after_save_data", array( $this, "spsp_grab_content_images" ), 10, 2 );
    2018
     19            add_action( 'rest_api_init', array( $this, 'rest_api_init_func' ) ); // Register custom API endpoints
     20        }
     21
     22
     23        function rest_api_init_func() {
     24            register_rest_route( 'sps/v1', '/data', array(
     25                'methods'  => 'POST',
     26                'callback' => array( $this, 'sps_get_request'  ),
     27            ) );
    2128        }
    2229
     
    7481        function sps_remote_post( $action, $args = array() ) {
    7582            do_action( 'spsp_before_send_data', $args );
    76             $url = $args['sps']['host_name']."/?sps_action=".$action;
    77             return wp_remote_post( $url, array( 'body' => $args ));
     83            $args['sps_action'] = $action;
     84            $url = $args['sps']['host_name']."/wp-json/sps/v1/data";
     85            $return = wp_remote_post( $url, array( 'body' => $args ));
     86            return $return;
    7887        }
    7988
     
    351360        }
    352361
    353         function sps_get_request() {
    354 
    355             if( isset($_REQUEST['sps_action']) && !empty($_REQUEST['sps_action']) ) {
     362        function sps_get_request( $request ) {
     363
     364            $sps_sync_data = $request->get_params();
     365            if( isset($sps_sync_data['sps_action']) && !empty($sps_sync_data['sps_action']) ) {
    356366                $this->is_website_post = false;
    357                 $sps_sync_data = $_REQUEST;
    358 
     367               
    359368                $sps_host_name        = isset($sps_sync_data['sps']['host_name']) ? esc_url_raw($sps_sync_data['sps']['host_name']) : '';
    360369                $sps_content_username = isset($sps_sync_data['sps']['content_username']) ? sanitize_text_field($sps_sync_data['sps']['content_username']) : '';
     
    393402                    $return['msg'] = __('Username or Password is null.', SPS_txt_domain);
    394403                }
    395                 echo json_encode( $return );
    396                 exit;
     404               
     405                return new WP_REST_Response( $return, 200 );
    397406            }
    398407        }
  • sync-post-with-other-site/trunk/readme.txt

    r3093320 r3095264  
    22Contributors: kp4coder
    33Donate link: https://buymeacoffee.com/kp4coder
    4 Tags: wp sync post, sync post content, sync post with multiple sites, post attachments, post content, post content sync, migrate post content, moving post data, synchronization post
     4Tags: wp sync post, sync post with multiple sites, post content sync, migrate post content, synchronization post
    55Requires at least: 4.5
    6 Tested up to: 6.5
    7 Stable tag: 1.3
     6Tested up to: 6.5.3
     7Stable tag: 1.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9999* Fix: Security Update
    100100
     101= 1.5.3 - April 03, 2024 =
     102* Fix: Send data using API, Security Update
     103
    101104== Upgrade notice ==
    102105
Note: See TracChangeset for help on using the changeset viewer.