You should use wp_localize_script()
after enqueuing your JS file that calls the countdown
method. I’m assuming you stored the date in an option called date_name
like January 1, 2015 13:30:00
.
In your case, you are storing it as an array with month, day, year, and time in the correct format
, so you should convert it to the January 1, 2015 13:30:00
format.
wp_enqueue_script( 'jsfilename' );
$stored_date = get_option( 'date_name', 'default value' );
// process stored date so that it gets to the January 1, 2015 13:30:00 format
$date_options = array( 'mydate' => $stored_date );
wp_localize_script( 'jsfilename', 'dateopts', $date_options );
Then in your JS file, you call:
$('.live-countdown').countdown({ date: dateopts.mydate });
Related Posts:
- What’s the best method for emptying an option created with the Settings API?
- How to add a new plugin page under desired Options page?
- Unified Approach for Placing Option Pages
- WordPress plugin options and jQuery
- How to localize data array in plugin’s option page
- Menu_slug used for creating options page
- framework for plugin/theme options panel? [closed]
- How to add a javascript snippet to the footer that requires jQuery
- Is get_option function cached?
- How to include jQuery and JavaScript files correctly?
- Update Option Stored in Multi-Dimensional Array
- Where to store plugin settings fields
- How Do I Use jQuery UI In My Plugin
- Remove profile picture option (and other things) from profile.php (in admin)
- Admin settings update updating every time home page is hit?
- WordPress updates defined vs add_filter?
- Creating Settings Page with dropdowns for Plugin
- Test to see if jQuery or Prototype is queued by another plugin?
- jQuery in header or footer
- Hook the Keydown Event in the TinyMCE Post Editor
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- Add a jQuery function to admin pages
- wp_localize_script $handle
- Naming Admin Menus and Submenus
- Help adding image upload functionality to widget
- Why won’t register_setting() create a setting?
- Multiple entries in get_option results? or why is _multiwidget set to 1?
- update_option_{$option} Too Few Arguments
- Using Ajax call in jQuery doesn’t work in widget
- How to add Font Awesome 5 icons in WP Admin dashboard menu?
- WP_LOCALIZE_SCRIPT doesn’t work
- Use of global variables within plugin [closed]
- array_map() for sanitizing $_POST
- Can I use the different settings sections over different pages using the save options group?
- Options API – Validation Callback $input is NULL
- Ajax in WordPress – path issue
- Best choice of options/settings framework for plugin/theme development
- Correct way check nonce (security) using old Options API
- OOP Plugin and Menu – Call to undefined function register_setting()
- How to store a medium amount of options?
- Loading jQuery and jQuery plugin script files correctly [duplicate]
- WordPress setting with select – where is my mistake?
- Custom delete option button in plugin settings
- Global State During an Admin Post
- How To Change Post Author Default?
- Sub Menu content is being duplicated
- Editing options pages?
- Multiple options pages validation for a plugin
- Set different custom menu items for different user roles
- is it recommended to use WP_List_Table?
- get_option() not returning expected value from plugin
- javascript datatables in a plugin
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Add a page in admin without adding menu item
- Hide shortcodes “code” when using the “editor” the same as wordpress do with “gallery”
- Access bloginfo, get_option, and plugins_url from a non-core php file
- get_option() will not work without access to wp-config.php
- Silently register plugin pages
- should i be checking for jquery before enqueing it in a plugin
- jQuery instantly executes (a button click and css change) on load
- WordPress theme options Menu
- Make Database query only when option is updated
- Unable to get a simple plugin admin page to work
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- ajax working when function is on child theme but not in plugin page
- Problem with display data from get_option
- why does get_option( ‘home’ ) not work while using in plugin [closed]
- sanitizing/escaping plugin options
- Pause plugin option page until all data manipulation is complete
- Using jQuery prepend() with file include
- Add multiple checkboxes as single field to Custom Shipping Method Settings Page
- escape html in jQuery for WordPress
- Jquery php request is returning a weird result
- Query String Filtering API
- update_option() passing empty array() but still updating
- jQueryUI draggable doesn’t work in WordPress plugin
- WordPress Jquery with heade and footer sritp plugin
- wp_ajax add_action fuction won’t fire on custom jQuery action
- Plugin setting page – update_option problem
- Filterable posts using categories
- Ajax Response Error | just getting error as the response
- mutiple shortcode instance on the same page
- WordPress function is not called and ajax return 0
- How can I add the Post ID to Class Name in Jquery?
- Add a description/hint field in the admin page of a plugin
- Can’t switch theme after activation
- Forcing ALL plugin Admin menus into a separate menu
- How do I build a settings panel under the plugin
- How do I call the dashboard’s sortable javascript in a plugin page?
- update_option() updating the option with an empty value?
- Plugin admin list pages as submenu
- Add_menu_page and saving settings
- Change Admin menu placement using hooks
- Plugin options page – save two related options as one entry
- Saving multiple fields as array
- Page reload occurs before request finishes
- How to design WooCommerce-like admin tabs for plugin settings page?
- Settings API not Saving to Database or Display
- How to get the value entered in the input field in wordpres
- How to access Elementor-navigation-elements via jQuery