All Projects → tommcfarlin → simple-autoloader-for-wordpress

tommcfarlin / simple-autoloader-for-wordpress

Licence: LGPL-3.0 License
An autoloader that aims to be as simple as dropping it into your WordPress project. All you need is a well-organized project.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to simple-autoloader-for-wordpress

benenson
A Gutenberg WordPress theme
Stars: ✭ 70 (-20.45%)
Mutual labels:  wordpress-development
gin
Foundation of the Tonik WordPress Starter Theme. Provides all custom functionalities which it offers.
Stars: ✭ 29 (-67.05%)
Mutual labels:  wordpress-development
WordPress-UIkit-Starter-Theme
A WordPress starter theme for developers using the frontend framework UIkit
Stars: ✭ 55 (-37.5%)
Mutual labels:  wordpress-development
wp-skeleton
Setup a new WordPress installation via Composer
Stars: ✭ 36 (-59.09%)
Mutual labels:  wordpress-development
dudestack
A toolkit for creating a new professional WordPress project with deployments. Originally based on Roots/bedrock.
Stars: ✭ 82 (-6.82%)
Mutual labels:  wordpress-development
starter-kit-theme
WordPress starter theme with a modern development stack for launching projects faster and easily
Stars: ✭ 25 (-71.59%)
Mutual labels:  wordpress-development
nginx-virtual-host-bash-script
Nginx Virtual Host Bash Script
Stars: ✭ 35 (-60.23%)
Mutual labels:  wordpress-development
WpGet-Private-wordpress-plugin-repository
Wordpress private repository for plugins
Stars: ✭ 24 (-72.73%)
Mutual labels:  wordpress-development
wp-optimize
The WP Optimize class provides a wrapper to optimize WordPress and remove unnecessary or unwanted functions and scripts.
Stars: ✭ 37 (-57.95%)
Mutual labels:  wordpress-development
wp-boilerplate-plugin-with-vuejs
This is an example plugin for Wp plugin developer.
Stars: ✭ 26 (-70.45%)
Mutual labels:  wordpress-development
air
A hyper-minimal WordPress starter theme for developers built with Tailwind CSS.
Stars: ✭ 45 (-48.86%)
Mutual labels:  wordpress-development
wordpress
📚 Recursos para aprender WordPress
Stars: ✭ 20 (-77.27%)
Mutual labels:  wordpress-development
untheme
A blank WordPress theme for developers.
Stars: ✭ 82 (-6.82%)
Mutual labels:  wordpress-development
WPKirk
A WP Bones skeleton Plugin
Stars: ✭ 28 (-68.18%)
Mutual labels:  wordpress-development
local-wordpress-development
WordPress Local Web Development Guide for Mac OS X
Stars: ✭ 17 (-80.68%)
Mutual labels:  wordpress-development
UpGulp
A Gulp Starter for your WordPress project
Stars: ✭ 29 (-67.05%)
Mutual labels:  wordpress-development
Inactive-Logout
Development copy from the WordPress repository. Will release here first.
Stars: ✭ 19 (-78.41%)
Mutual labels:  wordpress-development
eightshift-docs
A documentation website for Eightshift open source projects
Stars: ✭ 44 (-50%)
Mutual labels:  wordpress-development
wpaudit.site
An easy to use checklist to optimize your WordPress website.
Stars: ✭ 24 (-72.73%)
Mutual labels:  wordpress-development
wp-phpunit
WordPress core PHPUnit library. [READ ONLY] Versions for new WordPress releases are built daily.
Stars: ✭ 65 (-26.14%)
Mutual labels:  wordpress-development

Simple Autoloader for WordPress

An autoloader that aims to be as simple as dropping it into your WordPress project. All you need is a well-organized project.

More Information

TL;DR: An autoloader you can drop into a WordPress plugin and begin using it automagically.

In 2017, I gave a talk at WordCamp Atlanta about the importance of using Namespaces and Autoloading in WordPress.

Though for many projects, we can't adopt many of the new features of PHP7+, that doesn't mean can't use best practices when working on plugins and other projects.

I have a very simple autoloader that I'm sharing in this repository that I hope the greater (and smarter!) WordPress developers at large will contribute to improving.

Getting Started

This particular section is for those who want to use the autoloader. If you're looking to contribute to the codebase, please see the section below.

  1. Clone or download this repository.
  2. Copy the lib directory into the root of your project.
  3. Add include_once 'lib/autoload.php' to your main plugin file.

An Example

This autoloader expects several things:

  1. You're following the WordPress Coding Standards as it relates to naming your classes.
  2. The structure of your namespaces follows the structure of your directory structure

I've provided an example below for how both your code and your directory should be organized to take advantage of the autoloader.

The Code

Let's say you have a plugin and one of the files contains the following namespace:

namespace Pressware\API;

And it's using a class in another namespace:

use Pressware\Utility\Files\Reader;

The autoloader expects that the root namespace defined in your main plugin file to be:

namespace Pressware

The Directory Structure

And that all of the rest of the files are located in a directory structure like this:

+ plugin-name
|
|   API
|       ...
|       ...
|
|   Utility
|       ...
|
|   Files
|       class-reader.php
|       ...
|
|   plugin-bootstrap.php

Adding The Autoloader

Then, at the top of your plugin file add the following:

require_once 'lib/autoload.php';

This can work alongside another other autoloaders (such as those that come with Composer) and will prevent you from needing to add require_once or include_once all over the state of your application.

Other Information

If you're interested in contributing, reading more, and or following changes (all of which is welcome), please read below.

  • The project is licensed GPL.
  • If you're interested in contributing, please read this document.
  • See the CHANGELOG for a complete list of changes.

Oh yeah? Watch this!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].