@airfleet/generator-init 0.7.0 → 0.10.1

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.
@@ -1,6 +1,6 @@
1
1
  # <%= answers.npmTitle %>
2
2
 
3
- ![npm](https://img.shields.io/npm/v/<%= packageName %>)
3
+ [![npm](https://img.shields.io/npm/v/<%= packageName %>)](https://www.npmjs.com/package/<%= packageName %>)
4
4
  [![pipeline status](<%= repositoryBase %>/badges/main/pipeline.svg)](<%= repositoryBase %>/-/commits/main)
5
5
 
6
6
  <%= answers.npmDescription %>
@@ -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",
@@ -1 +0,0 @@
1
- PARCEL_WORKER_BACKEND=process
@@ -1,7 +1,13 @@
1
1
  stages:
2
+ - test
2
3
  - release
4
+ - upload
3
5
 
4
6
  include:
7
+ # Test
8
+ - project: "codersclan/tools/gitlab-ci-templates"
9
+ ref: main
10
+ file: "/test/wordpress.yaml"
5
11
  # Release process
6
12
  - project: "codersclan/tools/gitlab-ci-templates"
7
13
  ref: main
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,61 @@ 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();
12
+ public function initialize(): void {
13
+ $this->show_admin_notice_if_missing_framework();
14
+ add_action(
15
+ 'airfleet/init',
16
+ function () {
17
+ $this->plugin_basic_setup();
18
+ }
19
+ );
17
20
  }
18
21
 
19
22
  /**
20
- * Enqueue the scripts and styles.
23
+ * Basic setup for the plugin. Enqueue assets and add options page
21
24
  *
22
25
  * @return void
23
26
  */
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
- );
45
- 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
60
- );
61
- }
62
- );
27
+ public function plugin_basic_setup(): void {
28
+ $plugin = new \Airfleet\Plugin(
29
+ [
30
+ 'slug' => '<%= name.slug %>',
31
+ 'title' => '<%= name.title %>',
32
+ 'short_title' => '<%= nameNoAirfleet.title %>',
33
+ 'url' => \<%= name.constant %>_URL,
34
+ 'path' => \<%= name.constant %>_PATH,
35
+ 'version' => \<%= name.constant %>_VERSION,
36
+ ]
37
+ );
38
+ $plugin->setup_acf_json();
39
+ $plugin->enqueue();
40
+ $plugin->enqueue_admin();
41
+ <%_ if (answers.pluginCreateOptions) { _%>
42
+ $plugin->add_options_page();
43
+ <%_ } _%>
63
44
  }
64
- <%_ if (answers.pluginCreateOptions) {%>
45
+
65
46
  /**
66
- * Add theme options pages.
47
+ * Show and admin notification if the Airfleet Framework plugin is not enabled.
67
48
  *
68
49
  * @return void
69
50
  */
70
- public function add_option_pages() {
51
+ public function show_admin_notice_if_missing_framework(): void {
71
52
  add_action(
72
- 'acf/init',
53
+ 'admin_notices',
73
54
  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
- );
55
+ global $airfleet_framework_missing_notice;
56
+
57
+ if ( $airfleet_framework_missing_notice || defined( 'AIRFLEET_FRAMEWORK_VERSION' ) ) {
58
+ return;
59
+ }
60
+ $airfleet_framework_missing_notice = true;
61
+ ?>
62
+ <div class="notice notice-error">
63
+ <p>Please install the Airfleet Framework to enable the Airfleet plugins.</p>
64
+ </div>
65
+ <?php
88
66
  }
89
67
  );
90
68
  }
91
- <% } _%>
92
69
  }
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {},
44
44
  "devDependencies": {
45
- "@airfleet/wordpress-dev": "^0.3.0"
45
+ "@airfleet/wordpress-dev": "^0.3.2"
46
46
  },
47
47
  "browserslist": [
48
48
  "defaults",
@@ -26,8 +26,10 @@ if ( ! defined( 'ABSPATH' ) ) {
26
26
  die;
27
27
  }
28
28
 
29
- // Plugin version.
29
+ // Plugin constants.
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.7.0",
4
+ "version": "0.10.1",
5
5
  "scripts": {},
6
6
  "publishConfig": {
7
7
  "access": "public"