0

i am forced to use a wordpress theme together with my laravel framework. The wordpress theme is around 60 MB of size. Yes, it's ugly.

And no, I will not fix the entire wordpress theme only to avoid that stupid error. That would be bad as well, because if they do an update of the theme, i wouldnt be able to apply it.

Now back to the question, they do

if ($element[0]){
    ...
}else{
    return '';
}

now $element[0] can be, as expected, undefined. Now this was not a problem, unless it gets called from a laravel context, which i have to do. now the whole thing explodes with:

ErrorException in ga-scroll-event.php line 189: Undefined offset: 0

I repeat, no, i won't go and fix 60 MB of code.

what is the way to disable this error exception ?

2
  • check this question see if it helps Commented Jan 4, 2017 at 17:35
  • Complain to the theme makers. Commented Jan 4, 2017 at 17:39

1 Answer 1

0

You could just avoid the error:

if (isset($element[0]) && $element[0]){
    ...
}else{
    return '';
}
Sign up to request clarification or add additional context in comments.

7 Comments

i think the OP stated he was not open to editing the template files
@happymacarts fair enough, that's his choice.This isn't fixing 60mb of code though.
i think that is a great solution and probably how i would do it too.
sure right, so i fixed it at this file, now the next file has a problem. Do i fix it as well? and the next one? these guys just coded like that. Is that my fault? and then there is a theme update, I fix all files all over again? cunning coders
btw: you are coding like a decade ago. Shorter and nicer is if($element[0] ?? false) easier to read too
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.