• Resolved tbvdg

    (@tbvdg)


    [29-Jun-2023 14:05:56 UTC] PHP Fatal error: Uncaught Error: Call to a member function find() on bool in /home/saunapla/web/live/public_html/wp-content/plugins/accessibility-plus/accessibility.php:110
    Stack trace: 0 /home/saunapla/web/live/public_html/wp-content/plugins/accessibility-plus/accessibility.php(274): easywpstuff_assesplus_add_aria_labels_to_buttons('') 1 [internal function]: easywpstuff_assesplus_bstr_template_redirect('', 9) 2 /home/saunapla/web/live/public_html/wp-includes/functions.php(5309): ob_end_flush() 3 /home/saunapla/web/live/public_html/wp-includes/class-wp-hook.php(308): wp_ob_end_flush_all('') 4 /home/saunapla/web/live/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) 5 /home/saunapla/web/live/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 6 /home/saunapla/web/live/public_html/wp-includes/load.php(1144): do_action('shutdown') 7 [internal function]: shutdown_action_hook() 8 {main} thrown in /home/saunapla/web/live/public_html/wp-content/plugins/accessibility-plus/accessibility.php on line 110

    Hi,
    This is an error that is showing up occasionally in the debug log. I ended up putting if(!empty($dom)){} around it as a quick fix. That seems to have resolved it so far.
    Thanks,
    Toby

    function easywpstuff_assesplus_add_aria_labels_to_buttons($html) {
    
      $dom = lhb_str_get_html($html, false, true, 'UTF-8', false, PHP_EOL, ' ');
    
      if(!empty($dom)){
        $buttons = $dom->find('button');  
      
        foreach ($buttons as $button) {
          if (!trim($button->plaintext) && !$button->getattribute('aria-label')) {
            $child_elements = $button->find('*');
            if (empty($child_elements)) {
              $button->setattribute('aria-label', 'button');
            } else {
              $button->setattribute('aria-label', 'button');
            }
          }
      	  if (!$button->getattribute('aria-label')) {
          $svg = $button->find('svg',0);
          $path = $button->find('path',0);
          $span = $button->find('span',0);
          if($svg && $path){
            $button->setattribute('aria-label', 'button');
          }elseif($span){
            $span_text = trim($span->plaintext);
            if($span_text){
              $button->setattribute('aria-label', $span_text);
            }
          }
        }
        }
        return $dom->save();
      }
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Fatal Errors’ is closed to new replies.