You need to save the version to the database– aka. save it “as an option”– so that your script has a comparison case. That is, your script should…
- Check the database for a version number
- Compare that version number to the new version number– a variable or constant in your plugin file.
- Update things if need be
- Save the new version number to the database
If all you have is a constant in your .php file. It always matches, meaning it is pretty much useless for any automated updating. Of course, you can keep track of the plugin versions with just the constant, but the point of saving it to the database is to be able to automatically update things when needed.
As you say, if the plugin is simple enough it may not be necessary.
Related Posts:
- Performance of several get_option() calls
- Using Checkboxes on Plugin Options Page for Custom Plugin
- WordPress setting with select – where is my mistake?
- How to add new options to my WordPress plugin
- What could cause a WP Option to get truncated?
- update_option() passing empty array() but still updating
- Update option hook not firing
- WordPress plugin options page not saving options, no errors
- update_option with array_push adding mutiple copies
- Plugin forms overwrite each other’s options
- How to debug a plugin with Xdebug?
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Make Categories and Tags required in admin
- Getting wrong relationship value in $args in wp_Query?
- wp_schedule_event in a class
- custom XMLRPC method plus authentication of user & WooCommerce order
- Log in from one wordpress website to another wordpress website
- What’s the earliest point I can get the queried object ID?
- Custom admin_notices Messages Ignored During Redirects
- Show a user their recently viewed posts
- How is the data stored in the database?
- Is it save to require plugin.php early to be able to use get_plugin_data() earlier?
- How to prevent loading of all plugin’s resources?
- Unit Testing a Plugin functionality with cron
- Mediaelement.js feature doesn’t work
- Is it possible for a plugin to register a page template file?
- Best way for plugin to accept POSTs?
- What are the really difference writing WordPress 3.x widget plugins?
- Script to get a list of all images that are detached?
- Error “Call to a member function switch_to_locale() on null” during insert_with_markers
- multiple functions with same filter
- Calling plugins API within a theme
- How do you output enqueued scripts to an admin page?
- Woocommerce – Hide a Column in Cart Table
- Generate dynamic page through data from another page
- Does WordPress’s HTTP API use any caching?
- query users by role
- call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members
- How to Create Custom HTML Tag on Editor in `Text(HTML)` mode
- null callback in add_settings_section
- Comments do not respect display_name setting, how to make plugin to overcome this
- Is there a Filter that I can use to filter the tags before they are inserted in to the database?
- How long should it take for a plugin to fully load into the WordPress.org plugin repository?
- Which directory in my plugin repo does WordPress Plugin Directory package?
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- get post attachment using ajax
- Replace default Blogroll Links with Social Media Links
- How would you compose a complex plugin with lots of routes and functions? [closed]
- How to enqueue or include json file to a plugin
- Search and Filter
- Show error, when selecting image in WordPress media uploader if params mismatch
- Trying to code a simple plugin, infinite loop?
- Update own Plugin Repository on Multisite
- How to exit a plugin’s execution mid-stream?
- Issue with contextual help overwriting existing content
- Inserting code to HTML view from a pop up initiated from visual view
- CSS not affecting widget output
- Redeclaring a plugin function within a class
- Using a custom shortcode from within the template of a shortcode plugin
- What plugin development paradigm differences have occurred between version 3.5 and now?
- enqueue script/style plungin development
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- Error: Call to a member function get_error_code() on a non-object
- How to Add a Custom Size for Thumbnails for WP – Gallery
- How to get custom post_author?
- Will I get an error if I try unscheduling a WP Cron scheduled task that wasn’t scheduled?
- Conditional Generation of Image Sizes using add_image_size
- Plugins and caching
- Display time difference (6 hours ago) in a Soliloquy caption
- Empty Array is Giving Warning for array_merge()
- Is it possible to have instead mypage.com/?page_id=81 to have mypage.com/cool/?
- User Data Handling between two plugins
- wp.media Uncaught TypeError: Cannot read properties of undefined (reading ‘state’)
- Pass custom props to
- Translations only load from `wp-content/languages/plugins` but not from the plugin’s languages folder
- Woocommerce place order update shipping price
- GET request return value as error instead of success
- How to update global variables in plugin activation callback?
- How to include a page template and template part into my plugin
- WP_Fatal_Error_Handler OR WP_Error OR try/catch
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- ajax response strips multidimensional array and unable to decode
- Multiple instances of $opt_name in redux framework
- The Events Calendar featured image as body background?
- Pass javascript result to shortcode executer function
- How to affect front page by plugin
- Plugins and how to assign urls to content
- What method should I use to store my plugin data (multi level menus with options on each item)
- problem with blank page
- Getting error of unexpected output during activation
- Use custom clean URLs for a plug in
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- Select options not reloading after form submit
- first_name property missing inside register_user action hook
- Plugin SVN folder structure
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- how many rupee or dollar charge to client to make theme [closed]
- Load images from CDN and custom features to “Add Media” dialogue
- Saving metabox updates causing fatal error
- Calling get_header() with installed FSE theme