Voici la partie Mysql:
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' .', '.') WHERE post_title LIKE '% .%'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' ,', ',') WHERE post_title LIKE '% ,%'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' :', ' :') WHERE post_title LIKE '% :%'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' ;', ' ;') WHERE post_title LIKE '% ;%'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' !', ' !') WHERE post_title LIKE '% !%'
UPDATE X87fsk987_posts SET post_title = RE??PLACE (post_title, ' ?', ' ?') WHERE post_title LIKE '% ?%'???
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, '« ', '« ') WHERE post_title LIKE '%« %'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' »', ' »') WHERE post_title LIKE '% »%'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, '( ', '(') WHERE post_title LIKE '%( %'
UPDATE X87fsk987_posts SET post_title = REPLACE (post_title, ' )', ')') WHERE post_title LIKE '% )%'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' .', '.') WHERE post_content LIKE '% .%'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' ,', ',') WHERE post_content LIKE '% ,%'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' :', ' :') WHERE post_content LIKE '% :%'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' ;', ' ;') WHERE post_content LIKE '% ;%'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' !', ' !') WHERE post_content LIKE '% !%'
UPDATE X87fsk987_posts SET post_content = RE??PLACE (post_content, ' ?', ' ?') WHERE post_content LIKE '% ?%'???
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, '« ', '« ') WHERE post_content LIKE '%« %'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' »', ' »') WHERE post_content LIKE '% »%'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, '( ', '(') WHERE post_content LIKE '%( %'
UPDATE X87fsk987_posts SET post_content = REPLACE (post_content, ' )', ')') WHERE post_content LIKE '% )%'
Plus la partie PHP pour Wp
function correction_french_rule($post_id, $text) {
$bad_rule = array(" .", " ,", " :", " ;", " !", " ?", "« ", " »", "( ", " )", "test");
$good_rule = array(".", ",", " :", " ;", " !", " ?", "« ", " »", "(", ")", "corrigé");
$text_ruled = str_replace($bad_rule, $good_rule, $text);
return $text_ruled;
}
function corriger_with_french_rule($post_id) {
$my_postid = $post_id;
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$my_post = array(
'ID' => $post_id,
'post_title' => correction_french_rule($post_id,get_the_title( $post_id )),
'post_content' => correction_french_rule($post_id, $content ),
);
// Un-hook this function to avoid infinite loop
remove_action( 'edit_post', 'corriger_with_french_rule' );
// Update the post into the database
wp_update_post( $my_post );
// re-hook this function
add_action( 'edit_post', 'corriger_with_french_rule' );
}
add_filter('edit_post', 'corriger_with_french_rule');
Modifié par gotcha5832 (23 Oct 2015 - 16:19)