• Resolved Julianwave

    (@julianwave)


    Hi

    I have pasted the code you suggested:

    $typo = WP_Typography::get_instance();
    add_filter('acf_the_content', array( $typo, 'process' ) );

    into functions.php in the hope of activating the typography plugin for ACF fields.

    It seems to recognise it, all my quotemarks are converted to proper curly quotes for example. However, widow control seems a bit hit and miss. It seems to work in some places, not in others.

    Is this to be expected? Is there anything I can do about it?

    Thanks

    https://www.ads-software.com/plugins/wp-typography/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author pepe

    (@pputzer)

    This only happens with ACF fields? Or for all content? Have you got a specific example for me (i.e. content source, intended result and actual result)?

    Thread Starter Julianwave

    (@julianwave)

    Thanks for the quick reply. My site is only on mamp at the moment so I have nothing I can share. Basically I have 4 acf wysiwyg fields on a page. for 2 of them the widow control seems to be working, for the other 2 it seems to have no effect. It seems to be something to do with either the html or the css, because the 2 that work have a different layout and css to the 2 that don’t. When I get it online I will share it so you can see. I am trying out using acf for most of the layout, including the main content, so it is acf fields specifically I am referring to.

    Plugin Author pepe

    (@pputzer)

    You could post content source snippets here. Not sure about widows per se, but you have to ensure that your theme does not set hyphens: auto; if you want to use wp-Typography’s hyphenation settings.

    Thread Starter Julianwave

    (@julianwave)

    Quick update – I have had another problem. With wp typography enabled, and the code…

    $typo = WP_Typography::get_instance();
    add_filter(‘acf_the_content’, array( $typo, ‘process’ ) );`

    …added to functions php as recommended, I found captions to images stopped appearing.

    When I looked closer, captioned images added with the acf wysiwyg were no longer wrapped in a figure tag as they should be.

    I was also getting a “white screen of death” problem when I tried to deactivate the plugin. Eventually, removing the plugin from the plugins folder manually, and deleting the code from functions php fixed that.

    As I use a lot of acf, I think I had better keep wp typography turned off for now.

    It’s a great idea, I hope you continue to develop and improve it.

    Plugin Author pepe

    (@pputzer)

    Sure, if your functions.php calls WP_Typography::get_instance() when the plugin is not activated, you will get a white screen. You have to wrap your code with something like if ( class_exists( 'WP_Typography' ) ) { ... } to prevent that. (That goes for all custom plugin functions you access in your theme’s functions.php – always check if they are available first!)

    As for the problem with figure: Do you have an example for me? I don’t see how wp-Typography would interact with figures at all.

    PS: What version of WP_Typography are you using? The filter might be applied twice because recent versions already add it automatically for wysiwyg type fields.

    Thread Starter Julianwave

    (@julianwave)

    As I have disabled the plugin I can not show you a real example, especially as the site is not live. However I can tell you as closely as possible what seems to have happened, as far as the captions are concerned.

    I will go through it methodically.

    I have some acf wysiwyg fields.

    If I add content to them, including images with captions, and with wp typography turned off, the images and captions appear as they should, wrapped in figure tags. eg

    <p><figure id="attachment_78" class="wp-caption alignright fig-right" style="width: 1701px">
    <div class="wpa-ld img-right wp-image-78 size-full">
    <img id="longdesc-return-78" class=

    etc.

    However, with wp typography turned on, the images appear, but without captions, and not wrapped in figure tags, eg

    <p><div class="wpa-ld img-right alignright wp-image-78 size-full">
    <img id="longdesc-return-78" class=

    etc.

    I realise that the whole thing should not really be inside a p tag, however WordPress seems to be doing this by default. COuld that have something to do with it?

    Plugin Author pepe

    (@pputzer)

    That’s content inside a wysiwyg field? The <p> is probably a remnant of WordPress’ wpautop filter and should not be a problem. It looks like the <figure> tag was somehow removed. If wp-Typography’s filter is applied twice, that might be a symptom (it should not be be, but there is an HTML parser involved, which might skip the tag if the parser thought it was invalid).

    Could you try re-enabling wp-Typography 3.4.0, but disabling the extra code in your functions.php?

    Thread Starter Julianwave

    (@julianwave)

    I have made sure the unwanted p tags are removed, and reenabled wp typography, but still get the same problem.

    Which extra code in functions.php should be disabled?

    Plugin Author pepe

    (@pputzer)

    The line with add_filter('acf_the_content', array( $typo, 'process' ) );

    Thread Starter Julianwave

    (@julianwave)

    If I do that, the captions etc reappear, but presumably wp typography is no longer doing anything at all to any of the acf content?

    Plugin Author pepe

    (@pputzer)

    No, it is since 3.4.0. See https://github.com/mundschenk-at/wp-typography/blob/master/includes/class-wp-typography.php#L251 in the source. You can test this easily by adding an acronym somewhere in the caption and setting the option to add CSS classes for it in wp-Typography’s settings.

    Thread Starter Julianwave

    (@julianwave)

    If I remove the “add_filter” code then my acronym does not get the “caps” class. However if I re add the “add_filter” code then it does get the “aps” class added. However it is then that the captions disappear etc.

    Plugin Author pepe

    (@pputzer)

    Which version of ACF are you using?

    Thread Starter Julianwave

    (@julianwave)

    I’m using the latest version of everything.

    Plugin Author pepe

    (@pputzer)

    Well yes, but is that the free or the pro version?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘partial widow control’ is closed to new replies.