This repository has been archived by the owner on May 2, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checking in the plugin scaffold from project-scaffolds
- Loading branch information
Dave Ross
committed
Mar 16, 2018
0 parents
commit 0a2e375
Showing
13 changed files
with
439 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "10up/tenup-plugin-scaffold", | ||
"description": "Project Description", | ||
"authors": [ | ||
{ | ||
"name": "Author", | ||
"email": "email@10up.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"TenUpThemeScaffold\\": "includes/classes/" | ||
} | ||
}, | ||
"require-dev": { | ||
"10up/wp_mock": "dev-dev" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
namespace TenUp\dmr\Core; | ||
|
||
/** | ||
* Default setup routine | ||
* | ||
* @uses add_action() | ||
* @uses do_action() | ||
* | ||
* @return void | ||
*/ | ||
function setup() { | ||
$n = function( $function ) { | ||
return __NAMESPACE__ . "\\$function"; | ||
}; | ||
|
||
add_action( 'init', $n( 'i18n' ) ); | ||
add_action( 'init', $n( 'init' ) ); | ||
|
||
do_action( '<%= funcPrefix %>_loaded' ); | ||
} | ||
|
||
/** | ||
* Registers the default textdomain. | ||
* | ||
* @uses apply_filters() | ||
* @uses get_locale() | ||
* @uses load_textdomain() | ||
* @uses load_plugin_textdomain() | ||
* @uses plugin_basename() | ||
* | ||
* @return void | ||
*/ | ||
function i18n() { | ||
$locale = apply_filters( 'plugin_locale', get_locale(), '<%= funcPrefix %>' ); | ||
load_textdomain( '<%= funcPrefix %>', WP_LANG_DIR . '/<%= funcPrefix %>/<%= funcPrefix %>-' . $locale . '.mo' ); | ||
load_plugin_textdomain( '<%= funcPrefix %>', false, plugin_basename( <%= funcPrefix.toUpperCase() %>_PATH ) . '/languages/' ); | ||
} | ||
|
||
/** | ||
* Initializes the plugin and fires an action other plugins can hook into. | ||
* | ||
* @uses do_action() | ||
* | ||
* @return void | ||
*/ | ||
function init() { | ||
do_action( '<%= funcPrefix %>_init' ); | ||
} | ||
|
||
/** | ||
* Activate the plugin | ||
* | ||
* @uses init() | ||
* @uses flush_rewrite_rules() | ||
* | ||
* @return void | ||
*/ | ||
function activate() { | ||
// First load the init scripts in case any rewrite functionality is being loaded | ||
init(); | ||
flush_rewrite_rules(); | ||
} | ||
|
||
/** | ||
* Deactivate the plugin | ||
* | ||
* Uninstall routines should be in uninstall.php | ||
* | ||
* @return void | ||
*/ | ||
function deactivate() { | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "tenup-plugin-scaffold", | ||
"version": "1.0.0", | ||
"description": "Project Description", | ||
"main": "index.js", | ||
"author": { | ||
"name": "10up", | ||
"email": "info@10up.com", | ||
"url": "https://10up.com", | ||
"role": "developer" | ||
}, | ||
"scripts": { | ||
"test": "phpunit" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://project-git-repo.tld" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<phpunit | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
processIsolation="false" | ||
colors="false"> | ||
<testsuites> | ||
<testsuite name="Default"> | ||
<directory suffix="Tests.php">./tests/phpunit</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./includes</directory> | ||
</whitelist> | ||
</filter> | ||
<php> | ||
<ini name="error_reporting" value="32767" /> | ||
<ini name="display_errors" value="1" /> | ||
<ini name="display_startup_errors" value="1" /> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Plugin Name: <%= projectTitle %> | ||
* Plugin URI: <%= projectHome %> | ||
* Description: <%= description %> | ||
* Version: 0.1.0 | ||
* Author: <%= authorName %> | ||
* Author URI: <%= authorUrl %> | ||
* Text Domain: <%= funcPrefix %> | ||
* Domain Path: /languages | ||
*/ | ||
|
||
/** | ||
* Built using yo wp-make:plugin | ||
* Copyright (c) 2015 10up, LLC | ||
* https://github.com/10up/generator-wp-make | ||
*/ | ||
|
||
// Useful global constants | ||
define( '<%= funcPrefix.toUpperCase() %>_VERSION', '0.1.0' ); | ||
define( '<%= funcPrefix.toUpperCase() %>_URL', plugin_dir_url( __FILE__ ) ); | ||
define( '<%= funcPrefix.toUpperCase() %>_PATH', dirname( __FILE__ ) . '/' ); | ||
define( '<%= funcPrefix.toUpperCase() %>_INC', <%= funcPrefix.toUpperCase() %>_PATH . 'includes/' ); | ||
|
||
// Include files | ||
require_once <%= funcPrefix.toUpperCase() %>_INC . 'functions/core.php'; | ||
|
||
|
||
// Activation/Deactivation | ||
register_activation_hook( __FILE__, '\TenUp\<%= namespace %>\Core\activate' ); | ||
register_deactivation_hook( __FILE__, '\TenUp\<%= namespace %>\Core\deactivate' ); | ||
|
||
// Bootstrap | ||
TenUp\<%= namespace %>\Core\setup(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
=== <%= projectTitle %> === | ||
Contributors: <%= authorName %> | ||
Donate link: <%= authorUrl %> | ||
Tags: | ||
Requires at least: 4.9 | ||
Tested up to: 4.9 | ||
Stable tag: 0.1.0 | ||
|
||
<%= description %> | ||
|
||
== Description == | ||
|
||
|
||
|
||
== Installation == | ||
|
||
= Manual Installation = | ||
|
||
1. Upload the entire `/<%= basename %>` directory to the `/wp-content/plugins/` directory. | ||
2. Activate <%= projectTitle %> through the 'Plugins' menu in WordPress. | ||
|
||
== Frequently Asked Questions == | ||
|
||
|
||
== Screenshots == | ||
|
||
|
||
== Changelog == | ||
|
||
= 0.1.0 = | ||
* First release | ||
|
||
== Upgrade Notice == | ||
|
||
= 0.1.0 = | ||
First Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* <%= projectTitle %> | ||
* <%= projectHome %> | ||
* | ||
* Copyright (c) <%= new Date().getFullYear() %> <%= authorName %> | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* <%= projectTitle %> | ||
* <%= projectHome %> | ||
* | ||
* Copyright (c) <%= new Date().getFullYear() %> <%= authorName %> | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
if ( ! defined( 'PROJECT' ) ) { | ||
define( 'PROJECT', __DIR__ . '/../includes/' ); | ||
} | ||
|
||
if ( ! defined( '<%= funcPrefix.toUpperCase() %>_DIR' ) ) { | ||
define( '<%= funcPrefix.toUpperCase() %>_DIR', __DIR__ . '/' ); | ||
} | ||
|
||
// Place any additional bootstrapping requirements here for PHP Unit. | ||
if ( ! defined( 'WP_LANG_DIR' ) ) { | ||
define( 'WP_LANG_DIR', 'lang_dir' ); | ||
} | ||
if ( ! defined( '<%= funcPrefix.toUpperCase() %>_PATH' ) ) { | ||
define( '<%= funcPrefix.toUpperCase() %>_PATH', 'path' ); | ||
} | ||
|
||
if ( ! file_exists( __DIR__ . '/../vendor/autoload.php' ) ) { | ||
throw new PHPUnit_Framework_Exception( | ||
'ERROR' . PHP_EOL . PHP_EOL . | ||
'You must use Composer to install the test suite\'s dependencies!' . PHP_EOL | ||
); | ||
} | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
require_once __DIR__ . '/../tests/phpunit/test-tools/TestCase.php'; | ||
|
||
WP_Mock::setUsePatchwork( true ); | ||
WP_Mock::bootstrap(); | ||
WP_Mock::tearDown(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
namespace TenUp\<%= namespace %>\Core; | ||
|
||
/** | ||
* This is a very basic test case to get things started. You should probably rename this and make | ||
* it work for your project. You can use all the tools provided by WP Mock and Mockery to create | ||
* your tests. Coverage is calculated against your includes/ folder, so try to keep all of your | ||
* functional code self contained in there. | ||
* | ||
* References: | ||
* - http://phpunit.de/manual/current/en/index.html | ||
* - https://github.com/padraic/mockery | ||
* - https://github.com/10up/wp_mock | ||
*/ | ||
|
||
use TenUp\<%= namespace %> as Base; | ||
|
||
class Core_Tests extends Base\TestCase { | ||
|
||
protected $testFiles = [ | ||
'functions/core.php' | ||
]; | ||
|
||
/** | ||
* Test load method. | ||
*/ | ||
public function test_setup() { | ||
// Setup | ||
\WP_Mock::expectActionAdded( 'init', 'TenUp\<%= namespace %>\Core\i18n' ); | ||
\WP_Mock::expectActionAdded( 'init', 'TenUp\<%= namespace %>\Core\init' ); | ||
\WP_Mock::expectAction( '<%= funcPrefix %>_loaded' ); | ||
|
||
// Act | ||
setup(); | ||
|
||
// Verify | ||
$this->assertConditionsMet(); | ||
} | ||
|
||
/** | ||
* Test internationalization integration. | ||
*/ | ||
public function test_i18n() { | ||
// Setup | ||
\WP_Mock::wpFunction( 'get_locale', array( | ||
'times' => 1, | ||
'args' => array(), | ||
'return' => 'en_US', | ||
) ); | ||
\WP_Mock::onFilter( 'plugin_locale' )->with( 'en_US', '<%= funcPrefix %>' )->reply( 'en_US' ); | ||
\WP_Mock::wpFunction( 'load_textdomain', array( | ||
'times' => 1, | ||
'args' => array( '<%= funcPrefix %>', 'lang_dir/<%= funcPrefix %>/<%= funcPrefix %>-en_US.mo' ), | ||
) ); | ||
\WP_Mock::wpFunction( 'plugin_basename', array( | ||
'times' => 1, | ||
'args' => array( 'path' ), | ||
'return' => 'path', | ||
) ); | ||
\WP_Mock::wpFunction( 'load_plugin_textdomain', array( | ||
'times' => 1, | ||
'args' => array( '<%= funcPrefix %>', false, 'path/languages/' ), | ||
) ); | ||
|
||
// Act | ||
i18n(); | ||
|
||
// Verify | ||
$this->assertConditionsMet(); | ||
} | ||
|
||
/** | ||
* Test initialization method. | ||
*/ | ||
public function test_init() { | ||
// Setup | ||
\WP_Mock::expectAction( '<%= funcPrefix %>_init' ); | ||
|
||
// Act | ||
init(); | ||
|
||
// Verify | ||
$this->assertConditionsMet(); | ||
} | ||
|
||
/** | ||
* Test activation routine. | ||
*/ | ||
public function test_activate() { | ||
// Setup | ||
\WP_Mock::wpFunction( 'flush_rewrite_rules', array( | ||
'times' => 1 | ||
) ); | ||
|
||
// Act | ||
activate(); | ||
|
||
// Verify | ||
$this->assertConditionsMet(); | ||
} | ||
|
||
/** | ||
* Test deactivation routine. | ||
*/ | ||
public function test_deactivate() { | ||
// Setup | ||
|
||
// Act | ||
deactivate(); | ||
|
||
// Verify | ||
} | ||
} |
Oops, something went wrong.