Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0-beta.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
notjb committed Mar 16, 2021
2 parents d63d882 + fc035dc commit e04f977
Show file tree
Hide file tree
Showing 24 changed files with 5,753 additions and 127 deletions.
5,516 changes: 5,496 additions & 20 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@studiometa/create-wordpress-project",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"description": "A generator to kickstart a WordPress project in a few seconds! ⚡",
"bin": "cli.js",
"files": [
Expand Down
10 changes: 5 additions & 5 deletions saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ module.exports = {
{ name: 'Classic editor', value: 'classicEditor' },
{ name: 'Wordfence', value: 'wordfence' },
{ name: 'WP Rocket', value: 'wpRocket' },
{ name: 'Yoast SEO', value: 'yoastSeo' },
{ name: 'Rank Math', value: 'rankMath' },
],
default: [],
default: ['acf', 'wpRocket', 'classicEditor'],
},
],
templateData() {
Expand All @@ -63,14 +63,14 @@ module.exports = {
const classicEditor = features.includes('classicEditor');
const wordfence = features.includes('wordfence');
const wpRocket = features.includes('wpRocket');
const yoastSeo = features.includes('yoastSeo');
const rankMath = features.includes('rankMath');

return {
acf,
classicEditor,
wordfence,
wpRocket,
yoastSeo,
rankMath,
};
},
actions() {
Expand Down Expand Up @@ -106,7 +106,7 @@ module.exports = {
if (!this.answers.features.includes('acf')) {
actions.push({
type: 'remove',
files: 'web/wp-content/themes/studiometa/app/Managers/ACFManager.php',
files: 'web/wp-content/themes/<?= slug %>/app/Managers/ACFManager.php',
});
}

Expand Down
4 changes: 0 additions & 4 deletions template/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ AUTH_SALT=''
SECURE_AUTH_SALT=''
LOGGED_IN_SALT=''
NONCE_SALT=''
<%_ if (acf) { _%>

# ACF Configuration
ACF_PRO_KEY='key'
<%_ } _%>
<%_ if (wpRocket) { _%>

# WP Rocket config
Expand Down
52 changes: 52 additions & 0 deletions template/LocalValetDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* For easier configuration when using Valet to serve local vhosts
* LocalValetDriver.php file extending the default WordPressValerDriver
* to serve the content of the web/ directory
*
* @see https://laravel.com/docs/8.x/valet#custom-valet-drivers
*/
class LocalValetDriver extends WordPressValetDriver {
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function serves($sitePath, $siteName, $uri) {
$sitePath .= '/web';
return parent::serves($sitePath, $siteName, $uri);
}

/**
* isStaticFile determine if the incoming request is for a file that is "static"
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return bool
*/
public function isStaticFile($sitePath, $siteName, $uri) {
$sitePath .= '/web';
return parent::isStaticFile($sitePath, $siteName, $uri);
}

/**
* Get the fully resolved path to the application's front controller.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return string
*/
public function frontControllerPath($sitePath, $siteName, $uri) {
$sitePath .= '/web';
return parent::frontControllerPath(
$sitePath,
$siteName,
$this->forceTrailingSlash($uri)
);
}
}
5 changes: 0 additions & 5 deletions template/bin/source/wp-config-sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@
/** Configure directory paths if WP core is in a different directory */
define( 'WP_CONTENT_URL', WP_HOME . '/wp-content' );
define( 'WP_CONTENT_DIR', realpath( ABSPATH . '../wp-content/' ) );
<%_ if (acf) { _%>

/* ACF Configuration */
define( 'ACF_PRO_KEY', getenv( 'ACF_PRO_KEY' ) );
<%_ } _%>
<%_ if (wpRocket) { _%>

/* WP Rocket config */
Expand Down
25 changes: 13 additions & 12 deletions template/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^7.0",
"php": "^7.3",
"vlucas/phpdotenv": "^3.4",
"johnpbloch/wordpress": "^5.2",
"johnpbloch/wordpress": "5.*",
"timber/timber": "^1.10",
"studiometa/wp-mu-cleanup": "^1.0",
"studiometa/wp-assets": "dev-feature/v2",
Expand All @@ -23,13 +23,15 @@
<%_ if (classicEditor) { _%>
"wpackagist-plugin/classic-editor": "^1.5",
<%_ } _%>
<%_ if (yoastSeo) { _%>
"yoast/wordpress-seo": "^12.9",
<%_ if (rankMath) { _%>
"wpackagist-plugin/seo-by-rank-math": "^1.0",
<%_ } _%>
<%_ if (acf) { _%>
"advanced-custom-fields/advanced-custom-fields-pro": "^5.0.0",
"acf/advanced-custom-fields-pro": "dev-master",
"stoutlogic/acf-builder": "^1.10",
<%_ } _%>
"lkwdwrd/wp-muplugin-loader": "^1.0"
"lkwdwrd/wp-muplugin-loader": "^1.0",
"djboris88/twig-commented-include": "^1.2"
},
"require-dev": {
"wpackagist-plugin/query-monitor": "^3.6",
Expand All @@ -50,16 +52,15 @@
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "5.7.12",
"name": "acf/advanced-custom-fields-pro",
"type": "wordpress-plugin",
"version": "dev-master",
"dist": {
"type": "zip",
"url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t={%version}"
"url": "https://github.com/studiometa/advanced-custom-fields-pro/archive/master.zip"
},
"require": {
"composer/installers": "^1.4",
"ffraenz/private-composer-installer": "^2.0"
"composer/installers": "^1.4"
}
}
},
Expand Down Expand Up @@ -93,7 +94,7 @@
},
"autoload": {
"psr-4": {
"Studiometa\\": "web/wp-content/themes/studiometa/app"
"Studiometa\\": "web/wp-content/themes/<?= slug %>/app"
}
},
"extra": {
Expand Down
3 changes: 3 additions & 0 deletions template/phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<!-- Skip seed data -->
<exclude-pattern>/data/</exclude-pattern>

<!-- Skip LocalValetDriver -->
<exclude-pattern>LocalValetDriver.php</exclude-pattern>

<!-- Don't check composer dependencies -->
<exclude-pattern>/vendor/</exclude-pattern>

Expand Down
19 changes: 19 additions & 0 deletions template/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ git clone <%= repository %>
```

Créer et configurer le fichier `.env` en vous basant sur le fichier `.env.example`.
Créer et configurer le fichier `.htaccess` en vous basant sur le fichier `.htaccess.example`.

Installer les dépendances nécessaires :

Expand Down Expand Up @@ -51,6 +52,24 @@ npm install
| `composer phpcs` | Lint les fichiers PHP du thème et des plugins customs |
| `composer phpstan` | Analyse de manière statiques les fichiers PHP du thème et des plugins customs |


#### WP CLI

Une liste (non exaustive) des commandes utiles de [WPCLI](https://wp-cli.org/fr/)

> Si wp cli est installé sur votre machine et configuré dans votre $PATH utiliser les commandes ci-dessous, sinon utiliser `./vendor/bin/wp`
| Commande | Description |
|-|-|
| `wp user create <USER_LOGIN> <USER_EMAIL> --role=<ROLE_NAME> --user_pass=<PASSWORD>` | Créer un utilisateur |
| `wp transient delete --all` | Supprimer tous les transients de la base de données |
| `wp post delete $(wp post list --post_type='revision' --format=ids) --force` | Supprimer toutes les révisions |
| `wp plugin activate` | Activer un plugin |
| `wp plugin deactivate` | Désactiver un plugin |
| `wp search-replace 'http://old-domain.com/' 'http://new-domain.com/' --precise --recurse-objects --all-tables-with-prefix` | Remplacer toutes les URL's pour migrer une base de données. ⚠ Faire un backup avant de lancer cette commande, ajouter le paramètre `–dry-run` pour lancer la commande sans effectuer de changements |
| ` wp language core install fr_FR && wp language core activate fr_FR` | Installer une nouvelle langue de back-office (changer `fr_FR` par la langue souhaitée) |


### Ajouter des plugins et mu-plugins

Pour ajouter des plugins et mu-plugins tiers, utilisez Composer avec l'aide de [wpackagist.org](https://wpackagist.org/). Par exemple, pour ajouter le plugin [Classic Editor](), vous pouvez procéder comme suit :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,37 @@
/**
* Boostrap ACF
*
* Create ACF Fields group with stoutlogic/acf-builder package
*
* @see https://github.com/stoutlogic/acf-builder
* @package Studiometa
*/

namespace Studiometa\Managers;

use Studiometa\Managers\ManagerInterface;
use StoutLogic\AcfBuilder\FieldsBuilder;

/** Class **/
class ACFManager implements ManagerInterface {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/**
* @inheritDoc
*/
public function run() {
add_action( 'acf/init', array( $this, 'register_acf_default_group' ) );
add_action( 'acf/init', array( $this, 'register_acf_example_group' ) );
}

/**
* Register acf default field group
*
* Containing fields to use as clone to avoid
* overloading the database with fields references
*
* @link https://www.advancedcustomfields.com/resources/register-fields-via-php/
* @return void
*/
public function register_acf_default_group() {
acf_add_local_field_group(
array(
'key' => 'group_studiometa_default_group',
'title' => 'Default fields to use as clone',
'fields' => array(
array(
'key' => 'field_content',
'label' => 'Content',
'name' => 'content',
'type' => 'wysiwyg',
),
),
)
);
}

/**
* Register acf example field group
* Using the content field from the default group
*
* @return void
*/
public function register_acf_example_group() {
acf_add_local_field_group(
array(
'key' => 'group_studiometa_example_group',
'title' => 'Custom Fields for Posts',
'fields' => array(
array(
// key is unique and should not be the same as the default field.
'key' => 'field_post_content',
'label' => 'Content',
'name' => 'content',
'type' => 'clone',
'clone' => array(
// Use the default field key.
'field_content',
),
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
)
);
$example_group = new FieldsBuilder( 'example_group' );
$example_group->addImage( 'image' )
->setLocation( 'post_type', '==', 'post' );
acf_add_local_field_group( $example_group->build() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/** Class */
class AssetsManager implements ManagerInterface {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/**
* @inheritDoc
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/** Class **/
class CustomPostTypesManager implements ManagerInterface {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/**
* @inheritDoc
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ManagerFactory {
* @param array $managers to init.
* @return void
*/
static public function init( array $managers ) {
public static function init( array $managers ) {
foreach ( $managers as $manager ) {
$manager->run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/** Class **/
class TaxonomiesManager implements ManagerInterface {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/**
* @inheritDoc
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/** Class */
class ThemeManager implements ManagerInterface {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/**
* @inheritDoc
*/
Expand Down
Loading

0 comments on commit e04f977

Please sign in to comment.