Title: post2pdfのプラグインのconfig.inc.phpの修正方法
Last modified: 2009年11月9日

---

# post2pdfのプラグインのconfig.inc.phpの修正方法

 *  [wpbeg](https://ja.wordpress.org/support/users/wpbeg/)
 * (@wpbeg)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/)
 * いつも拝見させていただいております。
 * 投稿記事部分だけpdfで出力したくてpost2pdfというプラグインを発見したので
    インストール
   はしたのですが、config.inc.phpの中の設定がよくわからなくて、 いろいろ探しました
   が、見つけられなかったので教えていただけないでしょうか？
 * ＜原文＞
    <?php /* Default action once the plugin was activated: 1 to enable 
   automatic exportation for all posts except those with the exclude tag 0 to disable
   it and let export only post with the export tag placed inside */
 * $default_post_action = 1;
 * /*
    Enable or disable category exportation 0 to disable 1 to enable */
 * $export_category = 1;
 * $exclude_tag = “<!–post2pdf_exclude–>”;
    $export_tag = “<!–post2pdf_export–>”;
   $html_text = “convert this post to pdf.”; $html_post_code = “<span class=\”post2pdf_span\”
   style=\”border: 1px solid gray; width: 160px; text-align: left; \”><img src=\”##
   SITEURL##/wp-content/plugins/post2pdf/icon/pdf.png\” width=\”16px\” height=\”
   16px\” />”.$html_text.”</span>”; $html_category_code = ” [(<img src=’##SITEURL##/wp-content/plugins/post2pdf/icon/pdf.png’ width=’10px’ height=’10px’/>)](https://ja.wordpress.org/support/topic/post2pdf%E3%81%AE%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%81%AEconfigincphp%E3%81%AE%E4%BF%AE%E6%AD%A3%E6%96%B9%E6%B3%95/?output_format=md##SITEURL##/wp-content/plugins/post2pdf/generate.php?category=##CATEGORYID##&name=##CATEGORYNAME##)“;?
   >
 * を自分用に変更
    ＜変更部分＞ ##SITEURL## の部分を　http://www.xxxxxxx.com に変更##
   CATEGORYNAME## の部分を カテゴリ名に変更
 * ##GLOBALID## の部分がどう変更していいのか不明
 * この修正で、##SITEURL## と ##CATEGORYNAME##　の修正は正しいのでしょうか？
    また、##
   GLOBALID## は何に変更すればよろしいのでしょうか？

6件の返信を表示中 - 1 - 6件目 (全6件中)

 *  トピック投稿者 [wpbeg](https://ja.wordpress.org/support/users/wpbeg/)
 * (@wpbeg)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122097)
 * 失礼しました。原文部分がちゃんと書けていなかったようです。
 * ＜原文＞
 *     ```
       $html_post_code = "<span class=\"post2pdf_span\" style=\"border: 1px solid gray; width: 160px; text-align: left; \"><a href=\"##SITEURL##/wp-content/plugins/post2pdf/generate.php?post=##GLOBALID##\" rel=\"nofollow\"><img src=\"##SITEURL##/wp-content/plugins/post2pdf/icon/pdf.png\" width=\"16px\" height=\"16px\" />".$html_text."</a></span>";
       $html_category_code = "&nbsp;<a href='##SITEURL##/wp-content/plugins/post2pdf/generate.php?category=##CATEGORYID##&name=##CATEGORYNAME##' rel='nofollow' title='Export category ##CATEGORYNAME## as pdf'>(<img src='##SITEURL##/wp-content/plugins/post2pdf/icon/pdf.png' width='10px' height='10px'/>)</a>";
       ```
   
 *  [shokun0803](https://ja.wordpress.org/support/users/shokun0803/)
 * (@shokun0803)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122101)
 * ソースを見るとどうやらpost2pdf.phpの中で書き換えているようなんですよね。
 *     ```
       $siteurl = get_option("siteurl");
              $id = $wp_query->post->ID;
              $temp = eregi_replace("##SITEURL##",$siteurl, $html_post_code);
              $temp = eregi_replace("##GLOBALID##",$id ,$temp);
       ```
   
 * つまりconfig.inc.phpの$html_post_codeなどはclass指定などを変更したいなどの理由
   がなければ特に書き換える必用はないと。思うんですけど、ID拾ってこないですね(汗)
   ##
   SITEURL##は拾ってきているようですが・・・
 * まあ、いづれにしても日本語はだめですね。過去のフォーラムにもありました、解決し
   ていませんけど。
 *  [shokun0803](https://ja.wordpress.org/support/users/shokun0803/)
 * (@shokun0803)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122102)
 * ちょっと追記です。windowsのテスト環境で行っているので違うサーバーでも同じか保証
   はありません。
 * post2pdf.phpのeregi_replaceが置換するときの変数の中身の状態によって置換に失敗
   しているようです。
    `$id = 1`だと失敗しますが、`$id = "1"`だと成功します。 これ
   を踏まえて`$id = $wp_query->post->ID;`のあとに`$id .= "";`と追記してみると置換
   がうまく行えました。 これは数値を文字コードとして解釈されているためですが、そもそも
   php5.3で非推奨となっているようなので、preg_replaceに置き換えてみました。
 *     ```
       $temp = preg_replace("/##SITEURL##/",$siteurl, $html_post_code);
              $temp = preg_replace("/##GLOBALID##/",$id ,$temp);
       ```
   
 * 一応動きますが、相変わらず日本語はだめです;)
 *  トピック投稿者 [wpbeg](https://ja.wordpress.org/support/users/wpbeg/)
 * (@wpbeg)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122109)
 * shokun0803様
 * 貴重なアドバイスありがとうございました。
    エラーがなくできたのですが、投稿記事
   の内容（gallery=1 とhtmlで書いた表）が galleryで設定してある画像の表示ができなか
   った、表が崩れてしまっていた。 と、なっておりました。（せっかくアドバイスいただ
   いたのに）
 * 行ってみた修正点は・・・
    ・$id = $wp_query->post->ID;のあとに$id .= “”;と追記・
   preg_replaceに置き換え
 * 私のｺｰﾃﾞｨﾝｸﾞﾐｽなのでしょうか。
 *  [shokun0803](https://ja.wordpress.org/support/users/shokun0803/)
 * (@shokun0803)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122110)
 * > 行ってみた修正点は・・・
   >  ・$id = $wp_query->post->ID;のあとに$id .= “”;と追記・
   > preg_replaceに置き換え
 * 最初のはいりません;)
    preg_replaceに置き換えることで数値でも問題なく動くと思い
   ます。
 * > 私のｺｰﾃﾞｨﾝｸﾞﾐｽなのでしょうか。
 * 公式を見てみると、ページのすべてがPDF化できるわけではないようですよ。
    対応し
   ているタグがあって、そのタグ以外はそもそも認識できないようです。 まあβ版位の性能
   かと・・・
 *  トピック投稿者 [wpbeg](https://ja.wordpress.org/support/users/wpbeg/)
 * (@wpbeg)
 * [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122143)
 * shokun0803様
 * いろいろアドバイスありがとうございます。
    いろいろ試してみましたがうまくいきま
   せんでした。

6件の返信を表示中 - 1 - 6件目 (全6件中)

 トピック「post2pdfのプラグインのconfig.inc.phpの修正方法」には新たに返信すること
はできません。

## タグ

 * [post2pdf](https://ja.wordpress.org/support/topic-tag/post2pdf/)

 * フォーラム: [プラグイン](https://ja.wordpress.org/support/forum/plugins/)
 * 6件の返信
 * 2人の参加者
 * 最後の返信者: [wpbeg](https://ja.wordpress.org/support/users/wpbeg/)
 * 最後の活動: [16年、 11ヶ月前](https://ja.wordpress.org/support/topic/post2pdf%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%aeconfigincphp%e3%81%ae%e4%bf%ae%e6%ad%a3%e6%96%b9%e6%b3%95/#post-122143)
 * 状態: 未解決

## トピック

### 人気のトピック

### 返信がないトピック

### サポート関連ではないトピック

### 解決済みのトピック

### 未解決のトピック

### すべてのトピック
