Disable woocommerce cookies and delete cart data automatically

Your code is expiring the session after 24 hours. You need to change your return value to reflect the number of hours (commented in the example below): add_filter(‘wc_session_expiring’, ‘so_26545001_filter_session_expiring’ ); function so_26545001_filter_session_expiring($seconds) { return 60 * 60 * 1; // Change “1” to the number of hours: 1 for 1 hour, 4 for 4 hours, … Read more

How to enqueue style in WordPress plugin from theme files?

IF I’m understanding your question correctly, what you want to do is enqueue scripts and stylesheets using a plugin the same way you do with a theme… …if that’s the case then it’s really not that different: function yourplugin_enqueue_frontend() { wp_enqueue_style( ‘yourplugin-front’, plugins_url( ‘yourplugin-front.css’, __DIR__ ), array(), ‘1.0’ ); wp_enqueue_script( ‘yourplugin-front’, plugins_url( ‘yourplugin-front.js’, __DIR__ ), … Read more

Create a new post using rest api and save featured image using an external image url

Instead of using wp_ajax_ (i.e. admin-ajax.php), how about adding a custom REST API field and then using its update_callback, download the remote image and set it as the post featured image? Working Example add_action( ‘rest_api_init’, ‘wpse_381217’ ); function wpse_381217() { register_rest_field( ‘post’, ‘featured_image_url’, array( // If you don’t want to expose the field in the … Read more

Issue with querying

As I said, your code seems ok, but I think you dont get the current user beforehand. Something like this works: $user = wp_get_current_user(); // get current user, to get the ID $posts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘shipments’, ‘meta_key’ => ‘customer_user_id’, ‘meta_value’ => $user->ID )); if( $posts ){ echo ‘<ul class=”shipment-posts-list”>’; foreach( … Read more

How to get plugin activate URL to use URL vars?

It turns out getting the URL on activation is not likely through the standard $_GET so WP has hooks for that. Plugin Activation I need to check for back up files stored in wp-content root, if they were created previously during de-activation or update, and copy to the plugin’s folder. register_activation_hook(__FILE__, function() { add_option(‘move_blocks_activated’,’move-blocks’); if( … Read more