Plugin Directory

Changeset 3311879


Ignore:
Timestamp:
06/15/2025 11:48:07 AM (10 months ago)
Author:
xssdevelopment
Message:

merge-pdf update api endpoint

Location:
merge-pdf
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • merge-pdf/tags/1.0.2/includes/process-machine.php

    r3260511 r3311879  
    1313        'methods' => 'POST',
    1414        'callback' => 'cross_service_solutions_merge_pdf_on_submit',
    15         'permission_callback' => '__return_true',
     15        'permission_callback' => 'cross_service_solutions_merge_pdf_verify_nonce',
    1616    ));
    1717    register_rest_route('merge-pdf/v1', '/status/(?P<id>\d+)', array(
    1818        'methods' => 'GET',
    1919        'callback' => 'cross_service_solutions_merge_pdf_check_status',
    20         'permission_callback' => '__return_true',
     20        'permission_callback' => 'cross_service_solutions_merge_pdf_verify_nonce',
    2121    ));
    2222}
    2323add_action('rest_api_init', 'cross_service_solutions_merge_pdf_register_rest_api');
     24
     25function cross_service_solutions_merge_pdf_verify_nonce($request) {
     26    $nonce = $request->get_header('X-WP-Nonce');
     27
     28    // If not in header, try body
     29    if (!$nonce && isset($request['mergePDFFormNonce'])) {
     30        $nonce = sanitize_text_field($request['mergePDFFormNonce']);
     31    }
     32
     33    if (!$nonce || !wp_verify_nonce($nonce, 'merge_pdf_form_nonce_action')) {
     34        return false;
     35    }
     36
     37    return true;
     38}
    2439
    2540function cross_service_solutions_test_merge_pdf_api_callback() {
     
    2944// Handle form submission, then initiate processing
    3045function cross_service_solutions_merge_pdf_on_submit($request) {
    31     // Check if nonce is set and valid
    32     if (!isset($request['mergePDFFormNonce']) ||
    33        !wp_verify_nonce($request['mergePDFFormNonce'], 'merge_pdf_form_nonce_action')) {
    34        return new WP_Error('nonce_invalid', 'Nonce verification failed', array('status' => 403, 'message' => $request['mergePDFFormNonce']));
    35     }
    3646
    3747    $api_key = esc_attr(get_option('cross_service_solutions_api_key'));
     
    8797
    8898    // Make the API request using wp_remote_post
    89     $response = wp_remote_post('https://api.process-machine-stage.com/solutions/solutions/wordpress/30', array(
     99    $response = wp_remote_post('https://api.cross-service-solutions.com/solutions/solutions/wordpress/30', array(
    90100        'method'    => 'POST',
    91101        'body'      => $body,
     
    122132// Check status of processing task
    123133function cross_service_solutions_merge_pdf_check_status($request) {
    124     $nonce = $request->get_header('X-WP-Nonce');
    125     if (!$nonce || !wp_verify_nonce($nonce, 'merge_pdf_form_nonce_action')) {
    126         return new WP_Error('nonce_invalid', 'Nonce verification failed', array(
    127             'status' => 403,
    128             'message' => 'The provided nonce is invalid or expired. Please refresh and try again.'
    129         ));
    130     }
    131134
    132135    $api_key = esc_attr(get_option('cross_service_solutions_api_key'));
    133136    $id = sanitize_text_field($request['id']);
    134137
    135     $response = wp_remote_get("https://api.process-machine-stage.com/solutions/solutions/wordpress/{$id}", array(
     138    $response = wp_remote_get("https://api.cross-service-solutions.com/solutions/solutions/{$id}", array(
    136139        'headers' => array(
    137140            'Authorization' => 'Bearer ' . $api_key
  • merge-pdf/tags/1.0.2/includes/verification.php

    r3225930 r3311879  
    1717
    1818        // API request to verify the API Key
    19         $response = wp_remote_get('https://api.process-machine-stage.com/solutions/solutions/wordpress/organization', $args);
     19        $response = wp_remote_get('https://api.cross-service-solutions.com/solutions/solutions/wordpress/organization', $args);
    2020
    2121        if (is_wp_error($response)) {
  • merge-pdf/tags/1.0.2/readme.txt

    r3280591 r3311879  
    44Tags: pdf, merge, combine, pdf organization
    55Requires at least: 5.0
    6 Tested up to: 6.7
     6Tested up to: 6.8
    77Stable tag: 1.0.1
    88Requires PHP: 7.2
     
    9494== Changelog ==
    9595
     96= 1.0.2 =
     97* Updated verify and polling API endpoints
     98
    9699= 1.0.1 =
    97100* Implemented nonce validation for polling status GET request.
  • merge-pdf/trunk/includes/process-machine.php

    r3260511 r3311879  
    1313        'methods' => 'POST',
    1414        'callback' => 'cross_service_solutions_merge_pdf_on_submit',
    15         'permission_callback' => '__return_true',
     15        'permission_callback' => 'cross_service_solutions_merge_pdf_verify_nonce',
    1616    ));
    1717    register_rest_route('merge-pdf/v1', '/status/(?P<id>\d+)', array(
    1818        'methods' => 'GET',
    1919        'callback' => 'cross_service_solutions_merge_pdf_check_status',
    20         'permission_callback' => '__return_true',
     20        'permission_callback' => 'cross_service_solutions_merge_pdf_verify_nonce',
    2121    ));
    2222}
    2323add_action('rest_api_init', 'cross_service_solutions_merge_pdf_register_rest_api');
     24
     25function cross_service_solutions_merge_pdf_verify_nonce($request) {
     26    $nonce = $request->get_header('X-WP-Nonce');
     27
     28    // If not in header, try body
     29    if (!$nonce && isset($request['mergePDFFormNonce'])) {
     30        $nonce = sanitize_text_field($request['mergePDFFormNonce']);
     31    }
     32
     33    if (!$nonce || !wp_verify_nonce($nonce, 'merge_pdf_form_nonce_action')) {
     34        return false;
     35    }
     36
     37    return true;
     38}
    2439
    2540function cross_service_solutions_test_merge_pdf_api_callback() {
     
    2944// Handle form submission, then initiate processing
    3045function cross_service_solutions_merge_pdf_on_submit($request) {
    31     // Check if nonce is set and valid
    32     if (!isset($request['mergePDFFormNonce']) ||
    33        !wp_verify_nonce($request['mergePDFFormNonce'], 'merge_pdf_form_nonce_action')) {
    34        return new WP_Error('nonce_invalid', 'Nonce verification failed', array('status' => 403, 'message' => $request['mergePDFFormNonce']));
    35     }
    3646
    3747    $api_key = esc_attr(get_option('cross_service_solutions_api_key'));
     
    8797
    8898    // Make the API request using wp_remote_post
    89     $response = wp_remote_post('https://api.process-machine-stage.com/solutions/solutions/wordpress/30', array(
     99    $response = wp_remote_post('https://api.cross-service-solutions.com/solutions/solutions/wordpress/30', array(
    90100        'method'    => 'POST',
    91101        'body'      => $body,
     
    122132// Check status of processing task
    123133function cross_service_solutions_merge_pdf_check_status($request) {
    124     $nonce = $request->get_header('X-WP-Nonce');
    125     if (!$nonce || !wp_verify_nonce($nonce, 'merge_pdf_form_nonce_action')) {
    126         return new WP_Error('nonce_invalid', 'Nonce verification failed', array(
    127             'status' => 403,
    128             'message' => 'The provided nonce is invalid or expired. Please refresh and try again.'
    129         ));
    130     }
    131134
    132135    $api_key = esc_attr(get_option('cross_service_solutions_api_key'));
    133136    $id = sanitize_text_field($request['id']);
    134137
    135     $response = wp_remote_get("https://api.process-machine-stage.com/solutions/solutions/wordpress/{$id}", array(
     138    $response = wp_remote_get("https://api.cross-service-solutions.com/solutions/solutions/{$id}", array(
    136139        'headers' => array(
    137140            'Authorization' => 'Bearer ' . $api_key
  • merge-pdf/trunk/includes/verification.php

    r3225930 r3311879  
    1717
    1818        // API request to verify the API Key
    19         $response = wp_remote_get('https://api.process-machine-stage.com/solutions/solutions/wordpress/organization', $args);
     19        $response = wp_remote_get('https://api.cross-service-solutions.com/solutions/solutions/wordpress/organization', $args);
    2020
    2121        if (is_wp_error($response)) {
  • merge-pdf/trunk/readme.txt

    r3280591 r3311879  
    44Tags: pdf, merge, combine, pdf organization
    55Requires at least: 5.0
    6 Tested up to: 6.7
     6Tested up to: 6.8
    77Stable tag: 1.0.1
    88Requires PHP: 7.2
     
    9494== Changelog ==
    9595
     96= 1.0.2 =
     97* Updated verify and polling API endpoints
     98
    9699= 1.0.1 =
    97100* Implemented nonce validation for polling status GET request.
Note: See TracChangeset for help on using the changeset viewer.