Ticket #28449: 28449-the_content-orphans-v2.patch
File 28449-the_content-orphans-v2.patch, 4.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/default-filters.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
95 95 add_filter( $filter, 'wptexturize' ); 96 96 add_filter( $filter, 'convert_chars' ); 97 97 add_filter( $filter, 'esc_html' ); 98 add_filter( $filter, 'prevent_orphans' ); 98 99 } 99 100 100 101 // Format WordPress … … 106 107 foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { 107 108 add_filter( $filter, 'wptexturize' ); 108 109 add_filter( $filter, 'strip_tags' ); 110 add_filter( $filter, 'prevent_orphans' ); 109 111 } 110 112 111 113 // Format text area for display. … … 114 116 add_filter( $filter, 'convert_chars' ); 115 117 add_filter( $filter, 'wpautop' ); 116 118 add_filter( $filter, 'shortcode_unautop'); 119 add_filter( $filter, 'prevent_orphans' ); 117 120 } 118 121 119 122 // Format for RSS … … 124 127 add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); 125 128 126 129 // Display filters 127 add_filter( 'the_title', 'wptexturize' ); 128 add_filter( 'the_title', 'convert_chars' ); 129 add_filter( 'the_title', 'trim' ); 130 add_filter( 'the_title', 'wptexturize' ); 131 add_filter( 'the_title', 'convert_chars' ); 132 add_filter( 'the_title', 'trim' ); 133 add_filter( 'the_title', 'prevent_orphans'); 130 134 131 135 add_filter( 'the_content', 'wptexturize' ); 132 136 add_filter( 'the_content', 'convert_smilies' ); … … 134 138 add_filter( 'the_content', 'wpautop' ); 135 139 add_filter( 'the_content', 'shortcode_unautop' ); 136 140 add_filter( 'the_content', 'prepend_attachment' ); 141 add_filter( 'the_content', 'prevent_orphans' ); 137 142 138 143 add_filter( 'the_excerpt', 'wptexturize' ); 139 144 add_filter( 'the_excerpt', 'convert_smilies' ); 140 145 add_filter( 'the_excerpt', 'convert_chars' ); 141 146 add_filter( 'the_excerpt', 'wpautop' ); 142 147 add_filter( 'the_excerpt', 'shortcode_unautop'); 148 add_filter( 'the_excerpt', 'prevent_orphans' ); 143 149 add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); 144 150 145 151 add_filter( 'comment_text', 'wptexturize' ); … … 148 154 add_filter( 'comment_text', 'force_balance_tags', 25 ); 149 155 add_filter( 'comment_text', 'convert_smilies', 20 ); 150 156 add_filter( 'comment_text', 'wpautop', 30 ); 157 add_filter( 'comment_text', 'prevent_orphans' ); 151 158 152 159 add_filter( 'comment_excerpt', 'convert_chars' ); 160 add_filter( 'comment_excerpt', 'prevent_orphans' ); 153 161 154 162 add_filter( 'list_cats', 'wptexturize' ); 155 163 -
src/wp-includes/formatting.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
533 533 } 534 534 535 535 /** 536 * Prevent orphan or widow words wrapping to new line 537 * @param $text 538 * @param $min Optional. Words to wrap. Default 2. 539 * @param $special Optional. Boolean to add all UNICODE expressions of space. Array to explicitly specify chars to split on. 540 * 541 * @return string 542 */ 543 function prevent_orphans($text,$min,$special) { 544 // if not specified, wrap 2 characters 545 if ( ! $min ) $min = 2; 546 // default = basic space, double space, en-space, em-space, mid-space, thin-space, ideographic space, horizontal tab, 547 $space = [' ',' '," "," "," "," "," "," "," "," "," "," ","	"]; 548 // if set but not explicitly specified.. add more special representations of space 549 if ( $special == true ) $special = [ " "," "," "," "," ","zwj","‌","‍","⁠","⁠","","","​","​",",",",","","","","","","­","­","͏","͏" ]; 550 551 /** @var array $chars */ 552 $chars = $special ? $chars . array_merge( $space, $special ) : $space; 553 554 $explode = str_replace($chars, $chars[0], $text); 555 $arr = explode($chars[0], $explode); 556 557 if(count($arr) >= $min) { 558 $arr[count($arr) - 2].= ' '.$arr[count($arr) - 1]; 559 array_pop($arr); 560 $text = implode(' ',$arr); 561 } 562 return $text; 563 } 564 565 /** 536 566 * Checks to see if a string is utf8 encoded. 537 567 * 538 568 * NOTE: This function checks for 5-Byte sequences, UTF8