PHP header() not available to use in my plugin

You see that error because something is sending output (even space characters) before the header-location command. The error message tells you where the output is coming from. To fix, you’d have to edit that file – not a wise choice to edit core files, because the next update will overwrite your changes. Assuming your plugin … Read more

Comparing Dates within plugin using PHP If statement

$current_date is a timestamp and $compare_date is a formatted date, so you’re comparing different things. As you’re already using DateTime and as of PHP 5.2.2 DateTime objects can be compared using comparison operators, you can compare instead $expired_date (DateTime object) with today’s date as a DateTime object: $current_date = new DateTime(); $expired = new DateTime(); … Read more

How to get option values without requiring wp-load?

You could use Hooks , If you wish to print some styles in head just try add_action(‘wp_head’, ‘test_123’); function test_123(){ $options = get_option(‘option’); //Output it however you want 🙂 ob_start(); ?> <style type=”text/css” id=”someStyleInHead”> body.home{ font-size: <?php echo $options[‘fs_h’]; ?>; } </style> <?php $code = ob_get_clean(); echo $code; } I hope it help 🙂

How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]

The same way you would in any other HTML form <input type=”text” name=”name[]” /> <input type=”text” name=”email[]” /> <input type=”text” name=”name[]” /> <input type=”text” name=”email[]” /> <input type=”text” name=”name[]” /> <input type=”text” name=”email[]” /> The above will give you arrays instead of singular values in PHP, so $_POST[‘name’] is an array of 3 values. The … Read more

how to retrieve post_id under woocommerce_add_to_cart_validation hook?

woocommerce_add_to_cart_validation passes the product id as the second argument to the callback function, so you can access it like this: function custom_fields_validation( $passed_validation, $product_id ) { if( isRecurring( $product_id ) ) { if ( empty( $_POST[‘inputday’]) ){ wc_add_notice( __( ‘Please select field 1;’, ‘woocommerce’ ), ‘error’ ); return false; } if ( empty( $_POST[‘inputtime’] )){ … Read more