-1

I keep getting this error and I can't figure out exactly what's wrong.

PHP Fatal error: Can't use function return value in write context in /home1/mkwvscom/public_html/wp-content/themes/perprog/template-parts/header/logo.php on line 9

Line 9 is:

if (!empty(perprog_get_options('logo-media','url'))){ 

Anyone have any ideas?

Here is the full code from this file:

 <!-- .site-branding -->

    <!-- Logo Image -->

    <?php 

     if( perprog_get_options('opt-logo-text-image-select') == 'image'){ 

     if (!empty(perprog_get_options('logo-media','url'))){ 

    ?>




    <h1 class="site-title sitetitlewidth" > 

    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">

        <img class="logopositionheader" src="<?php echo esc_url(perprog_get_options('logo-media','url')); ?>"


        <?php if (!empty( perprog_get_options('logo-media-retina','url'))) 
        { echo 'data-at2x="'. esc_url(perprog_get_options('logo-media-retina','url')).'"';} 
        ?> alt="<?php bloginfo( 'name' ); ?>">

        <div class="clearboth"></div>



    </a>

        </h1> <!-- Logo Image -->


    <div class="clearboth"></div>

    <?php
    } 
    }

    else{  // Site title
    ?>


        <div class="site-branding">
            <?php
            if ( is_front_page() && is_home() ) : ?>
                <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php else : ?>
                <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php
            endif;

            $description = get_bloginfo( 'description', 'display' );
            if ( $description || is_customize_preview() ) : ?>
                <p class="site-description"><?php echo esc_html($description); /* WPCS: xss ok. */ ?></p>
            <?php
            endif; ?>
        </div>
    <?php } ?><!-- .site-branding -->

1 Answers1

0

Preferred option: Update to a modern PHP version. Old versions do not allow you to use the result of function calls in empty(). I don't recall the exact version where this change happened but I'm certain your current version is past end-of-life.

Backup option: Assign to a variable first, then check:

$temp = perprog_get_options('logo-media','url');
if (!empty($temp)){ 
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98