Override Copyright Message in Avada Theme

I was looking to modify the copyright message shown on a website which is using the Avada theme.

I wanted to add a little PHP code to keep the year current, as opposed to it getting older and older.

For this reason simply editing the copyright message every year, via the Avada theme options was not viable.

Considering my options for the change I viewed them as:

  • copy and edit the file footer.php
  • implement an override in functions.php

Whilst its possible to use the copied footer.php file, long term there is the possibility that at some point in the future an update to the theme will be different to the copied file. At this point the rendering would be different, a new copy would be required.

Differences between the updated Avada theme and the existing copied footer file would need to be checked each time the theme is updated.

The purpose of this exercise was to maintain the current date of the copyright message without further actions by the website owner. One item off the list of regular website actions.

My replacement for the Avada configured copyright message was:

echo ‘© ‘. date(“Y”) .’ website name.’;

Avada wraps this copyright message in a div, giving:

<div class="fusion-copyright-notice">
   <div>© 2019 website name.</div>
</div> 

I like to have a quick search on the Internet before starting a task such as this. It gives a feel for how others have approached the task. Whether its a common action. Maybe there are difficulties highlighted. Or perhaps a quick simple solution that will save me time.

My initial searching for information about modifying and automating the Avada theme copyright message suggested a simple add_action, referencing avada_footer_copyright_content. An example of this is shown below:

add_action( 'avada_footer_copyright_content', 'modify_avada_footer_copyright_content' ); function modify_avada_footer_copyright_content() {     echo '© 2019 website name'; }

But this doesn’t override the footer function. The additional content within the function is supplemented to that from the Avada theme.

We in effect end up with two copyright messages. The existing one and my changing year version.

I looked at the footer.php file, interested in how the code was presented. Perhaps there were clues to be found.

    <footer id="footer" class="fusion-footer-copyright-area<?php echo esc_attr( $footer_copyright_center_class ); ?>">
        <div class="fusion-row">
            <div class="fusion-copyright-content">

                <!--?php
                /**
                 * Footer Content (Copyright area) avada_footer_copyright_content hook.
                 *
                 * @hooked avada_render_footer_copyright_notice - 10 (outputs the HTML for the Theme Options footer copyright text)
                 * @hooked avada_render_footer_social_icons - 15 (outputs the HTML for the footer social icons)..
                 */
                do_action( 'avada_footer_copyright_content' );
                ?-->

            </div> <!-- fusion-fusion-copyright-content -->
        </div> <!-- fusion-row -->
    </footer> <!-- #footer -->

Looking at the code above it can be seen that there is the reference to avada_footer_copyright_content and two hooks. One of these avada_render_footer_copyright_notice is likely the item of interest.

I changed the add_action function to reference the hook by giving it the name of the function.

function avada_render_footer_copyright_notice() {
  echo '<div class="fusion-copyright-notice"><div>';
  echo '© '. date("Y") .' VNTweb.';
  echo '</div></div>';
}
add_action( 'avada_footer_copyright_content', 'avada_render_footer_copyright_notice' );

By adding this function to the functions.php file within the child theme I was able to override the copyright message generated by the options configured within the theme.

The theme used the name of the hook to be replaced and was referenced using an add_action which included references to this function avada_render_footer_copyright_notice and the content action avada_footer_copyright_content.

References

Avada Documentation: avada-hooks-actions-and-filters