From 6ce7787132dfe8e32d1c6a1961c185504ac96879 Mon Sep 17 00:00:00 2001 From: Kushtrim Aliu Date: Fri, 12 Jan 2024 11:31:35 +0100 Subject: [PATCH] Update ds_wp3_toggle_meta_boxes.php create_function() is deprecated since PHP 7.2. Using anonymous function to replace the function that works on PHP 8 --- ds_wp3_toggle_meta_boxes.php | 74 ++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/ds_wp3_toggle_meta_boxes.php b/ds_wp3_toggle_meta_boxes.php index 918f001..f890e73 100644 --- a/ds_wp3_toggle_meta_boxes.php +++ b/ds_wp3_toggle_meta_boxes.php @@ -251,29 +251,71 @@ function ds_extras_remove() { if( !isset($menu_perms[ 'contextual_help_link' ]) ) echo ''; // Quick Edit - //disable quickedit in post rows - if( !isset($menu_perms[ 'quick_edit_posts' ]) ) - add_filter('post_row_actions', create_function('$actions, $post', 'unset($actions["inline hide-if-no-js"]); return $actions ;'), 10, 2); + + //disable quickedit in post rows + if( !isset($menu_perms[ 'quick_edit_posts' ]) ) { + add_filter('post_row_actions', + function ($actions, $post) { + unset($actions["inline hide-if-no-js"]); + return $actions; + }, 10, 2); + } + //disable quickedit in page rows - if( !isset($menu_perms[ 'quick_edit_pages' ]) ) - add_filter('page_row_actions', create_function('$actions, $post', 'unset($actions["inline hide-if-no-js"]); return $actions ;'), 10, 2); + if( !isset($menu_perms[ 'quick_edit_pages' ]) ) { + add_filter('page_row_actions', + function ($actions, $post) { + unset($actions["inline hide-if-no-js"]); + return $actions; + }, 10, 2); + } //disable quickedit in any tag rows - if( !isset($menu_perms[ 'quick_edit_tag' ]) ) - add_filter('tag_row_actions', create_function('$actions, $post', 'unset($actions["inline hide-if-no-js"]); return $actions ;'), 10, 2); + if( !isset($menu_perms[ 'quick_edit_tag' ]) ) { + add_filter('tag_row_actions', + function ($actions, $post) { + unset($actions["inline hide-if-no-js"]); + return $actions; + }, 10, 2); + } + //disable quickedit in taxonomy=post_tag rows - if( !isset($menu_perms[ 'quick_edit_post_tag' ]) ) - add_filter('post_tag_row_actions', create_function('$actions, $post', 'unset($actions["inline hide-if-no-js"]); return $actions ;'), 10, 2); + if( !isset($menu_perms[ 'quick_edit_post_tag' ]) ) { + add_filter('post_tag_row_actions', + function ($actions, $post) { + unset($actions["inline hide-if-no-js"]); + return $actions; + }, 10, 2); + } + //disable quickedit in taxonomy=category rows - if( !isset($menu_perms[ 'quick_edit_category' ]) ) - add_filter('category_row_actions', create_function('$actions, $post', 'unset($actions["inline hide-if-no-js"]); return $actions ;'), 10, 2); + if( !isset($menu_perms[ 'quick_edit_category' ]) ) { + add_filter('category_row_actions', + function ($actions, $post) { + unset($actions["inline hide-if-no-js"]); + return $actions; + }, 10, 2); + } + //disable quickedit in taxonomy=link_category rows - if( !isset($menu_perms[ 'quick_edit_link_category' ]) ) - add_filter('link_category_row_actions', create_function('$actions, $post', 'unset($actions["inline hide-if-no-js"]); return $actions ;'), 10, 2); + if( !isset($menu_perms[ 'quick_edit_link_category' ]) ) { + add_filter('link_category_row_actions', + function ($actions, $post) { + unset($actions["inline hide-if-no-js"]); + return $actions; + }, 10, 2); + } //disable quickedit in comment rows - if( !isset($menu_perms[ 'quick_edit_comments' ]) ) - add_filter('comment_row_actions', create_function('$actions, $post', 'unset($actions["quickedit"]); return $actions ;'), 10, 2); + if( !isset($menu_perms[ 'quick_edit_comments' ]) ) { + add_filter('comment_row_actions', + function ($actions, $post) { + unset($actions["quickedit"]); + return $actions; + }, 10, 2); + } + + // Media Buttons if( !isset($menu_perms[ 'media_buttons' ]) ) remove_action( 'media_buttons', 'media_buttons' ); @@ -406,4 +448,4 @@ function ds_meta_box_option() { if (class_exists("ds_meta")) { $ds_meta = new ds_meta(); } -?> \ No newline at end of file +?>