|
@@ 145-174 (lines=30) @@
|
| 142 |
|
* @param bool $encode |
| 143 |
|
* @return string |
| 144 |
|
*/ |
| 145 |
|
public function _added( $lines, $encode = true ) { |
| 146 |
|
$r = ''; |
| 147 |
|
foreach ($lines as $line) { |
| 148 |
|
if ( $encode ) { |
| 149 |
|
$processed_line = htmlspecialchars( $line ); |
| 150 |
|
|
| 151 |
|
/** |
| 152 |
|
* Contextually filters a diffed line. |
| 153 |
|
* |
| 154 |
|
* Filters TextDiff processing of diffed line. By default, diffs are processed with |
| 155 |
|
* htmlspecialchars. Use this filter to remove or change the processing. Passes a context |
| 156 |
|
* indicating if the line is added, deleted or unchanged. |
| 157 |
|
* |
| 158 |
|
* @since 4.1.0 |
| 159 |
|
* |
| 160 |
|
* @param String $processed_line The processed diffed line. |
| 161 |
|
* @param String $line The unprocessed diffed line. |
| 162 |
|
* @param string null The line context. Values are 'added', 'deleted' or 'unchanged'. |
| 163 |
|
*/ |
| 164 |
|
$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'added' ); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
if ( $this->_show_split_view ) { |
| 168 |
|
$r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; |
| 169 |
|
} else { |
| 170 |
|
$r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n"; |
| 171 |
|
} |
| 172 |
|
} |
| 173 |
|
return $r; |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
/** |
| 177 |
|
* @ignore |
|
@@ 184-201 (lines=18) @@
|
| 181 |
|
* @param bool $encode |
| 182 |
|
* @return string |
| 183 |
|
*/ |
| 184 |
|
public function _deleted( $lines, $encode = true ) { |
| 185 |
|
$r = ''; |
| 186 |
|
foreach ($lines as $line) { |
| 187 |
|
if ( $encode ) { |
| 188 |
|
$processed_line = htmlspecialchars( $line ); |
| 189 |
|
|
| 190 |
|
/** This filter is documented in wp-includes/wp-diff.php */ |
| 191 |
|
$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'deleted' ); |
| 192 |
|
} |
| 193 |
|
if ( $this->_show_split_view ) { |
| 194 |
|
$r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n"; |
| 195 |
|
} else { |
| 196 |
|
$r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n"; |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
} |
| 200 |
|
return $r; |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
/** |
| 204 |
|
* @ignore |
|
@@ 211-227 (lines=17) @@
|
| 208 |
|
* @param bool $encode |
| 209 |
|
* @return string |
| 210 |
|
*/ |
| 211 |
|
public function _context( $lines, $encode = true ) { |
| 212 |
|
$r = ''; |
| 213 |
|
foreach ($lines as $line) { |
| 214 |
|
if ( $encode ) { |
| 215 |
|
$processed_line = htmlspecialchars( $line ); |
| 216 |
|
|
| 217 |
|
/** This filter is documented in wp-includes/wp-diff.php */ |
| 218 |
|
$line = apply_filters( 'process_text_diff_html', $processed_line, $line, 'unchanged' ); |
| 219 |
|
} |
| 220 |
|
if ( $this->_show_split_view ) { |
| 221 |
|
$r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line ) . "</tr>\n"; |
| 222 |
|
} else { |
| 223 |
|
$r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n"; |
| 224 |
|
} |
| 225 |
|
} |
| 226 |
|
return $r; |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
/** |
| 230 |
|
* Process changed lines to do word-by-word diffs for extra highlighting. |