bb_convert_chars

Converts a number of characters from a string.

Description

(string) bb_convert_chars( (string) $content ); 

Metadata tags <> and <<category>> are removed, <<br>> and <<hr>> are converted into correct XHTML and Unicode characters are converted to the valid range.</p> </section> <section id="returns"><h2>Returns <span class="count">(string)</span></h2><p>Converted string.</p> </section> <section id="params"><h2>Parameters <span class="count">(1)</span></h2><dl><dt> <span class="index">0.</span> <span class="param"> $content </span> <span class="type">(string)</span></dt><dd> String of characters to be converted.</dd></dl> </section><hr /> <section id="usage"><h2>Usage</h2><pre><ol><li><div>if ( !function_exists( '<span class="func">bb_convert_chars</span>' ) ) { </div></li><li><div> require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-formatting.php'; </div></li><li><div>} </div></li><li><div>  </div></li><li><div><span class="comment">// String of characters to be converted.</span> </div></li><li><div><span class="param">$content</span> = ''; </div></li><li><div>  </div></li><li><div><span class="comment">// NOTICE! Understand what this does before running.</span> </div></li><li><div><span class="param">$result</span> = <span class="func">bb_convert_chars</span>(<span class="param">$content</span>); </div></li><li><div>  </div></li></ol></pre></section><hr /> <section id="defined" class="source"><h2>Defined <span class="count">(1)</span></h2><p>The function is defined in the following location(s).</p><dl><dt><strong><a href="http://hookr.io/plugins/buddypress/2.8.2/files/bp-forums-bbpress-bb-includes-functions-bb-formatting/" class="file">/bp-forums/bbpress/bb-includes/functions.bb-formatting.php <span> </span></a></strong></dt><dd><pre><ol data-line="26" class="block" start="353"><li><div>function bb_convert_chars( $content ) { </div></li><li><div> // Translation of invalid Unicode references range to valid range </div></li><li><div> $wp_htmltranswinuni = array( </div></li><li><div> '€' => '€', // the Euro sign </div></li><li><div> '' => '',  </div></li><li><div> '‚' => '‚', // these are Windows CP1252 specific characters </div></li><li><div> 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers </div></li><li><div> '„' => '„',  </div></li><li><div> '…' => '…',  </div></li><li><div> '†' => '†',  </div></li><li><div> '‡' => '‡',  </div></li><li><div> 'ˆ' => 'ˆ',  </div></li><li><div> '‰' => '‰',  </div></li><li><div> 'Š' => 'Š',  </div></li><li><div> '‹' => '‹',  </div></li><li><div> 'Œ' => 'Œ',  </div></li><li><div> '' => '',  </div></li><li><div> 'Ž' => 'ž',  </div></li><li><div> '' => '',  </div></li><li><div> '' => '',  </div></li><li><div> '‘' => '‘',  </div></li><li><div> '’' => '’',  </div></li><li><div> '“' => '“',  </div></li><li><div> '”' => '”',  </div></li><li><div> '•' => '•',  </div></li><li><div> '–' => '–',  </div></li><li><div> '—' => '—',  </div></li><li><div> '˜' => '˜',  </div></li><li><div> '™' => '™',  </div></li><li><div> 'š' => 'š',  </div></li><li><div> '›' => '›',  </div></li><li><div> 'œ' => 'œ',  </div></li><li><div> '' => '',  </div></li><li><div> 'ž' => '',  </div></li><li><div> 'Ÿ' => 'Ÿ' </div></li><li><div> ); </div></li><li><div> </div></li><li><div> // Remove metadata tags </div></li><li><div> $content = preg_replace( '/<title>(.+?)<\/title>/', '', $content ); </div></li><li><div> $content = preg_replace( '/<category>(.+?)<\/category>/', '', $content ); </div></li><li><div> </div></li><li><div> // Converts lone & characters into & (a.k.a. &) </div></li><li><div> $content = preg_replace( '/&([^#])(?![a-z1-4]{1, 8};)/i', '&$1', $content ); </div></li><li><div> </div></li><li><div> // Fix Word pasting </div></li><li><div> $content = strtr( $content, $wp_htmltranswinuni ); </div></li><li><div> </div></li><li><div> // Just a little XHTML help </div></li><li><div> $content = str_replace( '<br>', '<br />', $content ); </div></li><li><div> $content = str_replace( '<hr>', '<hr />', $content ); </div></li><li><div> </div></li><li><div> return $content; </div></li><li><div>} </div></li></ol></pre></dd></dl> </section> </article></div><div id="sidebar"><ul class="widgets"><li> <a href="http://hookr.io/plugin/"><img src="http://hookr.io/wp-content/themes/hookr/assets/images/plugin-download.jpg" /></a></li><li id="versions"><dl><dt>Version(s)</dt><dd><dl><dt>Since</dt><dd> 2.7.4</dd><dt>Others</dt><dd><ul><li><a href="http://hookr.io/plugins/buddypress/2.8.2/functions/bb_convert_chars/" class="active">2.8.2</a></li><li><a href="http://hookr.io/plugins/buddypress/2.8.1/functions/bb_convert_chars/" class="">2.8.1</a></li><li><a href="http://hookr.io/plugins/buddypress/2.8.0/functions/bb_convert_chars/" class="">2.8.0</a></li><li><a href="http://hookr.io/plugins/buddypress/2.7.5/functions/bb_convert_chars/" class="">2.7.5</a></li><li><a href="http://hookr.io/plugins/buddypress/2.7.4/functions/bb_convert_chars/" class="">2.7.4</a></li></ul></dd></dl></dd></dl></li><li id="tags"><dl><dt>Tags</dt><dd><ul><li><span></span>plugin</li><li><span></span>function</li><li><span></span>bb_convert_chars</li><li><span></span>BuddyPress</li><li><span></span>2.8.2</li></ul></dd></dl></li></ul></div></div></div><script>Hookr.View.init();Hookr.Single.init();</script><footer><div><ul id="nav-social" class="pivot" role="navigation"><li id="twitter"><a href="http://twitter.com/hookr_io" title="Follow me!"></a></li></ul><div> © 2018 hookr.io <strong>(beta)</strong> | <a href="http://hookr.io/privacy/" title="Privacy">Privacy</a> | Proudly Powered by WordPress</div></div> </footer><script type="text/javascript" src="http://hookr.io/wp-content/cache/minify/000000/M9EvL9BNzU1KTdHLzcwDAA.js"></script><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create','UA-49583310-1','hookr.io');ga('send','pageview');</script></body></html>