Tag Info

Hot answers tagged

11

< and > are encoded as +ADw- and +AD4- in UTF-7. Now imagine the following: Someone sends +ADw-script+AD4-alert(+ACI-Hello+ACI-)+ADw-/script+AD4- as comment text. It will pass all validation unescaped. The database expects and treats all incoming data as UTF-8. Since all UTF-7 streams are valid UTF-8 too, this will never result in a SQL error, and ...


2

That conversion - among others - is caused by the wptexturize() filter being applied to the_content(). The sledge-hammer approach to preventing wp_texturize() being applied to the_content() is simply to remove the filter, like so: <?php remove_filter( 'the_content', 'wptexturize' ); ?>


2

first add this function to your functions.php file function max_title_length($title){ $max = 20; return substr( $title, 0, $max ). " &hellip;"; } then before the loop of the code you linked add this line to hook the above function: add_filter( 'the_title', 'max_title_length'); and after the loop remove this filter: remove_filter( ...


2

In the form you have posted this is more of PHP question - you could use strlen() functions to determine length of original title and apply ellipsis conditionally. However in WP context you should consider using wp_trim_words() since trimming based on words looks tidier and it will take care of appending string of your choice whet cutting.


1

You cannot change that value. The database schema is limited to 20 Bytes. See wp-admin/includes/schema.php: TABLE $wpdb->posts ( ID bigint(20) unsigned NOT NULL auto_increment, post_author bigint(20) unsigned NOT NULL default '0', post_date datetime NOT NULL default '0000-00-00 00:00:00', post_date_gmt datetime NOT NULL default '0000-00-00 ...


1

i used this code in one of my last projects: function ng_get_excerpt($count){ $permalink = get_permalink($post->ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, $count); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerpt = rtrim($excerpt,",.;:- _!$&#"); $excerpt = ...


1

Use the function utf8_truncate() from this answer and fight your way through wp_trim_excerpt(). Sample code, not tested: add_filter( 'excerpt_more', 'wpse_69436_excerpt_more' ); function wpse_69436_excerpt_more( $more ) { add_filter( 'wp_trim_excerpt', 'wpse_69436_trim_excerpt' ); // we remove the more text here return ''; } function ...


1

Quick and dirty, put this before your get_header() in your search.php <?php // Get the query string $query = get_search_query(); // if the first & last char is space, rip them $query = trim($query); // if there are more than one space, rip to one space $query = preg_replace('/\s\s+/', ' ',$query); // if chars count is less than 3, redirect them to ...


1

According to this page, you can use the tiny_mce_before_init filter, make sure the entity encoding is set to named, and then add whichever special characters you want to the entities array.


1

It appears that the site is still using the Unicode character set from the page header, but the database may have been corrupted. Ask Linode for a backup restore and/or if they changed anything with their MySQL servers. If you don't run your own regular database backups, you should. Try WordPress › WP-DB-Backup « WordPress Plugins. You can also use ...


1

If you run a wp_kses() on the_excerpt() (through a filter) you can whitelist specific HTML tags and such. In your case, the code would probably look something like this: if( is_page( 'your_page' ) ) { add_filter( 'the_excerpt', 'wpse44363_filter_the_excerpt' ); } function wpse44363_filter_the_excerpt( $excerpt ) { // this allows no html, you can ...


1

It's Wordpress. You could hack into wp-includes/formatting.php and comment out the contents of the sanitize_user() function. However, I don't think that's a good idea - it may compromize your site's security, and special characters can always cause trouble... And it's never a good idea to hack into the core (maybe you can do it also with remove_action() - ...


1

When one creates a WordPress site by default, or via the Fantastico tool in cPanel, it may create a blog with the Latin1 charset in the MySQL database. This causes Chinese characters (and other Unicode characters) to be switched into one or more ? question mark symbols, instead. The fix is to connect to your cPanel, connect to phpMyAdmin, find the WordPress ...


1

I know toscho doesn't like this very much, but anyway: Converted the input args to an array: function utf8_truncate( $args = array( 'string' => null, 'max_chars' => 200, 'append' => "\xC2\xA0…" ) ) { $args['string'] = strip_tags( $args['string'] ); $args['string'] = html_entity_decode( $args['string'], ENT_QUOTES, 'utf-8' ); // \xC2\xA0 ...



Only top voted, non community-wiki answers of a minimum length are eligible