-
Notifications
You must be signed in to change notification settings - Fork 143
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
Securing taxonomies export #872
Changes from all commits
691ca0c
838c79b
7eaa63c
eb38c29
894af74
f0f9202
b03c440
f8d6e5c
d55ea64
7126c31
f6caf8e
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 |
---|---|---|
|
@@ -227,6 +227,16 @@ function <?php echo esc_html( $callback ); ?>() { | |
*/ | ||
function cptui_get_single_taxonomy_registery( $taxonomy = [] ) { | ||
|
||
foreach( cptui_required_indexes() as $key ) { | ||
if ( ! array_key_exists($key, $taxonomy) ){ | ||
$taxonomy[$key] = ''; | ||
} | ||
} | ||
|
||
if ( ! array_key_exists('labels', $taxonomy) ){ | ||
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. Another nitpick, but spacing around our functions and logic statements. Her and above into the foreach loop above around line 241. I know Alok is also working on his own PHPCS review so best to not introduce new spots when able. 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. I'll run phpcs to check my added code |
||
$taxonomy['labels'] = []; | ||
} | ||
|
||
$post_types = "''"; | ||
if ( is_array( $taxonomy['object_types'] ) ) { | ||
$post_types = '[ "' . implode( '", "', $taxonomy['object_types'] ) . '" ]'; | ||
|
@@ -261,6 +271,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) { | |
} else { | ||
$rewrite = disp_boolean( $taxonomy['rewrite'] ); | ||
} | ||
|
||
$public = isset( $taxonomy['public'] ) ? disp_boolean( $taxonomy['public'] ) : 'true'; | ||
$publicly_queryable = isset( $taxonomy['publicly_queryable'] ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] ); | ||
$show_in_quick_edit = isset( $taxonomy['show_in_quick_edit'] ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] ); | ||
|
@@ -311,23 +322,25 @@ function cptui_get_single_taxonomy_registery( $taxonomy = [] ) { | |
?> | ||
|
||
/** | ||
* Taxonomy: <?php echo esc_html( $taxonomy['label'] ); ?>. | ||
*/ | ||
* Taxonomy: <?php echo esc_html( $taxonomy['label'] ); ?>. | ||
*/ | ||
|
||
$labels = [ | ||
"name" => __( "<?php echo esc_html( $taxonomy['label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ), | ||
"singular_name" => __( "<?php echo esc_html( $taxonomy['singular_label'] ); ?>", "<?php echo esc_html( $textdomain ); ?>" ), | ||
<?php | ||
foreach ( $taxonomy['labels'] as $key => $label ) { | ||
if ( ! empty( $label ) ) { | ||
echo "\t\t" . '"' . esc_html( $key ) . '" => __( "' . esc_html( $label ) . '", "' . esc_html( $textdomain ) . '" ),' . "\n"; | ||
foreach ( $taxonomy['labels'] as $key => $label ) { | ||
if ( ! empty( $label ) ) { | ||
echo "\t\t" . '"' . esc_html( $key ) . '" => __( "' . esc_html( $label ) . '", "' . esc_html( $textdomain ) . '" ),' . "\n"; | ||
} | ||
} | ||
} | ||
?> | ||
]; | ||
|
||
<?php | ||
|
||
$show_graphql = isset( $taxonomy['show_in_graphql'] ) ? (bool) $taxonomy['show_in_graphql'] : false; | ||
|
||
?> | ||
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. This looks like it was accidentally removed and we will want to have it in place still 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. no, it's this comment above: "For the show_graphql, sort, and queryvar parts, the disp_boolean() function is immediately casting them to string, which is what we're getting from the settings extraction anyway, so may as well not worry about type casting there." but I can leave it as it was, |
||
|
||
$args = [ | ||
|
@@ -412,6 +425,13 @@ function <?php echo esc_html( $callback ); ?>() { | |
*/ | ||
function cptui_get_single_post_type_registery( $post_type = [] ) { | ||
|
||
/* Check if all keys are present, initialize if not */ | ||
foreach( cptui_required_indexes_cpts() as $key ) { | ||
if ( array_key_exists($key, $post_type) ){ | ||
$post_type[$key] = ''; | ||
} | ||
} | ||
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. Same nitpick around spacing. 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. I'll run phpcs |
||
|
||
/* This filter is documented in custom-post-type-ui/custom-post-type-ui.php */ | ||
$post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type ); | ||
|
||
|
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 turn this into a function similar to
cptui_reserved_taxonomies()
where it returns this array? No need to add anapply_filters()
for it, just have it return the array.Could either still assign to
$must_have_keys
or it could replace the variable and just be used as such:The reason for this request is to make the array more usable in the future, if need arises.