Override plugin constant using a theme

You won’t be able to replace it at all if the plugin is not checking whether the constant has already been defined using if ( defined( ‘MAX_THINGS’ ) ). By definition constants can’t be overwritten, so this check is necessary to make a value ‘pluggable’. Adding @ to define() will suppress the error but it … Read more

Sanitizing, Validating , etc (Plugin)

You should check the Plugin Security section in the plugin developer’s handbook. 1) Data Must be Sanitized, Escaped, and Validated Validation – These are the checks that are run to ensure the data you have is what it should be. For instance, an e-mail looks like an e-mail address, that a date is a date, … Read more

How do I set register_meta for a specific CPT?

register_post_meta has a post type parameter, or just set object_subtype to the post type. register_meta( ‘post’, ‘_duib_cl_heading’, [ ‘auth_callback’ => ‘__return_true’, ‘default’ => __( ”, ‘_duib_cl_heading’ ), ‘show_in_rest’ => true, ‘single’ => true, ‘type’ => ‘string’, ‘object_subtype’ => ‘testimonial’, ] ); Or register_post_meta( ‘testimonial’, ‘_duib_cl_heading’, [ ‘auth_callback’ => ‘__return_true’, ‘default’ => __( ”, ‘_duib_cl_heading’ ), … Read more

Store large dataset in WordPress installation temporary

Transient names are limited to 172 characters; the data held in a transient can be much, much larger. set_transient() documentation Under the hood, transients are stored in the same table as options, and some WordPress code manages their lifetimes and expiry. You should easily be able to store 1MB of data in a transient. Autoloading … Read more