Prevent plugin from intruding on wp-json posts api

Basically what you would want is to disable the RPWE widget whenever a request is made through the API. I haven’t tested it, but this might work: add_action (‘widgets_init’, ‘wpse332374_remove_rpwe’, 0, 1000) // make sure this is the last action function wpse332374_remove_rpwe() { if (is_rest()) unregister_widget (‘recent_post_widget_extended’); // or whatever the handle is } Note … Read more

SQL query, error

You have the where clause of the query in the wrong place. Your query should be written like this: $query= “SELECT * FROM files WHERE custom > 0 ORDER BY id DESC LIMIT $from, $site”; As specified here https://dev.mysql.com/doc/refman/8.0/en/select.html in the MySQL reference.

correct sql query

You should use prepare only when you’re using SQL query – this function takes query and params and returns a safe SQL query filled with given params. Its result is a SQL query. So you can (and should) use it whenever you’re creating a SQL query and put some params in it. With $wpdb->delete or … Read more

Issue running db create table query from static method

plugin_dir_url() returns the URL directory path for your plugin, so this won’t work as expected (the function won’t be called): register_activation_hook(plugin_dir_url(__FILE__) . ‘frequentVisitorCoupons.php’, ‘Utilities::createTablesIfNotExists’); You should have used plugin_dir_path() which returns the file-system directory path for your plugin (e.g. /var/www/public/<user>/wp-content/plugins/your-plugin/). But if the code is in the main plugin file, then you could simply use … Read more

correct validate and sql query

What you’re doing is safe. However, some notes: See the WP_User_Query class in the Codex. This is the, “official,” way to do something like this, although you’ll get an integer-indexed array of WP_User objects. Instead of the ARRAY_A that you’ve specified. You probably don’t want _my_table, unless your table is called something like wp__my_table (note … Read more

Multisite – maximum number of users with specific role

Ok here is how I did it: add_action( ‘editable_roles’ , ‘hide_editable_roles’ ); function hide_editable_roles( $roles ){ $blog_id = get_current_blog_id(); // Get current subsite id switch($blog_id) { // Define different max agents numbers depending on subsite id case 6: $max_agents = 10; //for subsite id#6 we can have maximum 10 agents break; case 7: //for subsite … Read more