• Resolved doublesharp

    (@doublesharp)


    I am trying to hide the title from the generated PDF but am not able to do this with 1.0.5 as it calls:

    $pdf->SetTitle( $post->post_title );

    If this were passed through ‘the_title’ filter then it would get the correct title formatting if it is altered by a plugin, and also allows the value to be intercepted and removed if necessary (like in case).

    $pdf->SetTitle( apply_filters( 'the_title', $post->post_title ) );

    https://www.ads-software.com/plugins/wp-post-to-pdf-enhanced/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Lewis Rosenthal

    (@lewisr)

    Thanks so much for this great tip!

    Included in 1.1.0, and attribution added to readme. ??

    Lewis

    Thread Starter doublesharp

    (@doublesharp)

    Awesome, thanks!

    To step it up a bit more… the title is being used in the PDF itself and not just the metadata inside an H1 tag. It would be great to both run this through the the_title filter as well, but also include a new filter specific to this plugin that would let it be further modified/hidden – I have some PDF’s where we specifically don’t want the title to be displayed.

    In the version 1.1.1 on line 371 it currently reads:

    $html .= '<h1>' . html_entity_decode( $post->post_title, ENT_QUOTES ) . '</h1>';

    It would be awesome to have this look like the following:

    $html .= apply_filters( 'wp_pdf_page_title', '<h1>' . html_entity_decode( apply_filters( 'the_title', $post->post_title ), ENT_QUOTES ) . '</h1>' );

    This would allow the wp_pdf_page_title filter to be intercepted and removed, changed, etc. Could also just be around the “the_title” filters, and then a conditional check to apply the <H1> if the title isn’t empty.

    Thanks!

    Plugin Author Lewis Rosenthal

    (@lewisr)

    Excellent point.

    Pull wp-post-to-pdf-enhanced.php from svn. I’ve just pushed version 1.1.2b20150427 of the file with changeset 1147520.

    Please test, and let me know. I’m working on some other things which aren’t quite ready to go, yet, but I don’t think I have anything in that build which should break functionality by just overlaying the 1.1.1 version with that one.

    Thanks so much for the great suggestions. Geez, any more code snippets and I’ll have to add you as a contributor!! Then the trouble really starts. ??

    Cheers

    Lewis

    Thread Starter doublesharp

    (@doublesharp)

    Ha. Not sure if that’s necessary, but now that I know that might be an option/your responsiveness I’m pretty sure I can think of more tweaks :P. One thing that I added on my site was an action hook for save_post and then deleted the PDF cache. I’ll post the code in another topic.

    Jokes aside I usually know what I’m doing WordPress-wise if you would like me to help contribute (though I don’t always have a ton of free time). Check out this add-on plugin I wrote for Advanced Custom Fields: https://www.ads-software.com/plugins/validated-field-for-acf/

    The change is working great for my purposes, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filter Title through 'the_title'’ is closed to new replies.