wecobble / Subtitles

Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate Subtitles and you're ready to go.
http://wordpress.org/plugins/subtitles/
GNU General Public License v2.0
117 stars 186 forks source link

Subtitles do not show on Frontend #6

Closed Honkytonky closed 10 years ago

Honkytonky commented 10 years ago

Hi Arthur. Opening this thread coming from wordpress.org. The backend of subtitles works just fine but on my frontend no subtitles are being displayed. The theme I use is Zeitgeist from Enveato. It is well coded and h1 tags are properly set in the title. Nevertheless the h1 tag is being defined within a class called pagetitle as you can see in this css: [link removed by Philip for security]. I guess that this is the problem. I tried figure out how to modify your code but still had no success. If you have any idea please let me know. Cheers and thank you!

philiparthurmoore commented 10 years ago

@Honkytonky: I have removed the link you posted because it may expose your website to unwanted visitors. The only way that I will be able to figure this for you is if you email me the theme or help me troubleshoot it more. My guess is that something within your theme is manipulating your titles or titles are being called outside of your primary post loop. I cannot verify this without testing your theme, though. If you'd like to email me a copy for testing then please see my profile for contact details. Thanks.

Honkytonky commented 10 years ago

Would it not be best I grant you access to the site itself? I feel like you are to be trusted. Seems we have something in common. I am a German living in Chile, you seem to be American living in Vietnam. I have been working in Balikpapan, Borneo quite a while! Saludos! I could grant you access to the ftp or the wp admin itself if you feel that served you more.

philiparthurmoore commented 10 years ago

Hi @Honkytonky. My mother lived in Chile for 10 years as an expat in Horcón. Very cool. The problem is that I cannot debug your theme on your website. It's not safe and I'm not able to test code that may or may not be able to help you solve this issue. As Esmi mentioned, this is the problem with commercial theme support. They should really be helping you with this but because Subtitles is so new I would like to help you and see if there's anything in the plugin that's causing this to happen. I can only do this on my machine.

Honkytonky commented 10 years ago

Yeah, I see that. How cool is this mother thing. I have come here in 2011 living in Puerto Varas 1 year and working my second year in La Unión. Thats quite south! I will send you the theme! Where can I send it to? Greetz!

philiparthurmoore commented 10 years ago

Please see my profile for contact information (email). Please also send me the URL where I can see this exact error happening on your website, so that I know which template file to look into when you send the theme. Thank you.

Honkytonky commented 10 years ago

The email including the theme is just leaving. I will send you a second email with the data requested. Saludos!

philiparthurmoore commented 10 years ago

@Honkytonky, thank you for sending the theme. The reason your subtitle is not showing up is because your template file is not using page titles inside of The Loop, and so Subtitles is ignoring your title. You can adjust this manually, within your theme's single.php by doing the following:

<h1>
    <?php echo $htitle;?>
    <?php if ( function_exists( 'the_subtitle' ) ) : ?>
        <span class="entry-subtitle">
            <?php the_subtitle(); ?>
        </span>
    <?php endif; ?>
</h1>

Keep in mind that this will only work if you have the plugin installed. I will work on finding a better way of dealing with the fact that post and page titles outside of The Loop are not automatically filtered, but in general it's good practice to have that title inside of a loop, so that plugins are able to work with it and know that it's the primary title on the page.

Let me know if that fixes your issue and I'll also let you know when a more suitable plugin-specific fix for this has been rolled out.

Honkytonky commented 10 years ago

Philip, thank you so much. What part of the code am I supposed to replace exactely. Or do I have to add this bit you suggested?

philiparthurmoore commented 10 years ago

Open your single.php template file and look for the line that says:

<h1><?php echo $htitle;?></h1>

Change that to the code I've given you above. This is around line 100 in the file.

Honkytonky commented 10 years ago

Thank you so much, Philip. It works. Where would you personally style the subtitle so I do not lose the style while updating your plug? Muchos saludos :-)!

philiparthurmoore commented 10 years ago

Great, @Honkytonky. Glad to hear it (if you don't mind, would you leave a review on the plugin page?) The styling is already built into the plugin (see this) so that won't be lost. If you do update your theme, then you will just need to add the code above back into your template file. Hopefully by then I will have either a) made subtitles available outside The Loop or b) written documentation to explain how to deal with this issue.

philiparthurmoore commented 10 years ago

Hi @Honkytonky. Just a quick note that there's another way to do this also. I was looking at your theme and the reason this issue is happening is because of this line:

if(isset($pagecustoms['zeitgeist_header_title']))$htitle = $pagecustoms['zeitgeist_header_title']; else $htitle= get_the_title();

There is an option somewhere in your theme that's taking control of titles. If you turn off this option, then the title that will be returned to your page will be as follows:

$htitle= get_the_title();

The plugin will work fine in this instance, and you won't have to change anything in your single.php template file. So this boils down to the theme messing with titles due to a built-in option, and you'll have to choose whether you want to use its titles or your own.

Honkytonky commented 10 years ago

Philip, yeah I see that. You are right. Unfortunately I make use of this function in terms of SEO and would not want to give it up. But you are right, it would be less "messy". Still I am pretty good with your solution. As I do not intend to change the theme for this site it should be good to go. But I will follow your developement. Who knows where it is being headed in terms of this "issue" :-)! Thanks for all the love you put in this. I really appreciate it! Saludos desde Chile! Michael

philiparthurmoore commented 10 years ago

Sounds great, Michael. I'll close this Issue and please don't hesitate to get in touch again if you notice any other weird behavior with the plugin. All the best in Chile!

Honkytonky commented 10 years ago

Hey Philip.

thanks again for your help yesterday! I followed your update on the install today. Since then, when I insert a subtitle, it displays an ugly html code at the bottom of the article in the blog overview. Due to the fact that I have a mod running right now (your solution from yesterday) I do not know whether this is really related or not, but I felt like letting you know in any case. The “bug” is to be seen here: http://smlu.net/anuncios-santa-marta-la-union/ . Strangely it appears only when I add a subtitle to an image post as you see when you scroll to the second latest post (reforma educativa). Maybe there is an issue with PrettyPhoto-Lightbox?

Send you greets to Vietnam!

Michael

On Jun 13, 2014, at 11:20 PM, Philip Arthur Moore notifications@github.com wrote:

Sounds great, Michael. I'll close this Issue and please don't hesitate to get in touch again if you notice any other weird behavior with the plugin. All the best in Chile!

— Reply to this email directly or view it on GitHub.

philiparthurmoore commented 10 years ago

Hi Michael. That's weird. I did update the plugin to have better title and subtitle checking, so I'm not sure how that may or may not have changed things for you. What happens when you temporarily disable the photo plugin? I can take a look at this tomorrow if you give me more information about how to reproduce the error. Thanks!

Honkytonky commented 10 years ago

Hey Philip,

strange stuff, yeah, but I don’t think it is the modification, no. The prettyphoto links are part of the theme, an image posts takes the featured image and puts it on top of the post where when you hover the mouse can enlarge it in a kind of modal. It is actually not a plugin but part of the theme. All other post types display the subtitle correctly…that is why I assume it has to do with a function that is called just in case it is an image post. I am also looking into it already. If I find a solution in any case I will email you to make sure it is nothing with the plugin actually.

Reproducing it would just mean create an image post, give it a subtitle and view it in the blog overview page!

Saludos desde Chile :-)!

Micha

On Jun 14, 2014, at 6:53 PM, Philip Arthur Moore notifications@github.com wrote:

Hi Michael. That's weird. I did update the plugin to have better title and subtitle checking, so I'm not sure how that may or may not have changed things for you. What happens when you temporarily disable the photo plugin? I can take a look at this tomorrow if you give me more information about how to reproduce the error. Thanks! — Reply to this email directly or view it on GitHub.

Honkytonky commented 10 years ago

Hey Philip,

I kind of spotted at least the problem I guess. In the source of the blog overview it created the affected posts div like I have copied below the email. I guess your span is being inserted actually two times. Nevertheless deleting the subtitle in the post edit solves the problem so at least I guess it comes from the plugin. Whereas I am not quite sure whether this is due to my mod.

I will keep you up to date! Have a nice day on the other half :-)

Michael

```

Eduardo Burgos y Yessenia Rubilar, apoderados de Santa Marta La Unión, les informan.

```
```
``` On Jun 14, 2014, at 6:53 PM, Philip Arthur Moore notifications@github.com wrote: > Hi Michael. That's weird. I did update the plugin to have better title and > subtitle checking, so I'm not sure how that may or may not have changed > things for you. What happens when you temporarily disable the photo plugin? > I can take a look at this tomorrow if you give me more information about > how to reproduce the error. Thanks! > — > Reply to this email directly or view it on GitHub.
philiparthurmoore commented 10 years ago

Hi Michael. I'm pretty sure this has to do with the fact that your theme is outputting the_title in home_page.php where it shouldn't be doing it. Take a look in the file around line 338:

<a title="<?php the_title(); ?>"

Not only is this not safe due to potential security flaws in this approach, but it's also not the best function to use for outputting titles as attributes. If you change that to the following, I'm fairly certain that things will be fine:

<a title="<?php the_title_attribute(); ?>"

You should tell the developers of the theme to fix this immediately. the_title_attribute is a much safer function to use in this context and will prevent plugins like mine or any others from messing with your link attributes.

In the meantime, let me figure out a way to avoid the plugin from messing with titles contained in link attributes. But the proposed fix above should take care of your problem. Let me know.

Honkytonky commented 10 years ago

Philip,

thanks a lot. I had just been reading about this issue on the net and changed this in the code. It does not change the messed up html output but also does no other harm. Thanks for pointing this out. After solving this I will forward this with a detailed description!

Greetz!

Michael

On Jun 14, 2014, at 7:29 PM, Philip Arthur Moore notifications@github.com wrote:

Hi Michael. I'm pretty sure this has to do with the fact that your theme is outputting the_title in home_page.php where it shouldn't be doing it. Take a look in the file around line 338:

<a title="<?php the_title(); ?>" Not only is this not safe due to potential security flaws in this approach, but it's also not the best function to use for outputting titles as attributes. If you change that to the following, I'm fairly certain that things will be fine:

<a title="<?php the_title_attribute(); ?>" You should tell the developers of the theme to fix this immediately. the_title_attribute is a much safer function to use in this context and will prevent plugins like mine or any others from messing with your link attributes.

In the meantime, let me figure out a way to avoid the plugin from messing with titles contained in link attributes. But the proposed fix above should take care of your problem. Let me know.

— Reply to this email directly or view it on GitHub.

philiparthurmoore commented 10 years ago

Thanks Michael. Okay. I'll play with this tomorrow and see what I can come up with.

Honkytonky commented 10 years ago

Thanks Philip! I am also on it. In any case I keep you up to date if I find anything more on the issue!

Cheers!

On Jun 14, 2014, at 7:45 PM, Philip Arthur Moore notifications@github.com wrote:

Reopened #6.

— Reply to this email directly or view it on GitHub.

philiparthurmoore commented 10 years ago

Hi Michael. I've just performed a test with the_title_attribute() and indeed, everything works as expected. Are you sure that changing <a title="<?php the_title(); ?>" to <a title="<?php the_title_attribute(); ?>" has no effect on your site? There is absolutely no way that any HTML markup or tags are allowed in the output of the_title_attribute(), as seen by the core function of WordPress itself:

function the_title_attribute( $args = '' ) {
    $defaults = array( 'before' => '', 'after' =>  '', 'echo' => true, 'post' => get_post() );
    $r = wp_parse_args( $args, $defaults );

    $title = get_the_title( $r['post'] );

    if ( strlen( $title ) == 0 ) {
        return;
    }

    $title = $r['before'] . $title . $r['after'];
    $title = esc_attr( strip_tags( $title ) );

    if ( $r['echo'] ) {
        echo $title;
    } else {
        return $title;
    }
}

Just before anything is returned to the browser, escaping happens:

$title = esc_attr( strip_tags( $title ) );

So no matter what any plugin does to your title in the form of HTML output, using the function the_title_attribute() for attributes will make sure that they are always stripped and displayed properly. Can you confirm and try this again? Thanks!

Honkytonky commented 10 years ago

Philip,

you are right, I also do not know what happens. If you proceed to this site http://smlu.net/anuncios-santa-marta-la-union/ you see what happens below the second latest post. Below I post you the output html! Maybe I am just lost with what function in the theme and where exactly to override it. It seems wordpress does not have a proper page for the blog overview and I am not so sure where to grab the title and replace it! Everything I read on title-attribute confirms what you say!

Greetz

Michael

Eduardo Burgos y Yessenia Rubilar, apoderados de Santa Marta La Unión, les informan.

On Jun 14, 2014, at 10:29 PM, Philip Arthur Moore notifications@github.com wrote: > Hi Michael. I've just performed a test with the_title_attribute() and indeed, everything works as expected. Are you sure that changing > function the_title_attribute( $args = '' ) { > $defaults = array( 'before' => '', 'after' => '', 'echo' => true, 'post' => get_post() ); > $r = wp_parse_args( $args, $defaults ); > > ``` > $title = get_the_title( $r['post'] ); > > if ( strlen( $title ) == 0 ) { > return; > } > > $title = $r['before'] . $title . $r['after']; > $title = esc_attr( strip_tags( $title ) ); > > if ( $r['echo'] ) { > echo $title; > } else { > return $title; > } > ``` > > } > Just before anything is returned to the browser, escaping happens: > > $title = esc_attr( strip_tags( $title ) ); > So no matter what any plugin does to your title in the form of HTML output, using the function the_title_attribute() for attributes will make sure that they are always stripped and displayed properly. Can you confirm and try this again? Thanks! > > — > Reply to this email directly or view it on GitHub.
Honkytonky commented 10 years ago

Philip,

okay, I rewinded everything and looked for the string in home_page.php again. It appears one time and I repasted title_attribute. You can have a look here. The subtitle span nevertheless is generated 2 times. I am on it again. Hard nut to crack. Now I am looking for an interfering function or something like this.

Michael

On Jun 14, 2014, at 10:29 PM, Philip Arthur Moore notifications@github.com wrote:

Hi Michael. I've just performed a test with the_title_attribute() and indeed, everything works as expected. Are you sure that changing <a title="<?php the_title(); ?>" to <a title="<?php the_title_attribute(); ?>" has no effect on your site? There is absolutely no way that any HTML markup or tags are allowed in the output of the_title_attribute(), as seen by the core function of WordPress itself:

function the_title_attribute( $args = '' ) { $defaults = array( 'before' => '', 'after' => '', 'echo' => true, 'post' => get_post() ); $r = wp_parse_args( $args, $defaults );

$title = get_the_title( $r['post'] );

if ( strlen( $title ) == 0 ) {
    return;
}

$title = $r['before'] . $title . $r['after'];
$title = esc_attr( strip_tags( $title ) );

if ( $r['echo'] ) {
    echo $title;
} else {
    return $title;
}

} Just before anything is returned to the browser, escaping happens:

$title = esc_attr( strip_tags( $title ) ); So no matter what any plugin does to your title in the form of HTML output, using the function the_title_attribute() for attributes will make sure that they are always stripped and displayed properly. Can you confirm and try this again? Thanks!

— Reply to this email directly or view it on GitHub.

philiparthurmoore commented 10 years ago

Hi Michael. I'm pretty sure that you'll also need to make this change in index.php, and anywhere in your theme where <a title="<?php the_title(); ?>" is used. I've done a quick search and it appears to be used in the following files:

  • home_page.php
  • index.php
  • portfolio.php
  • single_portfolio.php

Let me know how that goes.

Honkytonky commented 10 years ago

Hey Philip,

how are you this morning? We have had a hell of a thunderstorm and its raining like hell around here today :-). I had your idea yesterday night and went for it…though all functionality remains intact it does not change the faulty html. Though I rewinded everything and did it again. With the same result. I kept all the changes online in any case. I changed the given files

home_page.php index.php portfolio.php single_portfolio.php . That is kind of a strange thing. I was also wondering if this result is resulting from the fact that the theme gives the opportunity to enter an alternative site title. Unfortunately I am still not sure where to turn that off. This might bring some clarity if the wrong behavior really results from injecting your span or not. Strangely it happens only on an image post, not on a slider post or anything. I will look deeper into it today. Maybe I scan the files for more affected a-tags. But last night I found exactly those you have had mentioned earlier. This is fun, haha. Have a great day on the other half!

Michael

On Jun 15, 2014, at 6:39 AM, Philip Arthur Moore notifications@github.com wrote:

Hi Michael. I'm pretty sure that you'll also need to make this change in index.php, and anywhere in your theme where <a title="<?php the_title(); ?>" is used. I've done a quick search and it appears to be used in the following files:

home_page.php index.php portfolio.php single_portfolio.php Let me know how that goes.

— Reply to this email directly or view it on GitHub.

Honkytonky commented 10 years ago

Philip,

just to add something from yesterday night that I already forgot this morning: I was also thinking about getting rid of the light box feature in the blog overview - I thought because it obviously does not happen on the post itself, just on the overview - I get rid of the link inside the image div in blog overview and thats it - strangely this did not affect the output on blog overview page…this might also indicate that something is interfering. I then scanned the functions but there is also nothing related.

I also though it might be my browser cache. I then emptied the caches and tried it with FF, Chrome, Safari and Opera without any luck!

Greetz

Michael

On Jun 15, 2014, at 6:39 AM, Philip Arthur Moore notifications@github.com wrote:

Hi Michael. I'm pretty sure that you'll also need to make this change in index.php, and anywhere in your theme where <a title="<?php the_title(); ?>" is used. I've done a quick search and it appears to be used in the following files:

home_page.php index.php portfolio.php single_portfolio.php Let me know how that goes.

— Reply to this email directly or view it on GitHub.

philiparthurmoore commented 10 years ago

Hi Michael. Thanks for the updates. I think the only thing that I can say (after looking at the theme again) is that you will need to change this...

a href="<?php the_title(); ?>"

...everywhere that it occurs in the theme.

I just did another scan to make sure that I wasn't missing anything, and the only places those show up in the theme are as follows:

  • home_page.php
  • index.php
  • portfolio.php
  • single_portfolio.php

I'm almost 100% sure that if you change thoes files, everything will be fine. I'd also very much tell the theme developers that they need to change that immediately. Have you had any success since your last update?

Honkytonky commented 10 years ago

Philip,

thanks for getting back to me. I played around a lot. Unfortunately even after changing the term in all the four files I did not have success in eliminating the double output of the span. It keeps destroying me image div. Nevertheless when I come home today I will try another time changing all the terms but in the online version right now all the terms are changed already. Yesterday night I had to deactivate the plugin but my heart is still bleeding. is just what I need and its so good. I will keep looking and keep you up to date, I wal also thinking about deactivating the lightbox preview in my blog overview to see whether i can find a simple workaround. It also dies not work - its forsaken to some point :-)

Te mando saludos hacia Vietnam

Michael

On Jun 16, 2014, at 11:59 AM, Philip Arthur Moore notifications@github.com wrote:

Hi Michael. Thanks for the updates. I think the only thing that I can say (after looking at the theme again) is that you will need to change this...

a href="<?php the_title(); ?>" ...everywhere that it occurs in the theme.

I just did another scan to make sure that I wasn't missing anything, and the only places those show up in the theme are as follows:

home_page.php index.php portfolio.php single_portfolio.php I'm almost 100% sure that if you change thoes files, everything will be fine. I'd also very much tell the theme developers that they need to change that immediately. Have you had any success since your last update?

— Reply to this email directly or view it on GitHub.

philiparthurmoore commented 10 years ago

Thanks for the update Michael. If you want to email me privately at philip@pressbuild.com (don't reply to this message or it will be public), maybe I can take a quick look at your site and try to figure out what's going on when I have some free time later this upcoming weekend. :) I'll close this thread. Cheers.