The solution is setting a function that’s hooked into init.
add_action('init', 'stats_cookie');
function stats_cookie()
{
if(!isset($_COOKIE['site_stats']))
{
$current = current_time( 'timestamp', 1);
setcookie('site_stats', $current, time()+60+60*24*7, COOKIEPATH, COOKIE_DOMAIN );
}
}
Related Posts:
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- Is get_option function cached?
- How to include jQuery and JavaScript files correctly?
- How do I log plugin (cron) actions?
- How can I run AJAX on a button click event?
- Is there a hook for when you switch themes?
- Adding pre-publish checks with Gutenberg
- Problems after wp_set_password() containing an apostrophe
- Error getting correct blog_id on MU from functions.php
- How Do I Make WordPress Run an Event Every Day?
- Front-End Form Submission in Shortcode
- How to add SQL file with PHP to WordPress database [closed]
- Plugin Localization
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- array_map() for sanitizing $_POST
- calling jquery function on plugin page
- Is there a faster way than wp_insert_post to add content to a blog
- How to include external library in wordpress plugin
- Delete a specific item menu when I deactivate my plugin
- Ajax in WordPress – path issue
- Platform/Website that Supports Crowd-Funded WordPress Projects? [closed]
- Get user id for delete and update selected user
- Decrease RSS cache time in plugin?
- Add version query tag to all images
- Creating table with plugin is not working
- How to add a custom tag in contact form 7 and change the output in email?
- How to delete an user including data from custom database tables
- How can I create a plugin that changes the title color of a website?
- How to check if Woocommerce Order number equals to post ID?
- Add custom element ID depending where the widget place is, sidebar or footer
- Two functions utilizing registration_errors filter
- Issue plugin commands in admin settings page
- My plugin class doesn’t work! [closed]
- Call PHP file within a plugin to activate function
- add_action not calling back to function
- Example Dashboard Widget, Cancel not working
- Woocommerce checkout update totals with datepicker
- add_shortcode() not working inside of function
- How to add and remove a page
- correct way to call javascript into hook function
- Multiple options pages validation for a plugin
- “dashboard”-named PHP file doesn’t get included
- How to get plugin activate URL to use URL vars?
- rewrite URL based on selected taxonomy for post page
- Woocommerce – Convert Delivery method into a custom field
- Woocommerce Composite Products – Add a composite product to cart programmatically via ajax [closed]
- Add a page in admin without adding menu item
- Possible to get all posts with my shortcode?
- Plugin uninstall function is not working
- Loading custom js file on the admin page through plugin
- How to prevent someone from entering strings without making it available for translation?
- Add information to HTTP Header in WordPress Plugin
- What’s wrong with my usage of add_filter
- Moving/dragging a metabox removes TinyMCE’s content
- How can I develop a plugin that generates a page dynamically
- Catching Gutenberg sidebar switch event
- Redirect in WordPress plugin
- Converting data-name editor plugin to Gutenberg plugin
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Copied files from plugin to theme not working
- How can I allow the user to press enter without creating a new element in the editor?
- Forward an old url rewrite scheme to a new one?
- $wpdb in php 5.5
- how to display a string in admin_notices hook from a class plugin
- How to Find a Gallery’s ID
- WP 3.3 makes it possible to add meta box to Category Editor Screen?
- Will a plugin able to know is_user_logged_in?
- Widget instance options not showing correctly
- Access to the template file of a plug-in
- Can’t remove action hook on plugin class
- Bootstrap within shortcode
- How to make premium plugin? I want to limit it until verification
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- Undefined cache functions in my custom plugin
- How to direct WordPress to load custom template for custom post type
- get_the_tags doesn’t works?
- WordPress discards PNG file when uploading plugin file
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Nested Hooks with do_action for performance reasons – safe/necessary?
- Registration Forms
- Replace the WordPress Media Library Uploader
- My plugin showing “Are you sure you want to do this” on screen with a “Argument #2 is not an array in load.php’
- Cannot save settings value
- Is it possible to modify an Elated plugin portfolio-list template in such a way that it will not conflict with future plugin updates?
- Select field value not returned after saving changes
- WP Query Relations / Compare
- Displaying settings information in a table
- action callback, for action dispatched as reported by hook sniffer, not called
- variable created in page.php is null inside of header.php
- Access WordPress Tag Function From Modal
- how can I insert a link on login page
- Shortcode attribute “title” doesn’t appear in $atts array
- Insert plugin html content to a specific spot in the frontpage
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Reinitiate Gutenburg’s blocks using javascript
- Generating Multiple Divi Pages from Database
- Is it smart to require_once wp-admin/includes/plugin.php when you need only one function from it