Skip to content
🚀 Write, edit and organize your code from your WordPress dashboard.

Back-End Code (PHP) ​

Add your own action hooks, filters, web services, apps, and other features to your back-end.

✨ Example - JSON Web Service ​

This example creates a web service that runs a query on the csv_demo_products table and returns the data in JSON format.

Similar functionality can be implemented using the WordPress REST API. (Read more...)

Code Manager - Back-End Code

Code ​

php
<?php

if ( ! function_exists('products_web_service') ) {
	
	function products_web_service() {
		header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
		header("Cache-Control: post-check=0, pre-check=0", false);
		header("Pragma: no-cache");
		header("Content-Type: application/json");

		global $wpdb;
		wp_send_json_success( $wpdb->get_results('select * from csv_demo_products') );

		wp_die();
	}

	add_action( 'wp_ajax_code_manager_products_web_service', 'products_web_service' );
	add_action( 'wp_ajax_nopriv_code_manager_products_web_service', 'products_web_service' ); // Add this to authorize anonymous users
	
}

?>

Usage ​

URL pattern to use the provided web service.

http(s)://your-domain.com/wp-admin/admin-ajax.php?action=code_manager_products_web_service

Output ​

Output for the provided web service in a browser.

Code Manager - Back-End Code