Question

I have been trying to do this for hours now but just can't get this to work. What I am trying to do is change the copyright info in my wordpress theme which is being pulled from wp-content\themes\corporate-plus\acmethemes\hooks\footer.php with the below code.

    <?php
/**
 * Footer content
 *
 * @since Corporate Plus 1.0.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_footer' ) ) :

    function corporate_plus_footer() {

        global $corporate_plus_customizer_all_values;
        ?>
    <div class="clearfix"></div>
    <footer class="site-footer">
        <div class="container">
            <div class="bottom">
                <?php
                if(
                    is_active_sidebar('footer-col-one') ||
                    is_active_sidebar('footer-col-two') ||
                    is_active_sidebar('footer-col-three') ||
                    is_active_sidebar('footer-col-four')
                ){
                    $footer_top_col = 'col-sm-3';
                    ?>
                    <div id="footer-top">
                        <div class="footer-columns">
                            <?php if( is_active_sidebar( 'footer-col-one' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-one' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-two' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-two' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-three' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-three' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-four' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-four' ); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div><!-- #foter-top -->
                    <div class="clearfix"></div>
                    <?php
                }
                ?>
            </div><!-- bottom-->
            <?php if( isset( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ) ): ?>
                <p class="init-animate text-center animated fadeInLeft">
                    <?php echo wp_kses_post( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ); ?>
                </p>
            <?php endif;
             if ( 1 == $corporate_plus_customizer_all_values['corporate-plus-enable-social'] ) {
                    /**
                     * Social Sharing
                     * corporate_plus_action_social_links
                     * @since Corporate Plus 1.1.0
                     *
                     * @hooked corporate_plus_social_links -  10
                     */
                    do_action('corporate_plus_action_social_links');
                }
             ?>
            <div class="clearfix"></div>
            <div class="footer-copyright border text-center init-animate animated fadeInRight">
                <div class="site-info">
                    <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'corporate-plus' ) ); ?>"><?php printf( esc_html__( 'TEST %s', 'corporate-plus' ), 'WordPress' ); ?></a>
                    <span class="sep"> | </span>
                    <?php printf( esc_html__( 'Theme: %1$s by %2$s', 'corporate-plus' ), 'Corporate Plus', '<a href="http://www.acmethemes.com/" rel="designer"></a>' ); ?>
                </div><!-- .site-info -->
            </div>
            <a href="#page" class="sm-up-container"><i class="fa fa-arrow-circle-up sm-up"></i></a>
        </div>
    </footer>
    <?php
    }
endif;
add_action( 'corporate_plus_action_footer', 'corporate_plus_footer', 10 );

/**
 * Page end
 *
 * @since Corporate Plus 1.1.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_page_end' ) ) :

    function corporate_plus_page_end() {
        ?>
        </div><!-- #page -->
    <?php
    }
endif;
add_action( 'corporate_plus_action_after', 'corporate_plus_page_end', 10 );

I can change the above copyright info where it says TEST and this will update on my site. The problem is when I try and do this in my child theme so this doesn't get knocked out when the theme updates.

I have tried adding the acmethemes\hooks folders to the child theme and this did not work. I have also tried pasting the above PHP into my child themes functions.php file and then adding this into the footer.php which i also can't get working.

The footer.php file in the child theme is the below code. Which is also the same in the parent theme.

    <?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Acme Themes
 * @subpackage Corporate Plus
 */


/**
 * corporate_plus_action_after_content hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked null
 */
do_action( 'corporate_plus_action_after_content' );

/**
 * corporate_plus_action_before_footer hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked null
 */
do_action( 'corporate_plus_action_before_footer' );

/**
 * corporate_plus_action_footer hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked corporate_plus_footer - 10
 */
do_action( 'corporate_plus_action_footer' );

/**
 * corporate_plus_action_after_footer hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked null
 */
do_action( 'corporate_plus_action_after_footer' );

/**
 * corporate_plus_action_after hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked corporate_plus_page_end - 10
 */
do_action( 'corporate_plus_action_after' );
wp_footer(); ?>
</body>
</html>

What I have noticed is in wp-content\themes\corporate-plus\acmethemes\hooks there is another footer.php file with the below code. I am not sure if I need to be doing anything with this.

    <?php
/**
 * Footer content
 *
 * @since Corporate Plus 1.0.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_footer' ) ) :

    function corporate_plus_footer() {

        global $corporate_plus_customizer_all_values;
        ?>
    <div class="clearfix"></div>
    <footer class="site-footer">
        <div class="container">
            <div class="bottom">
                <?php
                if(
                    is_active_sidebar('footer-col-one') ||
                    is_active_sidebar('footer-col-two') ||
                    is_active_sidebar('footer-col-three') ||
                    is_active_sidebar('footer-col-four')
                ){
                    $footer_top_col = 'col-sm-3';
                    ?>
                    <div id="footer-top">
                        <div class="footer-columns">
                            <?php if( is_active_sidebar( 'footer-col-one' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-one' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-two' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-two' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-three' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-three' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-four' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-four' ); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div><!-- #foter-top -->
                    <div class="clearfix"></div>
                    <?php
                }
                ?>
            </div><!-- bottom-->
            <?php if( isset( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ) ): ?>
                <p class="init-animate text-center animated fadeInLeft">
                    <?php echo wp_kses_post( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ); ?>
                </p>
            <?php endif;
             if ( 1 == $corporate_plus_customizer_all_values['corporate-plus-enable-social'] ) {
                    /**
                     * Social Sharing
                     * corporate_plus_action_social_links
                     * @since Corporate Plus 1.1.0
                     *
                     * @hooked corporate_plus_social_links -  10
                     */
                    do_action('corporate_plus_action_social_links');
                }
             ?>
            <div class="clearfix"></div>
            <div class="footer-copyright border text-center init-animate animated fadeInRight">
                <div class="site-info">
                    <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'corporate-plus' ) ); ?>"><?php printf( esc_html__( 'TEST %s', 'corporate-plus' ), 'WordPress' ); ?></a>
                    <span class="sep"> | </span>
                    <?php printf( esc_html__( 'Theme: %1$s by %2$s', 'corporate-plus' ), 'Corporate Plus', '<a href="http://www.acmethemes.com/" rel="designer"></a>' ); ?>
                </div><!-- .site-info -->
            </div>
            <a href="#page" class="sm-up-container"><i class="fa fa-arrow-circle-up sm-up"></i></a>
        </div>
    </footer>
    <?php
    }
endif;
add_action( 'corporate_plus_action_footer', 'corporate_plus_footer', 10 );

/**
 * Page end
 *
 * @since Corporate Plus 1.1.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_page_end' ) ) :

    function corporate_plus_page_end() {
        ?>
        </div><!-- #page -->
    <?php
    }
endif;
add_action( 'corporate_plus_action_after', 'corporate_plus_page_end', 10 );

I'm getting really confused now as I have tried adding the functions into my functions.php to try and override them and reference them in the footer.php with no luck.

Would someone be able to let me know where I am going wrong and what PHP i need to be adding where and I can give this another go.

Thanks in advance for any responses and help :)

Was it helpful?

Solution

Both functions check if the function corporate_plus_footer() exists. If not, one is defined. Without going deeper into hooks and filters, you can simply declare your own corporate_plus_footer() and the other won't get loaded.

Add this to your functions.php

function corporate_plus_footer() {
    echo 'it works';
}

No additional add_action() or similar. Just this function in your functions.php should already work.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top