I learned php in 2003 and have not really kept up with changes. I had the following function built for me in 2014. I just updated to php 7.3 and am getting these notices (although everything works fine). Please help me with what needs to change ion order to comply with 7.3 and not have these notices.
Here is the function:
add_filter( 'wp_nav_menu_objects', 'church_nav_menu_objects_filter',10,2);
function church_nav_menu_objects_filter( $items, $args ) {
if (( isset($_SESSION["church"])) && (!empty($_SESSION['church']))) {
//print "<pre>items:<br>
";
//var_dump( $items );
//print "</pre><br>
";
if ( is_array( $items ) ) {
for( $i=0 ; $i < count($items) ; $i++ ) {
if (( strpos($items[$i]->url,"thetrinitymission.org" )) && ( ! strpos($items[$i]->url,$_SESSION["church"]) ) ) $items[$i]->url=str_replace("thetrinitymission.org",$_SESSION["church"].".thetrinitymission.org",$items[$i]->url);
}
}
}
return( $items );
}
I get the following errors: Notice: Undefined offset: 0 in /thetrinitymission.org/wp-content/themes/twentynineteenkid/functions.php on line 360
Notice: Trying to get property 'url' of non-object in /thetrinitymission.org/wp-content/themes/twentynineteenkid/functions.php on line 360
Line 360 is the one that starts: if (( strpos($items[$i]->url,