-
Notifications
You must be signed in to change notification settings - Fork 0
Feature: Block Based Theme Training Complete #1
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
colinswinney
wants to merge
75
commits into
trunk
Choose a base branch
from
feature/movie-post-meta-panels
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 12 commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
f5aa254
Setup PostMeta classes and register some Movie fields
colinswinney cff3d1d
Setup Movie meta field plugin
colinswinney c4e50a2
Add Movie Runtime block
colinswinney 8de6d2d
Edit single Movie template to use bindings and Runtime block
colinswinney 46ddd9c
Add default value for Rating and fallback template values
colinswinney f14c7ae
Use time element for runtime block
colinswinney a6576d2
Update taxonomies with static functions
colinswinney 73710d3
Update and add more post meta fields
colinswinney b218aae
Add movie meta blocks
colinswinney fdf1a50
Add Group extension for separator
colinswinney cee51d0
Fix vars
colinswinney 93e5f44
Create block bindings and update template
colinswinney d552548
Add meta fields, editor panel, blocks, and templates for Person post …
colinswinney 2f8c2c9
Merge pull request #2 from 10up/feature/person-single-template
colinswinney e50511a
Refactor to use early returns
colinswinney 0128f3d
Fix linting errors
colinswinney 8ab2d12
Update the plugin to use 10up Framework
colinswinney 6844ad1
Fix style lint errors
colinswinney 882a724
Add WP Content Connect and set up movie to person relationship
colinswinney a68ce50
Remove keywords taxonomy and fix other ones
colinswinney 50ba3ed
Add new meta fields and blocks, delete ones we can't get from API
colinswinney e3ccada
Delete more meta fields
colinswinney 3f5eef2
Make secondary text color more accessible
colinswinney e7084c9
Use logical props
colinswinney 26ba42b
Make back button respect current page
colinswinney 85dd49d
Update single movie template to add video with fallback image
colinswinney 286c9eb
Update other templates
colinswinney 1c696e8
Update theme to use 10up Framework
colinswinney ae75fe2
Fix missing traits
colinswinney a11a8ea
Remove director block
colinswinney 85bf5f6
Use context to get post id in theme blocks
colinswinney 921a487
Merge origin/feature/move-theme-to-framework into fix/update-blocks-w…
colinswinney 1cbbe10
Merge pull request #5 from 10up/fix/update-blocks-with-context
colinswinney 3a3c7ec
Merge pull request #4 from 10up/feature/move-theme-to-framework
colinswinney 3d7d843
Update .gitignore
colinswinney 428aaea
chore: Rename fueled-movies-complete to fueled-movies
colinswinney e335699
fix: Restore @view-transition CSS rule for cross-page animations
colinswinney ee7f8d4
Fix icon imports
colinswinney d906069
Refactor to use shared components and bundle common dependencies
colinswinney 668eae7
Install Ignite plugins and begin transfer from custom blocks to bindings
colinswinney 611791e
Remove most blocks, relying instead on block bindings
colinswinney f9909c2
Rm Ignite plugins and move DL blocks to theme, move bindings to own file
colinswinney 0c11619
Add rate movie block
colinswinney 37392d4
Rm WatchProvider taxonomy
colinswinney 3f43990
Add button and group json styles, refine interactivty example
colinswinney 44840c1
Merge branch 'feature/move-theme-to-framework' into feature/movie-pos…
colinswinney 0710abf
Rm shared components webpack config
colinswinney 1369ef6
Add CLI script, make Content Connect MU, use imdb embeds vs youtube
colinswinney d37b19c
Add 10up block theme
colinswinney 970ac2a
Add clickable card functionality
colinswinney 9bbb8d9
Rename namespaces and packages in new theme so students can easily co…
colinswinney c6ed8e2
Maintain 10up block theme header part white space
colinswinney a6916bc
Format the footer part
colinswinney 3b5e02d
Update copyright year
colinswinney 46267e0
Clean up theme.json to allow for customings colors via editor palette
colinswinney 8eff68b
Delete Group style variation
colinswinney 132084e
Fix editor styles of the button secondary variation
colinswinney ba131ef
Use the 10up block theme index.html as is
colinswinney 4cb53c1
Update card pattern
colinswinney 6eff3e7
Minor chores
colinswinney b3aec1b
Update blocks to use render.php file names
colinswinney 7a0266d
Update comments
colinswinney da17253
Update php.yml with correct theme
colinswinney 0636450
Update params
colinswinney ed50a6d
Rm unused vars in the card
colinswinney e20354a
Add missing binding
colinswinney 067a7ef
Update text domain strings
colinswinney 08ab6c4
Fix indent
colinswinney 8b3cc9a
Clean up
colinswinney 55c41f8
Add composer desc
colinswinney a6fe035
Update composer
colinswinney 5a51082
Update CI
colinswinney 26858f7
Use wp_interactivity_data_wp_context
colinswinney f1a867e
Match theme.json schemas
colinswinney 75827ef
Add filter checks
colinswinney 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
211 changes: 211 additions & 0 deletions
211
mu-plugins/10up-plugin/includes/classes/PostMeta/AbstractPostMeta.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,211 @@ | ||
| <?php | ||
| /** | ||
| * AbstractPostMeta post meta | ||
| * | ||
| * @package TenUpPlugin | ||
| */ | ||
|
|
||
| namespace TenUpPlugin\PostMeta; | ||
|
|
||
| use TenUpPlugin\Module; | ||
|
|
||
| /** | ||
| * Abstract class for post meta. | ||
| * | ||
| * Usage: | ||
| * | ||
| * class FooPostMeta extends AbstractPostMeta { | ||
| * | ||
| * public $load_order = 5; | ||
| * | ||
| * const META_KEY = 'foo_post_meta'; | ||
| * | ||
| * public function get_description(): string { | ||
| * return __( 'Foo Post Meta', 'tenup' ); | ||
| * } | ||
| * | ||
| * public function get_post_types() { | ||
| * return TenUpPlugin\PostTypes\Post::get_name(); | ||
| * } | ||
| * | ||
| * public function can_register() { | ||
| * return true; | ||
| * } | ||
| * } | ||
| */ | ||
| abstract class AbstractPostMeta extends Module { | ||
|
|
||
| /** | ||
| * Used to alter the order in which clases are initialized. | ||
| * | ||
| * Lower number will be initialized first. | ||
| * | ||
| * @note This has no correlation to the `init` priority. It's just a way to allow certain classes to be initialized before others. | ||
| * | ||
| * @var int The priority of the module. | ||
| */ | ||
| public $load_order = 10; | ||
|
|
||
| /** | ||
| * Whether the field has key value options. | ||
| * | ||
| * @var bool | ||
| */ | ||
| protected $has_key_value_options = false; | ||
|
|
||
| /** | ||
| * The meta_key name. | ||
| * | ||
| * @var string|self::META_KEY | ||
| */ | ||
| const META_KEY = self::META_KEY; | ||
|
|
||
| /** | ||
| * Default value. | ||
| * | ||
| * @var array|string|bool|int|null | ||
| */ | ||
| protected $default_value = null; | ||
|
|
||
| /** | ||
| * Value type. | ||
| * Allowed options: 'string', 'boolean', 'integer', 'number', 'array', 'object' | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $type = 'string'; | ||
|
|
||
| /** | ||
| * Save only single or multiple values. | ||
| * | ||
| * @var bool | ||
| */ | ||
| protected $single_value_mode = true; | ||
|
|
||
| /** | ||
| * Disallow empty values. | ||
| * | ||
| * @var bool | ||
| */ | ||
| protected $is_required = false; | ||
|
|
||
| /** | ||
| * Checks whether the Module should run within the current context. | ||
| * | ||
| * @return bool | ||
| */ | ||
| abstract public function can_register(): bool; | ||
|
|
||
| /** | ||
| * Get the meta_key name. | ||
| * | ||
| * @return string | ||
| */ | ||
| public static function get_name(): string { | ||
| return static::META_KEY; | ||
| } | ||
|
|
||
| /** | ||
| * Get the field description. | ||
| * | ||
| * @return string | ||
| */ | ||
| public function get_description(): string { | ||
| return ''; | ||
| } | ||
|
|
||
| /** | ||
| * Get allowed values for field schema. | ||
| */ | ||
| public function allowed_values(): array { | ||
| return []; | ||
| } | ||
|
|
||
| /** | ||
| * Post types to register the post meta. | ||
| * | ||
| * @return array | ||
| */ | ||
| abstract public function get_post_types(): array; | ||
|
|
||
| /** | ||
| * Get the options. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function get_options() { | ||
| $options = [ | ||
| 'show_in_rest' => $this->get_schema(), | ||
| 'single' => $this->single_value_mode, | ||
| 'type' => $this->type, | ||
| ]; | ||
| if ( null !== $this->default_value ) { | ||
| $options['default'] = $this->default_value; | ||
| } | ||
| return $options; | ||
| } | ||
|
|
||
| /** | ||
| * Get the schema. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function get_schema(): array { | ||
| // Handle allowed values if data is provided in key/value pairs. | ||
| if ( $this->has_key_value_options ) { | ||
| $values = $this->allowed_values(); | ||
| $values = array_keys( $values ); | ||
| $enum = $values; | ||
| } else { | ||
| $enum = $this->allowed_values(); | ||
| } | ||
|
|
||
| return [ | ||
| 'schema' => [ | ||
| 'type' => $this->type, | ||
| 'description' => $this->get_description(), | ||
| 'required' => $this->is_required, | ||
| 'enum' => $enum, | ||
| ], | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Register all post meta fields. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function register_all(): void { | ||
| foreach ( $this->get_post_types() as $post_type ) { | ||
| \register_post_meta( | ||
| $post_type, | ||
| self::get_name(), | ||
| $this->get_options() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Register hooks and actions. | ||
| * | ||
| * @uses $this->get_post_types() to get the post types. | ||
| * @uses self::get_name() to get the key name. | ||
| * @return bool | ||
| */ | ||
| public function register() { | ||
|
|
||
| add_action( 'init', [ $this, 'register_all' ], 20 ); | ||
| $this->after_register(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Run any code after the post meta has been registered. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function after_register() { | ||
| // Register any hooks/filters you need. | ||
| } | ||
| } | ||
105 changes: 105 additions & 0 deletions
105
mu-plugins/10up-plugin/includes/classes/PostMeta/MovieMPARating.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,105 @@ | ||
| <?php | ||
| /** | ||
| * MovieMPARating post meta | ||
| * | ||
| * @package TenUpPlugin | ||
| */ | ||
|
|
||
| namespace TenUpPlugin\PostMeta; | ||
|
|
||
| use TenUpPlugin\PostTypes\Movie; | ||
|
|
||
| /** | ||
| * MovieMPARating meta field. | ||
| */ | ||
| class MovieMPARating extends AbstractPostMeta { | ||
|
|
||
| /** | ||
| * The meta_key name. | ||
| * | ||
| * @var string | ||
| */ | ||
| const META_KEY = 'tenup_movie_mpa_rating'; | ||
|
|
||
| /** | ||
| * Get the field description. | ||
| * | ||
| * @return string | ||
| */ | ||
| public function get_description(): string { | ||
| return __( 'Movie MPA Rating', 'tenup' ); | ||
| } | ||
|
|
||
| /** | ||
| * Default value. | ||
| * | ||
| * @var array|string|bool|int|null | ||
| */ | ||
| protected $default_value = 'Unrated'; | ||
|
|
||
| /** | ||
| * Whether the field has key value options. | ||
| * | ||
| * @var bool | ||
| */ | ||
| protected $has_key_value_options = true; | ||
|
|
||
| /** | ||
| * Get allowed values for field schema. | ||
| */ | ||
| public function allowed_values(): array { | ||
| return [ | ||
| 'Unrated' => 'Unrated', | ||
| 'G' => 'G', | ||
| 'PG' => 'PG', | ||
| 'PG-13' => 'PG-13', | ||
| 'R' => 'R', | ||
| 'NC-17' => 'NC-17', | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Get the post types. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function get_post_types(): array { | ||
| return [ | ||
| Movie::get_name(), | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether the Module should run within the current context. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function can_register(): bool { | ||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Add localized script. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function add_localized_script() { | ||
|
|
||
| wp_localize_script( | ||
| 'tenup_plugin_admin', | ||
| 'TenupMovieMPARating', | ||
| array( | ||
| 'options' => $this->allowed_values(), | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Run any code after the post meta has been registered. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function after_register() { | ||
| add_action( 'admin_enqueue_scripts', [ $this, 'add_localized_script' ] ); | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
mu-plugins/10up-plugin/includes/classes/PostMeta/MoviePlot.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,52 @@ | ||
| <?php | ||
| /** | ||
| * MoviePlot post meta | ||
| * | ||
| * @package TenUpPlugin | ||
| */ | ||
|
|
||
| namespace TenUpPlugin\PostMeta; | ||
|
|
||
| use TenUpPlugin\PostTypes\Movie; | ||
|
|
||
| /** | ||
| * MoviePlot meta field. | ||
| */ | ||
| class MoviePlot extends AbstractPostMeta { | ||
|
|
||
| /** | ||
| * The meta_key name. | ||
| * | ||
| * @var string | ||
| */ | ||
| const META_KEY = 'tenup_movie_plot'; | ||
|
|
||
| /** | ||
| * Get the field description. | ||
| * | ||
| * @return string | ||
| */ | ||
| public function get_description(): string { | ||
| return __( 'Movie Plot', 'tenup' ); | ||
| } | ||
|
|
||
| /** | ||
| * Get the post types. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function get_post_types(): array { | ||
| return [ | ||
| Movie::get_name(), | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether the Module should run within the current context. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function can_register(): bool { | ||
| return true; | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update this to use the 10up-framework like in the scaffold today?