-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from firestar300/release/1.0.0
Release/1.0.0
- Loading branch information
Showing
125 changed files
with
6,622 additions
and
2 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,2 @@ | ||
dist | ||
node_modules |
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,33 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2021, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix" | ||
], | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"semi": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
} |
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,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
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,2 @@ | ||
dist | ||
node_modules |
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,5 @@ | ||
{ | ||
"semi": false, | ||
"tabWidth": 2, | ||
"singleQuote": true | ||
} |
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,7 @@ | ||
# 1.0.0 | ||
- Initial commit | ||
- Add required WordPress files theme | ||
- Add Vite and configuration | ||
- Load assets for prodution / development environments | ||
- Add Eslint | ||
- Preloaded fonts |
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 |
---|---|---|
@@ -1,2 +1,51 @@ | ||
# vite-wordpress | ||
A simple and quick WordPress starter theme | ||
# Vite ⚡️ WordPress | ||
|
||
Vite WordPress is a simple and quick WordPress starter theme using the fastest build tool: [Vite](https://vitejs.dev/). | ||
|
||
## Get started 🚀 | ||
|
||
### Set WP_ENV constant | ||
|
||
In your `wp-config.php` file, you have to define a `WP_ENV` constant according to your environment so that Vite WordPress can determine which assets need to be loaded. | ||
In case you are in development mode, set the constant to `development`. | ||
|
||
```php | ||
define( 'WP_ENV', 'development' ); | ||
``` | ||
|
||
In production, set the constant to `production`. | ||
```php | ||
define( 'WP_ENV', 'production' ); | ||
``` | ||
|
||
### Install dependencies | ||
|
||
Inside the starter theme, run : | ||
```bash | ||
$ yarn | ||
|
||
# OR | ||
|
||
$ npm install | ||
``` | ||
|
||
### Development 🛠 | ||
|
||
Run your local backend server, then in your theme run : | ||
```bash | ||
$ yarn dev | ||
``` | ||
|
||
### Build 📦 | ||
|
||
```bash | ||
$ yarn build | ||
``` | ||
|
||
## Known issues 🪲 | ||
|
||
### HTTPS | ||
|
||
The theme currently doesn't work in dev environment with a https server. There is an infinite HMR reloading loop. | ||
|
||
## [Change logs](CHANGELOG.md) |
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,5 @@ | ||
</main> | ||
<footer id="footer" class="footer" role="contentinfo" aria-label="Pied de page"></footer> | ||
<?php wp_footer(); ?> | ||
</body> | ||
</html> |
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 @@ | ||
<?php | ||
get_header(); | ||
?> | ||
<div id="app"></div> | ||
<?php | ||
get_footer(); |
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,11 @@ | ||
<?php | ||
/** | ||
* Load all services | ||
*/ | ||
add_action( | ||
'after_setup_theme', | ||
function () { | ||
// Boot the service, at after_setup_theme. | ||
\ViteWP\Theme\Framework::get_container()->boot_services(); | ||
} | ||
); |
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,35 @@ | ||
<!DOCTYPE html> | ||
<html class="no-js" <?php language_attributes(); ?>> | ||
<head> | ||
<script type="text/javascript"> | ||
//<![CDATA[ | ||
(function(){ | ||
var c = document.documentElement.className; | ||
c = c.replace(/no-js/, 'js'); | ||
document.documentElement.className = c; | ||
})(); | ||
//]]> | ||
</script> | ||
|
||
<meta charset="<?php bloginfo( 'charset' ); ?>" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
|
||
<?php wp_head(); ?> | ||
</head> | ||
<body <?php body_class(); ?>> | ||
<ul class="skip-links skip-links--hidden" aria-label="Liens d'évitement"> | ||
<li> | ||
<a href="#content">Contenu principal</a> | ||
</li> | ||
<li> | ||
<a href="#footer">Pied de page</a> | ||
</li> | ||
</ul> | ||
|
||
<header id="header" class="header" role="banner" aria-label="Entête de page"></header> | ||
|
||
<main id="content" role="main" tabindex="-1" aria-label="Zone de contenus"> | ||
<?php | ||
wp_body_open(); |
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,67 @@ | ||
<?php | ||
|
||
namespace ViteWP\Theme; | ||
|
||
use ViteWP\Theme\Services\Assets; | ||
use ViteWP\Theme\Services\Assets_JS_Async; | ||
use ViteWP\Theme\Services\Fonts; | ||
use ViteWP\Theme\Services\Editor; | ||
use ViteWP\Theme\Services\Editor_Patterns; | ||
use ViteWP\Theme\Services\Menu; | ||
use ViteWP\Theme\Services\Sidebar; | ||
use ViteWP\Theme\Services\Svg; | ||
use ViteWP\Theme\Services\Theme; | ||
use ViteWP\Theme\Tools\Body_Class; | ||
use ViteWP\Theme\Tools\Template_Parts; | ||
|
||
/** | ||
* Class Framework | ||
* @author Milan Ricoul | ||
* @package ViteWP\Theme | ||
*/ | ||
class Framework { | ||
/** | ||
* @var Service_Container | ||
*/ | ||
protected static $container; | ||
|
||
/** | ||
* @var array $services | ||
*/ | ||
protected static $services = [ | ||
// Services | ||
Theme::class, | ||
Assets::class, | ||
Assets_JS_Async::class, | ||
Fonts::class, | ||
Editor::class, | ||
Editor_Patterns::class, | ||
Svg::class, | ||
Menu::class, | ||
|
||
// Services as Tools | ||
Body_Class::class, | ||
Template_Parts::class, | ||
]; | ||
|
||
/** | ||
* @return Service_Container | ||
*/ | ||
public static function get_container(): Service_Container { | ||
if ( is_null( self::$container ) ) { | ||
self::$container = new Service_Container(); | ||
array_map( [ __CLASS__, 'register_service' ], self::$services ); | ||
} | ||
|
||
return self::$container; | ||
} | ||
|
||
/** | ||
* Register Service | ||
* | ||
* @param $name | ||
*/ | ||
public static function register_service( $name ): void { | ||
self::get_container()->register_service( $name ); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
namespace ViteWP\Theme; | ||
|
||
/** | ||
* Interface Interface_Module | ||
* | ||
* @package ViteWP\Theme | ||
*/ | ||
interface Interface_Module { | ||
|
||
/** | ||
* Register the module | ||
* | ||
* @param Service_Container $container | ||
*/ | ||
public function register( Service_Container $container ); | ||
} |
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 | ||
namespace ViteWP\Theme; | ||
|
||
/** | ||
* Interface Service | ||
* | ||
* @package ViteWP\Theme | ||
*/ | ||
interface Service extends Interface_Module { | ||
|
||
/** | ||
* Register the service | ||
* | ||
* @param Service_Container $container | ||
*/ | ||
public function register( Service_Container $container ): void; | ||
|
||
/** | ||
* Boot the service | ||
* | ||
* @param Service_Container $container | ||
*/ | ||
public function boot( Service_Container $container ): void; | ||
|
||
/** | ||
* Get the service's name | ||
* | ||
* @return string | ||
*/ | ||
public function get_service_name(): string; | ||
} |
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,92 @@ | ||
<?php | ||
|
||
namespace ViteWP\Theme; | ||
|
||
/** | ||
* Class Service_Container | ||
* | ||
* @package ViteWP\Theme | ||
*/ | ||
class Service_Container { | ||
|
||
/** | ||
* The registered services. | ||
* | ||
* @var array | ||
*/ | ||
private $services = []; | ||
|
||
/** | ||
* Load all services. | ||
*/ | ||
public function boot_services(): void { | ||
$services = array_unique( $this->get_services() ); | ||
$services = array_map( [ $this, 'instantiate_service' ], $services ); | ||
|
||
array_walk( | ||
$services, | ||
function ( Service $service ) { | ||
$service->boot( $this ); | ||
$this->services[ $service->get_service_name() ] = $service; | ||
} | ||
); | ||
} | ||
|
||
/** | ||
* Get the list of services to register. | ||
* | ||
* @since 0.1.0 | ||
* | ||
* @return array[string] Array of fully qualified class names. | ||
*/ | ||
private function get_services(): array { | ||
return $this->services; | ||
} | ||
|
||
/** | ||
* Get a service's instance | ||
* | ||
* @param string $name the service name | ||
* | ||
* @return Service|bool The service instance or false if service not found | ||
*/ | ||
public function get_service( string $name ) { | ||
return $this->services[ $name ] ?? false; | ||
} | ||
|
||
/** | ||
* Register a service | ||
* | ||
* @param string $service | ||
* | ||
* @return bool | ||
* @author Clément Boirie | ||
*/ | ||
public function register_service( string $service ): bool { | ||
if ( ! class_exists( $service ) || ! in_array( Service::class, class_implements( $service ), true ) ) { | ||
return false; | ||
} | ||
|
||
$this->services[ $service ] = $service; | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Instantiate a single service. | ||
* | ||
* @param string $class Service class to instantiate. | ||
* | ||
* @return Service | ||
*/ | ||
private function instantiate_service( string $class ): Service { | ||
/** | ||
* @var Service $service | ||
*/ | ||
$service = new $class(); | ||
$service->register( $this ); | ||
$this->services[ $service->get_service_name() ] = $service; | ||
|
||
return $this->services[ $service->get_service_name() ]; | ||
} | ||
} |
Oops, something went wrong.