"; $added_to_front = $fipfcard_paypal->add_to_front( array( $pp_sdk_src, // 'js/paypal/result_message.js', // 'js/paypal/create_order.js', // 'js/paypal/on_approve.js', //"js/paypal/paypal.js", array("js/paypal/paypal.js", 'type'=>'module'), "html/paypal/paypal.html", ), ); return $added_to_front; } add_shortcode('fipf_paypal_shortcode', 'fipf_paypal_shortcode_content'); /** * the js file paypal.js needs to be imported as a module to use import * @see https://developer.wordpress.org/reference/hooks/script_loader_tag/ function fipf_add_id_to_script( $tag, $handle, $src ) { if ( $handle === 'PLGNTLS_paypal_js' ) { $tag = ''; } return $tag; } add_filter( 'script_loader_tag', 'fipf_add_id_to_script', 10, 3 ); */ // handling routes and endpoints // diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573 function fipf_routes_endpoints() { $base_rest_route = "fipf_plugin/api/v1"; register_rest_route($base_rest_route, '/orders', array( 'methods' => 'POST', 'callback' => 'fipf_handle_orders_request', )); // https://local_fipfcard_plugin.com/wp-json/fipf_plugin/api/v1/orders/21T129305J264761D/capture register_rest_route($base_rest_route, '/orders/(?P[a-zA-Z0-9]+)/capture', array( 'methods' => 'POST', 'callback' => 'fipf_handle_orders_capture_request', )); }; add_action('rest_api_init', 'fipf_routes_endpoints'); ?>