Skip to content

Conversation

@kenwilliams-nu
Copy link
Contributor

@kenwilliams-nu kenwilliams-nu commented Aug 13, 2024

OVERVIEW

These changes enable this WordPress plugin to be updated through WP Admin, when a new version of the plugin is available in this repo. The plugin's code determines if a new version is available by checking a json manifest file, served from GitHub pages and updated when that file is updated in the main branch of this repo.

DETAILS

manifest/info.json - This file contains information about the plugin, including the version and a URL for the associated release zip file. The json file is published to a GitHub page when changes are pushed to the branch. The plugin code checks this GitHub page to determine if a new version is available, to populate information about the update in the WP Admin plugin manager, and perform the update when triggered by the user.

.nojekyll - The presence of this file in root bypasses Jekyll processing on the GitHub page build, as no theming is needed given that we are just serving a json file.

nu_global_elements.php - Added a class to check for plugin updates (by checking the info.json manifest file hosted on GitHub pages, as described above), display information about the update in the WP Admin plugin manager, and perform the update when triggered by the user. For a detailed description of how the code works, see this article. I also added two constants, defined at the top of the file, for ease of changing the version number and json manifest URL. Note that the plugin version must be changed both in the comment at the top of the file, and the NU_GLOBAL_ELEMENTS_PLUGIN_VER constant. I also added the if (!defined('ABSPATH')) { exit; } line to keep the plugin from being run outside of WordPress.

README.md - Updated information in the readme.

I've tested this new update functionality locally and on the BC dev server an it works (you can test by manually reducing the version in the code of the installed plugin). Right now the json manifest file is published to a GitHub page when changes are pushed to this branch, but I will change that to the main branch once these changes are ready to be merged to main.

@kenwilliams-nu kenwilliams-nu added the enhancement New feature or request label Aug 13, 2024
@kenwilliams-nu kenwilliams-nu self-assigned this Aug 13, 2024
Copy link
Contributor

@raymondkingston raymondkingston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, man!

Copy link

@CeeRoo CeeRoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, Ken!

Copy link
Contributor

@cam-vanorman cam-vanorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you-are-awesome
🎉 🍻 🥳

Nice work, Ken!

@kenwilliams-nu kenwilliams-nu merged commit a66e821 into main Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants