@wp-operations/wp-ops 0.2.0 → 0.3.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.
- package/README.md +30 -27
- package/bin/wp-app.js +2 -0
- package/bin/wp-code.js +2 -0
- package/bin/wp-ide.js +2 -0
- package/package.json +12 -3
- package/src/commands/platform.js +16 -2
- package/src/commands/sandbox.js +3 -3
- package/src/main.js +10 -4
- package/wp-operations/CHANGELOG.md +14 -0
- package/wp-operations/README.md +39 -0
- package/wp-operations/agents/builder/AGENT.md +15 -0
- package/wp-operations/assets/admin.css +631 -0
- package/wp-operations/assets/admin.js +614 -0
- package/wp-operations/assets/app/app.css +1 -0
- package/wp-operations/assets/app/app.js +70 -0
- package/wp-operations/assets/app/fonts/inter-medium.woff +0 -0
- package/wp-operations/assets/app/fonts/inter-regular.woff +0 -0
- package/wp-operations/assets/app/fonts/inter-semibold.woff +0 -0
- package/wp-operations/assets/app/login.css +42 -0
- package/wp-operations/assets/brand/icon.svg +20 -0
- package/wp-operations/assets/brand/mark.svg +19 -0
- package/wp-operations/assets/editors/audiobook.css +311 -0
- package/wp-operations/assets/editors/audiofile.css +286 -0
- package/wp-operations/assets/editors/course.css +701 -0
- package/wp-operations/assets/editors/course.js +698 -0
- package/wp-operations/assets/editors/faq.css +258 -0
- package/wp-operations/assets/editors/faq.js +196 -0
- package/wp-operations/assets/editors/interactive.css +220 -0
- package/wp-operations/assets/editors/interactive.js +378 -0
- package/wp-operations/assets/editors/media-sources.css +3 -0
- package/wp-operations/assets/editors/media-sources.js +40 -0
- package/wp-operations/assets/editors/open-media.css +114 -0
- package/wp-operations/assets/editors/open-media.js +182 -0
- package/wp-operations/assets/editors/thumbnails.css +335 -0
- package/wp-operations/assets/editors/thumbnails.js +447 -0
- package/wp-operations/assets/editors/translator.css +818 -0
- package/wp-operations/functions.php +24 -0
- package/wp-operations/index.php +14 -0
- package/wp-operations/platform.json +1836 -0
- package/wp-operations/skills/ai-development-guardrails/SKILL.md +49 -0
- package/wp-operations/skills/gutenberg-reference/SKILL.md +45 -0
- package/wp-operations/skills/js-tooling-for-themes/SKILL.md +51 -0
- package/wp-operations/skills/tailwind-for-wp/SKILL.md +62 -0
- package/wp-operations/skills/wp-clean-classic-themes/SKILL.md +112 -0
- package/wp-operations/skills/wp-psr4-plugins/SKILL.md +2043 -0
- package/wp-operations/skills/wp-security/SKILL.md +90 -0
- package/wp-operations/src/Admin.php +78 -0
- package/wp-operations/src/App/Access.php +57 -0
- package/wp-operations/src/App/Admin.php +442 -0
- package/wp-operations/src/App/App.php +157 -0
- package/wp-operations/src/App/Apps.php +379 -0
- package/wp-operations/src/App/Bundle.php +111 -0
- package/wp-operations/src/App/Contents.php +676 -0
- package/wp-operations/src/App/Engine.php +554 -0
- package/wp-operations/src/App/Github.php +308 -0
- package/wp-operations/src/App/Module.php +23 -0
- package/wp-operations/src/App/Ops.php +470 -0
- package/wp-operations/src/App/Packages.php +289 -0
- package/wp-operations/src/App/Rest.php +539 -0
- package/wp-operations/src/App/Sandboxes.php +206 -0
- package/wp-operations/src/App/Store.php +104 -0
- package/wp-operations/src/App/Usage.php +268 -0
- package/wp-operations/src/Config.php +249 -0
- package/wp-operations/src/Content/Editor.php +223 -0
- package/wp-operations/src/Content/Fields.php +681 -0
- package/wp-operations/src/Content/Scoring.php +253 -0
- package/wp-operations/src/Content/Structure.php +293 -0
- package/wp-operations/src/Content/Types.php +150 -0
- package/wp-operations/src/Content/Uploads.php +50 -0
- package/wp-operations/src/Editors/AudiobookAuthor.php +61 -0
- package/wp-operations/src/Editors/AudiobookChapters.php +632 -0
- package/wp-operations/src/Editors/AudiobookCover.php +235 -0
- package/wp-operations/src/Editors/Audiofile.php +462 -0
- package/wp-operations/src/Editors/Course.php +784 -0
- package/wp-operations/src/Editors/Ebook.php +242 -0
- package/wp-operations/src/Editors/Editors.php +44 -0
- package/wp-operations/src/Editors/Faq.php +237 -0
- package/wp-operations/src/Editors/Files.php +139 -0
- package/wp-operations/src/Editors/Interactive/Builder.php +103 -0
- package/wp-operations/src/Editors/Interactive/Card.php +76 -0
- package/wp-operations/src/Editors/Interactive/Editor.php +42 -0
- package/wp-operations/src/Editors/Interactive/Field.php +272 -0
- package/wp-operations/src/Editors/Interactive/Map.php +84 -0
- package/wp-operations/src/Editors/Interactive/Models.php +227 -0
- package/wp-operations/src/Editors/Interactive/Report.php +59 -0
- package/wp-operations/src/Editors/Interactive/Save.php +323 -0
- package/wp-operations/src/Editors/Interactive/Scoring.php +244 -0
- package/wp-operations/src/Editors/Interactive/Structure.php +195 -0
- package/wp-operations/src/Editors/Legal.php +235 -0
- package/wp-operations/src/Editors/OpenMedia.php +140 -0
- package/wp-operations/src/Editors/OriginalTitle.php +112 -0
- package/wp-operations/src/Editors/Sources.php +28 -0
- package/wp-operations/src/Editors/Thumbnails/Admin.php +306 -0
- package/wp-operations/src/Editors/Thumbnails/Ajax.php +163 -0
- package/wp-operations/src/Editors/Thumbnails/Box.php +188 -0
- package/wp-operations/src/Editors/Thumbnails/Storage.php +228 -0
- package/wp-operations/src/Editors/Translator/Admin.php +913 -0
- package/wp-operations/src/Editors/Translator/Api.php +63 -0
- package/wp-operations/src/Editors/Translator/Bar.php +83 -0
- package/wp-operations/src/Editors/Translator/Fields.php +273 -0
- package/wp-operations/src/Editors/Translator/Storage.php +131 -0
- package/wp-operations/src/Editors/Translator/Thumbnail.php +215 -0
- package/wp-operations/src/Identity.php +104 -0
- package/wp-operations/src/Languages.php +45 -0
- package/wp-operations/src/Lockdown.php +85 -0
- package/wp-operations/src/Modules/Apps/Admin.php +472 -0
- package/wp-operations/src/Modules/Apps/Api.php +193 -0
- package/wp-operations/src/Modules/Apps/Apps.php +279 -0
- package/wp-operations/src/Modules/Apps/Formatters.php +478 -0
- package/wp-operations/src/Modules/Apps/Schemes.php +248 -0
- package/wp-operations/src/Modules/Apps/Table.php +101 -0
- package/wp-operations/src/Modules/Thumbnails.php +68 -0
- package/wp-operations/src/Modules/Translations.php +133 -0
- package/wp-operations/src/Platform.php +59 -0
- package/wp-operations/src/Setup.php +273 -0
- package/wp-operations/src/Status.php +99 -0
- package/wp-operations/src/Storage/Client.php +168 -0
- package/wp-operations/src/Storage/Offload.php +120 -0
- package/wp-operations/src/Storage/Settings.php +166 -0
- package/wp-operations/src/Storage/Storage.php +35 -0
- package/wp-operations/src/Updates.php +151 -0
- package/wp-operations/style.css +11 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Registers content types and taxonomies from platform.json.
|
|
4
|
+
*
|
|
5
|
+
* @package Platform
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
namespace Platform\Content;
|
|
9
|
+
|
|
10
|
+
use Platform\Config;
|
|
11
|
+
|
|
12
|
+
defined( 'ABSPATH' ) || exit;
|
|
13
|
+
|
|
14
|
+
final class Types {
|
|
15
|
+
|
|
16
|
+
public static function register(): void {
|
|
17
|
+
add_action( 'init', [ __CLASS__, 'register_types' ], 5 );
|
|
18
|
+
add_action( 'restrict_manage_posts', [ __CLASS__, 'filters' ] );
|
|
19
|
+
add_action( 'pre_get_posts', [ __CLASS__, 'filter_query' ] );
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static function filter_query( \WP_Query $query ): void {
|
|
23
|
+
global $pagenow;
|
|
24
|
+
|
|
25
|
+
if ( ! is_admin() || 'edit.php' !== $pagenow || ! $query->is_main_query() ) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
$type = Config::type( (string) $query->get( 'post_type' ) );
|
|
30
|
+
|
|
31
|
+
if ( ! $type || 'legal' === $type['editor'] ) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$tax = [];
|
|
36
|
+
|
|
37
|
+
foreach ( Config::taxonomies_for( $type['key'] ) as $key ) {
|
|
38
|
+
$slug = sanitize_title( wp_unslash( (string) ( $_GET[ $key ] ?? '' ) ) );
|
|
39
|
+
|
|
40
|
+
if ( '' !== $slug && '0' !== $slug ) {
|
|
41
|
+
$tax[] = [ 'taxonomy' => $key, 'field' => 'slug', 'terms' => $slug ];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ( $tax ) {
|
|
46
|
+
$query->set( 'tax_query', $tax );
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public static function filters( string $post_type ): void {
|
|
51
|
+
$type = Config::type( $post_type );
|
|
52
|
+
|
|
53
|
+
if ( ! $type || 'legal' === $type['editor'] ) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
foreach ( Config::taxonomies_for( $post_type ) as $key ) {
|
|
58
|
+
$taxonomy = Config::taxonomy( $key );
|
|
59
|
+
$object = get_taxonomy( $key );
|
|
60
|
+
|
|
61
|
+
if ( ! $object ) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
wp_dropdown_categories(
|
|
66
|
+
[
|
|
67
|
+
'show_option_all' => sprintf( 'All %s', $object->label ),
|
|
68
|
+
'taxonomy' => $taxonomy['key'],
|
|
69
|
+
'name' => $taxonomy['key'],
|
|
70
|
+
'orderby' => 'name',
|
|
71
|
+
'value_field' => 'slug',
|
|
72
|
+
'selected' => sanitize_title( wp_unslash( (string) ( $_GET[ $taxonomy['key'] ] ?? '' ) ) ),
|
|
73
|
+
'show_count' => true,
|
|
74
|
+
'hide_empty' => false,
|
|
75
|
+
'hierarchical' => $taxonomy['hierarchical'],
|
|
76
|
+
]
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public static function register_types(): void {
|
|
82
|
+
foreach ( Config::types() as $type ) {
|
|
83
|
+
$top = '' === $type['parent'];
|
|
84
|
+
|
|
85
|
+
register_post_type(
|
|
86
|
+
$type['key'],
|
|
87
|
+
[
|
|
88
|
+
'labels' => self::labels( $type['label'], $type['singular'] ),
|
|
89
|
+
'public' => false,
|
|
90
|
+
'show_ui' => $top,
|
|
91
|
+
'show_in_menu' => $top,
|
|
92
|
+
'show_in_rest' => false,
|
|
93
|
+
'menu_icon' => $type['icon'],
|
|
94
|
+
'menu_position' => $type['position'],
|
|
95
|
+
'supports' => $top ? $type['supports'] : array_values( array_unique( array_merge( $type['supports'], [ 'page-attributes' ] ) ) ),
|
|
96
|
+
'hierarchical' => false,
|
|
97
|
+
'has_archive' => false,
|
|
98
|
+
'rewrite' => false,
|
|
99
|
+
'query_var' => false,
|
|
100
|
+
'capability_type' => 'post',
|
|
101
|
+
'map_meta_cap' => true,
|
|
102
|
+
'service_content' => (bool) $type['api'],
|
|
103
|
+
'content_translation' => $type['translate'],
|
|
104
|
+
]
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
foreach ( Config::taxonomies() as $taxonomy ) {
|
|
109
|
+
register_taxonomy(
|
|
110
|
+
$taxonomy['key'],
|
|
111
|
+
$taxonomy['types'],
|
|
112
|
+
[
|
|
113
|
+
'labels' => self::labels( $taxonomy['label'], $taxonomy['singular'] ),
|
|
114
|
+
'public' => false,
|
|
115
|
+
'show_ui' => true,
|
|
116
|
+
'show_admin_column' => true,
|
|
117
|
+
'show_in_rest' => false,
|
|
118
|
+
'hierarchical' => $taxonomy['hierarchical'],
|
|
119
|
+
'rewrite' => false,
|
|
120
|
+
'query_var' => false,
|
|
121
|
+
'meta_box_cb' => 'one' === $taxonomy['relation'] ? [ Editor::class, 'term_select_box' ] : null,
|
|
122
|
+
'content_translation' => $taxonomy['translate'],
|
|
123
|
+
]
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private static function labels( string $plural, string $singular ): array {
|
|
129
|
+
return [
|
|
130
|
+
'name' => $plural,
|
|
131
|
+
'singular_name' => $singular,
|
|
132
|
+
'menu_name' => $plural,
|
|
133
|
+
'all_items' => sprintf( 'All %s', $plural ),
|
|
134
|
+
'add_new' => 'Add New',
|
|
135
|
+
'add_new_item' => sprintf( 'Add New %s', $singular ),
|
|
136
|
+
'edit_item' => sprintf( 'Edit %s', $singular ),
|
|
137
|
+
'new_item' => sprintf( 'New %s', $singular ),
|
|
138
|
+
'view_item' => sprintf( 'View %s', $singular ),
|
|
139
|
+
'update_item' => sprintf( 'Update %s', $singular ),
|
|
140
|
+
'search_items' => sprintf( 'Search %s', $plural ),
|
|
141
|
+
'not_found' => sprintf( 'No %s found', strtolower( $plural ) ),
|
|
142
|
+
'not_found_in_trash' => sprintf( 'No %s found in Trash', strtolower( $plural ) ),
|
|
143
|
+
'parent_item' => sprintf( 'Parent %s', $singular ),
|
|
144
|
+
'featured_image' => 'Thumbnail',
|
|
145
|
+
'set_featured_image' => 'Set thumbnail',
|
|
146
|
+
'remove_featured_image' => 'Remove thumbnail',
|
|
147
|
+
'use_featured_image' => 'Use as thumbnail',
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Direct-to-bucket uploads for media fields: the browser asks for a signed
|
|
4
|
+
*
|
|
5
|
+
* @package Platform
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
namespace Platform\Content;
|
|
9
|
+
|
|
10
|
+
use Platform\Storage\Storage;
|
|
11
|
+
|
|
12
|
+
defined( 'ABSPATH' ) || exit;
|
|
13
|
+
|
|
14
|
+
final class Uploads {
|
|
15
|
+
|
|
16
|
+
public static function register(): void {
|
|
17
|
+
add_action( 'wp_ajax_platform_upload_target', [ __CLASS__, 'target' ] );
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static function target(): void {
|
|
21
|
+
if ( ! check_ajax_referer( 'platform_admin', 'nonce', false ) || ! current_user_can( 'upload_files' ) ) {
|
|
22
|
+
wp_send_json_error( [ 'message' => 'Not allowed.' ], 403 );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$client = Storage::client();
|
|
26
|
+
|
|
27
|
+
if ( ! $client ) {
|
|
28
|
+
wp_send_json_error( [ 'message' => 'Storage is not set up.' ], 400 );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
$name = sanitize_file_name( wp_unslash( (string) ( $_POST['name'] ?? '' ) ) );
|
|
32
|
+
$check = wp_check_filetype( $name );
|
|
33
|
+
|
|
34
|
+
if ( ! $check['ext'] ) {
|
|
35
|
+
wp_send_json_error( [ 'message' => 'This file type is not allowed.' ], 400 );
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
$folder = sanitize_title( wp_unslash( (string) ( $_POST['folder'] ?? '' ) ) ) ?: 'media';
|
|
39
|
+
$base = sanitize_title( pathinfo( $name, PATHINFO_FILENAME ) ) ?: 'file';
|
|
40
|
+
$key = $folder . '/' . $base . '_' . uniqid() . '.' . $check['ext'];
|
|
41
|
+
|
|
42
|
+
wp_send_json_success(
|
|
43
|
+
[
|
|
44
|
+
'upload' => $client->presign_put( $key ),
|
|
45
|
+
'url' => $client->url( $key ),
|
|
46
|
+
'type' => $check['type'],
|
|
47
|
+
]
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
namespace Platform\Editors;
|
|
3
|
+
|
|
4
|
+
defined( 'ABSPATH' ) || exit;
|
|
5
|
+
|
|
6
|
+
final class AudiobookAuthor {
|
|
7
|
+
public function __construct() {
|
|
8
|
+
add_action('add_meta_boxes', array($this, 'register_metabox'));
|
|
9
|
+
|
|
10
|
+
add_action('save_post_audiobook', array($this, 'save_meta'));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public function register_metabox() {
|
|
14
|
+
add_meta_box(
|
|
15
|
+
'audiobook_author_metabox',
|
|
16
|
+
__( 'Author Name' ),
|
|
17
|
+
array($this, 'render_metabox'),
|
|
18
|
+
'audiobook',
|
|
19
|
+
'side',
|
|
20
|
+
'default'
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public function render_metabox($post) {
|
|
25
|
+
wp_nonce_field('audiobook_author_nonce_action', 'audiobook_author_nonce');
|
|
26
|
+
|
|
27
|
+
$author_name = get_post_meta($post->ID, '_audiobook_author_name', true);
|
|
28
|
+
?>
|
|
29
|
+
<p>
|
|
30
|
+
<label for="audiobook_author_name"><?php _e( 'Enter the author\'s name:' ); ?></label><br>
|
|
31
|
+
<input
|
|
32
|
+
type="text"
|
|
33
|
+
id="audiobook_author_name"
|
|
34
|
+
name="audiobook_author_name"
|
|
35
|
+
value="<?php echo esc_attr($author_name); ?>"
|
|
36
|
+
style="width:100%;"
|
|
37
|
+
/>
|
|
38
|
+
</p>
|
|
39
|
+
<?php
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public function save_meta($post_id) {
|
|
43
|
+
if (!isset($_POST['audiobook_author_nonce']) ||
|
|
44
|
+
!wp_verify_nonce($_POST['audiobook_author_nonce'], 'audiobook_author_nonce_action')) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!current_user_can('edit_post', $post_id)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (isset($_POST['audiobook_author_name'])) {
|
|
57
|
+
$author_name = sanitize_text_field($_POST['audiobook_author_name']);
|
|
58
|
+
update_post_meta($post_id, '_audiobook_author_name', $author_name);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|