cliffordp / cliff-wp-plugin-boilerplate Goto Github PK
View Code? Open in Web Editor NEWCliff's WordPress plugin boilerplate
License: GNU General Public License v3.0
Cliff's WordPress plugin boilerplate
License: GNU General Public License v3.0
.wordpress-org
directoryThe readme lists a number of areas in which a search and replace should be performed. I think it could be handy to have a script that guides users through this:
./bin/setup
(ie, it would not depend on WP CLI nor would it be a Composer script)composer install
at the endConceptually, what do you think—worthwhile/maybe useful but not sure/meh?
https://laravel.com/docs/master/helpers --> https://packagist.org/packages/laravel/helpers requires PHP 7.1.3
===
https://packagist.org/packages/symfony/string requires PHP 7.2.5
===
https://github.com/PHLAK/Twine requires PHP 7.2
===
https://github.com/phpfunct/funct seems to cover it all for both strings and arrays (re: #87) but isn't actively maintained.
Strings:
One thing missing from this library is to add prefix while accounting for it possibly existing already (and same for suffix): phpfunct/funct#47
===
https://packagist.org/packages/voku/stringy requires PHP 7.0, has all the string functions, and is actively maintained
So that's why we chose this one.
Review those available from https://github.com/beberlei/assert and implement without including that library, since there's already quite a bit of overlap with WP's built-ins as well as Stringy
https://github.com/Seldaek/monolog to replace/enhance /src/common/utilities/class-debug.php
References:
Consider using https://github.com/micropackage/requirements instead of TGMPA
Would have to play with it to see how error messages are sent.
https://github.com/afragen/wp-dependency-installer is another alternative.
Consider implementing https://github.com/micropackage/filesystem because it is helpful for getting our plugin path and url and is a wrapper for https://developer.wordpress.org/reference/classes/wp_filesystem_base/#methods
This custom control isn't fully finished - look for the TODOs, like here:
https://github.com/phpfunct/funct seems to cover it all for both strings and arrays but isn't actively maintained.
https://github.com/voku/arrayy is from a trusted source but doesn't seem to add the value we're aiming for.
Arrays:
Re: /inc/core/class-deactivator.php
if a wp-admin settings screen were to support tabs
https://deliciousbrains.com/create-wordpress-plugin-settings-page/ is great
or use a library like:
Make it as easy to create new Blocks as it is to create new Shortcodes, such as https://github.com/cliffordp/cliff-wp-plugin-boilerplate/blob/1a6c0f6dfcba5bc1ddf2773ad72c365df51d1d7b/src/shortcodes/class-tk_request.php
Idea (but maybe not ideal): Convert all of our shortcode's arguments to become Blocks (with fields) by adding custom parameters that create both a shortcode and a block.
Related: https://make.wordpress.org/core/2020/03/02/general-block-editor-api-updates/
I've used the boilerplate to create a custom plugin to track user engagement analytics on live streamed video assets. included in the plugin within the /public directory are some fairly robust JavaScripts that mesh with a webhook from the stream provider and a AJAX call to track real time player events.
It's my understanding that these scripts added to the enqueue_scripts() function in the public/class-plugin-name-public.php run on every single page in the rather vast WP site I'm intending to deploy it on. This seems inefficient and rather insecure...
What's best practice as far as only getting the scripts to run on specific pages...for instance, making a custom theme template and only applying that template file to a page containing video assets?
Make rendering / getting HTML more atomic without much overhead, plus allowing overriding via child theme. Plus for shortcodes to use as well.
Options:
Should also require method names to be prefixed with shortcode_
Inspiration: https://matthewhorne.me/defer-async-wordpress-scripts/
Would be best if WordPress implements this itself, though: https://core.trac.wordpress.org/ticket/12009
Same goes for SRIs:
We're already using Parcel (see #55), and it's working nicely, but WP uses Webpack so maybe we should, too:
Let's build things via Weback to compare not only the ease of use but also the file size of the resulting built files.
Investigate if multiple plugins including the same package from Composer causes any issues. If yes, consider these:
Please consider using proper namespaces.
namespace Company\WordPress\PluginName;
// e.g.
namespace AcmeLabs\WordPress\Mnemonic;
// then
namespace AcmeLabs\WordPress\Mnemonic\Frontend;
What do you think?
Maybe as a Command Line argument when creating project
Like this one: https://github.com/BracketSpace/Notification-Extension-Boilerplate/blob/master/rename.sh
The idea is that there would be a 'texts' JSON/YAML/etc file (ideally a format that allows comments). You set it and, when you run the 'texts' command, it does its replacements.
Ideally, it could run the replacement command over and over, not just the initial time, in case there was a typo or such... might require keeping start/end boundaries (like curly braces) to find them again and again to be replaced... but then that would require the build command to remove such boundaries/placeholders... Maybe the placeholders stay permanently there but then the build command does the string replacements. I think I like that idea the best 🤔
Related to #64
Idea is to be able to parse the plugin's readme.txt
so we could get things like the long description or the changelog. Just a nice-to-have.
https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#markdown
The readmes use a customized version of Markdown. Most Markdown calls work as expected.
Good choice if using Composer: https://github.com/erusev/parsedown - nothing specific to WP's flavor of markdown but MIT license
Good reference with some extra functionality (possibly same as / close to WP's markdown flavor): https://github.com/Automattic/jetpack/tree/master/_inc/lib/markdown - but not using a standardized license: https://github.com/michelf/php-markdown#copyright-and-license
https://github.com/danielguillan/bem-constructor might be great
/inc/frontend/views/
should either be included within class-frontend.php
or the views
directory should be removed
For things not supported by Composer or some other embedded code.
https://github.com/micropackage/cache can be good for transients and such
If SCRIPT_DEBUG
, set a JS/CSS file's version to time()
instead of the plugin version number for cache busting's sake
require
itstatic
static
and should get its setup data from Init, since it's already thereReferences:
https://flintci.io/docs#composernormalize to help keep Composer sane
https://github.com/tareq1988/wp-eloquent seems to be the only drop-in to consider, if to include at all
For simplicity and/or succinctness, let's consider:
And these libraries:
https://developer.wordpress.org/plugins/plugin-basics/best-practices/#boilerplate-starting-points
Does the comment on \WP_Plugin_Name\WP_Plugin_Name::$init
do what it says?
Reference: https://carlalexander.ca/singletons-in-wordpress/
Would make things a bit more flexible
https://github.com/julien731/WP-Review-Me exists for .org but optionally link elsewhere
Whether on our own or via an existing library:
For possible inclusion:
For inspiration:
Could use http://tgmpluginactivation.com/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.