// ================================ // Custom REST API endpoint for updating Rank Math SEO fields via n8n // ================================ add_action('rest_api_init', function () { register_rest_route('rankmath/v1', '/update-meta', array( 'methods' => 'POST', 'callback' => 'update_rankmath_meta_from_n8n', 'permission_callback' => '__return_true', // Secured by secret key )); }); function update_rankmath_meta_from_n8n(WP_REST_Request $request) { $secret_key = 'Mx8P@9qk#12Zr'; // Change to your own strong key // Security check if ($request->get_header('x-secret-key') !== $secret_key) { return new WP_REST_Response(array('error' => 'Unauthorized'), 401); } $post_id = intval($request->get_param('post_id')); $title = sanitize_text_field($request->get_param('title')); $description = sanitize_text_field($request->get_param('description')); $keywords = sanitize_text_field($request->get_param('keywords')); if (!$post_id) { return new WP_REST_Response(array('error' => 'Post ID required'), 400); } // Update Rank Math fields if (!empty($title)) { update_post_meta($post_id, 'rank_math_title', $title); } if (!empty($description)) { update_post_meta($post_id, 'rank_math_description', $description); } if (!empty($keywords)) { update_post_meta($post_id, 'rank_math_focus_keyword', $keywords); } return new WP_REST_Response(array( 'success' => true, 'post_id' => $post_id, 'title' => $title, 'description' => $description, 'keywords' => $keywords ), 200); } Laptop/Desktop Encryption: Keeping Your Data Safe and Secure - What is Encryption and How Does it Keep Your Data Safe?| Protect and Secure Data on Your Laptop| Data Protection Tips: Keeping Personal Info Safe| Desktop and Laptop Security| Use laptop encryption to protect mobile data| 11 practical ways to keep your IT systems safe and secure
Home System Service Laptop/Desktop Encryption: Keeping Your Data Safe and Secure

Menu

Subscribe to EchoPx

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

Copyright © 2024 | Website Developed by EchoPx.com

error: Content is protected !!