Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{css,less,scss}]
indent_style = space
indent_size = 2

[*.yml]
indent_style = space
indent_size = 2

[*.{js,jsx,json}]
indent_style = space
indent_size = 2
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
"extends": "airbnb",
"rules":{
// Prevent warnings for webpack resolve aliases.
"import/no-unresolved": "off",
// Prevent warnings for webpack extension resolution.
"import/extensions": "off",
// Prevent warnings for import statements with aliases.
"import/first": "off",
},
"settings": {
"react": {
"version": "latest"
}
}
};
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Build files
/dist/
/resources/styles/frontend/_sprite.scss
/resources/styles/*.config.scss

# Development files
/config.json

# Build modules
/node_modules/

# Composer packages
/vendor/

# NPM lockfile as it causes more problems than it solves
package-lock.json

# WordPress test environment
/tests/environment

# CLI tools
drone.json

# Common
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
.idea
18 changes: 18 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "stylelint-config-recommended-scss",
"plugins": [
"stylelint-order",
"stylelint-scss"
],
"rules": {
"no-empty-source": null,
"indentation": 2,
"order/order": [
"custom-properties",
"dollar-variables",
"declarations",
"rules",
"at-rules"
]
}
}
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions app/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
/**
* WP Emerge configuration.
*
* @link https://docs.wpemerge.com/#/framework/configuration
*
* @package CoffeeCodeChallenge
*/

return [
/**
* Default class namespace prefix.
*/
'namespace' => 'CoffeeCodeChallenge\\',

/**
* Array of service providers you wish to enable.
*/
'providers' => [
\WPEmergeAppCore\AppCore\AppCoreServiceProvider::class,
\WPEmergeAppCore\Assets\AssetsServiceProvider::class,
\WPEmergeAppCore\Avatar\AvatarServiceProvider::class,
\WPEmergeAppCore\Config\ConfigServiceProvider::class,
\WPEmergeAppCore\Image\ImageServiceProvider::class,
\WPEmergeAppCore\Sidebar\SidebarServiceProvider::class,
\CoffeeCodeChallenge\Routing\RouteConditionsServiceProvider::class,
\CoffeeCodeChallenge\View\ViewServiceProvider::class,
\CoffeeCodeChallenge\WordPress\AdminServiceProvider::class,
\CoffeeCodeChallenge\WordPress\AssetsServiceProvider::class,
\CoffeeCodeChallenge\WordPress\ContentTypesServiceProvider::class,
\CoffeeCodeChallenge\WordPress\ShortcodesServiceProvider::class,
\CoffeeCodeChallenge\WordPress\PluginServiceProvider::class,
\CoffeeCodeChallenge\WordPress\WidgetsServiceProvider::class,
],

/**
* Array of route group definitions and default attributes.
* All of these are optional so if we are not using
* a certain group of routes we can skip it.
* If we are not using routing at all we can skip
* the entire 'routes' option.
*/
'routes' => [
'web' => [
'definitions' => __DIR__ . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'web.php',
],
'admin' => [
'definitions' => __DIR__ . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'admin.php',
],
'ajax' => [
'definitions' => __DIR__ . DIRECTORY_SEPARATOR . 'routes' . DIRECTORY_SEPARATOR . 'ajax.php',
],
],

/**
* Register middleware class aliases.
* Use fully qualified middleware class names.
*
* Internal aliases that you should avoid overriding:
* - 'flash'
* - 'old_input'
* - 'csrf'
* - 'user.logged_in'
* - 'user.logged_out'
* - 'user.can'
*/
'middleware' => [
// phpcs:ignore
// 'mymiddleware' => \CoffeeCodeChallenge\Middleware\MyMiddleware::class,
],

/**
* Register middleware groups.
* Use fully qualified middleware class names or registered aliases.
* There are a couple built-in groups that you may override:
* - 'web' - Automatically applied to web routes.
* - 'admin' - Automatically applied to admin routes.
* - 'ajax' - Automatically applied to ajax routes.
* - 'global' - Automatically applied to all of the above.
* - 'wpemerge' - Internal group applied the same way 'global' is.
*
* Warning: The 'wpemerge' group contains some internal WP Emerge
* middleware which you should avoid overriding.
*/
'middleware_groups' => [
'global' => [],
'web' => [],
'ajax' => [],
'admin' => [],
],

/**
* Optionally specify middleware execution order.
* Use fully qualified middleware class names.
*/
'middleware_priority' => [
// phpcs:ignore
// \CoffeeCodeChallenge\Middleware\MyMiddlewareThatShouldRunFirst::class,
// \CoffeeCodeChallenge\Middleware\MyMiddlewareThatShouldRunSecond::class,
],

/**
* Custom directories to search for views.
* Use absolute paths or leave blank to disable.
* Applies only to the default PhpViewEngine.
*/
'views' => [ dirname( __DIR__ ) . DIRECTORY_SEPARATOR . 'views' ],

/**
* App Core configuration.
*/
'app_core' => [
'path' => dirname( __DIR__ ),
'url' => plugin_dir_url( COFFEE_CODE_CHALLENGE_PLUGIN_FILE ),
],

/**
* Other config goes after this comment.
*/

];
15 changes: 15 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Load helpers.
* Define any generic functions in a helper file and then require that helper file here.
*
* @package CoffeeCodeChallenge
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Load helpers.
// phpcs:ignore
// require_once __DIR__ . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'myhelper.php';
Empty file added app/helpers/.gitkeep
Empty file.
15 changes: 15 additions & 0 deletions app/hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Declare any actions and filters here.
* In most cases you should use a service provider, but in cases where you
* just need to add an action/filter and forget about it you can add it here.
*
* @package CoffeeCodeChallenge
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// phpcs:ignore
// add_action( 'some_action', 'some_function' );
18 changes: 18 additions & 0 deletions app/routes/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* WordPress Admin Routes.
* WARNING: Do not use \CoffeeCodeChallenge::route()->all() here, otherwise you will override
* ALL custom admin pages which you most likely do not want to do.
*
* @link https://docs.wpemerge.com/#/framework/routing/methods
*
* @package CoffeeCodeChallenge
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Using our ExampleController to handle a custom admin page registered using add_menu_page(), for example.
// phpcs:ignore
// \CoffeeCodeChallenge::route()->get()->where( 'admin', 'my-custom-admin-page-slug' )->handle( 'ExampleController@admin' );
18 changes: 18 additions & 0 deletions app/routes/ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* WordPress AJAX Routes.
* WARNING: Do not use \CoffeeCodeChallenge::route()->all() here, otherwise you will override
* ALL AJAX requests which you most likely do not want to do.
*
* @link https://docs.wpemerge.com/#/framework/routing/methods
*
* @package CoffeeCodeChallenge
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Using our ExampleController to handle a custom ajax action, for example.
// phpcs:ignore
// \CoffeeCodeChallenge::route()->get()->where( 'ajax', 'my-custom-ajax-action' )->handle( 'ExampleController@ajax' );
23 changes: 23 additions & 0 deletions app/routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Web Routes.
* WARNING: Do not use \CoffeeCodeChallenge::route()->all() here, otherwise you will override
* ALL web requests which you most likely do not want to.
*
* @link https://docs.wpemerge.com/#/framework/routing/methods
*
* @package CoffeeCodeChallenge
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Using our ExampleController to handle the homepage, for example.
// phpcs:ignore
// \CoffeeCodeChallenge::route()->get()->url( '/' )->handle( 'ExampleController@home' );

// If we do not want to hardcode a url, we can use one of the available route conditions instead.
// phpcs:ignore
// \CoffeeCodeChallenge::route()->get()->where( 'post_id', get_option( 'page_on_front' ) )->handle( 'ExampleController@home' );

13 changes: 13 additions & 0 deletions app/src/CoffeeCodeChallenge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use WPEmerge\Application\ApplicationTrait;

include( plugin_dir_path( __FILE__ ) . 'Controllers/Api/EndpointBase.php');
include( plugin_dir_path( __FILE__ ) . 'Controllers/Api/Endpoint.php');

/**
* @mixin \WPEmergeAppCore\Application\ApplicationMixin
*/
class CoffeeCodeChallenge {
use ApplicationTrait;
}
Empty file.
Empty file.
Empty file.
Loading