npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wptools/generator-plugin

v0.0.1

Published

The best way to start creating your WordPress plugin projects.

Downloads

8

Readme

banner

NPM version Build Status Dependency Status Coverage percentage Slack Chat

generator-wordpress-plugin

The best way to setup your WordPress custom plugins.

Installation

First of all, if you don't have it already installed on your system, install Yeoman using npm (we assume you have pre-installed node.js).

npm install -g yo

Than install the @wptools/generator-plugin generator globally on your system.

npm install -g @wptools/generator-plugin

Getting started

Now you have access to the generator through yeoman this mean you can generate new projects anywhere by typing:

yo @wptools/plugin

The generator will ask you some questions for setting the project configuration parameters and once is done the new project will be created.

Using subgenerators

Inside an existing project generated with this generator you can also use many sub generators to go further in the project base prototyping, let see some examples:

yo @wptools/plugin:metabox MyMetabox

Create a new metabox called "MyMetabox", the subgenerator take one argument which, in this case, is the class name of the metabox. You can use any name you want but it will fored to be capitalized CamelCase suffixed by "Metabox" or more generic, the subgenerator name, for generated class names, in order to follow common coding standards.

You have also other subgenerators, once it starts it will ask you some questions, based on the subgenerator context in order to customize the class and element rendering.

yo @wptools/plugin:shortcode MyShortcode
yo @wptools/plugin:widget MyWidget

The generator will also take care to update your plugin main class automatically to include the newly generated classes.


Generators

app

This is the default generator, once is called it will ask few questions and setup a working project for your WordPress Plugin. Depending on your answers the command can generate a grunt/gulp based project with sass, linters and a lot of features.

questions:

  • projectName: The unique name slug you want to use for this project. Default: <folder-name>
  • projectTitle: The title for your WordPress Plugin project. Default: <Folder Name>
  • projectDescription: The description of your project. Default: This is the <projectTitle> description.
  • projectManager: The build system you want to use for the project. Default: grunt
  • projectAuthor: The name of the project author. Default: <your-name>
  • projectLicense: The license under the project is developed and released. Default: ISC

Subgenerators

metabox

This command will create a metabox class inside the include/metabox/, than it will update the $metaboxes property on the main plugin class. The metabox template is based on WordPress Codex Metabox rules, for more information about the code please refer to it.

example: yo @wptools/plugin:metabox Test

shortcode

This command will create a shortcode class inside the include/shortcode/, than it will update the $shortcodes property on the main plugin class. The shortcode template is based on WordPress Codex Shortcode rules, for more information about the code please refer to it.

example: yo @wptools/plugin:shortcode Test

options:

| option | default | description | | --------- | ------- | ------------------------------------------------------ | | filter | false | Allow the shortcode attributes to be filtered | | enclosing | false | Create the shortcode as enclosing tag (enable content) |

widget

This command will create a widget class inside the include/widget/, than it will update the $widgets property on the main plugin class. The widget template is based on WordPress Codex Widget rules, for more information about the code please refer to it.

example: yo @wptools/plugin:widget Test

questions:

  • description: The description for the widget. Default: The [name] widget description.

dashwidget

This command makes very simple to add new widgets to the administration dashboard. Once is run it will create a dashwidget class inside the include/dashwidget/, than it will update the $dashwidgets property on the main plugin class. The dashwidget template is based on WordPress Codex Dashboard Widgets rules, for more information about the code please refer to it.

example: yo @wptools/plugin:dashwidget Test

toolbar

The Toolbar is an area of the screen just above the site that lists useful admininstration screen links such as add a new post or edit your profile. The Toolbar contains links to information about WordPress, as well as quick-links to create new posts, pages and links, add new users, review comments, and alerts to available updates to plugins and themes on your site.

This command will create a toolbar class inside the include/toolbar/, than it will update the $toolbars property on the main plugin class. The toolbar template is based on WordPress Codex Toolbar rules, for more information about the code please refer to it.

example: yo @wptools/plugin:toolbar Test

questions:

  • title: The title of the toolbar, that will be shown in the bar. Default: [name] Toolbar
  • hasChild: A boolean that decide if the toolbar is enabled for submenus. Default: true
  • childNumber: How many empty child submenu to create, only if hasChild is enabled. Default: 1

Development

Until the module it's not yet available as a global npm module. A global module may be created and symlinked to a local one, using npm.

Move inside the project folder and type:

npm link

That will install your project dependencies and symlink a global module to your local file. After npm is done, you'll be able to call yo @wptools/plugin

Contributing

  1. Create an issue and describe your idea
  2. Fork the project (https://github.com/codekraft-studio/generator-wordpress-plugin/fork)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Publish the branch (git push origin my-new-feature)
  6. Create a new Pull Request

License

Apache-2.0 © codekraft-studio


Getting To Know Yeoman

  • Yeoman has a heart of gold.
  • Yeoman is a person with feelings and opinions, but is very easy to work with.
  • Yeoman can be too opinionated at times but is easily convinced not to be.
  • Feel free to learn more about Yeoman.