• Resolved Anonymous User 12954455

    (@anonymized-12954455)


    Hello all

    I’m developing a simple plugin to show some social icons based on options. I have used if statements successfully before now with no issue. The following code is causing me problems:

    <?php if ( get_option('sd_facebook_visible') ) {
    					echo '<li><a href="' . get_option('sd_facebook') .  $linkcontent['facebook'] . '</a></li>';
    				} ?>

    I have done var_dump(get_option('sd_facebook_visible')); which returns the following.

    string(1) "1"

    It is a checkbox on my options page. No matter what state the checkbox is it just wont show any ideas?

    Many Thanks

Viewing 1 replies (of 1 total)
  • For once, the link attribute href is not closed it has to be like
    <a href="...">link text</a> You might also check the value a bit more clearer. Maybe this will do:

    $sd_facebook_visible = get_option( 'sd_facebook_visible' );
    
    if( $sd_facebook_visible === '1' || strtolower( $sd_facebook_visible ) === 'on' || (int) $sd_facebook_visible === 1 ) {
    
      echo '<li><a href="' . get_option('sd_facebook') . '">' . $linkcontent['facebook'] . '</a></li>';
    
    }
Viewing 1 replies (of 1 total)

The topic ‘Plugin if statement not working’ is closed to new replies.