Custom Search Function in WordPress Returns No Results

Here’s the right code I made a mistake with s param function custom_search_query($query) { if (!is_admin() && $query->is_main_query() && $query->is_search()) { $search_query = get_search_query(); // Retrieve the search query $api_url=”https://api.adenwalla.in/api/search/data”; $args = array( ‘body’ => json_encode(array(‘query’ => $search_query)), ‘headers’ => array(‘Content-Type’ => ‘application/json’), ‘timeout’ => 60 ); $response = wp_remote_post($api_url, $args); $body = wp_remote_retrieve_body($response); $results … Read more

Can plugin authors make db tables remain upon deactivation, but be removed upon plugin deletion?

Yes, there is a difference and it is possible for a plugin to know when it is deactivated or deleted. For deactivation the plugin may register a deactivation callback using register_deactivation_hook(). For deletion the plugin may either register a deletion callback using register_uninstall_hook() or include a uninstall.php file in its base folder. There’s an important … Read more

Webpack configuration for multiblock plugins behaves unexpectedly

Okay I found a quick and dirty solution for the viewScript. My webpack.config.js: /** * `@wordpress/scripts` path-based name multi-block Webpack configuration. * @see https://wordpress.stackexchange.com/questions/390282 */ // Native Depedencies. const path = require(“path”); // Third-Party Dependencies. const CopyPlugin = require(“copy-webpack-plugin”); const config = require(“@wordpress/scripts/config/webpack.config.js”); /** * Resolve a series of path parts relative to `./src`. * … Read more

Can I send a body using wp_remote_get()?

I think I’ve figured out the solution. The short answer is GET requests don’t usually have a body, but wp_remote_get() will take what one assigns to the body argument and make it into URL parameters. That’s why it expects an array (because each element of the array becomes a parameter added to the URL). One … Read more

add custom filter to plugins page?

you can do that with the help of 2 filters : add_filter(“plugins_list”, function ($plugins) { $filter_code = “with_b”; if ( isset($_GET[“plugin_status”]) && ($filter_code === $_GET[“plugin_status”]) ) { $GLOBALS[“status”] = $filter_code; // setting the filter to display in current page } // preparation of the plugins in the special category $plugins[$filter_code] = array_filter($plugins[“all”], function ($plugin) { … Read more

Install an external plugin from within the current plugin?

This solution should do the job for you. http://tgmpluginactivation.com/ The solution is meant for theme developers to package to download, automatically install and activate multiple plugins that are either packaged with a theme, downloaded from the WordPress Plugin Repository or downloaded elsewhere on the internet (perhaps a private repository. The code of the solution can … Read more