lundi 29 juin 2015

PHP variable ['url'] pushing wrong variable


I am not understanding why my variable $linkedin is not working properly. When I click the text, "linkedin" it will not redirect me to www.yahoo.com but instead add to the site.url + "/$linkedin". After I added the variable $linkedin into the if statements it will no longer appear and I believe it is because the variable is not identifying itself as a url. Causing it to fail if statements. Lastly, this is on WordPress + Advanced Custom Fields Plugin.

Added into the code a var_dump to hopefully show what my issue is.

Code:

function member_contact() {

    $vcard = get_field('vcard');
    $bio   = get_field('bio_pdf');
    $linkedin = get_field('linkedin');
    $phone = get_field('phone');
    $fax   = get_field('fax');
    $email = get_field('email');

    $post_info = '';

    if (isset($vcard['url'])) {
        $img = get_stylesheet_directory_uri() . "/images/mail-icon.png";
        $post_info .= '<a class="vcard" href="'.$vcard['url'].'"><img src="'.$img.'" /> Download Contact</a>';
    }

    if (isset($bio['url']) && isset($vcard['url'])) {
        $post_info .= ' | ';
    }

    if (isset($bio['url'])) {
        $post_info .= '<a class="bio-pdf" href="'.$bio['url'].'">Download Bio</a>';
    }

    if (isset($linkedin['url']) && isset($vcard['url']) || isset($bio['url'])) {
        $post_info .= ' | ';
    }

    if (isset($linkedin['url'])) {
        $post_info .= '<a href="'.$linkedin['url'].'"><i class="fa fa-linkedin" style="color:blue"></i> Linkedin</a>';
    }


    $post_info .= '<ul class="member-contact">';
    $post_info .= "<li>$email</li>";
    $post_info .= "<li>p: $phone</li>";
    $post_info .= "<li>f: $fax</li>";
    $post_info .= "</ul>";
    var_dump($linkedin);

Images:

HTML Front-End

enter image description here

HTML Back-End

enter image description here

Custom Field Plugin enter image description here


Aucun commentaire:

Enregistrer un commentaire