-
Notifications
You must be signed in to change notification settings - Fork 0
TMS-1173: Add hero-layout for blog-article archive & blog-category taxonomy archive #200
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
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
748540e
TMS-1173: Add description for blog-article taxonomy archive
eebbi 6e69827
TMS-1173: Add hero-layouts for blog-article archives
eebbi 369f8a5
TMS-1173: Return type fix
eebbi 032f2b6
TMS-1173: CR fix
eebbi d024f41
Merge branch 'master' into TMS-1173
eebbi 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
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,86 @@ | ||
| <?php | ||
| namespace TMS\Theme\Tredu\ACF; | ||
|
|
||
| use Geniem\ACF\Exception; | ||
| use Geniem\ACF\Group; | ||
| use Geniem\ACF\RuleGroup; | ||
| use Geniem\ACF\Field; | ||
| use TMS\Theme\Tredu\Logger; | ||
|
|
||
| /** | ||
| * Class BlogCategoryGroup | ||
| * | ||
| * @package TMS\Theme\Tredu\ACF | ||
| */ | ||
| class BlogCategoryGroup { | ||
|
|
||
| /** | ||
| * BlogCategoryGroup constructor. | ||
| */ | ||
| public function __construct() { | ||
| add_action( | ||
| 'init', | ||
| \Closure::fromCallable( [ $this, 'register_fields' ] ) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Register fields for blog-category taxonomy. | ||
| */ | ||
| protected function register_fields() : void { | ||
| try { | ||
| $field_group = ( new Group( 'Blogikategoria' ) ) | ||
| ->set_key( 'fg_blog_category_fields' ); | ||
|
|
||
| $rule_group = ( new RuleGroup() ) | ||
| ->add_rule( 'taxonomy', '==', 'blog-category' ); | ||
|
|
||
| $field_group | ||
| ->add_rule_group( $rule_group ) | ||
| ->set_position( 'normal' ); | ||
|
|
||
| $field_group->add_fields( | ||
| \apply_filters( | ||
| 'tms/acf/group/' . $field_group->get_key() . '/fields', | ||
| [ | ||
| $this->get_image_field( $field_group->get_key() ), | ||
| ] | ||
| ) | ||
| ); | ||
|
|
||
| $field_group = \apply_filters( | ||
| 'tms/acf/group/' . $field_group->get_key(), | ||
| $field_group | ||
| ); | ||
|
|
||
| $field_group->register(); | ||
| } | ||
| catch ( Exception $e ) { | ||
| ( new Logger() )->error( $e->getMessage(), $e->getTraceAsString() ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get image field. | ||
| * | ||
| * @param string $key Field group key. | ||
| * | ||
| * @return Field\Image | ||
| * @throws Exception In case of invalid option. | ||
| */ | ||
| protected function get_image_field( string $key ) : Field\Image { | ||
| $strings = [ | ||
| 'image' => [ | ||
| 'title' => \_x( 'Kuva', 'theme ACF', 'tms-theme-tredu' ), | ||
| 'instructions' => 'Kuvaa käytetään kategorian listaus-sivulla hero-kuvana', | ||
| ], | ||
| ]; | ||
|
|
||
| return ( new Field\Image( $strings['image']['title'] ) ) | ||
| ->set_key( "{$key}_image" ) | ||
| ->set_name( 'image' ) | ||
| ->set_instructions( $strings['image']['instructions'] ); | ||
| } | ||
| } | ||
|
|
||
| ( new BlogCategoryGroup() ); | ||
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
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
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
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.