skip to Main Content

https://i.stack.imgur.com/HdkBR.png

Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1
($function) must be a valid callback, class Wcore_Admin does not have
a method "sitemap_exclude_post_type" in
/var/www/html/wp-includes/class-wp-hook.php:292 Stack trace: #0
/var/www/html/wp-includes/plugin.php(212): WP_Hook->apply_filters() #1
/var/www/html/wp-content/plugins/wordpress-seo/inc/sitemaps/class-post-type-sitemap-provider.php(276):
apply_filters() #2
/var/www/html/wp-content/plugins/wordpress-seo/inc/sitemaps/class-post-type-sitemap-provider.php(253):
WPSEO_Post_Type_Sitemap_Provider->is_valid_post_type() #3
/var/www/html/wp-includes/class-wp-hook.php(294):
WPSEO_Post_Type_Sitemap_Provider->save_post() #4
/var/www/html/wp-includes/class-wp-hook.php(316):
WP_Hook->apply_filters() #5 /var/www/html/wp-includes/plugin.php(484):
WP_Hook->do_action() #6 /var/www/html/wp-includes/post.php(4384):
do_action() #7 /var/www/html/wp-admin/includes/post.php(690):
wp_insert_post() #8 /var/www/html/wp-admin/post-new.php(66):
get_default_post_to_edit() #9 {main} thrown in
/var/www/html/wp-includes/class-wp-hook.php on line 292 There has been
a critical error on this website. Please check your site admin email
inbox for instructions.

My server has been upgraded from PHP 7.4 to 8.0.8. I know it causes because of one of the plugins named wcore admin which was developed by custom. And It’s required plugin to do our jobs. I’m looking for a way to fix the issues and maintain the script myself since I’m very happy with it.

3

Answers


  1. I faced same issue on upgrade to php8.0, the error shows steps to debug

    ‘class Wcore_Admin does not have a method "sitemap_exclude_post_type"’

    the plugin or file class name Wcore_Admin does not have a function named sitemap_exclude_post_type. Remove the line calling a missing function, and it should work

    Login or Signup to reply.
  2. You should try

    call_user_func_array([new $this->controller, $this->action], array $args);
    
    Login or Signup to reply.
  3. Here are some examples of callback functions that do not use anonymous functions, with PHPUnit tests.

    <?php
    
    namespace AppCalculator;
    
    class SimpleAddition
    {
        protected $operands = [];
    
        public function setOperands(array $operands)
        {
            $this->operands = $operands;
        }
    
        function  callThisOne($a, $b){
            return $a + $b;
        }
    
        function returnCallThisTwo(){
            $callThis = function ($a, $b){
                return $a + $b;
            };
            return $callThis;
        }    
    
        public function callbackMethodOne()
        {                
            $callable = array($this, 'callThisOne');
            return array_reduce($this->operands, $callable, null);
        }
    
        public function callbackMethodTwo()
        {        
            $callable = $this->returnCallThisTwo();
            return array_reduce($this->operands, $callable, null);
        }
    
        public function callbackMethodThree()
        {
            $callable = function ($a, $b){
                return $a + $b;
            };
            return array_reduce($this->operands, $callable, null);
        }
    
    }
    ?>
    

    Here’s the unit tests:

    <?php
    
    namespace TestsUnit;
    
    use PHPUnitFrameworkTestCase;
    use AppCalculatorExceptonsNoOperandsException;
    
    class SimpleAdditionTest extends TestCase
    {
        /**
         * This will test the SimpleAddition class
         *
         * @return void
         */
        public function test_addition_with_callback_method_one()
        {
            $mathObject = new AppCalculatorSimpleAddition;
            $mathObject->setOperands([2,2]);
            $this->assertEquals(4, $mathObject->callbackMethodOne());
        }
    
        public function test_addition_with_callback_method_two()
        {
            $mathObject = new AppCalculatorSimpleAddition;
            $mathObject->setOperands([2,2]);
            $this->assertEquals(4, $mathObject->callbackMethodTwo());
        }
    
        public function test_addition_with_callback_method_three()
        {
            $mathObject = new AppCalculatorSimpleAddition;
            $mathObject->setOperands([2,2]);
            $this->assertEquals(4, $mathObject->callbackMethodThree());
        }
    
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search