partial widow control
-
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
-
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)?
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.
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.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.
Sure, if your
functions.phpcallsWP_Typography::get_instance()when the plugin is not activated, you will get a white screen. You have to wrap your code with something likeif ( class_exists( 'WP_Typography' ) ) { ... }to prevent that. (That goes for all custom plugin functions you access in your theme’sfunctions.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
wysiwygtype fields.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?
That’s content inside a
wysiwygfield? The<p>is probably a remnant of WordPress’wpautopfilter 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?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?
The line with
add_filter('acf_the_content', array( $typo, 'process' ) );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?
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.
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.
Which version of ACF are you using?
I’m using the latest version of everything.
Well yes, but is that the free or the pro version?
The topic ‘partial widow control’ is closed to new replies.