@airfleet/generator-init 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,6 +112,7 @@ export default class extends Generator {
112
112
  ".husky/.gitignore",
113
113
  ".husky/pre-commit",
114
114
  ".vscode/settings.json",
115
+ "acf-json/.gitkeep",
115
116
  "assets/admin/scripts/admin.entry.js",
116
117
  "assets/admin/styles/admin.scss",
117
118
  "assets/frontend/fonts/.gitkeep",
File without changes
@@ -12,7 +12,7 @@
12
12
  "composer/installers": "^2.0"
13
13
  },
14
14
  "require-dev": {
15
- "airfleet/wordpress-dev": "^1.0"
15
+ "airfleet/wordpress-dev": "^2.0"
16
16
  },
17
17
  "autoload": {
18
18
  "psr-4": {
@@ -9,84 +9,52 @@ class Setup {
9
9
  *
10
10
  * @return void
11
11
  */
12
- public function initialize() {
13
- <%_ if (answers.pluginCreateOptions) { _%>
14
- $this->add_option_pages();
15
- <%_ } _%>
16
- $this->enqueue();
17
- }
18
-
19
- /**
20
- * Enqueue the scripts and styles.
21
- *
22
- * @return void
23
- */
24
- public function enqueue() {
25
- $version = <%= name.constant %>_VERSION;
26
-
27
- add_action(
28
- 'wp_enqueue_scripts',
29
- function () use ( $version ) {
30
- wp_enqueue_style(
31
- '<%= name.slug %>-styles',
32
- plugins_url( '/dist/frontend/scripts/index.entry.css', __DIR__ ),
33
- [],
34
- $version
35
- );
36
- wp_enqueue_script(
37
- '<%= name.slug %>-scripts',
38
- plugins_url( '/dist/frontend/scripts/index.entry.js', __DIR__ ),
39
- [],
40
- $version,
41
- true
42
- );
43
- }
44
- );
12
+ public function initialize(): void {
13
+ $this->show_admin_notice_if_missing_framework();
45
14
  add_action(
46
- 'admin_enqueue_scripts',
47
- function () use ( $version ) {
48
- wp_enqueue_style(
49
- '<%= name.slug %>-admin-styles',
50
- plugins_url( '/dist/admin/scripts/admin.entry.css', __DIR__ ),
51
- [],
52
- $version
53
- );
54
- wp_enqueue_script(
55
- '<%= name.slug %>-admin-scripts',
56
- plugins_url( '/dist/admin/scripts/admin.entry.js', __DIR__ ),
57
- [],
58
- $version,
59
- true
15
+ 'airfleet/init',
16
+ function () {
17
+ $plugin = new \Airfleet\Plugin(
18
+ [
19
+ 'slug' => '<%= name.slug %>',
20
+ 'title' => '<%= name.title %>',
21
+ 'short_title' => '<%= nameNoAirfleet.title %>',
22
+ 'url' => \<%= name.constant %>_URL,
23
+ 'path' => \<%= name.constant %>_PATH,
24
+ 'version' => \<%= name.constant %>_VERSION,
25
+ ]
60
26
  );
27
+ $plugin->setup_acf_json();
28
+ $plugin->enqueue();
29
+ $plugin->enqueue_admin();
30
+ <%_ if (answers.pluginCreateOptions) { _%>
31
+ $plugin->add_options_page();
32
+ <%_ } _%>
61
33
  }
62
34
  );
63
35
  }
64
- <%_ if (answers.pluginCreateOptions) {%>
36
+
65
37
  /**
66
- * Add theme options pages.
38
+ * Show and admin notification if the Airfleet Framework plugin is not enabled.
67
39
  *
68
40
  * @return void
69
41
  */
70
- public function add_option_pages() {
42
+ public function show_admin_notice_if_missing_framework(): void {
71
43
  add_action(
72
- 'acf/init',
44
+ 'admin_notices',
73
45
  function () {
74
- \acf_add_options_page(
75
- [
76
- 'page_title' => __( 'Airfleet Theme Settings', 'airfleet' ),
77
- 'menu_title' => __( 'Airfleet', 'airfleet' ),
78
- 'menu_slug' => 'airfleet-settings',
79
- ]
80
- );
81
- \acf_add_options_sub_page(
82
- [
83
- 'page_title' => __( '<%= name.title %> Settings', '<%= name.slug %>' ),
84
- 'menu_title' => __( '<%= nameNoAirfleet.title %>', '<%= name.slug %>' ),
85
- 'parent_slug' => 'airfleet-settings',
86
- ]
87
- );
46
+ global $airfleet_framework_missing_notice;
47
+
48
+ if ( $airfleet_framework_missing_notice || defined( 'AIRFLEET_FRAMEWORK_VERSION' ) ) {
49
+ return;
50
+ }
51
+ $airfleet_framework_missing_notice = true;
52
+ ?>
53
+ <div class="notice notice-error">
54
+ <p>Please install the Airfleet Framework to enable the Airfleet plugins.</p>
55
+ </div>
56
+ <?php
88
57
  }
89
58
  );
90
59
  }
91
- <% } _%>
92
60
  }
@@ -28,6 +28,8 @@ if ( ! defined( 'ABSPATH' ) ) {
28
28
 
29
29
  // Plugin version.
30
30
  define( '<%= name.constant %>_VERSION', '<%= answers.pluginVersion %>' );
31
+ define( '<%= name.constant %>_PATH', plugin_dir_path( __FILE__ ) );
32
+ define( '<%= name.constant %>_URL', plugin_dir_url( __FILE__ ) );
31
33
 
32
34
  // Autoload classes.
33
35
  require_once __DIR__ . '/vendor/autoload.php';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airfleet/generator-init",
3
3
  "description": "A Yeoman generator to scaffold common Airfleet features",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "scripts": {},
6
6
  "publishConfig": {
7
7
  "access": "public"