• This repository has been archived on 24/Sep/2019
  • Stars
    star
    453
  • Rank 96,246 (Top 2 %)
  • Language
    PHP
  • Created about 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A WordPress plugin skeleton built using object-oriented principles and the MVC pattern.

WordPress Plugin Skeleton

The skeleton for an object-oriented/MVC WordPress plugin.

Features

  • Clean and organized
  • Designed with object-oriented principles
  • Implements the Model-View-Controller pattern
  • Includes basic classes for:
    • Custom post type and taxonomies
    • A settings page
    • Extra user profile fields
    • WP-Cron jobs
  • Includes examples of common functionality
    • Single and network-wide activation
    • Upgrade routine
    • Shortcodes
    • CSS/JavaScript enqueing
    • Input validation, output sanitization
    • Custom hooks for extensibility
    • JavaScript event handlers
    • A test suite for unit testing with SimpleTest
  • Includes render_template(), a wrapper for rendering view files that allows other plugins and themes to easily modify or completely override the view.

Notes

Installation

  • cd /var/www/vhosts/example.com/content/plugins
  • git clone --recursive https://github.com/iandunn/WordPress-Plugin-Skeleton.git plugin-slug
  • cd plugin-slug
  • git remote rm origin
  • git rm README.md
  • Update bootstrap.php headers
  • Reset version number to 0.1
  • Find/replace class names/slugs
  • git mv files to match class slugs
  • Comment out references to classes that aren't needed now. Delete ones that will never be needed.
  • Rename generic comments, method names, etc to describe their specific implementations.
  • If you're not using a custom post type or something else that updates the rewrite rules, you can comment out the flush_rewrite_rules() call in WordPresPluginSkeleton::activate() and ::deactivate().
  • For unit testing, install SimpleTest for WordPress and use a shortcode like this: [simpletest name="WordPress Plugin Skeleton Unit Test Suite" path="/wordpress-plugin-skeleton/tests/wpps-test-suite.php"]

New Code Checklist

  • Security
    • Input validation for domain correctness and security.
    • Output sanitization when sending untrusted data to browser.
      • All data should be considered untrusted.
      • Escape hardcoded data to future-proof.
    • Pass any manual SQL queries through $wpdb->prepare().
    • Add/check nonces for logged in users when submitting forms and AJAX requests.
    • Make sure current user is authorized to perform the action with current_user_can().
    • If added any kind of custom auth scheme, try to think how you could get around it, then protect against those methods.
  • Add custom actions and filters
  • Write unit and integration tests
  • Throw/catch exceptions when encountering invalid conditions.

License

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

More Repositories

1

wp-cli-rename-db-prefix

A WP-CLI command to rename WordPress' database prefix
PHP
103
star
2

wp-cli-plugin-active-on-sites

A WP-CLI command to list all sites in a Multisite network that have activated a given plugin
PHP
39
star
3

admin-notice-helper

Helps WordPress plugins and themes display messages/errors to the user within the Admin Panels
PHP
33
star
4

regolith

A WordPress installation template that's a little bit looser than Bedrock
PHP
23
star
5

compassionate-comments

WordPress plugin that encourages authors of toxic comments to re-phrase them to be more kind instead.
JavaScript
20
star
6

no-build-tools-no-problems

Experiment building a WordPress-centric React app without any build tools (ES6 + HTM).
JavaScript
13
star
7

quick-navigation-interface

Quickly access screens and content within wp-admin by typing the first few letters of the name.
JavaScript
10
star
8

WordPress-Functionality-Plugin-Skeleton

The skeleton for a WordPress functionality plugin
PHP
9
star
9

dotfiles

A central repository to store my personal config/settings for distribution across multiple systems
Shell
7
star
10

audit-trail-extension

[No longer maintained] Provides a framework for adding custom events to the Audit Trail plugin for WordPress
PHP
5
star
11

wp-filemaker-api-wrapper

[No longer maintained] Makes it easier for WordPress plugins and themes to connect to FileMaker databases via the official API or FX.PHP
PHP
2
star
12

game-of-life

Conway's Game of Life, in React, just for fun
1
star
13

time-blocker

Rough WIP for a JS app to block time the way I want to, which existing apps don't do well
JavaScript
1
star
14

publish-iandunn-2017

A child theme of kovshenin/publish for iandunn.name
CSS
1
star
15

wordcamp-remote-css-test

Tests for https://make.wordpress.org/community/2015/11/24/remote-css-plugin-launched-on-wordcamp-org/
CSS
1
star
16

password-confirm-action

Prompts the user for their password whenever they try to perform an action which could be used by an attacker to escalate privileges or engineer future access.
PHP
1
star
17

cash-flow-rebalancing-calculator

Calculator for rebalancing investment portfolios using the cash flow strategy.
JavaScript
1
star
18

Scratch

[No longer maintained] My personal WordPress starter theme, written from scratch
PHP
1
star
19

deep-work-timer

A minimal, unintrusive, and low-effort timer to help focus on deep work & flow state and resist distractions.
HTML
1
star