[WP/PHP] 直前のURLを確認して、リンクURLを変更する

<?phpfunction oc_get_back_link() { global $post; $back_link_url = "javascript:history.back();"; // 直前のURLをチェック同一ドメインからの遷移ならhistory.back()を返す $h = $_SERVER['HTTP_HOST']; if ( !empty($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'],$h) !== false)) { return $back_link_url; } // 外部サイトからの遷移の場合は、トップページへのURLを返す $back_link_url = get_home_url(); return $back_link_url;}

[WP]qTranslate X Cleanup to single language

<?php// qTranslate X Cleanup to single language// 1: database backup [important!!!]// 2: settings -> language ->[Import/Export] -> [Convert database to the "square bracket only" style.]check -> SaveChanges// 3: this code paste to functions.php// 4: reload your site// 5: delete this code from functions.php// 6: Remove qTranslate pluginglobal $post;$language = 'en'; // Language you want to keep$args = array( 'post_type' => array('post','page'), // Change if necessary 'post_status' => array('publish','pending','draft','auto-draft','future','private','inherit','trash'), // Change if necessary 'posts_per_page' => 9999999, 'offset' => 0, 'orderby' => 'ID', 'order' => 'ASC', 'suppress_filters' => true, 's'=> '[:]');$posts_array = get_posts( $args );foreach ( $posts_array as $post ) : setup_postdata( $post ); $post->post_content = qtrans_use($language, $post->post_content,false); $post->post_title = qtrans_use($language, $post->post_title,false); wp_update_post($post); $count++;endforeach;wp_reset_postdata();