Child Theme: how to override variables?

I’m going to build my first Child Theme. I understood how to override functions (hope!), but how to override variables?
For example, in a Premium Template I want to change the values of feed variables shown in functions.php:

$app_rss_feed = 'http://xxx.rss';
$app_twitter_rss_feed = 'http://yyy.rss';
$app_forum_rss_feed = 'http://zzz.rss';

But if I create my functions.php file inside my child theme and assign a different RSS feed value to these variables… nothing happens.
So, which is the right way to change variables?

Related posts

Leave a Reply

2 comments

  1. I’m mobile, so this will be short.

    Use the after_setup_theme hook to add a function to set those variables. Declare them as global inside that function before setting them.

    Hope that helps.

    If anybody wants to add an example to this answer before I get home, feel free. 😉

  2. The parent theme’s functions.php is loaded later, it will overwrite those variables. Show us the code where these variables are declared and where thex are used, there may be a filter you could use.

    An example: In fetch_feed() you can filter the feed URL:

    do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
    

    To filter the values, you could check for the parent theme’s URL:

    add_filter( 'wp_feed_options', 'wpse_46644_feed' );
    
    function wpse_46644_feed( $arr )
    {
        if ( 'http://example.com/feed/' === $arr[1] )
        {
            $arr[0]->set_feed_url( 'http://replacement.example.com/feed/' );
        }
    }
    

    Not tested, just an idea.