WP Rest API and json_decode()

wp_remote_get return array of results containing keys body, headers, response etc depending on arguments. And json_decode only accept JSON string. So correct your code in this way //return if not an error if ( ! is_wp_error( $response ) ) { //decode and return return json_decode( wp_remote_retrieve_body( $response ) ); } Ref: Return Values of wp_remote_get … Read more

How (or where) do I get wordpress plugin update download link?

The latest plugin update information is available by print_r(get_site_transient(‘update_plugins’)); or if you want to filter out wordpress.org plugins and make it more readable… $pluginupdates = get_site_transient(‘update_plugins’); foreach ($pluginupdates->response as $pluginupdate => $values) { if (!stristr($values->package,’wordpress.org’)) { echo “Plugin Name: “.$values->slug.” — “; echo “Update Package: “.$values->package.”<br>”.PHP_EOL; } } Of course, this will just return blank … Read more

Plugin upgrade failing during unzip

The name of the temporary file created by the download_url function is 118 characters long. The length of this is causing the full path name of some files or directories created during the unzip process to be longer than the allowable length on Windows. Therefore an error is thrown and the plugin upgrade fails. I … Read more

How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?

Try adding return false; to prevent the default submit action of the click. $(‘.grp_getnew’).on(‘click’, function(){ var data = { action: ‘get_random_post_tu’, usecategory: $(‘#categoryselect’).val() }; $.post( ajax_object.ajax_url, data, function(response) { if ( response.status != ‘error’ ) { var $link = $(“<a href=”” + response.link + “”>” + response.title + “</a><span >” + response.content +”</span>”); $(‘.grp_content’).html($link); } … Read more

wp_get_http has been deprecated. Use WP_Http instead

WP_Http is a: Core class used for managing HTTP transports and making HTTP requests. so it should most likely be this link: https://developer.wordpress.org/reference/classes/wp_http/ instead of: https://developer.wordpress.org/reference/functions/WP_Http that redirects you to: https://developer.wordpress.org/reference/functions/wp_http_supports/ Then there are wrappers like wp_remote_get(), wp_remote_post(), wp_safe_remote_get(), wp_safe_remote_post(), wp_remote_retrieve_response_code(), download_url(), … etc, that makes it easier to use. Check out e.g. the HTTP … Read more

Creating an admin meta box to save post as pending

The reason your code does not work is that the if-statement checking isset( $_POST[‘wp_cfc_save_meta_box’]) never evaluates to true. Your code generating the submit button, <?php submit_button( __( ‘Save as Pending’ ), ‘secondary button-large’, ‘Publish’, false ); ?> yields the following HTML: <input type=”submit” name=”Publish” id=”Publish” class=”button button-large” value=”Save as Pending” /> WordPress’ submit_button function takes … Read more