Coder Social home page Coder Social logo

cliffordp / cliff-wp-plugin-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
72.0 72.0 24.0 1.32 MB

Cliff's WordPress plugin boilerplate

License: GNU General Public License v3.0

PHP 80.66% CSS 3.31% JavaScript 16.02%
autoloader boilerplate composer customizer-optionsettings hacktoberfest minified namespace parcel php postcss react shortcode shortcodes tailwindcss unminified wordpress wordpress-development wordpress-plugin wordpress-plugin-boilerplate wp-plugin

cliff-wp-plugin-boilerplate's People

Contributors

allcontributors[bot] avatar cliffordp avatar stefan2409 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cliff-wp-plugin-boilerplate's Issues

Implement setup script

The 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:

  • Could be a standalone PHP script that can be executed using something like ./bin/setup (ie, it would not depend on WP CLI nor would it be a Composer script)
  • It could validate that the plugin slug (for example) is a valid slug before performing search-and-replace
  • Could provide a final summary of the changes and a chance to bail out or make changes
  • It could run composer install at the end

Conceptually, what do you think—worthwhile/maybe useful but not sure/meh?

Implement strings utility library instead of our own

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:

  • contains
  • starts with
  • ends with
  • truncate

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.

Correct `bash` commands

  1. Correct the commands, offer an alternative or comprehensive instructions
  2. Can we consolidate the number of required replacements, or do we need to add some missing ones?

Create abstract class for adding a settings tab

Add starter for new Blocks, like Shortcodes

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/

Best practice for enqueue_scripts()

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?

Consider moving from Parcel to Webpack

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.

Proper namespace

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?

Other boilerplates to reference for inspiration

Create a 'renamer' / text replacement generator

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

Implement markdown parser to read readme.txt

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

Get away from `static` and other design/loading improvements

  • main plugin file class broken into separate file and require it
  • main plugin file shouldn't be all static
  • activation/deactivation hooks should not fire unless initial requirements are met (PHP version and required plugins)
  • Common should not have static and should get its setup data from Init, since it's already there
  • each class should be wrapped with an if class exists check

References:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.