-
Notifications
You must be signed in to change notification settings - Fork 6
[DO NOT MERGE] Use category registration utility file in the patterns dir #124
Changes from all commits
a59ecdc
867881f
477d3f3
a1e7af1
ebaa2c6
b562add
65b77cb
8771720
6b47385
4302348
bb775a8
e28fbee
17aea7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
use function PatternManager\PatternDataHandlers\delete_pattern; | ||
use function PatternManager\PatternDataHandlers\tree_shake_theme_images; | ||
use function PatternManager\PatternDataHandlers\update_pattern; | ||
use function PatternManager\PatternDataHandlers\create_category_registration_file; | ||
|
||
/** | ||
* Gets the pattern content and title from the PHP file. | ||
|
@@ -54,6 +55,9 @@ function save_pattern_to_file( WP_Post $post ) { | |
return; | ||
} | ||
|
||
// Add the utility file for custom category registration. | ||
create_category_registration_file(); | ||
Comment on lines
+58
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The registration file is written to Maybe there is a more efficient way to approach this kind of idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think it's too much to maintain a separate utility file like this. Also, it invites questions, like "Is it insecure that PM writes PHP to my theme?" It's not insecure, but this is writing a lot of logic to PHP files. I think a simple But this is too abstract, in my opinion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah you might be right — this might be getting a bit too abstract unnecessarily. I like the idea of having a separate utility for this kind of thing, but we are actually writing this to themes, and a theme-maker might view this as being a bit overbearing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still, it's cool to know this is possible! |
||
|
||
$pattern = get_pattern_by_name( $post->post_name ); | ||
|
||
update_pattern( | ||
|
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.
Parsing to find which registered categories are custom (and from PM) is a bit tricky.
Initially, I tried adding another array item called
pm_meta
to the registration call, but querying registered categories from either the core data store (or via a PHP call to the category registry) does not always return the custom item.Prepending the
value
(registered asname
) with a custom string and checking against it has been the only reliable method I've found to fix this issue for now.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.
The drawback to this method — if the utility file is deleted for some reason, custom category labels will be ugly.