diff --git a/composer.json b/composer.json
index e012b86..096391e 100644
--- a/composer.json
+++ b/composer.json
@@ -2,6 +2,7 @@
"name": "modern-climate/mc-wp-starter-theme",
"description": "A WordPress starter theme for Modern Climate.",
"type": "wordpress-theme",
+ "text-domain": "mc-starter",
"config": {
"vendor-dir": "vendor",
"bin-dir": "bin"
@@ -12,10 +13,9 @@
}
},
"require": {
- "squizlabs/php_codesniffer": "*",
- "wordplate/acf": "^8.6"
+ "vinkla/extended-acf": "*"
},
"require-dev": {
- "paulthewalton/acf-stubs": "*"
+ "php-stubs/acf-pro-stubs": "*"
}
}
diff --git a/composer.lock b/composer.lock
index ff95853..35f4eb0 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,89 +4,33 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "9577e135d41de1e752041ec5e2d7d3ea",
+ "content-hash": "34f061920733575c8816468779beb808",
"packages": [
{
- "name": "squizlabs/php_codesniffer",
- "version": "3.6.2",
+ "name": "vinkla/extended-acf",
+ "version": "11.2.0",
"source": {
"type": "git",
- "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a"
+ "url": "https://github.com/vinkla/extended-acf.git",
+ "reference": "4ed02a95435b49e37459b8a0c4759797314aafd1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a",
- "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a",
+ "url": "https://api.github.com/repos/vinkla/extended-acf/zipball/4ed02a95435b49e37459b8a0c4759797314aafd1",
+ "reference": "4ed02a95435b49e37459b8a0c4759797314aafd1",
"shasum": ""
},
"require": {
- "ext-simplexml": "*",
- "ext-tokenizer": "*",
- "ext-xmlwriter": "*",
- "php": ">=5.4.0"
+ "php": "^7.4 || ^8.0"
},
"require-dev": {
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
+ "phpunit/phpunit": "^9.5",
+ "squizlabs/php_codesniffer": "^3.6"
},
- "bin": [
- "bin/phpcs",
- "bin/phpcbf"
- ],
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.x-dev"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Greg Sherwood",
- "role": "lead"
- }
- ],
- "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
- "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
- "keywords": [
- "phpcs",
- "standards"
- ],
- "support": {
- "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
- "source": "https://github.com/squizlabs/PHP_CodeSniffer",
- "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
- },
- "time": "2021-12-12T21:44:58+00:00"
- },
- {
- "name": "wordplate/acf",
- "version": "8.6.0",
- "source": {
- "type": "git",
- "url": "https://github.com/wordplate/extended-acf.git",
- "reference": "0810ef4cf49e76d079ea850257f26c5f4dd1f57d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/wordplate/extended-acf/zipball/0810ef4cf49e76d079ea850257f26c5f4dd1f57d",
- "reference": "0810ef4cf49e76d079ea850257f26c5f4dd1f57d",
- "shasum": ""
- },
- "require": {
- "php": "^7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.4",
- "squizlabs/php_codesniffer": "^3.5"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "8.6-dev"
+ "dev-master": "11.2-dev"
}
},
"autoload": {
@@ -121,58 +65,103 @@
"wordpress"
],
"support": {
- "issues": "https://github.com/wordplate/extended-acf/issues",
- "source": "https://github.com/wordplate/extended-acf/tree/8.6.0"
+ "issues": "https://github.com/vinkla/extended-acf/issues",
+ "source": "https://github.com/vinkla/extended-acf/tree/11.2.0"
},
- "time": "2020-11-19T09:29:30+00:00"
+ "time": "2021-11-03T13:41:55+00:00"
}
],
"packages-dev": [
{
- "name": "paulthewalton/acf-stubs",
- "version": "5.8.7",
+ "name": "php-stubs/acf-pro-stubs",
+ "version": "v6.0.6",
"source": {
"type": "git",
- "url": "https://github.com/paulthewalton/acf-stubs.git",
- "reference": "722096c127186c41ac98395b418195d1db9cf576"
+ "url": "https://github.com/php-stubs/acf-pro-stubs.git",
+ "reference": "3301f61c975ee6078fc89c1f6ba70358349ea137"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/paulthewalton/acf-stubs/zipball/722096c127186c41ac98395b418195d1db9cf576",
- "reference": "722096c127186c41ac98395b418195d1db9cf576",
+ "url": "https://api.github.com/repos/php-stubs/acf-pro-stubs/zipball/3301f61c975ee6078fc89c1f6ba70358349ea137",
+ "reference": "3301f61c975ee6078fc89c1f6ba70358349ea137",
"shasum": ""
},
+ "require": {
+ "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0"
+ },
"require-dev": {
- "ext-gettext": "*",
- "giacocorsiglia/stubs-generator": "^0.5.0",
- "giacocorsiglia/wordpress-stubs": "*",
- "php": "^7.1",
- "wpackagist-plugin/advanced-custom-fields": "5.8.7"
+ "php": "~7.1",
+ "php-stubs/generator": "^0.8"
+ },
+ "suggest": {
+ "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
+ "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan"
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
- "GPL-2.0+"
- ],
- "authors": [
- {
- "name": "Paul Walton",
- "email": "pwalton@live.ca",
- "role": "copycat"
- }
+ "GPL-2.0-or-later"
],
- "description": "Based on giacocorsiglia/wordpress-stubs. Advanced Custom Fields function, class, and global variable declaration stubs for easier static analysis.",
+ "description": "Advanced Custom Fields PRO stubs for static analysis.",
+ "homepage": "https://github.com/php-stubs/acf-pro-stubs",
"keywords": [
+ "PHPStan",
"acf",
- "advanced custom fields",
"static analysis",
"wordpress"
],
"support": {
- "issues": "https://github.com/paulthewalton/acf-stubs/issues",
- "source": "https://github.com/paulthewalton/acf-stubs/tree/5.8.7"
+ "issues": "https://github.com/php-stubs/acf-pro-stubs/issues",
+ "source": "https://github.com/php-stubs/acf-pro-stubs/tree/v6.0.6"
+ },
+ "time": "2022-12-25T22:14:41+00:00"
+ },
+ {
+ "name": "php-stubs/wordpress-stubs",
+ "version": "v6.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-stubs/wordpress-stubs.git",
+ "reference": "19e7966c8e70a99a4824b3e5d1526680a151f13b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/19e7966c8e70a99a4824b3e5d1526680a151f13b",
+ "reference": "19e7966c8e70a99a4824b3e5d1526680a151f13b",
+ "shasum": ""
+ },
+ "replace": {
+ "giacocorsiglia/wordpress-stubs": "*"
+ },
+ "require-dev": {
+ "nikic/php-parser": "< 4.12.0",
+ "php": "~7.3 || ~8.0",
+ "php-stubs/generator": "^0.8.1",
+ "phpdocumentor/reflection-docblock": "^5.3",
+ "phpstan/phpstan": "^1.2"
+ },
+ "suggest": {
+ "paragonie/sodium_compat": "Pure PHP implementation of libsodium",
+ "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
+ "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan"
+ },
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "WordPress function and class declaration stubs for static analysis.",
+ "homepage": "https://github.com/php-stubs/wordpress-stubs",
+ "keywords": [
+ "PHPStan",
+ "static analysis",
+ "wordpress"
+ ],
+ "support": {
+ "issues": "https://github.com/php-stubs/wordpress-stubs/issues",
+ "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.1.0"
},
- "time": "2019-12-04T19:26:53+00:00"
+ "time": "2022-11-09T05:33:25+00:00"
}
],
"aliases": [],
@@ -182,5 +171,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
- "plugin-api-version": "2.2.0"
+ "plugin-api-version": "2.3.0"
}
diff --git a/doc/Autoformatting.md b/doc/Autoformatting.md
new file mode 100644
index 0000000..ebea6c1
--- /dev/null
+++ b/doc/Autoformatting.md
@@ -0,0 +1,44 @@
+# Autoformatting
+
+### Prettier
+
+Autoformats _CSS_, _SCSS_, _PHP_, _JS_, _TS_, and _MD_
+**VSCode**
+
+- Install from Code > Preferences > Extensions: [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
+
+### ESLint
+
+Finds and fixes problems in JS/TS
+**VSCode**
+
+- Install from Code > Preferences > Extensions: [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
+
+### Format on save [Editor]
+
+**VSCode**
+Make sure the following settings are present in `settings.json` to enable prettier to format on save:
+
+```
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "editor.formatOnSave": true,
+ "prettier.requireConfig": true,
+ "[javascript]": {
+ "editor.tabSize": 2,
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[typescript]": {
+ "editor.tabSize": 2,
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[json]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+ "[jsonc]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ },
+```
+
+Note: prettier will only autoformat if there is a `.prettierrc.json` file present. This way you won't autoformat other projects where you wish to not do so.
+
+Note: all other settings can be handled on a project basis in the prettierrc.json, .prettierignore, etc. files
diff --git a/doc/ThemeScripts.md b/doc/ThemeScripts.md
new file mode 100644
index 0000000..2b943de
--- /dev/null
+++ b/doc/ThemeScripts.md
@@ -0,0 +1,20 @@
+# Theme Scripts
+
+Navigate to `./tools` to run the following commands
+
+## Changing the theme namespace
+
+`node theme --namespace [MyNewNameSpace]`
+Will read the theme root composer.json `autoload` `psr-4` namespace value then replace all namespaces in the theme .php files. It then updates the theme root composer.json namespace and finally runs `composer dump-autoload` to create new autoload files with updated namespace.
+
+## Changing the theme text domain
+
+`node theme --text-domain [some-new-text-domain]`
+Will read the `text-domain` property value in the theme root package.json file and replace it with the specified value you provide to the above command. It will traverse all theme .php files and replace the text-domain with what you specify. It will also update root package.json `text-domain` property value.
+
+## Changing the theme version
+
+`node theme --theme-version #.#.#`
+Will read the `version` property value in the theme root package.json file and replace it with the specified version from the command. It will also update style.css and functions.php and finally will run a new build.
+
+Note that you can do all of the above manually. The scripts are just helpers.
diff --git a/doc/acf/FieldRegistration.md b/doc/acf/FieldRegistration.md
index 67285ef..5e6546a 100644
--- a/doc/acf/FieldRegistration.md
+++ b/doc/acf/FieldRegistration.md
@@ -1,104 +1,111 @@
# ACF Field Registration
-Register advanced custom fields with object oriented PHP using the Extended ACF Plugin.
+
+Register advanced custom fields with object oriented PHP using the Extended ACF Plugin.
Visit the [Extended ACF github README](https://github.com/wordplate/extended-acf) for a full list of field examples and documentation.
## **Field Names**
+
By default, the field name is created by sanitizing the title (all lowercase and spaces replaced with dashes). If you prefer to name it something different, this can be added as a second argument to the `make` method for any field.
## **Examples**
+
_Note: Use statements must be added for every class (field) used._
**Basic Fields**
+
```php
Text::make(__('Headline', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->required();
```
```php
Textarea::make(__('Content', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->rows(2);
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->rows(2);
```
```php
Wysiwyg::make(__('Content', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->mediaUpload(false)
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->mediaUpload(false)
+ ->required();
```
```php
Url::make(__('Url', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->required();
```
```php
ColorPicker::make(__('Color', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->defaultValue('#4a9cff')
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->defaultValue('#4a9cff')
+ ->required();
```
```php
Image::make(__('Image', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->returnFormat('array')
- ->previewSize('thumbnail') // thumbnail, medium or large
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->returnFormat('array')
+ ->previewSize('thumbnail') // thumbnail, medium or large
+ ->required();
```
```php
Select::make(__('Select', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->choices([
- 'choice-1' => __('Choice 1', 'mc-starter'),
- 'choice-2' => __('Choice 2', 'mc-starter'),
- ])
- ->defaultValue('choice-1')
- ->returnFormat('value') // value, label or array
- ->allowMultiple()
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->choices([
+ 'choice-1' => __('Choice 1', 'mc-starter'),
+ 'choice-2' => __('Choice 2', 'mc-starter'),
+ ])
+ ->defaultValue('choice-1')
+ ->returnFormat('value') // value, label or array
+ ->allowMultiple()
+ ->required();
```
```php
TrueFalse::make(__('True or False', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->defaultValue(false)
- ->stylisedUi() // optinal on and off text labels
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->defaultValue(false)
+ ->stylisedUi() // optinal on and off text labels
+ ->required();
```
**Group**
+
```php
Group::make(__('Group', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->fields([
- Text::make(__('Text', 'mc-starter')),
- Image::make(__('Image', 'mc-starter')),
- ])
- ->layout('row')
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->fields([
+ Text::make(__('Text', 'mc-starter')),
+ Image::make(__('Image', 'mc-starter')),
+ ])
+ ->layout('row')
+ ->required();
```
**Repeater**
+
```php
Repeater::make(__('Repeater', 'mc-starter'))
- ->instructions(__('Instructions go here.', 'mc-starter'))
- ->fields([
- Text::make(__('Text', 'mc-starter')),
- Image::make(__('Image', 'mc-starter')),
- ])
- ->min(2)
- ->collapsed('name')
- ->buttonLabel(__('Add Component', 'mc-starter'))
- ->layout('table') // block, row or table
- ->required();
+ ->instructions(__('Instructions go here.', 'mc-starter'))
+ ->fields([
+ Text::make(__('Text', 'mc-starter')),
+ Image::make(__('Image', 'mc-starter')),
+ ])
+ ->min(2)
+ ->collapsed('name')
+ ->buttonLabel(__('Add Component', 'mc-starter'))
+ ->layout('table') // block, row or table
+ ->required();
```
**Conditional Logic**
+
```php
Select::make(__('Select', 'mc-starter'))
->choices([
@@ -109,4 +116,4 @@ Text::make(__('Text', 'mc-starter'))
->conditionalLogic([
ConditionalLogic::if('select')->equals('choice-1')
]);
-```
\ No newline at end of file
+```
diff --git a/doc/acf/UtilityFunctions.md b/doc/acf/UtilityFunctions.md
index fcc0e14..9228588 100644
--- a/doc/acf/UtilityFunctions.md
+++ b/doc/acf/UtilityFunctions.md
@@ -1,4 +1,5 @@
# ACF Utility Functions
+
Advanced Custom Fields comes with a number of [built in functions](https://www.advancedcustomfields.com/resources/)
to retrieve ACF data. Commonly used functions include `get_field()`, `get_fields()`, and `get_sub_field()`. These
functions are convenient but significantly increase database queries compared to WP core functions and should not
@@ -11,24 +12,28 @@ Fortunately the MC Wordpress Starter Theme comes with some handy utilities to av
`/App/Fields/ACF.php`
### `getPostMeta()`
+
Used to retrieve ACF values from the database the preferred way.
**Example**
`$post_meta = ACF::getPostMeta(get_the_ID());`
### `getField()`
+
Utility function to check field key and avoid PHP errors
**Example**
`$heading = ACF::getField('heading', $your_flat_acf_data);`
### `getRowsLayout()`
+
Loops through Flexible Modules or Repeater Fields and compiles a multidimensional array.
**Example**
`$links = ACF::getRowsLayout('links', $your_flat_acf_data);`
### `getAttachmentByID()`
+
Used to return an image array based on the ACF image ID.
**Location**
diff --git a/footer.php b/footer.php
index b3e24d8..5829874 100755
--- a/footer.php
+++ b/footer.php
@@ -7,7 +7,7 @@
?>