How get Themes list via REST api?

You can write your own endpoint and use wp_get_themes to get a list of themes via that. Here is a simple one: add_action( ‘rest_api_init’, function () { //Path to rest endpoint register_rest_route( ‘theme_API/v1’, ‘/get_theme_list/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘theme_list_function’ ) ); }); // Our function to get the themes function theme_list_function(){ // Get … Read more

How to Hit External REST POST API in WordPress? [closed]

WordPress has several functions for sending requests via PHP, including wp_remote_post(), which you can use to send a POST request to an API. Then you can use wp_remote_retrieve_body() to handle the response. It would look something like: $response = wp_remote_post( ‘http://example.org/api’ ); $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); If you need to interact … Read more

Advanced Integration – WordPress + YOURLS

I would probably go about this way: The plugin has a function called: wp_ozh_yourls_send_tweet($tweet); as you can see it accepts the tweet message and posts it to twitter, also it has another function called: wp_ozh_yourls_geturl( $post_id ); which accepts a post id and returns a shorturl as string. so after knowing that I would use … Read more

How to get title tag of an external page with http api?

here is a function i have for that: function get_page_title($url){ if( !class_exists( ‘WP_Http’ ) ) include_once( ABSPATH . WPINC. ‘/class-http.php’ ); $request = new WP_Http; $result = $request->request( $url ); if( is_wp_error( $result ) ) return false; if( preg_match(“#<title>(.+)<\/title>#iU”, $result[‘body’], $t)) { return trim($t[1]); } else { return false; } } Usage: $title = get_page_title(‘http://www.google.com’); … Read more

Custom routing for plugins

The WordPress Way of doing it is using query_vars so first you add you vars to the array: //add to query vars function add_query_vars($vars) { $new_vars = array(‘custom_method’,’cm_parameter’); $vars = $new_vars + $vars; return $vars; } add_filter(‘query_vars’, ‘add_query_vars’); then you can check in your plugin for the vars: global $wp; if (array_key_exists(‘custom_method’, $wp->query_vars) && isset($wp->query_vars[‘custom_method’])){ … Read more

API for Post Stats for Self-Hosted WordPress using JetPack [closed]

There is indeed a Stats API that will allow you to access stats from a WordPress.com or a Jetpack site. You can read more about it here: http://stats.wordpress.com/csv.php http://phoxis.org/2011/04/24/wordpress-com-stats-api/ http://wpgr.org/2013/03/02/rendering-jetpack-stats/ Jetpack uses this API to populate the Top Posts widget: http://plugins.trac.wordpress.org/browser/jetpack/tags/2.5/modules/widgets/top-posts.php#L223

How to check if WordPress is updating plugins?

Instead of re-ordering your plugins to load in a specific order, have each of them that requires some other plugin to be loaded to defer their initialization until the “plugins_loaded” action hook. In other words, when a plugin with a dependency is included and ran, it shouldn’t do anything directly. Instead, it should have functions, … Read more