Functions aren't changing labels or words in the List Widget

Home Forums Calendar Products Events Calendar PRO Functions aren't changing labels or words in the List Widget

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1006927
    MIKE
    Participant

    So I’m using the following functions:

    
    /*
    * CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR
    */
    function tribe_custom_theme_text ( $translations, $text, $domain ) {
    // Put your custom text here in a key => value pair
    // Example: 'Text you want to change' => 'This is what it will be changed to'
    // The text you want to change is the key, and it is case-sensitive
    // The text you want to change it to is the value
    // You can freely add or remove key => values, but make sure to separate them with a comma
    // This example changes the label “Venue” to “Location”, and “Related Events” to “Similar Events”
    $custom_text = array(
    'Venue' => 'Location',
    'Venues' => 'Locations',
    'Organizers' => 'Instructors',
    'Organizer' => 'Instructor'
    );
    // If this text domain starts with “tribe-“, and we have replacement text
    if(strpos($domain, 'the-') === 0 && array_key_exists($text, $custom_text) ) {
    $text = $custom_text[$text];
    }
    return $text;
    }
    add_filter('gettext', 'tribe_custom_theme_text', 20, 3);
    
    // Change VENUE to LOCATION
    function filter_translations($translation, $text, $domain) {
        if ($domain == 'the-events-calendar') {
            switch ($text) {
                case 'Organizer':
                    $translation = 'Instructor';
                    break;
            }
        }
      
        return $translation;
    }
    add_filter('gettext', 'filter_translations', 10, 3);
    

    However, the changes aren’t being made to the List Widget.

    #1007298
    George
    Participant

    I’m sorry this isn’t working, @MIKE – for starters, I think you’ll have much better luck using the new method for doing this which is described (with example code) in the knowledgebase article here → https://theeventscalendar.com/knowledgebase/relabeling-the-venue-organizer-sections-in-event-meta/

    That should make a difference – let me know if it does, or if your List Widget still seems to not be affected. If this is latter situation is the case, then I’d recommend that you share your System Information if possible (learn how to do that here → https://theeventscalendar.com/knowledgebase/sharing-sys-info/).

    Cheers!
    George

    #1007320
    MIKE
    Participant

    This reply is private.

    #1007501
    George
    Participant

    Hey @MIKE,

    Thanks for the system information! Nothing looks out of the ordinary there, so I’m wondering, when you mention having tried the method I linked to already, did you place that code in your theme’s functions.php file? If so, can you add it back to your functions.php file like you did before, and see if it works any better? If it doesn’t work any better, then can you paste your ENTIRE functions.php file, un-edited in full, into a Gist at http://gist.github.com and then share a link to that Gist here?

    There may be a problem that I can spot from this, as that method should be working and is a better method than the gettext method you posted in your first post on this thread.

    Thank you for your patience!

    — George

    #1007689
    MIKE
    Participant
    #1007883
    George
    Participant

    Hey @MIKE,

    Thanks for this! To be clear, with the second style of venue and organizer-related label code in place, can you remove the first method you’ve added at the top of your functions.php file?

    Does this help at all? I’ve checked our code and these labels should be changing – let me know if this helps.

    If not, then can you take a screenshot of the labels on your site that are not changing? Then, upload this screenshot to a site like Imgur.com or something, and share the URL in your reply here so we can see it…

    Thank you for your patience here!

    #1007895
    MIKE
    Participant

    Ok, now I’ve edited it to

    https://gist.github.com/anonymous/ab396513824b1f9b8b33

    and it’s still not changing.

    #1007916
    MIKE
    Participant

    Oh, here’s why.
    In pro/widgets/modules/single-event.php it’s hard coded:

    
    <?php if ( isset( $organizer ) && $organizer && tribe_get_organizer() != '' ): ?>
    	<span class="tribe-organizer">
    		<?php esc_html_e( 'Organizer:', 'tribe-events-calendar-pro' ); ?>
    		<?php echo tribe_get_organizer_link(); ?>
    	</span>
    <?php endif ?>
    

    [sad face]

    #1008222
    George
    Participant

    Hey Mike,

    I’m really sorry about this bug! And that I didn’t see it myself!

    The “organizer” label isn’t quite hard-coded there, it’s still fully translatable, but it should be calling in the organizer label dynamically for our filter to work. Here’s how to replace that to get the code I recommended to work:


    <?php if ( isset( $organizer ) && $organizer && tribe_get_organizer() != '' ): ?>

    <span class="tribe-organizer">
    <?php echo esc_html( sprintf( __( '%:', 'tribe-events-calendar-pro' ), tribe_get_organizer_label_singular() ) ); ?>
    <?php echo tribe_get_organizer_link(); ?>
    </span>

    <?php endif ?>

    Let me know if this helps! I will make a ticket for our developers to fix this immediately.

    #1008319
    MIKE
    Participant

    Thanks George! While you’re at it, let them know it exists in the event calendar as well in src/Tribe/Admin/Organizer_Chooser_Meta_Box.php, line 142

    
             /**
    	 * Renders the "Add Another Organizer" button
    	 *
    	 * @return void
    	 */
    	protected function render_add_organizer_button() {
    		printf( '<tfoot><tr><td colspan="2"><a class="tribe-add-organizer" href="#">%s</a></td></tr></tfoot>', __( 'Add another organizer', 'the-events-calendar' ) );
    	}
    

    Keep up the good work!

    #1008688
    George
    Participant

    Thank you for reporting this one, too, @MIKE!

    Much appreciated – I’m sorry that these things aren’t fixed, but I will indeed add this second one to the development ticket and we’ll have them patched up quick! 🙂

    Cheers,
    George

    P.S.

    If you would like to manually fix this second bug for now, you can do so by replacing it with code like this:


    /**
    * Renders the "Add Another Organizer" button
    *
    * @return void
    */
    protected function render_add_organizer_button() {
    echo '

    ' . sprintf( __( 'Add another %s', 'the-events-calendar' ), tribe_get_organizer_label_singular() ) . '

    ';
    }

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Functions aren't changing labels or words in the List Widget’ is closed to new replies.