GithubHelp home page GithubHelp logo

tommcfarlin / namespaces-and-autoloading-in-wordpress Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 2.0 18 KB

[WordPress] A simple example of namespaces an autoloading used to demonstrate the concepts in a presentation at WordCamp Atlanta 2017.

License: GNU General Public License v3.0

PHP 100.00%
wordpress wordpress-plugin wordpress-development php namespaces autoloading wordcamp

namespaces-and-autoloading-in-wordpress's Introduction

Namespaces and Autoloading in WordPress

This plugin is a companion plugin to a talk given at WordCamp Atlanta 2017. It's explained in further detail in this article and this slide deck.

About This Plugin

Once you install the plugin and click activate, you should see two notices appear at the top of your administration screen.

There's no other functionality than this as its meant purely for the purposes of how to use namespaces and autoloading.

How It Works

  1. Upon activation, the plugin will display a message at the top of your administration screen.
  2. The messages that you should indicate the autoloader was successful in locating and loading the files.

Installation

Using The WordPress Dashboard

  1. Navigate to the 'Add New' Plugin Dashboard
  2. Select namespaces-and-autoloading-in-wordpress.zip from your computer
  3. Upload
  4. Activate the plugin on the WordPress Plugin Dashboard

Using FTP

  1. Extract namespaces-and-autoloading-in-wordpress.zip to your computer
  2. Upload the namespaces-and-autoloading-in-wordpress.zip directory to your wp-content/plugins directory
  3. Activate the plugin on the WordPress Plugins Dashboard

Changes

For information about changes related to the project, be sure to review the CHANGELOG.

More Information

The complete article for this plugin can be read on my blog.

namespaces-and-autoloading-in-wordpress's People

Contributors

tommcfarlin avatar

Stargazers

 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

namespaces-and-autoloading-in-wordpress's Issues

Autoloader finds files from other plugin

I tried using this autoloader on a plugin I'm working on, and besides loading the files from my plugin (when my classes are instantiated), the autoloader will include (and fail, but since it's using include_once instead of require_once there won't be an error thrown) other classes.

I have WooCommerce installed and I can see these files included:

public_html/wp-content/plugins/my_plugin/class-woocommerce.php
public_html/wp-content/plugins/my_plugin/class-wc-structured-data.php
public_html/wp-content/plugins/my_plugin/class-jetpack-omnisearch-posts.php
public_html/wp-content/plugins/my_plugin/class-wc-shortcodes.php

Which don't exist in my plugin ofc.

I tried adding a str_pos( 'my-plugin-slug', $fully_qualified_path ) check, but this fails for some reason.

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.