Skip to content

Commit 23e2b27

Browse files
committed
Fix versions and include title options to block class
1 parent 61f348d commit 23e2b27

File tree

2 files changed

+39
-44
lines changed

2 files changed

+39
-44
lines changed

acf-gutenberg.php

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author URI: http://40q.com.ar
88
* Text Domain: acf-gutenberg
99
* Domain Path: /resources/languages
10-
* Version: 0.1.0
10+
* Version: 1.0.4
1111
*
1212
* @package ACF_Gutenberg
1313
*/
@@ -17,36 +17,30 @@
1717
// Exit if accessed directly.
1818
defined('ABSPATH') || exit;
1919

20-
2120
$plugin = (object) [
2221
'name' => 'ACF Gutenberg',
23-
'version' => '0.1.0',
22+
'version' => '1.0.4',
2423

2524
'requiredPHP' => '7.1',
2625
'requiredWP' => '4.7.0',
2726

28-
'composer' => __DIR__.'/vendor/autoload.php',
27+
'composer' => __DIR__ . '/vendor/autoload.php',
2928
];
3029

30+
define('ACFGB_PATH', dirname(__FILE__));
31+
define('ACFGB_FOLDER', basename(ACFGB_PATH));
32+
define('ACFGB_URL', plugin_dir_url(__FILE__));
3133

32-
define( 'ACFGB_PATH', dirname( __FILE__ ) );
33-
define( 'ACFGB_FOLDER', basename( ACFGB_PATH ) );
34-
define( 'ACFGB_URL', plugin_dir_url( __FILE__ ) );
35-
36-
37-
define( 'ACFGB_PATH_RESOURCES', dirname( __FILE__ ) . '/resources' );
38-
define( 'ACFGB_URL_RESOURCES', ACFGB_URL . '/resources' );
39-
define( 'ACFGB_PATH_SRC', dirname( __FILE__ ) . '/src' );
40-
define( 'ACFGB_URL_SRC', ACFGB_URL . '/src' );
41-
define( 'ACFGB_PATH_BIN', dirname( __FILE__ ) . '/bin' );
42-
define( 'ACFGB_URL_BIN', ACFGB_URL . '/bin' );
43-
34+
define('ACFGB_PATH_RESOURCES', dirname(__FILE__) . '/resources');
35+
define('ACFGB_URL_RESOURCES', ACFGB_URL . '/resources');
36+
define('ACFGB_PATH_SRC', dirname(__FILE__) . '/src');
37+
define('ACFGB_URL_SRC', ACFGB_URL . '/src');
38+
define('ACFGB_PATH_BIN', dirname(__FILE__) . '/bin');
39+
define('ACFGB_URL_BIN', ACFGB_URL . '/bin');
4440

4541
/** Initialize error collector */
4642
$errors = [];
4743

48-
49-
5044
/**
5145
* Helper function for displaying errors.
5246
* @param $errors []
@@ -67,36 +61,36 @@
6761
*/
6862
version_compare($plugin->requiredPHP, phpversion(), '<')
6963
?: $errors[] = (object) [
70-
'title' => __('Invalid PHP version', 'plugin-name'),
71-
'message' => __(
72-
sprintf('You must be using PHP %s or greater.', $plugin->requiredPHP),
73-
'plugin-name'
74-
),
75-
];
64+
'title' => __('Invalid PHP version', 'plugin-name'),
65+
'message' => __(
66+
sprintf('You must be using PHP %s or greater.', $plugin->requiredPHP),
67+
'plugin-name'
68+
),
69+
];
7670

7771
/**
7872
* Ensure the correct WordPress version is being used.
7973
*/
8074
version_compare($plugin->requiredWP, get_bloginfo('version'), '<')
8175
?: $errors[] = (object) [
82-
'title' => __('Invalid WordPress version', 'plugin-name'),
83-
'message' => __(
84-
sprintf('You must be using WordPress %s or greater.', $plugin->requiredWP),
85-
'plugin-name'
86-
),
87-
];
76+
'title' => __('Invalid WordPress version', 'plugin-name'),
77+
'message' => __(
78+
sprintf('You must be using WordPress %s or greater.', $plugin->requiredWP),
79+
'plugin-name'
80+
),
81+
];
8882

8983
/**
9084
* Ensure dependencies can be loaded.
9185
*/
9286
file_exists($plugin->composer)
9387
?: $errors[] = (object) [
94-
'title' => __('Autoloader not found', 'plugin-name'),
95-
'message' => __(
96-
sprintf('You must run <code>composer install</code> from the %s plugin directory.', $plugin->name),
97-
'plugin-name'
98-
),
99-
];
88+
'title' => __('Autoloader not found', 'plugin-name'),
89+
'message' => __(
90+
sprintf('You must run <code>composer install</code> from the %s plugin directory.', $plugin->name),
91+
'plugin-name'
92+
),
93+
];
10094

10195
/**
10296
* If there are no errors, boot the plugin, or else display errors:
@@ -121,4 +115,4 @@
121115
add_action('admin_notices', function () use ($errors, $display_errors) {
122116
$display_errors($errors, true);
123117
});
124-
}
118+
}

resources/blocks/sample-block/sample-block.class.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<?php
22

33
namespace ACF_Gutenberg\Blocks;
4+
45
use ACF_Gutenberg\Classes\Block;
56
use StoutLogic\AcfBuilder\FieldsBuilder;
67

78
class SampleBlock extends Block
89
{
10+
public $block_title = 'Sample Block';
911

1012
public $fields_config = [
1113
'bg_color' => true,
1214
'text_color' => true,
1315
'button' => true,
14-
];
16+
];
1517

1618
public function init()
1719
{
@@ -22,25 +24,24 @@ public function set_settings()
2224
{
2325
// Available options: title, icon, category, description, keywords
2426
$this->settings = [
25-
'title' => __('Sample Block'),
26-
'icon' => 'admin-comments',
27+
'title' => __($this->block_title),
28+
'icon' => 'edit',
2729
];
2830
}
2931

3032
public function set_fields()
3133
{
32-
3334
$fields[$this->slug] = new FieldsBuilder($this->slug);
3435
$fields[$this->slug]
3536
->addTab('Content', [
3637
'wrapper' => [
3738
'width' => '100%',
38-
'class' => 'acfgb-tab acfgb-tab-content acfgb-tab-content-'.$this->slug,
39-
'id' => 'acfgb-tab-content-'.$this->slug,
39+
'class' => 'acfgb-tab acfgb-tab-content acfgb-tab-content-' . $this->slug,
40+
'id' => 'acfgb-tab-content-' . $this->slug,
4041
]
4142
])
4243
->addText('title', [
43-
'default_value' => 'Exampleeee'
44+
'default_value' => 'Sample Title'
4445
])
4546
->addText('text', [
4647
'default_value' => 'Sample Text'

0 commit comments

Comments
 (0)