$wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once
$wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once
$wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once
WordPress Action Hook inside Classes
Overwrite WordPress Plugin Class Function
Its likely due to the WordPress load process. Plugins are not all loaded at once. It’s possible that when you in the constructor phase on one plugin the other plugin is not yet loaded. This means you need to “hook” into the “init” of WordPress and check your function or class exists before running your … Read more
So you’re trying to call the hide_empty_fields() and maybe_add_disclaimer_and_courtesy() methods in the Register_Impress_Shortcodes class, from within a global function, and it’s not impossible to call class methods from within such global functions, but you cannot use $this in your function because $this is only available from within a class method which is called from within … Read more
Sometimes it takes asking a question to find out the answer. function my_attachment_grid() { $args = [ ‘post_type’ => ‘attachment’, ]; add_filter( ‘post_query_args’, ‘my_filter’, 10, 1 ); do_grid( ‘post’, $args ); } function my_filter( $args ) { $defaults = [‘post_status’=>’inherit’]; $args = array_merge( $args, $defaults ); return $args; }
That’s a very good question. It goes down to the dark heart of the plugin API and best programming practices. For the following answer I created a simple plugin to illustrate the problem with easy to read code. <?php # -*- coding: utf-8 -*- /* Plugin Name: Anonymous OOP Action */ if ( ! class_exists( … Read more
How to get data with Select AJAX PHP
This is a perfect use case for Transients. In WordPress, transients are short-lived data objects. By default, they’re persisted to the database using WordPress’ built-in WP_Object_Cache object. However, you can use a variety of caching plugins (Batcache is an outstanding one that works with Memcached) to store Transients in memory. To set a transient, call … Read more
Function not being called on form submit, only blank admin-post.php page