Title: Cannot process strings programmatically&#8230;?
Last modified: February 14, 2022

---

# Cannot process strings programmatically…?

 *  Resolved [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
 * (@leanderbraunschweig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/)
 * Hi there,
 * first of all: What a great plugin, many many thanks for creating and maintaining
   it!
 * I encountered an issue where I could use some advice…
 * I am trying to filter / process a string in order to add hyphenation but cannot
   get it to work. I double-checked already that a) no other filtering is happening
   which could remove the `&shy;`-tags and b) that the function calls are working
   fine and c) the user settings are correctly set.
 * So essentially this is my demo code:
 *     ```
       if(class_exists('WP_Typography')) {
         $s = \WP_Typography::get_user_settings();
         $title_with_big_words = 'Bei Profis und Amateuren gleichermaßen beliebtes Leinenschläppchen mit geteilter Sohle';
         $hyphenated_title = \WP_Typography::process_title($title_with_big_words, $s);
         echo $hyphenated_title;
       }
       ```
   
 * And this is what I am getting:
 * `Bei Profis und Amateuren gleichermaßen beliebtes Leinenschläppchen mit geteilter
   Sohle`
 * But I would expect to see:
 * `Bei Pro&shy;fis und Ama&shy;teu&shy;ren glei&shy;cher&shy;ma&shy;ßen belieb&
   shy;tes Lei&shy;nen&shy;schläpp&shy;chen mit geteil&shy;ter Soh&shy;le`
 * What could be the culprit here?
 * I can var_dump the settings object just fine and wp-typogrophy definitely works
   because the content filtering is happening and I am seeing the `&shy;`-tags there
   just fine.
 * Using WP 5.9 with the latest plugin version.
 * Thanks for any help regarding further debugging this!
    -  This topic was modified 4 years, 1 month ago by [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/).

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15365133)
 * Can you post the settings dump (JSON would be best)? You have probably disabled
   hyphenation for titles.
 *  Thread Starter [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
 * (@leanderbraunschweig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15366019)
 * Hi [@pputzer](https://wordpress.org/support/users/pputzer/),
 * you are right – title hyphenation was unchecked / disabled and thus the `WP_Typography::
   process_title`-function couldn’t work…
 * But deviating from the code I have posted above I am actually using `WP_Typography::
   process` in order to hyphenate my string and that doesn’t work as well despite
   not falling under said setting. Obviously the title-setting overwrites any hyphenation-
   processing?
 * Guess we would like to not have the titles be hyphenated and still programmatically
   process strings – how would that be possible?
 * Thanks & regards!
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15369146)
 * Please post your settings array and your updated `WP_Typography::process` line(
   including the exact HTML fragment). The interplay between settings and what is
   considered a title for hyphenation purposes is a bit complex.
 *  Thread Starter [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
 * (@leanderbraunschweig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15370253)
 * Hi [@pputzer](https://wordpress.org/support/users/pputzer/),
 * sure thing:
 * **Settings output**
 * [See this gist](https://gist.github.com/E-VANCE/24404a5fdf133b5ebb0a0b34056bb12d)
 * **Filter / code used**
 *     ```
       // Add product sublines (via ACF)
       add_action('woocommerce_after_shop_loop_item_title', function() {
         $tagline = get_field('tagline');
   
         if(class_exists('WP_Typography')) {
           $s = \WP_Typography::get_user_settings();
           $tagline = \WP_Typography::process($tagline, $s);
         }
   
         echo '<p class="tagline">' . $tagline . '</p>';
       }, 9);
       ```
   
 * Besides the action hook I also tested directly in the template, thus the usage
   of a filter / hook or not doesn’t make a difference with regards to the missing
   hyphenation here…
 * I can also send you the link to our development environment where you can view
   the output directly if that is helpful.
 * Thanks so much for looking into this!
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15373225)
 * [@leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
   what does `$tagline` contain exactly?
 * (BTW, when you don’t change the settings as defined in the plugin options, you
   can omit the parameter, no need to copy the object.)
 *  Thread Starter [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
 * (@leanderbraunschweig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15378281)
 * Hi [@pputzer](https://wordpress.org/support/users/pputzer/),
 * > What does $tagline contain exactly?
 * Just a regular string… It works fine when activating the “hyphenate titles” option.
   And I tried with said string _“Bei Profis und Amateuren gleichermaßen beliebtes
   Leinenschläppchen mit geteilter Sohle”_ directly to go around any possible issues
   with input or filters and could reproduce the behaviour.
 * Did you test on your end yet? Should be easily reproducible – at least that’s
   my guess.
 * > (BTW, when you don’t change the settings as defined in the plugin options, 
   > you can omit the parameter, no need to copy the object.)
 * Makes sense 🙂 Thanks for pointing it out!
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15384803)
 * Ah, I meant which string is contained in `$tagline` (including any markup).
 *  Thread Starter [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
 * (@leanderbraunschweig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15412029)
 * [@pputzer](https://wordpress.org/support/users/pputzer/)
 * No markup, just a string like
 * > Wildleder-Tanzschuh, kleiner Absatz
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15412424)
 * Weird then. I’ll have to look more closely at this.
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15431649)
 * Hi [@leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/),
   I overlooked something previously: In your snippet, you call `::process` with
   the same parameters as `::process_title`. However, it has a different signature(
   some additional boolean parameters in between `$text` and `$settings`). The first
   of these is the `$is_title` parameter. The settings object evaluates to `true`
   in a boolean context, so you are basically using `process_title` by accident.
 *  Thread Starter [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/)
 * (@leanderbraunschweig)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15434682)
 * Ah, gotcha – that makes sense then…
 * I followed [your documentation](https://code.mundschenk.at/wp-typography/api/)
   and there it doesn’t mention the `$is_title` parameter. I could / should have
   checked the source I guess 😐
 * Anyhow, thanks for getting back and I’ll adjust the code accordingly.
    -  This reply was modified 4 years, 1 month ago by [leanderbraunschweig](https://wordpress.org/support/users/leanderbraunschweig/).
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15435683)
 * Thanks, I’ve fixed this documentation bug. Looks like all the parameter sections
   were copy-pasta. I’ll have to look into autogenerating the API documentation 
   again (was not easy to set up a nice theme last time, so I dropped it).

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Cannot process strings programmatically…?’ is closed to new replies.

 * ![](https://ps.w.org/wp-typography/assets/icon.svg?rev=2663995)
 * [wp-Typography](https://wordpress.org/plugins/wp-typography/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-typography/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-typography/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-typography/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-typography/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-typography/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [pepe](https://wordpress.org/support/users/pputzer/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/cannot-process-strings-programmatically/#post-15435683)
 * Status: resolved