Plugin Directory

Changeset 1907460


Ignore:
Timestamp:
07/11/2018 06:16:39 AM (8 years ago)
Author:
ejointjp
Message:

v0.4.0

Location:
wp-tocjs/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-tocjs/trunk/languages/wp-tocjs-ja.po

    r1848102 r1907460  
    22msgstr ""
    33"Project-Id-Version: WP TocJS\n"
    4 "POT-Creation-Date: 2018-03-28 10:34+0900\n"
    5 "PO-Revision-Date: 2018-03-28 10:34+0900\n"
     4"POT-Creation-Date: 2018-07-11 15:13+0900\n"
     5"PO-Revision-Date: 2018-07-11 15:13+0900\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    7979
    8080#: wp-tocjs.php:198
     81msgid "Post type to disable TOC"
     82msgstr "目次を無効にする投稿タイプ"
     83
     84#: wp-tocjs.php:206
    8185msgid "Do not use plugin's CSS"
    8286msgstr "プラグインのCSSを使わない"
    8387
    84 #: wp-tocjs.php:206
     88#: wp-tocjs.php:214
    8589msgid "Do not use plugin's JS"
    8690msgstr "プラグインのJavaScriptを使わない"
    8791
    88 #: wp-tocjs.php:221
     92#: wp-tocjs.php:229
    8993msgid "As the TOC function becomes invalid, please do not usually disable it."
    9094msgstr "目次機能が無効になります。通常は無効にしないでください。"
    9195
    92 #: wp-tocjs.php:227
     96#: wp-tocjs.php:235
    9397msgid ""
    9498"The contents of the element specified here becomes the target area of the "
     
    96100msgstr "ここで指定した要素内が目次の対象エリアとなります。"
    97101
    98 #: wp-tocjs.php:228
     102#: wp-tocjs.php:236
    99103msgid "In the format of a jQuery selector."
    100104msgstr "jQuery(CSS)セレクタの形式で入力ください。"
    101105
    102 #: wp-tocjs.php:234
     106#: wp-tocjs.php:242
    103107msgid "Please enter the target headings in h1 - h6 separated by comma."
    104108msgstr "目次の対象とする見出しタグをh1-h6でカンマ区切りで入力してください"
    105109
    106 #: wp-tocjs.php:240
     110#: wp-tocjs.php:248
    107111msgid ""
    108112"If the number of target headings is less than or equal to the value, the TOC "
     
    110114msgstr "目次の対象となる見出しがこの数以下の場合、目次を表示しません。"
    111115
    112 #: wp-tocjs.php:257
     116#: wp-tocjs.php:265
    113117msgid "Please input as attribute name of class, not selector."
    114118msgstr "セレクタではなく、クラス名を入力してください。"
    115119
    116 #: wp-tocjs.php:303
     120#: wp-tocjs.php:348
    117121msgid "Hidden on this page"
    118122msgstr "このページの目次を表示しない"
  • wp-tocjs/trunk/languages/wp-tocjs.pot

    r1848102 r1907460  
    44"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    55"Project-Id-Version: WP TocJS\n"
    6 "POT-Creation-Date: 2018-03-28 10:33+0900\n"
     6"POT-Creation-Date: 2018-07-11 15:14+0900\n"
    77"PO-Revision-Date: 2018-03-05 13:46+0900\n"
    88"Last-Translator: \n"
     
    7777
    7878#: wp-tocjs.php:198
     79msgid "Post type to disable TOC"
     80msgstr ""
     81
     82#: wp-tocjs.php:206
    7983msgid "Do not use plugin's CSS"
    8084msgstr ""
    8185
    82 #: wp-tocjs.php:206
     86#: wp-tocjs.php:214
    8387msgid "Do not use plugin's JS"
    8488msgstr ""
    8589
    86 #: wp-tocjs.php:221
     90#: wp-tocjs.php:229
    8791msgid "As the TOC function becomes invalid, please do not usually disable it."
    8892msgstr ""
    8993
    90 #: wp-tocjs.php:227
     94#: wp-tocjs.php:235
    9195msgid ""
    9296"The contents of the element specified here becomes the target area of the "
     
    9498msgstr ""
    9599
    96 #: wp-tocjs.php:228
     100#: wp-tocjs.php:236
    97101msgid "In the format of a jQuery selector."
    98102msgstr ""
    99103
    100 #: wp-tocjs.php:234
     104#: wp-tocjs.php:242
    101105msgid "Please enter the target headings in h1 - h6 separated by comma."
    102106msgstr ""
    103107
    104 #: wp-tocjs.php:240
     108#: wp-tocjs.php:248
    105109msgid ""
    106110"If the number of target headings is less than or equal to the value, the "
     
    108112msgstr ""
    109113
    110 #: wp-tocjs.php:257
     114#: wp-tocjs.php:265
    111115msgid "Please input as attribute name of class, not selector."
    112116msgstr ""
    113117
    114 #: wp-tocjs.php:303
     118#: wp-tocjs.php:348
    115119msgid "Hidden on this page"
    116120msgstr ""
  • wp-tocjs/trunk/readme.txt

    r1903719 r1907460  
    44Tags: shortcode, quote, quotation, blockquote
    55Requires at least: 4.0
    6 Tested up to: 4.9.6
    7 Stable tag: 0.3.1
     6Tested up to: 4.9.7
     7Stable tag: 0.4.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555== Changelog ==
    5656
     57= 0.4.0 =
     58
     59* Update: Supported Custom Post Types.
     60* カスタム投稿タイプに対応しました。
     61
    5762= 0.3.1 =
    5863
  • wp-tocjs/trunk/wp-tocjs.php

    r1903719 r1907460  
    44Plugin URI: http://e-joint.jp/works/wp-tocjs/
    55Description: A WordPress plugin that makes Table of Contents automatically.
    6 Version: 0.3.1
     6Version: 0.4.0
    77Author: e-JOINT.jp
    88Author URI: http://e-joint.jp
     
    195195
    196196    add_settings_field(
     197      'disable_post_type',
     198      __('Post type to disable TOC', $this->textdomain),
     199      array($this, 'disable_post_type_callback'),
     200      'wptjs-setting',
     201      'wptjs-setting-section-id'
     202    );
     203
     204    add_settings_field(
    197205      'nocss',
    198206      __('Do not use plugin\'s CSS', $this->textdomain),
     
    266274    $checked = isset($this->options['toc_number']) ? checked($this->options['toc_number'], 1, false) : false;
    267275    ?><input type="checkbox" id="toc-number" name="wptjs-setting[toc_number]" value="1"<?php echo $checked; ?>><?php
     276  }
     277
     278  public function disable_post_type_callback() {
     279    $post_types = $this->post_types();
     280    $data = $this->options['disable_post_type'];
     281    $html = '';
     282    $html .= '<fieldset>';
     283
     284    foreach($post_types as $post_type) {
     285      $name = $post_type->name;
     286
     287      if(is_array($data)) {
     288        $checked = in_array($name, $data) ? ' checked="checked"' : '';
     289      } else {
     290        $checked = '';
     291      }
     292
     293      $html .= sprintf('<label><input type="checkbox" name="wptjs-setting[disable_post_type][]" value="%s"%s> %s</label><br>', $name, $checked, $post_type->label);
     294    }
     295
     296    $html .= '</fieldset>';
     297
     298    echo $html;
    268299  }
    269300
     
    292323  // カスタムフィールドの追加
    293324  public function add_custom_field() {
    294     add_meta_box('wptjs-setting', 'WP TocJS', array($this, 'custom_field_metabox'), 'post', 'side');
    295     add_meta_box('wptjs-setting', 'WP TocJS', array($this, 'custom_field_metabox'), 'page', 'side');
     325    $post_types = $this->post_types();
     326    $disable_post_type = $this->options['disable_post_type'];
     327
     328    if(is_null($disable_post_type)) {
     329      foreach($post_types as $post_type) {
     330        add_meta_box('wptjs-setting', 'WP TocJS', array($this, 'custom_field_metabox'), $post_type->name, 'side');
     331      }
     332    } else {
     333      foreach($post_types as $post_type) {
     334        if(!in_array($post_type->name, $disable_post_type)) {
     335          add_meta_box('wptjs-setting', 'WP TocJS', array($this, 'custom_field_metabox'), $post_type->name, 'side');
     336        }
     337      }
     338    }
     339    // add_meta_box('wptjs-setting', 'WP TocJS', array($this, 'custom_field_metabox'), 'post', 'side');
     340    // add_meta_box('wptjs-setting', 'WP TocJS', array($this, 'custom_field_metabox'), 'page', 'side');
    296341  }
    297342
     
    321366  }
    322367
    323   public function generate_scripts() { ?>
     368  public function generate_scripts() {
     369
     370    if($this->is_disabled()) {
     371      return;
     372    }
     373    ?>
    324374    <script>
    325375    jQuery("<?php echo $this->default_option('src') ?>").tocjs({
     
    336386  <?php }
    337387
    338   function the_content($content) {
     388  protected function post_types() {
     389    $post_types = get_post_types('', 'objects');
     390    $unsets = ['attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request'];
     391
     392    foreach($unsets as $unset) {
     393      unset($post_types[$unset]);
     394    }
     395
     396    return $post_types;
     397  }
     398
     399  protected function is_disabled() {
     400    $disable_post_type = $this->options['disable_post_type'];
     401    $post_type = get_post_type();
     402
     403    if(is_null($disable_post_type)) {
     404      $disabled = false;
     405
     406    } else {
     407      $disabled = in_array($post_type, $disable_post_type);
     408    }
     409
     410    return $disabled;
     411  }
     412
     413  public function the_content($content) {
     414    if($this->is_disabled()) {
     415      return $content;
     416    }
    339417
    340418    $add_html = do_shortcode('[tocjs]');
Note: See TracChangeset for help on using the changeset viewer.