-
Notifications
You must be signed in to change notification settings - Fork 125
Add Activity Library — activity_kit post type, archive, single pages, stats dashboard #3496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Piyopiyo-Kitsune
wants to merge
10
commits into
trunk
Choose a base branch
from
feature/activity-library
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
62e74e9
Add Activity Library feature for learn.wordpress.org
Piyopiyo-Kitsune 3b2f17b
Apply prettier formatting to existing plugin JS files
Piyopiyo-Kitsune 7974c72
Refine Activity Library: UX polish, stats dashboard, feedback strip, …
Piyopiyo-Kitsune 9d0422e
Fix JS lint failures: root ESLint scope, import order, identifier names
Piyopiyo-Kitsune 84f131d
Add "Last updated" date to single activity kit header
Piyopiyo-Kitsune 170e2be
Update "Read the handbook" link to activity kits handbook page
Piyopiyo-Kitsune 0c4a6c0
Address Copilot code review: fix bugs, remove dead code, harden CI lint
Piyopiyo-Kitsune 25d9232
Fix PluginDocumentSettingPanel import: use @wordpress/edit-post
Piyopiyo-Kitsune 1463689
Fix import command: seed kits as drafts, not published
Piyopiyo-Kitsune c63a0cc
Fix PHPCS docblock: align @param spacing in activity_kit_query_vars
Piyopiyo-Kitsune File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| <?php | ||
| // This file handles special loading of mu-plugins. | ||
|
|
||
| require_once __DIR__ . '/wporg-mu-plugins/mu-plugins/loader.php'; | ||
| require_once __DIR__ . '/pub/class-validator.php'; | ||
| require_once __DIR__ . '/pub/locales.php'; | ||
| if ( file_exists( __DIR__ . '/wporg-mu-plugins/mu-plugins/loader.php' ) ) { | ||
| require_once __DIR__ . '/wporg-mu-plugins/mu-plugins/loader.php'; | ||
| } | ||
| if ( file_exists( __DIR__ . '/pub/class-validator.php' ) ) { | ||
| require_once __DIR__ . '/pub/class-validator.php'; | ||
| } | ||
| if ( file_exists( __DIR__ . '/pub/locales.php' ) && file_exists( __DIR__ . '/pub/locales/locales.php' ) ) { | ||
| require_once __DIR__ . '/pub/locales.php'; | ||
| } | ||
|
|
||
| // Enable Jetpack OpenGraph output. | ||
| add_filter( 'jetpack_enable_open_graph', '__return_true' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| module.exports = { | ||
| root: true, | ||
| extends: 'plugin:@wordpress/eslint-plugin/recommended', | ||
|
|
||
| parserOptions: { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "useTabs": true, | ||
| "tabWidth": 4, | ||
| "printWidth": 80 | ||
| } |
138 changes: 138 additions & 0 deletions
138
wp-content/plugins/wporg-learn/inc/activity-kit-import.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| <?php | ||
|
|
||
| namespace WPOrg_Learn\Activity_Kit_Import; | ||
|
|
||
| defined( 'WPINC' ) || die(); | ||
|
|
||
| if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { | ||
| return; | ||
| } | ||
|
|
||
| /** | ||
| * WP-CLI commands for Activity Kit management. | ||
| */ | ||
| class Activity_Kit_CLI { | ||
|
|
||
| /** | ||
| * Import the initial 11 Activity Kit posts. | ||
| * | ||
| * ## OPTIONS | ||
| * | ||
| * [--force] | ||
| * : Re-import even if posts already exist. | ||
| * | ||
| * ## EXAMPLES | ||
| * | ||
| * wp activity-kit import | ||
| * | ||
| * @when after_wp_load | ||
| */ | ||
| public function import( $args, $assoc_args ) { | ||
| $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); | ||
|
|
||
| $kits = array( | ||
| array( | ||
| 'title' => 'Debugging for Developers', | ||
| 'topics' => array( 'development' ), | ||
| 'levels' => array( 'Intermediate' ), | ||
| ), | ||
| array( | ||
| 'title' => 'Debugging for Site Owners', | ||
| 'topics' => array( 'site-management' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'eCommerce with WooCommerce', | ||
| 'topics' => array( 'woocommerce', 'ecommerce' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'SEO Foundations', | ||
| 'topics' => array( 'seo' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'WordPress Playground', | ||
| 'topics' => array( 'playground' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'Content Creation', | ||
| 'topics' => array( 'content-creation' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'Using AI in your WordPress Dashboard', | ||
| 'topics' => array( 'ai', 'site-management' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'Managing your WordPress site with AI', | ||
| 'topics' => array( 'ai', 'site-management' ), | ||
| 'levels' => array( 'Intermediate' ), | ||
| ), | ||
| array( | ||
| 'title' => 'Contributor Onboarding', | ||
| 'topics' => array( 'contributing' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'WordPress Security Essentials', | ||
| 'topics' => array( 'security' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| array( | ||
| 'title' => 'Accessibility Testing in WordPress', | ||
| 'topics' => array( 'accessibility' ), | ||
| 'levels' => array( 'Beginner' ), | ||
| ), | ||
| ); | ||
|
|
||
| foreach ( $kits as $kit_data ) { | ||
| $existing_query = new \WP_Query( | ||
| array( | ||
| 'post_type' => 'activity_kit', | ||
| 'post_status' => 'any', | ||
| 'title' => $kit_data['title'], | ||
| 'posts_per_page' => 1, | ||
| 'fields' => 'ids', | ||
| ) | ||
| ); | ||
| $existing = $existing_query->have_posts() ? get_post( $existing_query->posts[0] ) : null; | ||
|
|
||
| if ( $existing && ! $force ) { | ||
| \WP_CLI::log( sprintf( 'Skipping "%s" — already exists (ID %d). Use --force to re-import.', $kit_data['title'], $existing->ID ) ); | ||
| continue; | ||
| } | ||
|
|
||
| $post_id = wp_insert_post( | ||
| array( | ||
| 'post_title' => $kit_data['title'], | ||
| 'post_type' => 'activity_kit', | ||
| 'post_status' => 'draft', | ||
| 'post_author' => 1, | ||
| ), | ||
| true | ||
| ); | ||
|
|
||
| if ( is_wp_error( $post_id ) ) { | ||
| \WP_CLI::warning( sprintf( 'Failed to create "%s": %s', $kit_data['title'], $post_id->get_error_message() ) ); | ||
| continue; | ||
| } | ||
|
|
||
| if ( ! empty( $kit_data['topics'] ) ) { | ||
| wp_set_object_terms( $post_id, $kit_data['topics'], 'topic' ); | ||
| } | ||
|
|
||
| if ( ! empty( $kit_data['levels'] ) ) { | ||
| wp_set_object_terms( $post_id, $kit_data['levels'], 'level' ); | ||
| } | ||
|
|
||
| \WP_CLI::success( sprintf( 'Created "%s" (ID %d)', $kit_data['title'], $post_id ) ); | ||
| } | ||
|
|
||
| \WP_CLI::log( 'Import complete.' ); | ||
| } | ||
| } | ||
|
|
||
| \WP_CLI::add_command( 'activity-kit', __NAMESPACE__ . '\Activity_Kit_CLI' ); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.