Skip to content

Commit

Permalink
Add Laravel Mix support
Browse files Browse the repository at this point in the history
Revamp directory structure
Clean up example.php
Rewrite README.md
  • Loading branch information
Log1x committed Sep 3, 2017
1 parent 08b5425 commit 3e9d437
Show file tree
Hide file tree
Showing 11 changed files with 6,973 additions and 222 deletions.
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
# ACF Field Boilerplate
# ACF Field Boilerplate
[![Packagist](https://img.shields.io/packagist/v/log1x/acf-field-boilerplate.svg?style=flat-square)](https://packagist.org/packages/log1x/acf-field-boilerplate)
[![Packagist Downloads](https://img.shields.io/packagist/dt/log1x/acf-field-boilerplate.svg?style=flat-square)](https://packagist.org/packages/log1x/acf-field-boilerplate)

This is a work in progress boilerplate for cleaning up and simplifying the creation of custom fields for ACF5.

This is an ACF Field Type boilerplate to quickly make clean, well structured custom field types.

This is entirely based off of the original [acf-field-type-template](https://github.com/elliotcondon/acf-field-type-template) provided by the creator of ACF.

## Features

* [Laravel Mix](https://laravel.com/docs/5.5/mix) for compiling assets, optimizing images, and concatenating and minifying files
* PSR-2 coding style
* Namespacing
* Cleaner DocBlocks
* Cleaner directory structure

## Requirements
* PHP >= 7
* ACF >= 5

## Usage
TBA
Make sure all dependencies have been installed before moving on:

* [ACF](https://www.advancedcustomfields.com/pro/) >= 5.0
* [PHP](http://php.net/manual/en/install.php) >= 7.0
* [Composer](https://getcomposer.org/download/)
* [Node.js](http://nodejs.org/) >= 6.9.x
* [Yarn](https://yarnpkg.com/en/docs/install)

## Boilerplate installation
Install ACF Field Boilerplate using Composer:

```
$ composer create-project log1x/acf-field-boilerplate:dev-master
```
## Field development
* Run `yarn` from the boilerplate directory to install dependencies

### Build commands

* `yarn run build` — Compile and optimize the files in your assets directory
* `yarn run build:production` — Compile assets for production

After you have your project created, simply go through and change the namespace to your field name and use the provided `example.php` to quickly get started.
62 changes: 31 additions & 31 deletions acf-field-boilerplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,40 @@

// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
exit;
}

if (!class_exists('init')) {
class init
{
/**
* Construct
*/
public function __construct()
{
$this->settings = [
'version' => '1.0.0',
'url' => plugin_dir_url(__FILE__),
'path' => plugin_dir_path(__FILE__)
];

load_plugin_textdomain('acf-field-boilerplate', false, plugin_basename(dirname(__FILE__ )) . '/lang');
add_action('acf/include_field_types', [$this, 'field_types']);
add_action('acf/register_fields', [$this, 'field_types']);
}


/**
* Include our ACF Field Types
*
* @param integer $version
* @return void
*/
public function field_types($version = 5)
{
include_once('fields/example.php');
}
}
class init
{
/**
* Construct
*/
public function __construct()
{
$this->settings = [
'version' => '1.0.0',
'url' => plugin_dir_url(__FILE__),
'path' => plugin_dir_path(__FILE__)
];

load_plugin_textdomain('acf-field-boilerplate', false, plugin_basename(dirname(__FILE__ )) . '/resources/lang');
add_action('acf/include_field_types', [$this, 'fields']);
add_action('acf/register_fields', [$this, 'fields']);
}


/**
* Include our ACF Field Types
*
* @param integer $version
* @return void
*/
public function fields($version = 5)
{
include_once('fields/example.php');
}
}

// Initialize
new init();
Expand Down
Empty file removed assets/css/input.css
Empty file.
Loading

0 comments on commit 3e9d437

Please sign in to comment.