now we can add attributes to js files using the tools class
This commit is contained in:
@@ -11,7 +11,8 @@ function fipfcard_plugin_content() {
|
||||
$fipfcard = new PLGNTLS_class();
|
||||
|
||||
echo $fipfcard->add_to_front( array(
|
||||
"js/menu/example_menu.js",
|
||||
array("js/menu/example_menu.js", 'type'=>'module'),
|
||||
"js/menu/example_menu_2.js",
|
||||
"html/menu/example_menu.html",
|
||||
));
|
||||
}
|
||||
@@ -27,7 +28,7 @@ ajax
|
||||
- to access the content of the data object properties of the ajax call :
|
||||
use $_POST['property_name']
|
||||
*/
|
||||
function fipfcard_ajax_handler()
|
||||
function fipfcard_menu_fetch_handler()
|
||||
{
|
||||
return new WP_REST_Response('hello', 200);
|
||||
}
|
||||
@@ -35,7 +36,7 @@ function fipfcard_menu_endpoint()
|
||||
{
|
||||
register_rest_route('plgntls', '/get_data', array(
|
||||
'methods' => 'POST',
|
||||
'callback' => 'fipfcard_ajax_handler',
|
||||
'callback' => 'fipfcard_menu_fetch_handler',
|
||||
));
|
||||
};
|
||||
add_action('rest_api_init', 'fipfcard_menu_endpoint');
|
||||
|
||||
@@ -59,7 +59,8 @@ function fipf_paypal_shortcode_content()
|
||||
// 'js/paypal/result_message.js',
|
||||
// 'js/paypal/create_order.js',
|
||||
// 'js/paypal/on_approve.js',
|
||||
"js/paypal/paypal.js",
|
||||
//"js/paypal/paypal.js",
|
||||
array("js/paypal/paypal.js", 'type'=>'module'),
|
||||
"html/paypal/paypal.html",
|
||||
),
|
||||
);
|
||||
@@ -71,7 +72,6 @@ function 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 = '<script type="module" src="' . esc_url( $src ) . '" ></script>';
|
||||
@@ -79,6 +79,7 @@ function fipf_add_id_to_script( $tag, $handle, $src ) {
|
||||
return $tag;
|
||||
}
|
||||
add_filter( 'script_loader_tag', 'fipf_add_id_to_script', 10, 3 );
|
||||
*/
|
||||
|
||||
|
||||
// handling routes and endpoints
|
||||
|
||||
Reference in New Issue
Block a user