variable endpoints for webservice

Ok, so it might have been working all along, and I just hadn’t flushed the rewrites! function my_dept_listing_init() { //Easy flush if (isset($_GET[‘flush’])) { flush_rewrite_rules(); } //endpoint onto which queries are made add_rewrite_endpoint( ‘individuals’, EP_PAGES ); //This filter acts as a controller, inject into content add_filter(‘the_content’, ‘my_dept_listing_content_ctrl’); } add_action(‘init’, ‘my_dept_listing_init’); function my_dept_listing_content_ctrl($content) { global $post; … Read more

GET web api method from a WordPress PHP script

wp_remote_get was causing the issue and switch over to a curl solution. The code below replaced my old solution: $serverIP = ‘x.x.x.x’; $serviceAPI = ‘/Get_VacationRequest’; $jsonData = urlencode(json_encode($_REQUEST)); // Set up the server information where we will consume the API $url=”http://” . $serverIP . $serviceAPI . ‘?name=” . $jsonData; // Start the curl session $curl … Read more

How to create REST Based JSON API(how to modify the code below)?

try this: if (isset($_GET[‘api’])) { if ($_GET[‘api’] == ‘json’ && isset($_GET[‘id’])) { $args = array( ‘p’ => $_GET[‘id’], ‘post_type’ => ‘any’// ID of a page, post, or custom type ); $query = new WP_Query($args); // $query is the WP_Query Object $post = $query->post; // $post contains the post object header(“content-type: application/json”); echo json_encode($post); } exit(); … Read more

WordPress Security tools

There are many precautions you can (and should) follow. Select good hosting/server. Set strong passwords for your hosting and FTP accounts. Don’t use servers that allow remote connections to the DB. If you want to host multiple sites on one server, make sure they’re separated (so one site can’t access files from other sites – … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)