• Hi there,

    Here is a patch to solve the warning about create_function() being deprecated in php 7.2. There is no way to attach a file, so I paste it.

    $ diff -ur edit-screen.php edit-screen.php72.php 
    --- edit-screen.php	2019-02-15 14:39:26.735882831 +0100
    +++ edit-screen.php72.php	2019-02-15 14:39:15.627788872 +0100
    @@ -118,11 +118,11 @@
     
     					if ( ! in_array( $metabox_id, $default_metaboxes ) ) {
     						if ( $metabox_id == 'titlediv' || $metabox_id == 'postdivrich' ) {
    -							$func = create_function('', 'echo "jQuery(\"#' . $metabox_id . '\").addClass(\"' . $class . '\");";');
    +							$func = function(){echo "jQuery(\"#' . $metabox_id . '\").addClass(\"' . $class . '\");";};
     							add_action( 'tabify_custom_javascript' , $func );
     						}
     						else {
    -							$func = create_function( '$args', 'array_push( $args, "' . $class . '" ); return $args;' );
    +							$func = function($args){array_push( $args, "' . $class . '" ); return $args;};
     							add_action( 'postbox_classes_' . $post_type . '_' . $metabox_id, $func );
     
     							if ( isset( $this->all_metaboxes[ $metabox_id ] ) ) {
    @@ -153,7 +153,7 @@
     					$class .= ' tabifybox-hide';
     				}
     
    -				$func = create_function( '$args', 'array_push( $args, "' . $class . '" ); return $args;' );
    +				$func = function($args){array_push( $args, "' . $class . '" ); return $args;};
     				add_action( 'postbox_classes_' . $post_type . '_' . $metabox_id, $func );
     			}
     		}
    @@ -180,7 +180,7 @@
     		else { //default
     			$tabs  = $this->submit_button();
     			$tabs .= $this->editscreen_tabs->get_tabs_with_container();
    -			$func  = create_function('', 'echo "$(\'#post\').prepend(\'' . addslashes( $tabs ) . '\');";');
    +			$func  = function(){echo "$(\'#post\').prepend(\'' . addslashes( $tabs ) . '\');";};
     
     			add_action( 'tabify_custom_javascript' , $func );
     		}
  • The topic ‘Patch proposed : create_function() is deprecated in edit-screen.php (PHP 7.2)’ is closed to new replies.