WordPress.org

Support

Support » How-To and Troubleshooting » 2.3 and Headline Images Plugin

2.3 and Headline Images Plugin

  • intricateartist

    @intricateartist

    Wondering if something in 2.3 would cause the Headline Images plugin using the_title(‘-image-‘) not to function?

    I’m getting a hyperlink rendering of the title with -image- in front of it on reload after upgrading.

Viewing 15 replies - 1 through 15 (of 34 total)
  • intricateartist

    @intricateartist

    I should add that the call to the plugin works in other instances in the blog (sidebar, menu, etc.) – it just does not appear to work in the title template tag.

    I believe this has something to do with the new parameters for the_title() function now, as it seems to have a “before”, “after”, and “display” setting.

    Unfortunately, I’m not familiar enough with PHP to adapt the plugin to these changes.

    intricateartist

    @intricateartist

    Thanks, Jeff.

    I didn’t see anything depreciating in the title template tag which is what made me wonder why there’s a problem.

    <?php the_title('before', 'after', display); ?>

    where normally you’d modify the title for Image Headlines to:

    <?php the_title('-image-'); ?>

    The Image Headlines author is not supporting or upgrading the plugin – if it requires upgrading for 2.3, is there anyone willing?

    Someone please help. *sob.*

    From what I’ve been able to figure out, the new the_title() function doesn’t pass the ‘before’ parameter to the PHP, even when display = false is enabled. If we could figure out a way to pass a parameter (or an extra parameter) to the plugin hook, I think we could solve the problem.

    Anyone know how to pass parameters to a plugin?

    I had a friend of mine take a look at the php and this was his suggestion; replace the following segment of code in the plugin:

    // Check for XML feeds. Don't replace in feeds.
            // If you have $before set, and it doesn't match, we're done.
            if( strpos($text, $current_settings['before_text']) === FALSE ) {
                return $text;
            } else {
                if( !empty($current_settings['before_text']) ) {
                    $text = substr( $text, strlen($current_settings['before_text']) );
                }   
    
                // If you have problems, set this to TRUE and see what pops up ;-)
                $DebugImgHead = true;
    
                if( ImageHeadline_option_set( 'disable_headlines' ) )
                {
                    return $text;
                }
                else
                {
                    // get/make an image for this text.
                    return ImageHeadline_render( $text );
                }
            }

    with

    // Check for XML feeds. Don't replace in feeds.
            if(strpos($_SERVER['REQUEST_URI'],"/feed") !== FALSE) {
                return $text;
            } else {
                // If you have problems, set this to TRUE and see what pops up ;-)
                $DebugImgHead = true;
    
                if( ImageHeadline_option_set( 'disable_headlines' ) )
                {
                    return $text;
                }
                else
                {
                    // get/make an image for this text.
                    return ImageHeadline_render( $text );
                }
            }

    Dreamhost is having server problems so I haven’t been able to test it yet but he thinks it will work.

    You should also remove the -image- part from your template because supposedly that part of the code only was used to hide the text from showing up in an XML feed. He changed the call so that it renders the image by default unless the URL requested is that of a feed.

    If anyone can test it out and report back I’d appreciate it!

    Well it works, I tested it. However it’s returning everything that calls the title and generates an image for it, which isn’t exactly what I wanted originally. Trying to see if it can be gotten-around.

    Okay! This works.

    Replace the above code with the following:

    // Check for XML feeds. Don't replace in feeds.
            global $imageheadings_is_title;
    
            if(!isset($imageheadings_is_title))
                $imageheadings_is_title = FALSE;
    
            if(!$imageheadings_is_title) {
                return $text;
            } else {
                // If you have problems, set this to TRUE and see what pops up ;-)
                $DebugImgHead = true;
    
                if( ImageHeadline_option_set( 'disable_headlines' ) )
                {
                    return $text;
                }
                else
                {
                    // get/make an image for this text.
                    return ImageHeadline_render( $text );
                }
            }

    Then in your template replace the line where -image- used to be with this. Replace the whole second php_title call, not just adding -image- like previously:

    <?php
    
    global $imageheadings_is_title;
    $imageheadings_is_title = TRUE;
    the_title();
    $imageheadings_is_title = FALSE;
    
    ?>

    There may be a more elegant solution but this works for me so far, only returning the specific titles in each entry and not elsewhere in the template.

    dawaldi

    @dawaldi

    tyvm, this solution works fine 😀

    Thank you! This solution is in essence what I was trying to do, but instead of passing a parameter, a global variable is set. There must be a more elegant way to do it, but I’ll be damned if I know.

    Kudos for getting us a working version.

    ColdForged

    @coldforged

    After looking at the 2.3 codebase, the problem is that they’ve changed where the ‘the_title’ filter is applied. It used to be applied from within the ‘the_title()’ function and it was applied such that the before and after text was included in the text being filtered so the filter — and hence my plugin — was given the before and after text to work with. Now the filter is applied in the ‘get_the_title()’ function before the before and after text are applied so the filter — and again, by extension, my plugin — doesn’t get the before text anymore.

    So, frankly, I’m busted. I’m glad people are finding workarounds but the global variable method isn’t clean enough for me to include in a plugin update. If I think of something else, I’ll issue an update but WP has sort of tied my hands on this one.

    intricateartist

    @intricateartist

    THANK YOU!!!!

    intricateartist

    @intricateartist

    And thanks for looking into it, ColdForged – It’s a great plugin obviously, so the recent fix is so important to so many people. 🙂

    Yeah ColdForged, I wish there was a better solution but this works at least; your plugin is VITAL as far as I’m concerned. I was having panic attacks when it wasn’t working.

    Thanks for trying to look into it at any rate.

    ColdForged

    @coldforged

    Yeah, real nice work on getting a workaround at all. There may be something possible that is “confined” to the plugin instead of having to change the template more but I haven’t thought of it yet :(.

    And, frankly, I’m still on 1.5 so I can’t diddle with it much :).

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘2.3 and Headline Images Plugin’ is closed to new replies.