This repository has been archived by the owner on Feb 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
gutenberg-fields-middleware.php
64 lines (58 loc) · 2.36 KB
/
gutenberg-fields-middleware.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Plugin Name: Gutenberg Fields Middleware
* Plugin URI: https://github.com/rtCamp/gutenberg-fields-middleware
* Description: Provides middleware to easily register fields for Gutenberg blocks.
* Version: 0.2
* Author: rtCamp
* Contributors: Sayed Taqui, Daniel Bachhuber
* License: GPLv2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: gutenberg-fields-middleware
* Domain Path: /languages
*
* Copyright (c) 2018 rtCamp (http://rtcamp.com/)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 or, at
* your discretion, any later version, as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package GutenbergFieldsMiddleware
*/
if ( ! defined( 'GUTENBERG_FIELDS_MIDDLEWARE_IS_DEV' ) ) {
define( 'GUTENBERG_FIELDS_MIDDLEWARE_IS_DEV', false );
}
if ( ! defined( 'GUTENBERG_FIELDS_MIDDLEWARE_PLUGIN_DIR' ) ) {
define( 'GUTENBERG_FIELDS_MIDDLEWARE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
/**
* Register Middleware Script.
*/
function gutenberg_fields_middleware_register_scripts() {
wp_register_script(
'gutenberg-fields-middleware',
plugins_url( 'dist/middleware.js', __FILE__ ),
array( 'wp-editor', 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-date', 'underscore' ),
filemtime( GUTENBERG_FIELDS_MIDDLEWARE_PLUGIN_DIR. '/dist/middleware.js' )
);
wp_register_style( 'gutenberg-fields-middleware', plugins_url( 'dist/middleware-editor.css', __FILE__ ) );
wp_enqueue_style( 'gutenberg-fields-middleware' );
wp_enqueue_script( 'gutenberg-fields-middleware' );
}
add_action( 'enqueue_block_editor_assets', 'gutenberg_fields_middleware_register_scripts' );
if ( GUTENBERG_FIELDS_MIDDLEWARE_IS_DEV ) {
include 'examples/all-fields-block/examples.php';
include 'examples/fields-using-php/example.php';
include 'examples/single-fields/example.php';
include 'examples/block-using-hoc/example.php';
}