Still under active development? And how to get started? #59
-
I just came across Underpin, and it seems like a dream come true for Wordpress plugin development. I've been bashing my head over how unintuitive everything is in WP, and I love how smooth and object-oriented Underpin seems to make everything. But it looks like with the upgrade to v3.0, the main readme was gutted, and there's not much info regarding how to actually set up a new plugin with underpin. So far I've been able to figure out that I needed to maybe drop the plugin boilerplate directly into my mu-plugins directory (https://github.com/Underpin-WP/underpin)? But also that I could maybe just include it in a single plugin rather than as a sitewide must-use plugin (#42)? I tried both, and I'm just trying to test it out by setting up a new custom post type with the appropriate loader, but nothing seems to happen. <?php
/*
Plugin Name: Plugin Name Replace Me
Description: Plugin Description Replace Me
Version: 1.0.0
Author: An awesome developer
Text Domain: plugin_name_replace_me
Domain Path: /languages
Requires at least: 5.1
Requires PHP: 7.0
Author URI: https://www.designframesolutions.com
*/
use Underpin\Abstracts\Underpin;
if (!defined('ABSPATH')) {
exit;
}
// Load Underpin, and its dependencies.
$autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php';
require_once($autoload);
/**
* Fetches the instance of the plugin.
* This function makes it possible to access everything else in this plugin.
* It will automatically initiate the plugin, if necessary.
* It also handles autoloading for any class in the plugin.
*
* @since 1.0.0
*
* @return \Underpin\Factories\Underpin_Instance The bootstrap for this plugin.
*/
function plugin_name_replace_me()
{
return Underpin::make_class([
'root_namespace' => 'Plugin_Name_Replace_Me',
'text_domain' => 'plugin_name_replace_me',
'minimum_php_version' => '7.0',
'minimum_wp_version' => '5.1',
'version' => '1.0.0',
])->get(__FILE__);
}
// Lock and load.
plugin_name_replace_me();
plugin_name_replace_me()->custom_post_types()->add('test_post_type', [
'type' => 'test_post_type', // see register_post_type
'args' => [
'name' => _x('Test Post Types', 'Post Type General Name', 'text_domain'),
'singular_name' => _x('Test Post Type', 'Post Type Singular Name', 'text_domain'),
'menu_name' => __('Test Post Types', 'text_domain'),
'name_admin_bar' => __('Test Post Type', 'text_domain'),
], // see register_post_type
]); What am I doing wrong here? And thank you so much for this! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @harmolipi - Sorry, you've kind-of caught me in the midst of a transition, here. Yep, this is still very much in active development (I just issued a new release a few days ago). I'm in the midst of refactoring this to be less-opinionated, while still remaining super useful. The short-term simplest thing to-do in the mid-term is to downgrade to use Underpin 2.1.0. It all works quite well, I just realized that I don't always want to write plugins using this pattern and wanted to expand the functionality to be able to work on different platforms, as well as with different paradigms. It works well if that's the pattern you want to use, and WordPress code doesn't change often enough that there's any concerns that it will become incompatible in the future. This tutorial can show you how to set that up. The newer version has loads of nice things, and I have been using it on personal projects using this boilerplate, but I haven't drawn a line in the sand to put it all together and make it cohesive yet. I just haven't found the time to do it. I gutted the readme because none of it was true at the moment (although, I really should add a note in the readme to downgrade to 2.1.0 if you're wanting to use the older approach). |
Beta Was this translation helpful? Give feedback.
Hey @harmolipi - Sorry, you've kind-of caught me in the midst of a transition, here.
Yep, this is still very much in active development (I just issued a new release a few days ago). I'm in the midst of refactoring this to be less-opinionated, while still remaining super useful.
The short-term simplest thing to-do in the mid-term is to downgrade to use Underpin 2.1.0. It all works quite well, I just realized that I don't always want to write plugins using this pattern and wanted to expand the functionality to be able to work on different platforms, as well as with different paradigms. It works well if that's the pattern you want to use, and WordPress code doesn't change often enough that t…