How to change 'follow me' text on Twitter widget

  • jrothra

    #1453

    I’m not sure where to go to change it, but I want to change “me” to the organization’s abbreviation. Where do I do that?

    jamilla

    #15875

    Hi jrothra,

    I know it will require changing the text in your functions.php, but I am pretty sure you shouldn’t do this in the main functions.php – it may require creating a child one… Or adding code to an already created child one and changing it in there..

    I’m still learning and I’ve got this far, but don’t know the rest!

    Sorry I don’t have an answer, I would also like to know the answer to this one.. 🙂

    Cheers

    Jami

    Mod

    Kenneth John Odle

    #15876

    in functions.php, find this line (#1071):

    <p id="tweetfollow" class="sidebar_ablock"><a href="http://twitter.com/<?php echo $twitter_username; ?>"><?php _e('Follow me on Twitter', 'graphene') ?></a></p>

    Change “me” to organization name.

    Again, only try this in a child theme, or this customization will be lost in the next upgrade.

    Ken

    Admin

    Syahir Hakim

    #15877

    Editing the theme’s functions.php file directly is bad. Don’t do it.

    Doing this in a child theme will require creating a new functions.php file, and then copying the entire code block that defines the Twitter widget from the theme’s functions.php file into the child theme’s functions.php file, and then make the edit in the child theme’s funcitons.php file. This is not as bad as editing the theme’s original functions.php file, but it’s still bad, because you will miss out on any improvements on the Twitter widget in future updates.

    The third option would be to use the Codestyling Localization plugin, which will allow you to modify the theme’s strings without actually touching any of the theme’s codes.

    Admin

    Syahir Hakim

    #15878

    Scrap my suggestion above. Here’s a (much) better way. Throw this code into your child theme’s functions.php file:

    function graphene_filter_gettext( $translated, $original, $domain ) {
    $strings = array(
    'Follow me on Twitter' => 'Follow my organisation on Twitter',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );

    Obviously, change the following line to reflect your organisation’s name or initial:

    'Follow me on Twitter' => 'Follow my organisation on Twitter',

    jrothra

    #15879

    Syahir,

    Where in the child’s functions.php file do I throw it?

    Admin

    Syahir Hakim

    #15880

    The positioning doesn’t matter, just put it in anywhere in between the opening <?php and closing ?> tags.

    jrothra

    #15881

    I tried that, but when I went to activate the child theme, I got this warning:

    Warning: require_once(admin/options-defaults.php) [function.require-once]: failed to open stream: No such file or directory in /home/gcgop/public_html/wp-content/themes/graphene-child/functions.php on line 53

    Fatal error: require_once() [function.require]: Failed opening required ‘admin/options-defaults.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/gcgop/public_html/wp-content/themes/graphene-child/functions.php on line 53

    The code you mentioned I placed near the top of the file, changing nothing else. Here’s the code to my functions.php file that shows line 53 and where I placed the customization.

    <?php
    /**
    * Graphene functions and definitions
    *
    * Sets up the theme and provides some helper functions. Some helper functions
    * are used in the theme as custom template tags. Others are attached to action and
    * filter hooks in WordPress to change core functionality.
    *
    * The first function, graphene_setup(), sets up the theme by registering support
    * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
    *
    * When using a child theme (see http://codex.wordpress.org/Theme_Development and
    * http://codex.wordpress.org/Child_Themes), you can override certain functions
    * (those wrapped in a function_exists() call) by defining them first in your child theme's
    * functions.php file. The child theme's functions.php file is included before the parent
    * theme's file, so the child theme functions would be used.
    *
    * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
    * to a filter or action hook. The hook can be removed by using remove_action() or
    * remove_filter() and you can attach your own function to the hook.
    *
    * We can remove the parent theme's hook only after it is attached, which means we need to
    * wait until setting up the child theme:
    *
    * <code>
    * add_action( 'after_setup_theme', 'my_child_theme_setup' );
    * function my_child_theme_setup() {
    *
    * remove_filter('filter_hook', 'callback_function' );
    * ...
    * }
    * </code>
    *
    * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
    *
    * @package WordPress
    * @subpackage Graphene
    * @since Graphene 1.0
    */

    /**
    * Before we do anything, let's get the mobile extension's init file if it exists
    */
    $mobile_path = dirname( dirname( __FILE__ ) ) . '/graphene-mobile/includes/theme-plugin.php';
    if ( file_exists($mobile_path) ) { include( $mobile_path ); }

    /**
    * Retrieve the theme's user settings and default settings. Individual files can access
    * these setting via a global variable call, so database query is only
    * done once.
    */
    require_once( 'admin/options-defaults.php' );
    function graphene_get_settings(){
    global $graphene_defaults;
    $graphene_settings = array_merge( $graphene_defaults, (array) get_option( 'graphene_settings', array() ) );
    return apply_filters( 'graphene_settings', $graphene_settings );
    }
    global $graphene_settings;
    $graphene_settings = graphene_get_settings();

    /* CUSTOMIZATION BY JLR START - CHANGE WORDING OF LINK AT BOTTOM OF TWITTER WIDGET */
    function graphene_filter_gettext( $translated, $original, $domain ) {
    $strings = array(
    'Follow me on Twitter' => 'Follow GCGOP on Twitter',
    );
    if ( ! empty( $strings[$original] ) ) {
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }
    return $translated;
    }
    add_filter( 'gettext', 'graphene_filter_gettext', 10, 3 );
    /* CUSTOMIZATION BY JLR END - CHANGE WORDING OF LINK AT BOTTOM OF TWITTER WIDGET */

    /**
    * If there is no theme settings in the database yet (e.g. first install), add the database entry.
    */

    Here’s what’s in my child folder:

    – footer.php

    – functions.php

    – gcgop.ico

    – loop.php

    – style.css

    – images/img_slider_generic.png

    – images/sprite_h-JLR.png

    – images/sprite_h_light-JLR.png

    The child theme worked fine until I copied the parent theme’s functions.php file, added the code you mentioned, and saved the customized version into the child folder (leaving the parent unchanged).

    jrothra

    #15883

    When I removed the customized functions.php file from the child theme folder, things worked better (though the changes I made to the things such as the header and options (all using the WP Dashboard based interface) were undone, such as my custom header banner, custom menu. I never changed the functions.php folder in the parent directory.

    Admin

    Syahir Hakim

    #15884

    Don’t copy the parent theme’s functions.php file, that will throw everything into disarray. Just create an empty functions.php file inside the child theme folder, and add the code I mentioned above.

Viewing 10 posts - 1 through 10 (of 17 total)

You must be logged in to reply to this topic.

Do NOT follow this link or you will be banned from the site!