@wp-operations/wp-ops 0.3.0 → 0.4.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.
Files changed (119) hide show
  1. package/README.md +6 -3
  2. package/package.json +6 -2
  3. package/src/commands/platform.js +58 -2
  4. package/src/commands/start.js +2 -2
  5. package/src/main.js +19 -8
  6. package/wp-operations/CHANGELOG.md +14 -0
  7. package/wp-operations/README.md +39 -0
  8. package/wp-operations/agents/builder/AGENT.md +15 -0
  9. package/wp-operations/assets/admin.css +631 -0
  10. package/wp-operations/assets/admin.js +614 -0
  11. package/wp-operations/assets/app/app.css +1 -0
  12. package/wp-operations/assets/app/app.js +70 -0
  13. package/wp-operations/assets/app/fonts/inter-medium.woff +0 -0
  14. package/wp-operations/assets/app/fonts/inter-regular.woff +0 -0
  15. package/wp-operations/assets/app/fonts/inter-semibold.woff +0 -0
  16. package/wp-operations/assets/app/login.css +42 -0
  17. package/wp-operations/assets/brand/icon.svg +20 -0
  18. package/wp-operations/assets/brand/mark.svg +19 -0
  19. package/wp-operations/assets/editors/audiobook.css +311 -0
  20. package/wp-operations/assets/editors/audiofile.css +286 -0
  21. package/wp-operations/assets/editors/course.css +701 -0
  22. package/wp-operations/assets/editors/course.js +698 -0
  23. package/wp-operations/assets/editors/faq.css +258 -0
  24. package/wp-operations/assets/editors/faq.js +196 -0
  25. package/wp-operations/assets/editors/interactive.css +220 -0
  26. package/wp-operations/assets/editors/interactive.js +378 -0
  27. package/wp-operations/assets/editors/media-sources.css +3 -0
  28. package/wp-operations/assets/editors/media-sources.js +40 -0
  29. package/wp-operations/assets/editors/open-media.css +114 -0
  30. package/wp-operations/assets/editors/open-media.js +182 -0
  31. package/wp-operations/assets/editors/thumbnails.css +335 -0
  32. package/wp-operations/assets/editors/thumbnails.js +447 -0
  33. package/wp-operations/assets/editors/translator.css +818 -0
  34. package/wp-operations/functions.php +24 -0
  35. package/wp-operations/index.php +14 -0
  36. package/wp-operations/platform.json +1836 -0
  37. package/wp-operations/skills/ai-development-guardrails/SKILL.md +49 -0
  38. package/wp-operations/skills/gutenberg-reference/SKILL.md +45 -0
  39. package/wp-operations/skills/js-tooling-for-themes/SKILL.md +51 -0
  40. package/wp-operations/skills/tailwind-for-wp/SKILL.md +62 -0
  41. package/wp-operations/skills/wp-clean-classic-themes/SKILL.md +112 -0
  42. package/wp-operations/skills/wp-psr4-plugins/SKILL.md +2043 -0
  43. package/wp-operations/skills/wp-security/SKILL.md +90 -0
  44. package/wp-operations/src/Admin.php +78 -0
  45. package/wp-operations/src/App/Access.php +57 -0
  46. package/wp-operations/src/App/Admin.php +442 -0
  47. package/wp-operations/src/App/App.php +157 -0
  48. package/wp-operations/src/App/Apps.php +379 -0
  49. package/wp-operations/src/App/Bundle.php +111 -0
  50. package/wp-operations/src/App/Contents.php +676 -0
  51. package/wp-operations/src/App/Engine.php +554 -0
  52. package/wp-operations/src/App/Github.php +308 -0
  53. package/wp-operations/src/App/Module.php +23 -0
  54. package/wp-operations/src/App/Ops.php +470 -0
  55. package/wp-operations/src/App/Packages.php +289 -0
  56. package/wp-operations/src/App/Rest.php +539 -0
  57. package/wp-operations/src/App/Sandboxes.php +206 -0
  58. package/wp-operations/src/App/Store.php +104 -0
  59. package/wp-operations/src/App/Usage.php +268 -0
  60. package/wp-operations/src/Config.php +249 -0
  61. package/wp-operations/src/Content/Editor.php +223 -0
  62. package/wp-operations/src/Content/Fields.php +681 -0
  63. package/wp-operations/src/Content/Scoring.php +253 -0
  64. package/wp-operations/src/Content/Structure.php +293 -0
  65. package/wp-operations/src/Content/Types.php +150 -0
  66. package/wp-operations/src/Content/Uploads.php +50 -0
  67. package/wp-operations/src/Editors/AudiobookAuthor.php +61 -0
  68. package/wp-operations/src/Editors/AudiobookChapters.php +632 -0
  69. package/wp-operations/src/Editors/AudiobookCover.php +235 -0
  70. package/wp-operations/src/Editors/Audiofile.php +462 -0
  71. package/wp-operations/src/Editors/Course.php +784 -0
  72. package/wp-operations/src/Editors/Ebook.php +242 -0
  73. package/wp-operations/src/Editors/Editors.php +44 -0
  74. package/wp-operations/src/Editors/Faq.php +237 -0
  75. package/wp-operations/src/Editors/Files.php +139 -0
  76. package/wp-operations/src/Editors/Interactive/Builder.php +103 -0
  77. package/wp-operations/src/Editors/Interactive/Card.php +76 -0
  78. package/wp-operations/src/Editors/Interactive/Editor.php +42 -0
  79. package/wp-operations/src/Editors/Interactive/Field.php +272 -0
  80. package/wp-operations/src/Editors/Interactive/Map.php +84 -0
  81. package/wp-operations/src/Editors/Interactive/Models.php +227 -0
  82. package/wp-operations/src/Editors/Interactive/Report.php +59 -0
  83. package/wp-operations/src/Editors/Interactive/Save.php +323 -0
  84. package/wp-operations/src/Editors/Interactive/Scoring.php +244 -0
  85. package/wp-operations/src/Editors/Interactive/Structure.php +195 -0
  86. package/wp-operations/src/Editors/Legal.php +235 -0
  87. package/wp-operations/src/Editors/OpenMedia.php +140 -0
  88. package/wp-operations/src/Editors/OriginalTitle.php +112 -0
  89. package/wp-operations/src/Editors/Sources.php +28 -0
  90. package/wp-operations/src/Editors/Thumbnails/Admin.php +306 -0
  91. package/wp-operations/src/Editors/Thumbnails/Ajax.php +163 -0
  92. package/wp-operations/src/Editors/Thumbnails/Box.php +188 -0
  93. package/wp-operations/src/Editors/Thumbnails/Storage.php +228 -0
  94. package/wp-operations/src/Editors/Translator/Admin.php +913 -0
  95. package/wp-operations/src/Editors/Translator/Api.php +63 -0
  96. package/wp-operations/src/Editors/Translator/Bar.php +83 -0
  97. package/wp-operations/src/Editors/Translator/Fields.php +273 -0
  98. package/wp-operations/src/Editors/Translator/Storage.php +131 -0
  99. package/wp-operations/src/Editors/Translator/Thumbnail.php +215 -0
  100. package/wp-operations/src/Identity.php +104 -0
  101. package/wp-operations/src/Languages.php +45 -0
  102. package/wp-operations/src/Lockdown.php +85 -0
  103. package/wp-operations/src/Modules/Apps/Admin.php +472 -0
  104. package/wp-operations/src/Modules/Apps/Api.php +193 -0
  105. package/wp-operations/src/Modules/Apps/Apps.php +279 -0
  106. package/wp-operations/src/Modules/Apps/Formatters.php +478 -0
  107. package/wp-operations/src/Modules/Apps/Schemes.php +248 -0
  108. package/wp-operations/src/Modules/Apps/Table.php +101 -0
  109. package/wp-operations/src/Modules/Thumbnails.php +68 -0
  110. package/wp-operations/src/Modules/Translations.php +133 -0
  111. package/wp-operations/src/Platform.php +59 -0
  112. package/wp-operations/src/Setup.php +273 -0
  113. package/wp-operations/src/Status.php +99 -0
  114. package/wp-operations/src/Storage/Client.php +168 -0
  115. package/wp-operations/src/Storage/Offload.php +120 -0
  116. package/wp-operations/src/Storage/Settings.php +166 -0
  117. package/wp-operations/src/Storage/Storage.php +35 -0
  118. package/wp-operations/src/Updates.php +151 -0
  119. package/wp-operations/style.css +11 -0
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: wp-security
3
+ description: >
4
+ WordPress & ClassicPress security: the threat model behind the private
5
+ vendor-package strategy, the four-point request pattern, hardening
6
+ checklist, and what actually gets sites hacked. Applies to both engines.
7
+ references:
8
+ - https://developer.wordpress.org/apis/security/
9
+ - https://owasp.org/www-project-top-ten/
10
+ ---
11
+
12
+ ## The actual threat model
13
+
14
+ Understand what attacks WordPress sites in practice, in order of volume:
15
+
16
+ 1. **Automated exploitation of known plugin/theme CVEs.** Bots scan for
17
+ `/wp-content/plugins/<popular-plugin>/` paths and version strings, then fire
18
+ known exploits. This is the overwhelming majority of compromises.
19
+ 2. **Credential attacks** — password stuffing on `wp-login.php` and xmlrpc.
20
+ 3. **Vulnerable custom code** — SQLi, XSS, CSRF, IDOR in bespoke plugins/themes.
21
+ 4. **Supply chain** — compromised plugin updates, nulled plugins.
22
+ 5. Server-level issues (outdated PHP, exposed backups, weak SFTP).
23
+
24
+ ## The private vendor-package posture
25
+
26
+ Running your own private PSR-4 Composer packages as plugins (instead of public
27
+ marketplace plugins) removes you from category 1 entirely: no public CVE database
28
+ lists your code, no bot scans for it, no mass campaign targets it.
29
+
30
+ **The honest trade-off:** nobody audits your code but you. Obscurity is not
31
+ security — it is *attack-surface reduction*. The compensating controls are
32
+ mandatory, not optional:
33
+
34
+ - Every request handler follows the four-point pattern (below)
35
+ - The wp-psr4-plugins handbook rules are enforced, not aspirational
36
+ - Dependencies (composer + npm) are audited and pinned
37
+
38
+ ## The four-point pattern
39
+
40
+ Every form handler, AJAX callback, REST endpoint, admin-post handler:
41
+
42
+ ```
43
+ 1. Capability — current_user_can(), before anything else
44
+ 2. Nonce — wp_verify_nonce() / check_ajax_referer()
45
+ 3. Sanitize in — wp_unslash() then sanitize_*() / absint() on every input
46
+ 4. Escape out — esc_html/esc_attr/esc_url/wp_kses at the point of echo
47
+ ```
48
+
49
+ Public endpoints (nopriv AJAX, open REST) skip point 1 as an explicit, commented
50
+ decision — never by omission. See wp-psr4-plugins §12–14 for full code patterns.
51
+
52
+ ## SQL
53
+
54
+ - `$wpdb->prepare()` for every query touching any variable. Zero concatenation.
55
+ - `%d` / `%s` / `%f` placeholders; `{$wpdb->prefix}` for table names.
56
+ - Prefer WP APIs (`WP_Query`, meta, options) over raw SQL wherever possible.
57
+
58
+ ## Common custom-code vulnerabilities and their fixes
59
+
60
+ | Vulnerability | Broken pattern | Fix |
61
+ |---|---|---|
62
+ | SQLi | `"WHERE id = $id"` | `$wpdb->prepare('WHERE id = %d', $id)` |
63
+ | Reflected XSS | `echo $_GET['q']` | `echo esc_html(sanitize_text_field(wp_unslash($_GET['q'] ?? '')))` |
64
+ | Stored XSS | saving raw HTML to meta | `wp_kses_post()` on write, escape on output anyway |
65
+ | CSRF | form without nonce | `wp_nonce_field()` + `wp_verify_nonce()` |
66
+ | IDOR | trusting `$_POST['order_id']` | ownership check: compare stored customer id with `get_current_user_id()` |
67
+ | Privilege escalation | missing capability check on admin-post | `current_user_can()` first line |
68
+ | Open redirect | `wp_redirect($_GET['next'])` | `wp_safe_redirect()` + `esc_url_raw()` |
69
+ | File upload RCE | trusting `$_FILES` names/types | `wp_handle_upload()` with allowed mime array |
70
+ | Path traversal | `include $_GET['template']` | never include from request data; whitelist map |
71
+ | Object injection | `unserialize()` on user data | JSON only: `json_decode()` |
72
+
73
+ ## Hardening checklist (site level)
74
+
75
+ - [ ] PHP >= 8.0, auto minor core updates on
76
+ - [ ] Unique salts in wp-config; `DISALLOW_FILE_EDIT` true
77
+ - [ ] xmlrpc disabled unless actually used
78
+ - [ ] Login protected (rate limit, 2FA for admins, no `admin` username)
79
+ - [ ] Application passwords for REST auth, never cookie reuse from scripts
80
+ - [ ] DB user has only needed grants; table prefix is cosmetic, not security
81
+ - [ ] Backups exist, are offsite, and are restore-tested
82
+ - [ ] `WP_DEBUG` off in production; debug.log outside webroot if on
83
+ - [ ] Composer/npm lockfiles committed; `composer audit` / `npm audit` in CI
84
+ - [ ] Secrets in environment/config outside VCS, never in code
85
+
86
+ ## Disclosure hygiene
87
+
88
+ Remove version leaks where cheap (generator meta, readme.html), but never rely
89
+ on it. If you ship a public plugin later: security.txt, a disclosure contact,
90
+ and patch-before-disclose discipline.
@@ -0,0 +1,78 @@
1
+ <?php
2
+ /**
3
+ * Admin and front end trimming from platform.json "admin".
4
+ *
5
+ * @package Platform
6
+ */
7
+
8
+ namespace Platform;
9
+
10
+ defined( 'ABSPATH' ) || exit;
11
+
12
+ final class Admin {
13
+
14
+ public static function register(): void {
15
+ add_action( 'after_setup_theme', [ __CLASS__, 'supports' ] );
16
+ add_action( 'admin_menu', [ __CLASS__, 'menus' ], 999 );
17
+ add_action( 'admin_init', [ __CLASS__, 'block' ], 1 );
18
+ add_action( 'admin_bar_menu', [ __CLASS__, 'admin_bar' ], 999 );
19
+ add_action( 'init', [ __CLASS__, 'front' ] );
20
+ add_filter( 'map_meta_cap', [ __CLASS__, 'deny_capabilities' ], 10, 2 );
21
+ }
22
+
23
+ public static function deny_capabilities( array $caps, string $cap ): array {
24
+ return in_array( $cap, (array) Config::get( 'admin.deny_capabilities', [] ), true ) ? [ 'do_not_allow' ] : $caps;
25
+ }
26
+
27
+ public static function supports(): void {
28
+ add_theme_support( 'post-thumbnails' );
29
+ add_theme_support( 'html5', [ 'script', 'style' ] );
30
+ }
31
+
32
+ public static function menus(): void {
33
+ foreach ( (array) Config::get( 'admin.hide_menus', [] ) as $slug ) {
34
+ remove_menu_page( (string) $slug );
35
+ }
36
+
37
+ foreach ( (array) Config::get( 'admin.hide_submenus', [] ) as $parent => $children ) {
38
+ foreach ( (array) $children as $child ) {
39
+ remove_submenu_page( (string) $parent, (string) $child );
40
+ }
41
+ }
42
+ }
43
+
44
+ public static function block(): void {
45
+ global $pagenow;
46
+
47
+ $screen = $pagenow . ( isset( $_GET['post_type'] ) ? '?post_type=' . sanitize_key( wp_unslash( $_GET['post_type'] ) ) : '' );
48
+ $blocked = (array) Config::get( 'admin.block_screens', [] );
49
+
50
+ if ( in_array( $screen, $blocked, true ) || ( 'edit.php' === $pagenow && ! isset( $_GET['post_type'] ) && in_array( 'edit.php?post_type=post', $blocked, true ) ) ) {
51
+ wp_safe_redirect( admin_url() );
52
+ exit;
53
+ }
54
+ }
55
+
56
+ public static function admin_bar( \WP_Admin_Bar $bar ): void {
57
+ foreach ( (array) Config::get( 'admin.hide_admin_bar', [] ) as $node ) {
58
+ $bar->remove_node( (string) $node );
59
+ }
60
+ }
61
+
62
+ public static function front(): void {
63
+ remove_action( 'wp_head', 'wp_generator' );
64
+ remove_action( 'wp_head', 'wlwmanifest_link' );
65
+ remove_action( 'wp_head', 'rsd_link' );
66
+ remove_action( 'wp_head', 'wp_shortlink_wp_head' );
67
+
68
+ if ( false === Config::get( 'admin.feeds', true ) ) {
69
+ foreach ( [ 'do_feed', 'do_feed_rdf', 'do_feed_rss', 'do_feed_rss2', 'do_feed_atom' ] as $feed ) {
70
+ add_action( $feed, [ __CLASS__, 'no_feed' ], 1 );
71
+ }
72
+ }
73
+ }
74
+
75
+ public static function no_feed(): void {
76
+ wp_die( 'No feeds available.', '', [ 'response' => 404 ] );
77
+ }
78
+ }
@@ -0,0 +1,57 @@
1
+ <?php
2
+ namespace Platform\App;
3
+
4
+ defined( 'ABSPATH' ) || exit;
5
+
6
+ final class Access {
7
+
8
+ const OVERRIDE = 'platform_access';
9
+
10
+ public static function register(): void {
11
+ add_filter( 'user_has_cap', [ __CLASS__, 'grant' ], 10, 4 );
12
+ }
13
+
14
+ public static function cap(): string {
15
+ return sanitize_key( (string) Module::config( 'access.capability', 'prompt' ) ) ?: 'prompt';
16
+ }
17
+
18
+ public static function grant( array $allcaps, array $caps, array $args, \WP_User $user ): array {
19
+ if ( in_array( self::cap(), $caps, true ) ) {
20
+ $allcaps[ self::cap() ] = self::allowed( $user );
21
+ }
22
+
23
+ return $allcaps;
24
+ }
25
+
26
+ public static function allowed( \WP_User $user ): bool {
27
+ $override = self::override( $user->ID );
28
+
29
+ if ( 'deny' === $override ) {
30
+ return false;
31
+ }
32
+
33
+ if ( 'allow' === $override ) {
34
+ return true;
35
+ }
36
+
37
+ return self::by_role( $user );
38
+ }
39
+
40
+ public static function by_role( \WP_User $user ): bool {
41
+ $roles = (array) $user->roles;
42
+ $include = array_filter( (array) Module::config( 'access.include_roles', [] ) ) ?: [ 'administrator', 'editor' ];
43
+ $exclude = (array) Module::config( 'access.exclude_roles', [] );
44
+
45
+ return ! array_intersect( $roles, $exclude ) && (bool) array_intersect( $roles, $include );
46
+ }
47
+
48
+ public static function override( int $user_id ): string {
49
+ $value = (string) get_user_meta( $user_id, self::OVERRIDE, true );
50
+
51
+ return in_array( $value, [ 'allow', 'deny' ], true ) ? $value : '';
52
+ }
53
+
54
+ public static function can(): bool {
55
+ return is_user_logged_in() && current_user_can( self::cap() );
56
+ }
57
+ }