WordPress.org

Ready to get started?Download WordPress

Forums

2.3 and Headline Images Plugin (35 posts)

  1. intricateartist
    Member
    Posted 6 years ago #

    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.

  2. intricateartist
    Member
    Posted 6 years ago #

    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.

  3. jeff_n
    Member
    Posted 6 years ago #

    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.

  4. intricateartist
    Member
    Posted 6 years ago #

    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?

  5. mixvio
    Member
    Posted 6 years ago #

    Someone please help. *sob.*

  6. jeff_n
    Member
    Posted 6 years ago #

    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?

  7. mixvio
    Member
    Posted 6 years ago #

    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!

  8. mixvio
    Member
    Posted 6 years ago #

    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.

  9. mixvio
    Member
    Posted 6 years ago #

    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.

  10. dawaldi
    Member
    Posted 6 years ago #

    tyvm, this solution works fine :D

  11. jeff_n
    Member
    Posted 6 years ago #

    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.

  12. ColdForged
    Member
    Posted 6 years ago #

    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.

  13. intricateartist
    Member
    Posted 6 years ago #

    THANK YOU!!!!

  14. intricateartist
    Member
    Posted 6 years ago #

    And thanks for looking into it, ColdForged - It's a great plugin obviously, so the recent fix is so important to so many people. :)

  15. mixvio
    Member
    Posted 6 years ago #

    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.

  16. ColdForged
    Member
    Posted 6 years ago #

    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 :).

  17. jeff_n
    Member
    Posted 6 years ago #

    Out of curiosity, does anyone know what Matt is using? He seemed to update without a hiccup, so perhaps he has his own personal plugin to make headline images.

  18. courtneyelizabeth
    Member
    Posted 6 years ago #

    Yeah, Matt...spill it!

  19. Ethel
    Member
    Posted 6 years ago #

    OMG it works perfectly! Thank youuuuuu! :D

  20. ANappyGirl
    Member
    Posted 6 years ago #

    I fixed it! YAY! It's a DYNAMIC plugin, and I hated to lose it!

    Thanks for ALL your help! My heart is warm!

  21. ccbookreviews
    Member
    Posted 6 years ago #

    ANappyGirl!

    What did you do? I so need help with this too.

  22. ANappyGirl
    Member
    Posted 6 years ago #

    @eebookreviews

    I just followed the instructions posted in the earlier part of the thread. If you need help with a specific part of the instructions (I had to figure out WHERE to find the code to replace it with the workaround), tell us which part, and we'll help you!

  23. ANappyGirl
    Member
    Posted 6 years ago #

    Only thing: The headline doesn't display correctly, when I click on specific posts, listed under "categories". What could be causing that? Did I not do a complete edit of the code?

  24. ccbookreviews
    Member
    Posted 6 years ago #

    Oh! Lord... I got it! It's funny cause I followed the same steps before and it didn't work. Oh well. It's works now and that's the main thing.

  25. ccbookreviews
    Member
    Posted 6 years ago #

    So if I wanted to use this plugin for the headers on my sidebars. How would I do that?

  26. ccbookreviews
    Member
    Posted 6 years ago #

    Oh never mind. It works the same as it did before in the installation instructions.

  27. lethean
    Member
    Posted 6 years ago #

    IANAPC (I am not a PHP coder), but is there any reason you can't add this to the code (as a separate function):

    if( !function_exists( 'image_title' ) ) {
    	function image_title() {
    		global $imageheadings_is_title;
    		$imageheadings_is_title = TRUE;
    		the_title();
    		$imageheadings_is_title = FALSE;
    	}
    }

    If you combine that with mixvio's global variable modification, you should just be able to replace all instances of the_title('image') with image_title(). (Works for me.)

  28. felipelavinz
    Member
    Posted 6 years ago #

    Maybe I'm being naive, newbie or just lame... but why not just use ImageHeadline_render? Like this:

    <?php echo ImageHeadline_render(''.$post->post_title.''); ?>

    Works for me, with no need to change the code... the plugin's code, I mean... it really is the simplest workaround I can think of.

  29. jrrl
    Member
    Posted 6 years ago #

    Here's a different solution. I reworked the plugin to give you a couple of new template tags and then reworked the whole admin interface because I was on a roll. Anyway, my alternative plugin is called TTFTitles and can be found at http://templature.com/2007/10/18/ttftitles-wordpress-plugin/.

    Couldn't have done any of it without Brian's code to work from, of course.

  30. ANappyGirl
    Member
    Posted 6 years ago #

    @jrrl

    I'm about to test our your new plugin, in my new template. If this works, you will get the BIGGEST hug in your entire life — in cyberspace, of course.

    Be right back...

    *Update* I got tons of "Warning: Unexpected Character input..." errors. And what is "chmod a+w"? I'm familiar with permissions, but I've never seen it written like that.

Topic Closed

This topic has been closed to new replies.

About this Topic