jQuery Ajax passing empty parameters to my function?

The values are not passed as parameters, but passed in the $_POST array. You need to add nonce for security using check_ajax_nonce https://developer.wordpress.org/reference/functions/check_ajax_referer/ You need to sanitize values submitted before inserting into database Here’s how this should be done: add_action( ‘wp_ajax_send_projectmessage’, ‘send_projectmessage’ ); function send_projectmessage() { global $wpdb; check_ajax_referer( ‘send_projectmessage’, ‘send_projectmessage_nonce’ ); $projectid = sanitize_text_field( … Read more

How to add WP API and JS featured image attachment

I manage to solved it by adding this code (at the bottom) to the YOUR BLOG THEMES my path : wp-content/themes/twentysixteen/function.php: function ws_register_images_field() { register_rest_field( ‘post’, ‘images’, array( ‘get_callback’ => ‘ws_get_images_urls’, ‘update_callback’ => null, ‘schema’ => null, ) ); } add_action( ‘rest_api_init’, ‘ws_register_images_field’ ); function ws_get_images_urls( $object, $field_name, $request ) { $medium = wp_get_attachment_image_src( get_post_thumbnail_id( … Read more

Sending jsPDF documents to the server

Keep in mind not everyone is running JavaScript, so you really need a server-side form processor like PHP rather than relying solely on jQuery. Best thing to do on a WordPress site is create a plugin that processes your form. You can include helper libraries like FPDF to not only generate the PDFs but that … Read more

Put CSS inside a PHP file and include it the right way

You might try conditional classes instead. In your regular “style.css” file you would include both classes: .theme-header-title.green { color:green; } .theme-header-title.blue { color:blue; } (Tip 1: avoid !important, just use a more specific style if needed – for example, h1.theme-header-title.green.) Then in your HTML, which is likely in your “header.php” file, you’d use the Customizer … Read more

How to make custom total price reactive in navigation

Using woocommerce woocommerce_add_to_cart_fragments filter you can do that. Going by the id attribute that you currently have for the span that displays the cart total, you can use the following code add_filter(‘woocommerce_add_to_cart_fragments’, ‘bt_update_cart_total’); function bt_update_cart_total ($fragments) { $fragments[‘#order-total-price’] = ‘<span id=”order-total-price”>’ . WC()->cart->get_cart_subtotal() . ‘</span>’; return $fragments; } Add this code to your functions.php file … Read more

trying to use wp_handle_upload with ajax

You need to include a few files to get wp_handle_upload to work, and i have a function just for that : function My_wp_handle_upload($file_handler,$overrides) { // check to make sure its a successful upload if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false(); require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); $upload = … Read more