Improve fcn_select_page_template cap

Does now also prevent the parent and order from being updated.
This commit is contained in:
Tetrakern 2023-08-19 20:05:21 +02:00
parent 6797895ff0
commit d40eab8ca6
3 changed files with 21 additions and 3 deletions

View File

@ -304,7 +304,7 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
| `user_has_cap` | `fictioneer_edit_only_comments`
| `wp_list_comments_args` | `fictioneer_comment_list_args`
| `wp_handle_upload_prefilter` | `fictioneer_upload_restrictions`
| `wp_insert_post_data` | `fictioneer_remove_restricted_block_content`, `fictioneer_strip_shortcodes_on_save`, `fictioneer_see_some_evil`, `fictioneer_enforce_permalink`, `fictioneer_prevent_publish_date_update`
| `wp_insert_post_data` | `fictioneer_remove_restricted_block_content`, `fictioneer_strip_shortcodes_on_save`, `fictioneer_see_some_evil`, `fictioneer_enforce_permalink`, `fictioneer_prevent_publish_date_update`, `fictioneer_prevent_parent_and_order_update`
| `wp_is_application_passwords_available` | `__return_false`
| `wp_robots` | `fictioneer_add_noindex_to_robots`
| `wp_sitemaps_enabled` | `__return_false`

View File

@ -429,7 +429,7 @@ function fictioneer_hide_epub_inputs() {
global $post_type;
if ( $post_type === 'fcn_story' ) {
echo '<style> #acf-group_60edb914ba16c {display: none !important;}</style>';
echo '<style type="text/css"> #acf-group_60edb914ba16c {display: none !important;}</style>';
}
}

View File

@ -505,6 +505,23 @@ if ( ! current_user_can( 'manage_options' ) ) {
// === FCN_SELECT_PAGE_TEMPLATE ==============================================
/**
* Prevents parent and order from being updated
*
* @param array $data An array of slashed, sanitized, and processed post data.
*
* @return array The potentially modified post data.
*/
function fictioneer_prevent_parent_and_order_update( $data ) {
// Remove items
unset( $data['post_parent'] );
unset( $data['menu_order'] );
// Continue filter
return $data;
}
/**
* Filters the page template selection
*
@ -561,6 +578,7 @@ if ( ! current_user_can( 'manage_options' ) ) {
if ( ! current_user_can( 'fcn_select_page_template' ) ) {
add_filter( 'update_post_metadata', 'fictioneer_prevent_page_template_update', 1, 4 );
add_filter( 'theme_templates', 'fictioneer_disallow_page_template_select', 1 );
add_filter( 'wp_insert_post_data', 'fictioneer_prevent_parent_and_order_update', 1 );
}
// === MODERATE_COMMENTS =====================================================
@ -1334,7 +1352,7 @@ if ( ! current_user_can( 'manage_options' ) ) {
* @param array $data An array of slashed, sanitized, and processed post data.
* @param array $postarr An array of sanitized (and slashed) but otherwise unmodified post data.
*
* @return array The potentially modified post data.
* @return array The potentially modified post data.
*/
function fictioneer_prevent_publish_date_update( $data, $postarr ) {