Coder Social home page Coder Social logo

dmhendricks / wordpress-base-plugin Goto Github PK

View Code? Open in Web Editor NEW
85.0 12.0 21.0 1.19 MB

A starter template for WordPress plugins, with autoloading, namespaces and object caching (where available).

License: GNU General Public License v2.0

JavaScript 17.79% PHP 77.41% CSS 4.80%
wordpress wordpress-plugin carbon-fields wordpress-boilerplate wordpress-plugin-boilerplate wordpress-plugin-development wordpress-base-plugin multisite wordpress-network

wordpress-base-plugin's People

Contributors

dmhendricks 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

wordpress-base-plugin's Issues

Required PHP Version

Hey man,

just a quick hint. In your composer.json you require "php": ">=5.3.29". But in multiple files you're using PHP's short array syntax [ 'value' ], which is available from PHP 5.4+.

Gutenberg solution

In case anyone needs to add Gutenbergs blocks to the plugin:

  1. Create the folder "Gutenbergs".
  2. Create a file inside: Gutenbergs_Loader.php
  3. Create a file inside: MyGutenberg.php
  4. Change Plugin.php file.

Gutenbergs_Loader.php content:

<?php

namespace VendorName\PluginName\Gutenbergs;
use VendorName\PluginName\Plugin;

class Gutenbergs_Loader extends Plugin
{
	public function __construct()
	{
		new MyGutenberg();
	}
}

MyGutenberg.php content:

<?php

namespace VendorName\PluginName\Gutenbergs;
use VendorName\PluginName\Plugin;
use Carbon_Fields\Block;
use Carbon_Fields\Field;

class MyGutenberg extends Plugin {

  public function __construct() {
CARBON FIELDS BLOCK CODE

  }
}

https://docs.carbonfields.net/learn/containers/gutenberg-blocks.html

Plugin.php content
// Load Gutenbergs new Gutenbergs\Gutenbergs_Loader(); at load_plugin()

Remove closing PHP Tag

In wordpress-base-plugin.php is the closing tag ?> used. I learnt that this is bad practice and should be avoided.

Different project vision?

Hi,

thank you first off all for inviting me as collaborator. I appreciate that. As you already saw I forked the project and worked on some own ideas. The reason why I did not send a pull request is, I have the feeling we have different ideas how things should be built. I don't say my style is better than your's but different. So before I join forces, I would like to see how this thing might work out.

My Idea / Vision

I would like to build nice boilerplate plugin, which implements current best practices (from the PHP world not only WordPress) and is ready to run and has some example code already on board. But I guess this not the main issue because your repo already goes in that direction ๐Ÿ‘

Design Decisions

The things that keep me thinking are different design decisions. Based on my last issues, I conclude we do things differently. And so I would like hear what you think about some ideas I implemented on my fork.

  1. I added a more granular project structure with more directories (PostTypes/, Shortcodes/, 'Widgets/`)
  2. One files holds only one class (see WdigetLoader and ExampleWidget)
  3. I added a ShortcodeLoader according to WidgetLoader. And to make things more OOP I also added an interface ShortcodeInterface to make sure every shortcodes follows the some structure
  4. I use webpack with Laravel Mix as wrapper
  5. I like to separate compiled files from assets. I renamed assets/ to resources/ and all compiled files are placed in public/. (This is how Laravel does it)
  6. I will use WPUpdatePHP
  7. I require PHP 5.6+, because this is the oldes but supported php version. Although I code in PHP 7 most of the times
  8. Your idea with the $settings variable in Plugin is nice, but I would go a step further an decouple that from that class and introduce a registry.

These are the things I changed so far. What do you think?

plugin prefix on multiple plugin installation

Hi ,
I don't know if im doing something wrong, but I edit and installed the pluggin twice, in the same wordpress installation.
I did all the steps in the Documentation, Installing carbon field with composer in both of them.
both have a custom posttype with custom fields created with carbon fields.
but the fields in the second plugin are saved with a wrong prefix . Both custom posts, from two different plugins, get the same prefix for theirs metas.
if I deactivate the first plugin, the other plugin gets fixed, and its custom fields are saved right.

Thanks!

Use WPUpdatePHP to check for PHP Version

Add PHP Check wpupdatephp/wp-update-php.

I like to use WPupdatePHP in my plugins, because I thinks it is good practice to inform the user if their PHP version does not fit my requirements.

Especially useful, when PHP 7 is used in a Plugin.

Path issue on windows

When installing on a windows machine, I'm getting this error:

Warning: fopen(C:\Users\admin\Code\CES-Wordpress-Base\wp-content\plugins\CES-Client/CES-Client/CES-Client.php): failed to open stream: No such file or directory in C:\Users\admin\Code\CES-Wordpress-Base\wp-includes\functions.php on line 4835

This folder doesn't exist:
C:\Users\admin\Code\CES-Wordpress-Base\wp-content\plugins\CES-Client/CES-Client/

Plugin is installed at
C:\Users\admin\Code\CES-Wordpress-Base\wp-content\plugins\CES-Client/

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.