Disappearing/Reappearing Link


#1

I am trying to edit this code/make a child theme for a website per instruction of the theme help desk. I do not know PHP.

If I remove the final comma and “FameTheme” surrounded by two single quote marks the link disappears in the footer. If I remove the “FameTheme” and two single quote marks but leave the comma, I am left with the word “by” next to the link. I therefore think the comma means place the word “by” after the link. Presently I only need the “Privacy Policy” link. Later I will add another link for a site map. What is the proper coding to make the link appear but nothing following it? Also, can I get an explanation of how the “by” is showing up?

Thank you

function screenr_plus_footer_credits(){

    $c = get_theme_mod( 'screenr_footer_copyright_text' );
    if ( ! $c ) {
        $c = sprintf( esc_html__('Copyright %1$s %2$s %3$s. All Rights Reserved.', 'screenr'), '©', date_i18n('Y'), get_bloginfo() );
    }
    $h = get_theme_mod( 'screenr_hide_author_link', 0 );
    if ( $c || !$h ) {
        ?>
        <div id="footer-site-info" class="site-info">
            <div class="container">
                <div class="site-copyright">
                    <?php echo wp_kses_post( $c ); ?>
                    <?php ; ?>
                </div><!-- .site-copyright -->
                <div class="theme-info <?php echo ( $h ) ? 'screen-reader-text' : ''; ?>">
                    <div class="theme-info <?php echo ( $h ) ? 'screen-reader-text' : ''; ?>">
                    <?php printf( esc_html__('%1$s by %2$s', 'screen'), '<a href="https://www.assabetbicycles.com/privacy-policy">Privacy Policy</a>','FameTheme'); ?>
                </div>
            </div>
        </div><!-- .site-info -->
        <?php
    }
    ?>
    <?php
}

#2

If you just search for “by” (ctrl+F) you see the word is contained by these percentage-placeholders. Every percentage-placeholder is (in short) replaced by one of the following parameters, either the link or the name. If you remove the name, you must also remove the according percentage-placeholder, otherwise you should get an error message, which looks supressed on your server.

Change that, the manual is your friend:

https://secure.php.net/manual/en/function.printf.php


#3

Thank you again. Quick follow ups. What is the ‘screen’ bit in that line? Also, if I want to add a pipe (|) where the “by” was followed by a second link would this work: printf( esc_html__(’%1$s | %2$s’, ‘screen’)…


#4

I recommend to try changes by yourself first, in most cases it makes no sense to let other people simulate the PHP-interpreter.

As esc_html__ is not a PHP built-in function, you have to look into your software what this function does - a good start to learn the language.


closed #5

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.