- ステータス
- 未解決
- 関連するプラグイン/テーマ
- Header Footer Code Manager
- トピックタグ
- Compatibility
問題の概要
Header Footer Code Managerプラグインを使用して特定のページにスニペットを挿入する場合、WPMLを使用していると翻訳されたページに表示条件が正しく適用されません。その結果、翻訳されたページでスニペットが欠落します。
回避策
続行する前に、必ずサイトの完全なバックアップを取得してください。
- …/wp-content/plugins/header-footer-code-manager/99robots-header-footer-code-manager.phpファイルを開きます。
- 550行目を探します。
- 変更前:
case 's_pages': $is_not_empty_s_pages = self::hfcm_not_empty( $scriptdata, 's_pages' ); if ( $is_not_empty_s_pages ) { // Gets the page ID of the blog page $blog_page = get_option( 'page_for_posts' ); // Checks if the blog page is present in the array of selected pages if ( in_array( $blog_page, json_decode( $scriptdata->s_pages ) ) ) { if ( is_page( json_decode( $scriptdata->s_pages ) ) || (!is_front_page() && is_home()) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } elseif ( is_page( json_decode( $scriptdata->s_pages ) ) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } break;
- 変更後:
case 's_pages': $is_not_empty_s_pages = self::hfcm_not_empty( $scriptdata, 's_pages' ); if ( $is_not_empty_s_pages ) { // WPML workaround for compsupp-7802 $original_ids = json_decode( $scriptdata->s_pages); foreach ( $original_ids as $original_id ) { $translated_ids[] = apply_filters( 'wpml_object_id', $original_id, 'page'); } // Gets the page ID of the blog page $blog_page = get_option( 'page_for_posts' ); // Checks if the blog page is present in the array of selected pages if ( in_array( $blog_page, json_decode( $scriptdata->s_pages ) ) ) { if ( is_page( $translated_ids ) || (!is_front_page() && is_home()) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } elseif ( is_page( $translated_ids ) ) { $out = self::hfcm_render_snippet( $scriptdata ); } } break;