LuckyWP Table of Contents - Version 1.3.0

Version Description

  • Skip headings by level or text.
Download this release

Release Info

Developer theluckywp
Plugin Icon 128x128 LuckyWP Table of Contents
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.2 to 1.3.0

admin/Admin.php CHANGED
@@ -192,6 +192,12 @@ class Admin extends BaseObject
192
  if (null !== $v = $getValue($source, 'wrapNoindex')) {
193
  $rows[] = [esc_html__('Wrap table of contents with <!--noindex--> tag', 'lwptoc'), $v ? __('Enabled', 'lwptoc') : __('Disabled', 'lwptoc')];
194
  }
 
 
 
 
 
 
195
  return array_map(function ($row) {
196
  if ($row[1] !== null && ArrayHelper::getValue($row, 2, true) === true) {
197
  $row[1] = esc_html($row[1]);
192
  if (null !== $v = $getValue($source, 'wrapNoindex')) {
193
  $rows[] = [esc_html__('Wrap table of contents with <!--noindex--> tag', 'lwptoc'), $v ? __('Enabled', 'lwptoc') : __('Disabled', 'lwptoc')];
194
  }
195
+ if (null !== $v = $getValue($source, 'skipHeadingLevel')) {
196
+ $rows[] = [esc_html__('Skip headings', 'lwptoc'), Core::$plugin->skipHeadingLevelToLabel($v)];
197
+ }
198
+ if (null !== $v = $getValue($source, 'skipHeadingText')) {
199
+ $rows[] = [esc_html__('Skip headings', 'lwptoc'), $v == '' ? null : $v];
200
+ }
201
  return array_map(function ($row) {
202
  if ($row[1] !== null && ArrayHelper::getValue($row, 2, true) === true) {
203
  $row[1] = esc_html($row[1]);
admin/assets/main.min.css CHANGED
@@ -1 +1 @@
1
- @keyframes lwptocLightSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocLightSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocLightSpinner div{position:absolute;width:5px;height:5px;background:#fff;border-radius:50%;animation:lwptocLightSpinnerKeyFrames 1.2s linear infinite}.lwptocLightSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocLightSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocLightSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocLightSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocLightSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocLightSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocLightSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocLightSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocLightSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocLightSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocLightSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocLightSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}@keyframes lwptocDarkSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocDarkSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocDarkSpinner div{position:absolute;width:5px;height:5px;background:#aaa;border-radius:50%;animation:lwptocDarkSpinnerKeyFrames 1.2s linear infinite}.lwptocDarkSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocDarkSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocDarkSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocDarkSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocDarkSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocDarkSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocDarkSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocDarkSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocDarkSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocDarkSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocDarkSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocDarkSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}.lwptocPreloaderWrapper{position:relative!important}.lwptocPreloaderOverlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:50;background:rgba(255,255,255,.7)}.lwptocPreloaderOverlay>DIV{position:absolute;top:50%;left:50%;margin-left:-32px;margin-top:-32px}.lwptocModal-container,.lwptocModal-overlay{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000}.lwptocModal-container{overflow:auto}.lwptocModal-container_i{display:table;height:100%;margin:0 auto}.lwptocModal-container_i2{display:table-cell;padding:24px}.lwptocModal-error{padding:20px;border-radius:10px;background:#000;color:#fff}.lwptocModal-preloader{width:80px;height:80px;border-radius:10px;background:#000 url(preloader.gif) no-repeat 50% 50%}.lwptocModalBox{position:relative;width:500px;background:#fff;color:#000;box-shadow:0 3px 6px rgba(0,0,0,.3)}.lwptocModalBox_close{position:absolute;top:4px;right:8px;color:#666;text-align:center;line-height:29px;width:29px;height:29px;cursor:pointer}.lwptocModalBox_close:before{content:'\f158';font:normal 20px/29px dashicons}.lwptocModalBox_close:hover{color:#00a0d2}.lwptocModalBox_title{background:#fcfcfc;border-bottom:1px solid #dfdfdf;font-weight:600;font-size:13px;line-height:19px;padding:8px 29px 10px 18px}.lwptocModalBox_body{padding:18px 18px 22px 18px}.lwptocModalBox_footer{padding:18px;border-top:1px solid #dfdfdf}.lwptocModalBox_footer_buttons{text-align:right}.lwptocModalBox_footer_buttons .button{margin-left:4px}.lwptocModalBox_footer_buttons .button:first-child{margin-left:0}.lwptocModalBox_footer_buttons:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocMetabox P{padding:0;margin:12px 0 0!important}.lwptocMetabox P:first-child{margin-top:0}.lwptocMetabox .button-link{margin-left:12px}.lwptocMetabox_settings{margin:6px 0 18px;padding:6px 0 6px 4px;box-shadow:-2px 0 0 #fafafa,-4px 0 0 #ddd,4px 0 0 #fafafa;background:#fafafa}.lwptocMetabox_settings_item{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:4px}.lwptocMetabox_settings_item:first-child{margin-top:0}.lwptocMetabox_settings_item B{font-weight:400;color:#888}.lwptocMetabox_settings_item .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.lwptocCustomize .lwptocModalBox_body{padding:0 0 22px}.lwptocCustomize_errors{margin:14px;border-left:2px solid red;background:#fff4f6;padding:4px 12px 6px;color:red}.lwptocCustomize_errors P{margin:2px 0 0 0}.lwptocCustomize_errors P:first-child{margin-top:0}.lwptocCustomize_tabs{padding:0 14px;margin-top:12px;background:#f1f1f1}.lwptocCustomize_tabs:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocCustomize_tab{float:left;white-space:nowrap;padding:6px 12px 7px;cursor:pointer}.lwptocCustomize_tab:hover{background:#ddd}.lwptocCustomize_tab-active{background:#0073aa!important;color:#fff;cursor:default}.lwptocCustomize_fields{display:none;padding:16px 18px 0}.lwptocCustomize_field{position:relative;margin-top:12px}.lwptocCustomize_field:first-child{margin-top:0}.lwptocCustomize_field_label{font-weight:700}.lwptocCustomize_field_default{float:right;margin-left:4px;cursor:pointer;color:#0073aa;border-bottom:1px dotted #0073aa}.lwptocCustomize_field_default:hover{color:#00a0d2;border-color:#00a0d2}.lwptocCustomize_field_override{display:none;position:absolute;left:-4px;top:-4px;right:-4px;bottom:-4px;background:rgba(42,150,204,.8);color:#fff;font-size:16px;font-weight:700;text-align:center;padding-top:12px;cursor:pointer;-webkit-transition:.1s linear;-moz-transition:.1s linear;-o-transition:.1s linear;transition:.1s linear;opacity:0}.lwptocCustomize_field_defaultValue{display:none;font-size:16px;line-height:20px;font-style:italic;color:#aaa}.lwptocCustomize_field_el{margin-top:4px}.lwptocCustomize_field_el_select,.lwptocCustomize_field_el_textInput{width:100%}.lwptocCustomize_field_desc{margin-top:2px;font-size:90%;color:#888}.lwptocCustomize_field-default .lwptocCustomize_field_default,.lwptocCustomize_field-default .lwptocCustomize_field_el{display:none}.lwptocCustomize_field-default .lwptocCustomize_field_defaultValue,.lwptocCustomize_field-default .lwptocCustomize_field_override{display:block}.lwptocCustomize_field-default .lwptocCustomize_field_desc{margin-top:0}.lwptocCustomize_field-default:hover .lwptocCustomize_field_override{opacity:1}.lwptocWidthField_custom{display:inline}.lwptocWidthField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocWidthField_unitInput{vertical-align:top}.lwptocFontSizeField_custom{display:inline}.lwptocFontSizeField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocFontSizeField_unitInput{vertical-align:top}.lwptocModalSuccess{text-align:center;cursor:default;color:#8bc34a}.lwptocModalSuccess_ico{font-family:dashicons;font-size:160px;line-height:124px}.lwptocModalSuccess_text{color:#fff;font-size:24px;line-height:30px}.lwptocColorBadge B{display:inline-block;margin-right:4px;width:12px;height:12px;border-radius:6px}.lwptocFloatLeft{float:left}.lwptocEditorBlock{display:block;padding:12px 16px 13px;border:2px dashed #ddd;background:#fff;color:#333;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif}.lwptocEditorBlock_title{font-size:14px;line-height:18px;font-weight:700}.lwptocEditorBlock_title-loading{color:#aaa}.lwptocEditorBlock_items{margin-top:4px;font-size:12px;line-height:16px}.lwptocEditorBlock_item{margin-top:2px}.lwptocEditorBlock_item:first-child{margin-top:0}.lwptocEditorBlock_item_label{color:#888}.lwptocEditorBlock .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.mce-i-lwptocButton:before{font:400 20px/1 dashicons;content:"\f163"}
1
+ @keyframes lwptocLightSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocLightSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocLightSpinner div{position:absolute;width:5px;height:5px;background:#fff;border-radius:50%;animation:lwptocLightSpinnerKeyFrames 1.2s linear infinite}.lwptocLightSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocLightSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocLightSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocLightSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocLightSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocLightSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocLightSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocLightSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocLightSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocLightSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocLightSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocLightSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}@keyframes lwptocDarkSpinnerKeyFrames{0%,100%,20%,80%{transform:scale(.7)}50%{transform:scale(1.5)}}.lwptocDarkSpinner{display:inline-block;position:relative;width:64px;height:64px}.lwptocDarkSpinner div{position:absolute;width:5px;height:5px;background:#aaa;border-radius:50%;animation:lwptocDarkSpinnerKeyFrames 1.2s linear infinite}.lwptocDarkSpinner div:nth-child(1){animation-delay:0s;top:29px;left:53px}.lwptocDarkSpinner div:nth-child(2){animation-delay:-.1s;top:18px;left:50px}.lwptocDarkSpinner div:nth-child(3){animation-delay:-.2s;top:9px;left:41px}.lwptocDarkSpinner div:nth-child(4){animation-delay:-.3s;top:6px;left:29px}.lwptocDarkSpinner div:nth-child(5){animation-delay:-.4s;top:9px;left:18px}.lwptocDarkSpinner div:nth-child(6){animation-delay:-.5s;top:18px;left:9px}.lwptocDarkSpinner div:nth-child(7){animation-delay:-.6s;top:29px;left:6px}.lwptocDarkSpinner div:nth-child(8){animation-delay:-.7s;top:41px;left:9px}.lwptocDarkSpinner div:nth-child(9){animation-delay:-.8s;top:50px;left:18px}.lwptocDarkSpinner div:nth-child(10){animation-delay:-.9s;top:53px;left:29px}.lwptocDarkSpinner div:nth-child(11){animation-delay:-1s;top:50px;left:41px}.lwptocDarkSpinner div:nth-child(12){animation-delay:-1.1s;top:41px;left:50px}.lwptocPreloaderWrapper{position:relative!important}.lwptocPreloaderOverlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:50;background:rgba(255,255,255,.7)}.lwptocPreloaderOverlay>DIV{position:absolute;top:50%;left:50%;margin-left:-32px;margin-top:-32px}.lwptocModal-container,.lwptocModal-overlay{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000}.lwptocModal-container{overflow:auto}.lwptocModal-container_i{display:table;height:100%;margin:0 auto}.lwptocModal-container_i2{display:table-cell;padding:24px}.lwptocModal-error{padding:20px;border-radius:10px;background:#000;color:#fff}.lwptocModal-preloader{width:80px;height:80px;border-radius:10px;background:#000 url(preloader.gif) no-repeat 50% 50%}.lwptocModalBox{position:relative;width:500px;background:#fff;color:#000;box-shadow:0 3px 6px rgba(0,0,0,.3)}.lwptocModalBox_close{position:absolute;top:4px;right:8px;color:#666;text-align:center;line-height:29px;width:29px;height:29px;cursor:pointer}.lwptocModalBox_close:before{content:'\f158';font:normal 20px/29px dashicons}.lwptocModalBox_close:hover{color:#00a0d2}.lwptocModalBox_title{background:#fcfcfc;border-bottom:1px solid #dfdfdf;font-weight:600;font-size:13px;line-height:19px;padding:8px 29px 10px 18px}.lwptocModalBox_body{padding:18px 18px 22px 18px}.lwptocModalBox_footer{padding:18px;border-top:1px solid #dfdfdf}.lwptocModalBox_footer_buttons{text-align:right}.lwptocModalBox_footer_buttons .button{margin-left:4px}.lwptocModalBox_footer_buttons .button:first-child{margin-left:0}.lwptocModalBox_footer_buttons:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocMetabox P{padding:0;margin:12px 0 0!important}.lwptocMetabox P:first-child{margin-top:0}.lwptocMetabox .button-link{margin-left:12px}.lwptocMetabox_settings{margin:6px 0 18px;padding:6px 0 6px 4px;box-shadow:-2px 0 0 #fafafa,-4px 0 0 #ddd,4px 0 0 #fafafa;background:#fafafa}.lwptocMetabox_settings_item{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:4px}.lwptocMetabox_settings_item:first-child{margin-top:0}.lwptocMetabox_settings_item B{font-weight:400;color:#888}.lwptocMetabox_settings_item .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.lwptocCustomize .lwptocModalBox_body{padding:0 0 22px}.lwptocCustomize_errors{margin:14px;border-left:2px solid red;background:#fff4f6;padding:4px 12px 6px;color:red}.lwptocCustomize_errors P{margin:2px 0 0 0}.lwptocCustomize_errors P:first-child{margin-top:0}.lwptocCustomize_tabs{padding:0 14px;margin-top:12px;background:#f1f1f1}.lwptocCustomize_tabs:after{content:".";display:block;height:0;font-size:0;line-height:0;clear:both;visibility:hidden}.lwptocCustomize_tab{float:left;white-space:nowrap;padding:6px 12px 7px;cursor:pointer}.lwptocCustomize_tab:hover{background:#ddd}.lwptocCustomize_tab-active{background:#0073aa!important;color:#fff;cursor:default}.lwptocCustomize_fields{display:none;padding:16px 18px 0}.lwptocCustomize_field{position:relative;margin-top:12px}.lwptocCustomize_field:first-child{margin-top:0}.lwptocCustomize_field_label{font-weight:700}.lwptocCustomize_field_default{float:right;margin-left:4px;cursor:pointer;color:#0073aa;border-bottom:1px dotted #0073aa}.lwptocCustomize_field_default:hover{color:#00a0d2;border-color:#00a0d2}.lwptocCustomize_field_override{display:none;position:absolute;left:-4px;top:-4px;right:-4px;bottom:-4px;background:rgba(42,150,204,.8);color:#fff;font-size:16px;font-weight:700;text-align:center;padding-top:12px;cursor:pointer;-webkit-transition:.1s linear;-moz-transition:.1s linear;-o-transition:.1s linear;transition:.1s linear;opacity:0}.lwptocCustomize_field_defaultValue{display:none;font-size:16px;line-height:20px;font-style:italic;color:#aaa}.lwptocCustomize_field_el{margin-top:4px}.lwptocCustomize_field_el_select,.lwptocCustomize_field_el_textInput{width:100%}.lwptocCustomize_field_desc{margin-top:2px;font-size:90%;color:#888}.lwptocCustomize_field-default .lwptocCustomize_field_default,.lwptocCustomize_field-default .lwptocCustomize_field_el{display:none}.lwptocCustomize_field-default .lwptocCustomize_field_defaultValue,.lwptocCustomize_field-default .lwptocCustomize_field_override{display:block}.lwptocCustomize_field-default .lwptocCustomize_field_desc{margin-top:0}.lwptocCustomize_field-default:hover .lwptocCustomize_field_override{opacity:1}.lwptocWidthField_custom{display:inline}.lwptocWidthField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocWidthField_unitInput{vertical-align:top}.lwptocFontSizeField_custom{display:inline}.lwptocFontSizeField_sizeInput{vertical-align:top;width:64px;padding-bottom:4px;text-align:center}.lwptocFontSizeField_unitInput{vertical-align:top}.lwptocSkipHeadingLevelField LABEL{margin-right:12px}.lwptocModalSuccess{text-align:center;cursor:default;color:#8bc34a}.lwptocModalSuccess_ico{font-family:dashicons;font-size:160px;line-height:124px}.lwptocModalSuccess_text{color:#fff;font-size:24px;line-height:30px}.lwptocColorBadge B{display:inline-block;margin-right:4px;width:12px;height:12px;border-radius:6px}.lwptocFloatLeft{float:left}.lwptocEditorBlock{display:block;padding:12px 16px 13px;border:2px dashed #ddd;background:#fff;color:#333;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",sans-serif}.lwptocEditorBlock_title{font-size:14px;line-height:18px;font-weight:700}.lwptocEditorBlock_title-loading{color:#aaa}.lwptocEditorBlock_items{margin-top:4px;font-size:12px;line-height:16px}.lwptocEditorBlock_item{margin-top:2px}.lwptocEditorBlock_item:first-child{margin-top:0}.lwptocEditorBlock_item_label{color:#888}.lwptocEditorBlock .lwptocColorBadge B{position:relative;top:1px;margin-left:2px}.mce-i-lwptocButton:before{font:400 20px/1 dashicons;content:"\f163"}
admin/forms/CustomizeForm.php CHANGED
@@ -86,6 +86,12 @@ class CustomizeForm extends Model
86
  public $defaultWrapNoindex;
87
  public $wrapNoindex;
88
 
 
 
 
 
 
 
89
  /**
90
  * @var PostSettings
91
  */
@@ -121,6 +127,8 @@ class CustomizeForm extends Model
121
  'hoverLinkColor',
122
  'visitedLinkColor',
123
  'wrapNoindex',
 
 
124
  ];
125
 
126
  /**
@@ -197,6 +205,14 @@ class CustomizeForm extends Model
197
  'filter' => [Core::$plugin->settings, 'sanitizeCallbackColor'],
198
  ],
199
  ['wrapNoindex', 'boolean'],
 
 
 
 
 
 
 
 
200
  ];
201
  }
202
 
@@ -266,6 +282,8 @@ class CustomizeForm extends Model
266
  'hoverLinkColor' => $this->defaultHoverLinkColor ? null : ($this->hoverLinkColor ? $this->hoverLinkColor : ''),
267
  'visitedLinkColor' => $this->defaultVisitedLinkColor ? null : ($this->visitedLinkColor ? $this->visitedLinkColor : ''),
268
  'wrapNoindex' => $this->defaultWrapNoindex ? null : (bool)$this->wrapNoindex,
 
 
269
  ];
270
  }
271
  }
86
  public $defaultWrapNoindex;
87
  public $wrapNoindex;
88
 
89
+ public $defaultSkipHeadingLevel;
90
+ public $skipHeadingLevel;
91
+
92
+ public $defaultSkipHeadingText;
93
+ public $skipHeadingText;
94
+
95
  /**
96
  * @var PostSettings
97
  */
127
  'hoverLinkColor',
128
  'visitedLinkColor',
129
  'wrapNoindex',
130
+ 'skipHeadingLevel',
131
+ 'skipHeadingText',
132
  ];
133
 
134
  /**
205
  'filter' => [Core::$plugin->settings, 'sanitizeCallbackColor'],
206
  ],
207
  ['wrapNoindex', 'boolean'],
208
+ ['skipHeadingLevel', 'filter', 'filter' => [Settings::className(), 'sanitizeSkipHeadingLevel']],
209
+ [
210
+ 'skipHeadingText',
211
+ 'filter',
212
+ 'filter' => function ($value) {
213
+ return Core::$plugin->skipHeadingTextMultipleStringToString((string)$value);
214
+ }
215
+ ],
216
  ];
217
  }
218
 
282
  'hoverLinkColor' => $this->defaultHoverLinkColor ? null : ($this->hoverLinkColor ? $this->hoverLinkColor : ''),
283
  'visitedLinkColor' => $this->defaultVisitedLinkColor ? null : ($this->visitedLinkColor ? $this->visitedLinkColor : ''),
284
  'wrapNoindex' => $this->defaultWrapNoindex ? null : (bool)$this->wrapNoindex,
285
+ 'skipHeadingLevel' => $this->defaultSkipHeadingLevel ? null : $this->skipHeadingLevel,
286
+ 'skipHeadingText' => $this->defaultSkipHeadingText ? null : $this->skipHeadingText,
287
  ];
288
  }
289
  }
admin/widgets/customizeModal/views/modal.php CHANGED
@@ -8,6 +8,7 @@
8
 
9
  use luckywp\tableOfContents\admin\widgets\fontSizeField\FontSizeField;
10
  use luckywp\tableOfContents\admin\widgets\OverrideColorBadge;
 
11
  use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
12
  use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
13
  use luckywp\tableOfContents\core\Core;
@@ -507,6 +508,69 @@ echo $onlyBody ? '' : '<div class="lwptocCustomize lwptocCustomize-metabox">';
507
  </div>
508
  </div>
509
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  </div>
511
 
512
  </div>
8
 
9
  use luckywp\tableOfContents\admin\widgets\fontSizeField\FontSizeField;
10
  use luckywp\tableOfContents\admin\widgets\OverrideColorBadge;
11
+ use luckywp\tableOfContents\admin\widgets\skipHeadingLevelField\SkipHeadingLevelField;
12
  use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
13
  use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
14
  use luckywp\tableOfContents\core\Core;
508
  </div>
509
  </div>
510
 
511
+ <?php $defaultValue = ($model->isPostSettings || is_null($model->postSettings->skipHeadingLevel)) ? Core::$plugin->settings->getMiscSkipHeadingLevel() : $model->postSettings->skipHeadingLevel ?>
512
+ <div class="lwptocCustomize_field<?= $model->defaultSkipHeadingLevel ? ' lwptocCustomize_field-default' : '' ?>">
513
+ <div class="lwptocCustomize_field_header">
514
+ <span class="lwptocCustomize_field_label"><?= esc_html__('Skip heading by level', 'lwptoc') ?></span>
515
+ <span class="lwptocCustomize_field_default"><?= esc_html__('default', 'lwptoc') ?></span>
516
+ </div>
517
+ <div class="lwptocCustomize_field_override">
518
+ <?= esc_html__('Click for override default value', 'lwptoc') ?>
519
+ </div>
520
+ <div class="lwptocCustomize_field_el">
521
+ <?= SkipHeadingLevelField::widget([
522
+ 'name' => Html::getInputName($model, 'skipHeadingLevel'),
523
+ 'value' => $model->defaultSkipHeadingLevel ? $defaultValue : $model->skipHeadingLevel,
524
+ ]) ?>
525
+ <?= Html::hiddenInput(Html::getInputName($model, 'defaultSkipHeadingLevel'), $model->defaultSkipHeadingLevel, [
526
+ 'class' => 'lwptocCustomize_field_inputDefault',
527
+ ]) ?>
528
+ </div>
529
+ <div class="lwptocCustomize_field_defaultValue">
530
+ <?= Core::$plugin->skipHeadingLevelToLabel($defaultValue) ?>
531
+ </div>
532
+ </div>
533
+
534
+ <?php $defaultValue = ($model->isPostSettings || is_null($model->postSettings->skipHeadingText)) ? Core::$plugin->settings->getMiscSkipHeadingText() : $model->postSettings->skipHeadingText ?>
535
+ <div class="lwptocCustomize_field<?= $model->defaultSkipHeadingText ? ' lwptocCustomize_field-default' : '' ?>">
536
+ <div class="lwptocCustomize_field_header">
537
+ <span class="lwptocCustomize_field_label"><?= esc_html__('Skip heading by text', 'lwptoc') ?></span>
538
+ <span class="lwptocCustomize_field_default"><?= esc_html__('default', 'lwptoc') ?></span>
539
+ </div>
540
+ <div class="lwptocCustomize_field_override">
541
+ <?= esc_html__('Click for override default value', 'lwptoc') ?>
542
+ </div>
543
+ <div class="lwptocCustomize_field_el">
544
+ <?php
545
+ $value = $model->defaultSkipHeadingText ? $defaultValue : $model->skipHeadingText;
546
+ echo Html::textarea(Html::getInputName($model, 'skipHeadingText'), Core::$plugin->skipHeadingTextToMultipleString((string)$value), [
547
+ 'class' => 'regular-text',
548
+ 'rows' => 5,
549
+ ]);
550
+ echo '<div class="lwptocCustomize_field_desc">';
551
+ echo esc_html__('Specify headings (one per line) to be excluded from the table of contents.', 'lwptoc');
552
+ echo '<br>';
553
+ echo sprintf(
554
+ esc_html__('Use an asterisk %s as a wildcard to match any text.', 'lwptoc'),
555
+ '<code>*</code>'
556
+ );
557
+ echo '</div>';
558
+ ?>
559
+ <?= Html::hiddenInput(Html::getInputName($model, 'defaultSkipHeadingText'), $model->defaultSkipHeadingText, [
560
+ 'class' => 'lwptocCustomize_field_inputDefault',
561
+ ]) ?>
562
+ </div>
563
+ <div class="lwptocCustomize_field_defaultValue">
564
+ <?php
565
+ if ('' == $defaultValue) {
566
+ echo '<i>' . esc_html__('empty', 'lwptoc') . '</i>';
567
+ } else {
568
+ echo $defaultValue;
569
+ }
570
+ ?>
571
+ </div>
572
+ </div>
573
+
574
  </div>
575
 
576
  </div>
admin/widgets/skipHeadingLevelField/SkipHeadingLevelField.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace luckywp\tableOfContents\admin\widgets\skipHeadingLevelField;
4
+
5
+ use luckywp\tableOfContents\core\base\Widget;
6
+ use luckywp\tableOfContents\core\Core;
7
+
8
+ class SkipHeadingLevelField extends Widget
9
+ {
10
+
11
+ /**
12
+ * @var string
13
+ */
14
+ public $name;
15
+
16
+ /**
17
+ * @var string
18
+ */
19
+ public $value;
20
+
21
+ public function run()
22
+ {
23
+ return $this->render('field', [
24
+ 'name' => $this->name,
25
+ 'value' => Core::$plugin->skipHeadingLevelToArray($this->value),
26
+ 'items' => Core::$plugin->getHeadingsList(),
27
+ ]);
28
+ }
29
+ }
admin/widgets/skipHeadingLevelField/views/field.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var $name string
4
+ * @var $value array
5
+ * @var $items array
6
+ */
7
+
8
+ use luckywp\tableOfContents\core\helpers\Html;
9
+
10
+ ?>
11
+ <div class="lwptocSkipHeadingLevelField">
12
+ <?php
13
+ echo Html::hiddenInput($name);
14
+ foreach ($items as $id => $label) {
15
+ $options = [
16
+ 'label' => $label,
17
+ 'value' => $id,
18
+ ];
19
+ echo Html::checkbox($name . '[]', in_array($id, $value), $options) . ' ';
20
+ }
21
+ ?>
22
+ </div>
config/settings.php CHANGED
@@ -1,10 +1,12 @@
1
  <?php
2
 
3
  use luckywp\tableOfContents\admin\widgets\fontSizeField\FontSizeField;
 
4
  use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
5
  use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
6
  use luckywp\tableOfContents\admin\widgets\PostTypes;
7
  use luckywp\tableOfContents\core\Core;
 
8
  use luckywp\tableOfContents\plugin\Settings;
9
 
10
  return [
@@ -335,6 +337,42 @@ return [
335
  ],
336
  ],
337
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  ],
339
  ],
340
  ];
1
  <?php
2
 
3
  use luckywp\tableOfContents\admin\widgets\fontSizeField\FontSizeField;
4
+ use luckywp\tableOfContents\admin\widgets\skipHeadingLevelField\SkipHeadingLevelField;
5
  use luckywp\tableOfContents\admin\widgets\widthField\WidthField;
6
  use luckywp\tableOfContents\core\admin\helpers\AdminHtml;
7
  use luckywp\tableOfContents\admin\widgets\PostTypes;
8
  use luckywp\tableOfContents\core\Core;
9
+ use luckywp\tableOfContents\core\helpers\Html;
10
  use luckywp\tableOfContents\plugin\Settings;
11
 
12
  return [
337
  ],
338
  ],
339
  ],
340
+ 'skipHeading' => [
341
+ 'title' => esc_html__('Skip Headings', 'lwptoc'),
342
+ 'fields' => [
343
+ 'skipHeadingLevel' => [
344
+ 'label' => esc_html__('By Level', 'lwptoc'),
345
+ 'widget' => function ($field) {
346
+ echo SkipHeadingLevelField::widget([
347
+ 'name' => $field['name'],
348
+ 'value' => Core::$plugin->settings->getValue($field['group'], $field['id'], [], false),
349
+ ]);
350
+ },
351
+ 'sanitizeCallback' => [Settings::className(), 'sanitizeSkipHeadingLevel'],
352
+ ],
353
+ 'skipHeadingText' => [
354
+ 'label' => esc_html__('By Text', 'lwptoc'),
355
+ 'widget' => function ($field) {
356
+ $value = Core::$plugin->settings->getValue($field['group'], $field['id'], '', false);
357
+ echo Html::textarea($field['name'], Core::$plugin->skipHeadingTextToMultipleString((string)$value), [
358
+ 'class' => 'regular-text',
359
+ 'rows' => 5,
360
+ ]);
361
+ echo '<p class="description">';
362
+ echo esc_html__('Specify headings (one per line) to be excluded from the table of contents.', 'lwptoc');
363
+ echo '<br>';
364
+ echo sprintf(
365
+ esc_html__('Use an asterisk %s as a wildcard to match any text.', 'lwptoc'),
366
+ '<code>*</code>'
367
+ );
368
+ echo '</p>';
369
+ },
370
+ 'sanitizeCallback' => function ($value) {
371
+ return Core::$plugin->skipHeadingTextMultipleStringToString((string)$value);
372
+ },
373
+ ],
374
+ ],
375
+ ],
376
  ],
377
  ],
378
  ];
core/helpers/Html.php CHANGED
@@ -148,6 +148,12 @@ class Html
148
  return static::input('text', $name, $value, $options);
149
  }
150
 
 
 
 
 
 
 
151
  /**
152
  * @param string $name
153
  * @param string $value
148
  return static::input('text', $name, $value, $options);
149
  }
150
 
151
+ public static function textarea($name, $value = null, $options = [])
152
+ {
153
+ $options['name'] = $name;
154
+ return static::tag('textarea', $value, $options);
155
+ }
156
+
157
  /**
158
  * @param string $name
159
  * @param string $value
languages/lwptoc-ru_RU.mo CHANGED
Binary file
languages/lwptoc.pot CHANGED
@@ -1,7 +1,8 @@
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: \n"
4
- "POT-Creation-Date: 2019-04-23 17:49+0300\n"
5
  "PO-Revision-Date: 2019-04-23 17:51+0300\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
@@ -31,68 +32,68 @@ msgstr ""
31
  msgid "Edit"
32
  msgstr ""
33
 
34
- #: admin/Admin.php:127 admin/forms/CustomizeForm.php:213
35
- #: admin/widgets/customizeModal/views/modal.php:48 config/settings.php:283
36
  msgid "Position"
37
  msgstr ""
38
 
39
- #: admin/Admin.php:130 admin/widgets/customizeModal/views/modal.php:71
40
- #: config/settings.php:20
41
  msgid "Minimal Count of Headers"
42
  msgstr ""
43
 
44
- #: admin/Admin.php:133 admin/forms/CustomizeForm.php:209
45
- #: admin/widgets/customizeModal/views/modal.php:94 config/settings.php:32
46
  msgid "Depth"
47
  msgstr ""
48
 
49
- #: admin/Admin.php:136 admin/widgets/customizeModal/views/modal.php:116
50
- #: config/settings.php:41
51
  msgid "Hierarchical View"
52
  msgstr ""
53
 
54
  #: admin/Admin.php:136 admin/Admin.php:145 admin/Admin.php:154
55
  #: admin/Admin.php:157 admin/Admin.php:193
56
- #: admin/widgets/customizeModal/views/modal.php:132
57
- #: admin/widgets/customizeModal/views/modal.php:203
58
- #: admin/widgets/customizeModal/views/modal.php:266
59
- #: admin/widgets/customizeModal/views/modal.php:289
60
- #: admin/widgets/customizeModal/views/modal.php:506
61
  msgid "Enabled"
62
  msgstr ""
63
 
64
  #: admin/Admin.php:136 admin/Admin.php:145 admin/Admin.php:154
65
  #: admin/Admin.php:157 admin/Admin.php:193
66
- #: admin/widgets/customizeModal/views/modal.php:132
67
- #: admin/widgets/customizeModal/views/modal.php:203
68
- #: admin/widgets/customizeModal/views/modal.php:266
69
- #: admin/widgets/customizeModal/views/modal.php:289
70
- #: admin/widgets/customizeModal/views/modal.php:506
71
  msgid "Disabled"
72
  msgstr ""
73
 
74
- #: admin/Admin.php:139 admin/forms/CustomizeForm.php:210
75
- #: admin/widgets/customizeModal/views/modal.php:139 config/settings.php:52
76
  msgid "Numeration"
77
  msgstr ""
78
 
79
- #: admin/Admin.php:142 admin/widgets/customizeModal/views/modal.php:161
80
- #: config/settings.php:67
81
  msgid "Title"
82
  msgstr ""
83
 
84
- #: admin/Admin.php:145 admin/widgets/customizeModal/views/modal.php:187
85
- #: config/settings.php:73
86
  msgid "Toggle Show/Hide"
87
  msgstr ""
88
 
89
- #: admin/Admin.php:148 admin/forms/CustomizeForm.php:211
90
- #: admin/widgets/customizeModal/views/modal.php:210 config/settings.php:85
91
  msgid "Label Show"
92
  msgstr ""
93
 
94
- #: admin/Admin.php:151 admin/forms/CustomizeForm.php:212
95
- #: admin/widgets/customizeModal/views/modal.php:230 config/settings.php:96
96
  msgid "Label Hide"
97
  msgstr ""
98
 
@@ -100,52 +101,57 @@ msgstr ""
100
  msgid "Hide Items"
101
  msgstr ""
102
 
103
- #: admin/Admin.php:157 admin/widgets/customizeModal/views/modal.php:273
104
- #: config/settings.php:124
105
  msgid "Smooth Scroll"
106
  msgstr ""
107
 
108
- #: admin/Admin.php:160 admin/widgets/customizeModal/views/modal.php:296
109
  msgid "Smooth Scroll Offset Top"
110
  msgstr ""
111
 
112
- #: admin/Admin.php:163 admin/widgets/customizeModal/views/modal.php:320
113
- #: config/settings.php:160
114
  msgid "Width"
115
  msgstr ""
116
 
117
- #: admin/Admin.php:166 admin/forms/CustomizeForm.php:214
118
- #: admin/widgets/customizeModal/views/modal.php:343 config/settings.php:172
119
  msgid "Float"
120
  msgstr ""
121
 
122
- #: admin/Admin.php:169 admin/widgets/customizeModal/views/modal.php:365
123
- #: config/settings.php:181
124
  msgid "Title Font Size"
125
  msgstr ""
126
 
127
- #: admin/Admin.php:172 admin/forms/CustomizeForm.php:215
128
- #: admin/widgets/customizeModal/views/modal.php:389 config/settings.php:194
129
  msgid "Title Font Weight"
130
  msgstr ""
131
 
132
- #: admin/Admin.php:175 admin/widgets/customizeModal/views/modal.php:411
133
- #: config/settings.php:203
134
  msgid "Items Font Size"
135
  msgstr ""
136
 
137
- #: admin/Admin.php:178 admin/forms/CustomizeForm.php:216
138
- #: admin/widgets/customizeModal/views/modal.php:435 config/settings.php:216
139
  msgid "Color Scheme"
140
  msgstr ""
141
 
142
- #: admin/Admin.php:193 admin/widgets/customizeModal/views/modal.php:490
143
- #: config/settings.php:331
144
  msgid "Wrap table of contents with <!--noindex--> tag"
145
  msgstr ""
146
 
 
 
 
 
147
  #: admin/controllers/EditorBlockController.php:71
148
  #: admin/controllers/ShortcodeController.php:74
 
149
  #: admin/widgets/metabox/views/box.php:26
150
  msgid "empty"
151
  msgstr ""
@@ -158,98 +164,120 @@ msgstr ""
158
  msgid "from scheme"
159
  msgstr ""
160
 
161
- #: admin/widgets/customizeModal/views/modal.php:23
162
- #: admin/widgets/customizeModal/views/modal.php:515
163
  msgid "Cancel"
164
  msgstr ""
165
 
166
- #: admin/widgets/customizeModal/views/modal.php:24
167
  msgid "Customize Table of Contents"
168
  msgstr ""
169
 
170
- #: admin/widgets/customizeModal/views/modal.php:38 config/settings.php:14
171
  msgid "General"
172
  msgstr ""
173
 
174
- #: admin/widgets/customizeModal/views/modal.php:39 config/settings.php:154
175
  msgid "Appearance"
176
  msgstr ""
177
 
178
- #: admin/widgets/customizeModal/views/modal.php:40 config/settings.php:313
179
  msgid "Misc."
180
  msgstr ""
181
 
182
- #: admin/widgets/customizeModal/views/modal.php:49
183
- #: admin/widgets/customizeModal/views/modal.php:72
184
- #: admin/widgets/customizeModal/views/modal.php:95
185
- #: admin/widgets/customizeModal/views/modal.php:117
186
- #: admin/widgets/customizeModal/views/modal.php:140
187
- #: admin/widgets/customizeModal/views/modal.php:162
188
- #: admin/widgets/customizeModal/views/modal.php:188
189
- #: admin/widgets/customizeModal/views/modal.php:211
190
- #: admin/widgets/customizeModal/views/modal.php:231
191
- #: admin/widgets/customizeModal/views/modal.php:251
192
- #: admin/widgets/customizeModal/views/modal.php:274
193
- #: admin/widgets/customizeModal/views/modal.php:297
194
- #: admin/widgets/customizeModal/views/modal.php:321
195
- #: admin/widgets/customizeModal/views/modal.php:344
196
- #: admin/widgets/customizeModal/views/modal.php:366
197
- #: admin/widgets/customizeModal/views/modal.php:390
198
- #: admin/widgets/customizeModal/views/modal.php:412
199
- #: admin/widgets/customizeModal/views/modal.php:436
200
- #: admin/widgets/customizeModal/views/modal.php:466
201
- #: admin/widgets/customizeModal/views/modal.php:491
 
 
202
  msgid "default"
203
  msgstr ""
204
 
205
- #: admin/widgets/customizeModal/views/modal.php:52
206
- #: admin/widgets/customizeModal/views/modal.php:75
207
- #: admin/widgets/customizeModal/views/modal.php:98
208
- #: admin/widgets/customizeModal/views/modal.php:120
209
- #: admin/widgets/customizeModal/views/modal.php:143
210
- #: admin/widgets/customizeModal/views/modal.php:165
211
- #: admin/widgets/customizeModal/views/modal.php:191
212
- #: admin/widgets/customizeModal/views/modal.php:214
213
- #: admin/widgets/customizeModal/views/modal.php:234
214
- #: admin/widgets/customizeModal/views/modal.php:254
215
- #: admin/widgets/customizeModal/views/modal.php:277
216
- #: admin/widgets/customizeModal/views/modal.php:300
217
- #: admin/widgets/customizeModal/views/modal.php:324
218
- #: admin/widgets/customizeModal/views/modal.php:347
219
- #: admin/widgets/customizeModal/views/modal.php:369
220
- #: admin/widgets/customizeModal/views/modal.php:393
221
- #: admin/widgets/customizeModal/views/modal.php:415
222
- #: admin/widgets/customizeModal/views/modal.php:439
223
- #: admin/widgets/customizeModal/views/modal.php:469
224
- #: admin/widgets/customizeModal/views/modal.php:494
 
 
225
  msgid "Click for override default value"
226
  msgstr ""
227
 
228
- #: admin/widgets/customizeModal/views/modal.php:84 config/settings.php:28
229
  msgid ""
230
  "If the count of headers in the post is less, then table of contents is not "
231
  "displayed."
232
  msgstr ""
233
 
234
- #: admin/widgets/customizeModal/views/modal.php:125
235
- #: admin/widgets/customizeModal/views/modal.php:196
236
- #: admin/widgets/customizeModal/views/modal.php:259
237
- #: admin/widgets/customizeModal/views/modal.php:282
238
- #: admin/widgets/customizeModal/views/modal.php:499
239
- #: admin/widgets/metabox/views/box.php:45 config/settings.php:45
240
- #: config/settings.php:77 config/settings.php:128 config/settings.php:275
241
  msgid "Enable"
242
  msgstr ""
243
 
244
- #: admin/widgets/customizeModal/views/modal.php:176
245
  msgid "Without title"
246
  msgstr ""
247
 
248
- #: admin/widgets/customizeModal/views/modal.php:250 config/settings.php:111
249
  msgid "By default, items of contents will be hidden"
250
  msgstr ""
251
 
252
- #: admin/widgets/customizeModal/views/modal.php:518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  msgid "Save"
254
  msgstr ""
255
 
@@ -285,74 +313,86 @@ msgstr ""
285
  msgid "Click \"Enable\" for automatic add table of contents to this post."
286
  msgstr ""
287
 
288
- #: config/settings.php:63
289
  msgid "Header"
290
  msgstr ""
291
 
292
- #: config/settings.php:69 plugin/Settings.php:87
293
  msgid "Contents"
294
  msgstr ""
295
 
296
- #: config/settings.php:92 plugin/Settings.php:103
297
  msgid "show"
298
  msgstr ""
299
 
300
- #: config/settings.php:103 plugin/Settings.php:111
301
  msgid "hide"
302
  msgstr ""
303
 
304
- #: config/settings.php:120
305
  msgid "Behavior"
306
  msgstr ""
307
 
308
- #: config/settings.php:136
309
  msgid "Scroll Offset Top"
310
  msgstr ""
311
 
312
- #: config/settings.php:226
313
  msgid "Override Color Scheme Colors"
314
  msgstr ""
315
 
316
- #: config/settings.php:231
317
  msgid "Background Color"
318
  msgstr ""
319
 
320
- #: config/settings.php:236
321
  msgid "Border Color"
322
  msgstr ""
323
 
324
- #: config/settings.php:241
325
  msgid "Title Color"
326
  msgstr ""
327
 
328
- #: config/settings.php:246
329
  msgid "Link Color"
330
  msgstr ""
331
 
332
- #: config/settings.php:251
333
  msgid "Hover Link Color"
334
  msgstr ""
335
 
336
- #: config/settings.php:256
337
  msgid "Visited Link Color"
338
  msgstr ""
339
 
340
- #: config/settings.php:265
341
  msgid "Auto Insert"
342
  msgstr ""
343
 
344
- #: config/settings.php:271
345
  msgid "Auto Insert Table of Contents"
346
  msgstr ""
347
 
348
- #: config/settings.php:295
349
  msgid "Post Types"
350
  msgstr ""
351
 
352
- #: config/settings.php:318
353
  msgid "Hash Format"
354
  msgstr ""
355
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  #: core/admin/AdminController.php:46
357
  msgid "Sorry, you are not allowed to access this page."
358
  msgstr ""
@@ -445,7 +485,7 @@ msgstr ""
445
  msgid "Heavy"
446
  msgstr ""
447
 
448
- #: plugin/Plugin.php:163
449
  msgid "None"
450
  msgstr ""
451
 
@@ -497,7 +537,7 @@ msgstr ""
497
  msgid "Full Width"
498
  msgstr ""
499
 
500
- #: plugin/Plugin.php:244
501
  msgid ""
502
  "Creates a table of contents for your posts/pages. Works automatically or "
503
  "manually (via shortcode or Gutenberg block)."
1
+ #, fuzzy
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: \n"
5
+ "POT-Creation-Date: 2019-05-08 18:43+0300\n"
6
  "PO-Revision-Date: 2019-04-23 17:51+0300\n"
7
  "Last-Translator: \n"
8
  "Language-Team: \n"
32
  msgid "Edit"
33
  msgstr ""
34
 
35
+ #: admin/Admin.php:127 admin/forms/CustomizeForm.php:229
36
+ #: admin/widgets/customizeModal/views/modal.php:49 config/settings.php:285
37
  msgid "Position"
38
  msgstr ""
39
 
40
+ #: admin/Admin.php:130 admin/widgets/customizeModal/views/modal.php:72
41
+ #: config/settings.php:22
42
  msgid "Minimal Count of Headers"
43
  msgstr ""
44
 
45
+ #: admin/Admin.php:133 admin/forms/CustomizeForm.php:225
46
+ #: admin/widgets/customizeModal/views/modal.php:95 config/settings.php:34
47
  msgid "Depth"
48
  msgstr ""
49
 
50
+ #: admin/Admin.php:136 admin/widgets/customizeModal/views/modal.php:117
51
+ #: config/settings.php:43
52
  msgid "Hierarchical View"
53
  msgstr ""
54
 
55
  #: admin/Admin.php:136 admin/Admin.php:145 admin/Admin.php:154
56
  #: admin/Admin.php:157 admin/Admin.php:193
57
+ #: admin/widgets/customizeModal/views/modal.php:133
58
+ #: admin/widgets/customizeModal/views/modal.php:204
59
+ #: admin/widgets/customizeModal/views/modal.php:267
60
+ #: admin/widgets/customizeModal/views/modal.php:290
61
+ #: admin/widgets/customizeModal/views/modal.php:507
62
  msgid "Enabled"
63
  msgstr ""
64
 
65
  #: admin/Admin.php:136 admin/Admin.php:145 admin/Admin.php:154
66
  #: admin/Admin.php:157 admin/Admin.php:193
67
+ #: admin/widgets/customizeModal/views/modal.php:133
68
+ #: admin/widgets/customizeModal/views/modal.php:204
69
+ #: admin/widgets/customizeModal/views/modal.php:267
70
+ #: admin/widgets/customizeModal/views/modal.php:290
71
+ #: admin/widgets/customizeModal/views/modal.php:507
72
  msgid "Disabled"
73
  msgstr ""
74
 
75
+ #: admin/Admin.php:139 admin/forms/CustomizeForm.php:226
76
+ #: admin/widgets/customizeModal/views/modal.php:140 config/settings.php:54
77
  msgid "Numeration"
78
  msgstr ""
79
 
80
+ #: admin/Admin.php:142 admin/widgets/customizeModal/views/modal.php:162
81
+ #: config/settings.php:69
82
  msgid "Title"
83
  msgstr ""
84
 
85
+ #: admin/Admin.php:145 admin/widgets/customizeModal/views/modal.php:188
86
+ #: config/settings.php:75
87
  msgid "Toggle Show/Hide"
88
  msgstr ""
89
 
90
+ #: admin/Admin.php:148 admin/forms/CustomizeForm.php:227
91
+ #: admin/widgets/customizeModal/views/modal.php:211 config/settings.php:87
92
  msgid "Label Show"
93
  msgstr ""
94
 
95
+ #: admin/Admin.php:151 admin/forms/CustomizeForm.php:228
96
+ #: admin/widgets/customizeModal/views/modal.php:231 config/settings.php:98
97
  msgid "Label Hide"
98
  msgstr ""
99
 
101
  msgid "Hide Items"
102
  msgstr ""
103
 
104
+ #: admin/Admin.php:157 admin/widgets/customizeModal/views/modal.php:274
105
+ #: config/settings.php:126
106
  msgid "Smooth Scroll"
107
  msgstr ""
108
 
109
+ #: admin/Admin.php:160 admin/widgets/customizeModal/views/modal.php:297
110
  msgid "Smooth Scroll Offset Top"
111
  msgstr ""
112
 
113
+ #: admin/Admin.php:163 admin/widgets/customizeModal/views/modal.php:321
114
+ #: config/settings.php:162
115
  msgid "Width"
116
  msgstr ""
117
 
118
+ #: admin/Admin.php:166 admin/forms/CustomizeForm.php:230
119
+ #: admin/widgets/customizeModal/views/modal.php:344 config/settings.php:174
120
  msgid "Float"
121
  msgstr ""
122
 
123
+ #: admin/Admin.php:169 admin/widgets/customizeModal/views/modal.php:366
124
+ #: config/settings.php:183
125
  msgid "Title Font Size"
126
  msgstr ""
127
 
128
+ #: admin/Admin.php:172 admin/forms/CustomizeForm.php:231
129
+ #: admin/widgets/customizeModal/views/modal.php:390 config/settings.php:196
130
  msgid "Title Font Weight"
131
  msgstr ""
132
 
133
+ #: admin/Admin.php:175 admin/widgets/customizeModal/views/modal.php:412
134
+ #: config/settings.php:205
135
  msgid "Items Font Size"
136
  msgstr ""
137
 
138
+ #: admin/Admin.php:178 admin/forms/CustomizeForm.php:232
139
+ #: admin/widgets/customizeModal/views/modal.php:436 config/settings.php:218
140
  msgid "Color Scheme"
141
  msgstr ""
142
 
143
+ #: admin/Admin.php:193 admin/widgets/customizeModal/views/modal.php:491
144
+ #: config/settings.php:333
145
  msgid "Wrap table of contents with <!--noindex--> tag"
146
  msgstr ""
147
 
148
+ #: admin/Admin.php:196 admin/Admin.php:199
149
+ msgid "Skip headings"
150
+ msgstr ""
151
+
152
  #: admin/controllers/EditorBlockController.php:71
153
  #: admin/controllers/ShortcodeController.php:74
154
+ #: admin/widgets/customizeModal/views/modal.php:566
155
  #: admin/widgets/metabox/views/box.php:26
156
  msgid "empty"
157
  msgstr ""
164
  msgid "from scheme"
165
  msgstr ""
166
 
167
+ #: admin/widgets/customizeModal/views/modal.php:24
168
+ #: admin/widgets/customizeModal/views/modal.php:579
169
  msgid "Cancel"
170
  msgstr ""
171
 
172
+ #: admin/widgets/customizeModal/views/modal.php:25
173
  msgid "Customize Table of Contents"
174
  msgstr ""
175
 
176
+ #: admin/widgets/customizeModal/views/modal.php:39 config/settings.php:16
177
  msgid "General"
178
  msgstr ""
179
 
180
+ #: admin/widgets/customizeModal/views/modal.php:40 config/settings.php:156
181
  msgid "Appearance"
182
  msgstr ""
183
 
184
+ #: admin/widgets/customizeModal/views/modal.php:41 config/settings.php:315
185
  msgid "Misc."
186
  msgstr ""
187
 
188
+ #: admin/widgets/customizeModal/views/modal.php:50
189
+ #: admin/widgets/customizeModal/views/modal.php:73
190
+ #: admin/widgets/customizeModal/views/modal.php:96
191
+ #: admin/widgets/customizeModal/views/modal.php:118
192
+ #: admin/widgets/customizeModal/views/modal.php:141
193
+ #: admin/widgets/customizeModal/views/modal.php:163
194
+ #: admin/widgets/customizeModal/views/modal.php:189
195
+ #: admin/widgets/customizeModal/views/modal.php:212
196
+ #: admin/widgets/customizeModal/views/modal.php:232
197
+ #: admin/widgets/customizeModal/views/modal.php:252
198
+ #: admin/widgets/customizeModal/views/modal.php:275
199
+ #: admin/widgets/customizeModal/views/modal.php:298
200
+ #: admin/widgets/customizeModal/views/modal.php:322
201
+ #: admin/widgets/customizeModal/views/modal.php:345
202
+ #: admin/widgets/customizeModal/views/modal.php:367
203
+ #: admin/widgets/customizeModal/views/modal.php:391
204
+ #: admin/widgets/customizeModal/views/modal.php:413
205
+ #: admin/widgets/customizeModal/views/modal.php:437
206
+ #: admin/widgets/customizeModal/views/modal.php:467
207
+ #: admin/widgets/customizeModal/views/modal.php:492
208
+ #: admin/widgets/customizeModal/views/modal.php:515
209
+ #: admin/widgets/customizeModal/views/modal.php:538
210
  msgid "default"
211
  msgstr ""
212
 
213
+ #: admin/widgets/customizeModal/views/modal.php:53
214
+ #: admin/widgets/customizeModal/views/modal.php:76
215
+ #: admin/widgets/customizeModal/views/modal.php:99
216
+ #: admin/widgets/customizeModal/views/modal.php:121
217
+ #: admin/widgets/customizeModal/views/modal.php:144
218
+ #: admin/widgets/customizeModal/views/modal.php:166
219
+ #: admin/widgets/customizeModal/views/modal.php:192
220
+ #: admin/widgets/customizeModal/views/modal.php:215
221
+ #: admin/widgets/customizeModal/views/modal.php:235
222
+ #: admin/widgets/customizeModal/views/modal.php:255
223
+ #: admin/widgets/customizeModal/views/modal.php:278
224
+ #: admin/widgets/customizeModal/views/modal.php:301
225
+ #: admin/widgets/customizeModal/views/modal.php:325
226
+ #: admin/widgets/customizeModal/views/modal.php:348
227
+ #: admin/widgets/customizeModal/views/modal.php:370
228
+ #: admin/widgets/customizeModal/views/modal.php:394
229
+ #: admin/widgets/customizeModal/views/modal.php:416
230
+ #: admin/widgets/customizeModal/views/modal.php:440
231
+ #: admin/widgets/customizeModal/views/modal.php:470
232
+ #: admin/widgets/customizeModal/views/modal.php:495
233
+ #: admin/widgets/customizeModal/views/modal.php:518
234
+ #: admin/widgets/customizeModal/views/modal.php:541
235
  msgid "Click for override default value"
236
  msgstr ""
237
 
238
+ #: admin/widgets/customizeModal/views/modal.php:85 config/settings.php:30
239
  msgid ""
240
  "If the count of headers in the post is less, then table of contents is not "
241
  "displayed."
242
  msgstr ""
243
 
244
+ #: admin/widgets/customizeModal/views/modal.php:126
245
+ #: admin/widgets/customizeModal/views/modal.php:197
246
+ #: admin/widgets/customizeModal/views/modal.php:260
247
+ #: admin/widgets/customizeModal/views/modal.php:283
248
+ #: admin/widgets/customizeModal/views/modal.php:500
249
+ #: admin/widgets/metabox/views/box.php:45 config/settings.php:47
250
+ #: config/settings.php:79 config/settings.php:130 config/settings.php:277
251
  msgid "Enable"
252
  msgstr ""
253
 
254
+ #: admin/widgets/customizeModal/views/modal.php:177
255
  msgid "Without title"
256
  msgstr ""
257
 
258
+ #: admin/widgets/customizeModal/views/modal.php:251 config/settings.php:113
259
  msgid "By default, items of contents will be hidden"
260
  msgstr ""
261
 
262
+ #: admin/widgets/customizeModal/views/modal.php:514
263
+ msgid "Skip heading by level"
264
+ msgstr ""
265
+
266
+ #: admin/widgets/customizeModal/views/modal.php:537
267
+ msgid "Skip heading by text"
268
+ msgstr ""
269
+
270
+ #: admin/widgets/customizeModal/views/modal.php:551 config/settings.php:362
271
+ msgid ""
272
+ "Specify headings (one per line) to be excluded from the table of contents."
273
+ msgstr ""
274
+
275
+ #: admin/widgets/customizeModal/views/modal.php:554 config/settings.php:365
276
+ #, php-format
277
+ msgid "Use an asterisk %s as a wildcard to match any text."
278
+ msgstr ""
279
+
280
+ #: admin/widgets/customizeModal/views/modal.php:582
281
  msgid "Save"
282
  msgstr ""
283
 
313
  msgid "Click \"Enable\" for automatic add table of contents to this post."
314
  msgstr ""
315
 
316
+ #: config/settings.php:65
317
  msgid "Header"
318
  msgstr ""
319
 
320
+ #: config/settings.php:71 plugin/Settings.php:87
321
  msgid "Contents"
322
  msgstr ""
323
 
324
+ #: config/settings.php:94 plugin/Settings.php:103
325
  msgid "show"
326
  msgstr ""
327
 
328
+ #: config/settings.php:105 plugin/Settings.php:111
329
  msgid "hide"
330
  msgstr ""
331
 
332
+ #: config/settings.php:122
333
  msgid "Behavior"
334
  msgstr ""
335
 
336
+ #: config/settings.php:138
337
  msgid "Scroll Offset Top"
338
  msgstr ""
339
 
340
+ #: config/settings.php:228
341
  msgid "Override Color Scheme Colors"
342
  msgstr ""
343
 
344
+ #: config/settings.php:233
345
  msgid "Background Color"
346
  msgstr ""
347
 
348
+ #: config/settings.php:238
349
  msgid "Border Color"
350
  msgstr ""
351
 
352
+ #: config/settings.php:243
353
  msgid "Title Color"
354
  msgstr ""
355
 
356
+ #: config/settings.php:248
357
  msgid "Link Color"
358
  msgstr ""
359
 
360
+ #: config/settings.php:253
361
  msgid "Hover Link Color"
362
  msgstr ""
363
 
364
+ #: config/settings.php:258
365
  msgid "Visited Link Color"
366
  msgstr ""
367
 
368
+ #: config/settings.php:267
369
  msgid "Auto Insert"
370
  msgstr ""
371
 
372
+ #: config/settings.php:273
373
  msgid "Auto Insert Table of Contents"
374
  msgstr ""
375
 
376
+ #: config/settings.php:297
377
  msgid "Post Types"
378
  msgstr ""
379
 
380
+ #: config/settings.php:320
381
  msgid "Hash Format"
382
  msgstr ""
383
 
384
+ #: config/settings.php:341
385
+ msgid "Skip Headings"
386
+ msgstr ""
387
+
388
+ #: config/settings.php:344
389
+ msgid "By Level"
390
+ msgstr ""
391
+
392
+ #: config/settings.php:354
393
+ msgid "By Text"
394
+ msgstr ""
395
+
396
  #: core/admin/AdminController.php:46
397
  msgid "Sorry, you are not allowed to access this page."
398
  msgstr ""
485
  msgid "Heavy"
486
  msgstr ""
487
 
488
+ #: plugin/Plugin.php:163 plugin/Plugin.php:290
489
  msgid "None"
490
  msgstr ""
491
 
537
  msgid "Full Width"
538
  msgstr ""
539
 
540
+ #: plugin/Plugin.php:366
541
  msgid ""
542
  "Creates a table of contents for your posts/pages. Works automatically or "
543
  "manually (via shortcode or Gutenberg block)."
luckywp-table-of-contents.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: LuckyWP Table of Contents
4
  Plugin URI: https://theluckywp.com/product/table-of-contents/
5
  Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode or Gutenberg block).
6
- Version: 1.2.2
7
  Author: LuckyWP
8
  Author URI: https://theluckywp.com/
9
  Text Domain: lwptoc
@@ -29,6 +29,6 @@ $lwptocAutoloader->register();
29
  $lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
30
 
31
  $config = require(__DIR__ . '/config/plugin.php');
32
- (new \luckywp\tableOfContents\plugin\Plugin($config))->run('1.2.2', __FILE__, 'lwptoc_');
33
 
34
  require_once __DIR__ . '/functions.php';
3
  Plugin Name: LuckyWP Table of Contents
4
  Plugin URI: https://theluckywp.com/product/table-of-contents/
5
  Description: Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode or Gutenberg block).
6
+ Version: 1.3.0
7
  Author: LuckyWP
8
  Author URI: https://theluckywp.com/
9
  Text Domain: lwptoc
29
  $lwptocAutoloader->addNamespace('luckywp\tableOfContents', __DIR__);
30
 
31
  $config = require(__DIR__ . '/config/plugin.php');
32
+ (new \luckywp\tableOfContents\plugin\Plugin($config))->run('1.3.0', __FILE__, 'lwptoc_');
33
 
34
  require_once __DIR__ . '/functions.php';
plugin/Plugin.php CHANGED
@@ -239,6 +239,128 @@ class Plugin extends BasePlugin
239
  return $fontSize == 'default' ? esc_html__('Default', 'lwptoc') : $fontSize;
240
  }
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  private function pluginI18n()
243
  {
244
  __('Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode or Gutenberg block).', 'lwptdr');
239
  return $fontSize == 'default' ? esc_html__('Default', 'lwptoc') : $fontSize;
240
  }
241
 
242
+ /**
243
+ * @return array
244
+ */
245
+ public function getHeadingsList()
246
+ {
247
+ return [
248
+ 'h1' => 'H1',
249
+ 'h2' => 'H2',
250
+ 'h3' => 'H3',
251
+ 'h4' => 'H4',
252
+ 'h5' => 'H5',
253
+ 'h6' => 'H6',
254
+ ];
255
+ }
256
+
257
+ /**
258
+ * @param string|array $value
259
+ * @return array
260
+ */
261
+ public function skipHeadingLevelToArray($value)
262
+ {
263
+ if (is_array($value)) {
264
+ $ids = $value;
265
+ } else {
266
+ $ids = explode(',', (string)$value);
267
+ $ids = array_map('trim', $ids);
268
+ $ids = array_map('strtolower', $ids);
269
+ }
270
+ $list = $this->getHeadingsList();
271
+ return array_filter($ids, function ($id) use ($list) {
272
+ return array_key_exists($id, $list);
273
+ });
274
+ }
275
+
276
+ /**
277
+ * @param string $value
278
+ * @return string
279
+ */
280
+ public function skipHeadingLevelToLabel($value)
281
+ {
282
+ $ids = $this->skipHeadingLevelToArray($value);
283
+ $labels = [];
284
+ if ($ids) {
285
+ $list = $this->getHeadingsList();
286
+ foreach ($ids as $id) {
287
+ $labels[] = $list[$id];
288
+ }
289
+ }
290
+ return $labels ? implode(', ', $labels) : esc_html__('None', 'lwptoc');
291
+ }
292
+
293
+ /**
294
+ * @param string $string
295
+ * @return array
296
+ */
297
+ public function skipHeadingTextToArray($string)
298
+ {
299
+ $string = str_replace('\|', '%%lwptocplug%%', $string);
300
+ $els = explode('|', $string);
301
+ $els = array_map('trim', $els);
302
+ $els = array_filter($els, function ($el) {
303
+ return $el != '';
304
+ });
305
+ $els = array_map(function ($el) {
306
+ return str_replace('%%lwptocplug%%', '|', $el);
307
+ }, $els);
308
+ return $els;
309
+ }
310
+
311
+ /**
312
+ * @param string $string
313
+ * @return string
314
+ */
315
+ public function skipHeadingTextToMultipleString($string)
316
+ {
317
+ return implode(PHP_EOL, $this->skipHeadingTextToArray($string));
318
+ }
319
+
320
+ /**
321
+ * @param $string
322
+ * @return string
323
+ */
324
+ public function skipHeadingTextMultipleStringToString($string)
325
+ {
326
+ $els = explode(PHP_EOL, $string);
327
+ $els = array_map('trim', $els);
328
+ $els = array_filter($els, function ($el) {
329
+ return $el != '';
330
+ });
331
+ $els = array_map(function ($el) {
332
+ return str_replace('|', '\|', $el);
333
+ }, $els);
334
+ return implode('|', $els);
335
+ }
336
+
337
+ /**
338
+ * @param string|array $src
339
+ * @return string|false
340
+ */
341
+ public function skipHeadingTextToRegex($src)
342
+ {
343
+ if (!is_array($src)) {
344
+ $src = $this->skipHeadingTextToArray($src);
345
+ }
346
+ $regex = [];
347
+ foreach ($src as $t) {
348
+ $t = strtr($t, [
349
+ '\\\\' => '%%lwptocslash%%',
350
+ '\*' => '%%lwptocstar%%',
351
+ ]);
352
+ $t = str_replace('*', '___lwptocany___', $t);
353
+ $t = strtr($t, [
354
+ '%%lwptocslash%%' => '\\',
355
+ '%%lwptocstar%%' => '*',
356
+ ]);
357
+ $t = preg_quote($t);
358
+ $t = str_replace('___lwptocany___', '.*', $t);
359
+ $regex[] = $t;
360
+ }
361
+ return $regex ? '#^(' . implode('|', $regex) . ')$#i' : false;
362
+ }
363
+
364
  private function pluginI18n()
365
  {
366
  __('Creates a table of contents for your posts/pages. Works automatically or manually (via shortcode or Gutenberg block).', 'lwptdr');
plugin/PostSettings.php CHANGED
@@ -139,6 +139,16 @@ class PostSettings extends BaseObject
139
  */
140
  public $wrapNoindex;
141
 
 
 
 
 
 
 
 
 
 
 
142
  /**
143
  * @var int
144
  */
@@ -180,6 +190,8 @@ class PostSettings extends BaseObject
180
  $this->hoverLinkColor = ArrayHelper::getValue($data, 'hoverLinkColor');
181
  $this->visitedLinkColor = ArrayHelper::getValue($data, 'visitedLinkColor');
182
  $this->wrapNoindex = ArrayHelper::getValue($data, 'wrapNoindex');
 
 
183
  }
184
  }
185
  }
@@ -262,6 +274,12 @@ class PostSettings extends BaseObject
262
  if ($this->wrapNoindex !== null) {
263
  $data['wrapNoindex'] = (bool)$this->wrapNoindex;
264
  }
 
 
 
 
 
 
265
  if ($data || !$this->enabled) {
266
  $data['enabled'] = $this->enabled;
267
  update_post_meta($this->postId, '_lwptoc_settings', $data);
139
  */
140
  public $wrapNoindex;
141
 
142
+ /**
143
+ * @var string|null
144
+ */
145
+ public $skipHeadingLevel;
146
+
147
+ /**
148
+ * @var string|null
149
+ */
150
+ public $skipHeadingText;
151
+
152
  /**
153
  * @var int
154
  */
190
  $this->hoverLinkColor = ArrayHelper::getValue($data, 'hoverLinkColor');
191
  $this->visitedLinkColor = ArrayHelper::getValue($data, 'visitedLinkColor');
192
  $this->wrapNoindex = ArrayHelper::getValue($data, 'wrapNoindex');
193
+ $this->skipHeadingLevel = ArrayHelper::getValue($data, 'skipHeadingLevel');
194
+ $this->skipHeadingText = ArrayHelper::getValue($data, 'skipHeadingText');
195
  }
196
  }
197
  }
274
  if ($this->wrapNoindex !== null) {
275
  $data['wrapNoindex'] = (bool)$this->wrapNoindex;
276
  }
277
+ if ($this->skipHeadingLevel !== null) {
278
+ $data['skipHeadingLevel'] = $this->skipHeadingLevel;
279
+ }
280
+ if ($this->skipHeadingText !== null) {
281
+ $data['skipHeadingText'] = wp_slash($this->skipHeadingText);
282
+ }
283
  if ($data || !$this->enabled) {
284
  $data['enabled'] = $this->enabled;
285
  update_post_meta($this->postId, '_lwptoc_settings', $data);
plugin/Settings.php CHANGED
@@ -292,6 +292,31 @@ class Settings extends \luckywp\tableOfContents\core\wp\Settings
292
  return (bool)$this->getValue('misc', 'wrapNoindex', false);
293
  }
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  /**
296
  * @param string $value
297
  * @return string
292
  return (bool)$this->getValue('misc', 'wrapNoindex', false);
293
  }
294
 
295
+ /**
296
+ * @return string
297
+ */
298
+ public function getMiscSkipHeadingLevel()
299
+ {
300
+ return static::sanitizeSkipHeadingLevel($this->getValue('misc', 'skipHeadingLevel', false));
301
+ }
302
+
303
+ /**
304
+ * @param mixed $value
305
+ * @return string
306
+ */
307
+ public static function sanitizeSkipHeadingLevel($value)
308
+ {
309
+ return implode(',', Core::$plugin->skipHeadingLevelToArray($value));
310
+ }
311
+
312
+ /**
313
+ * @return string
314
+ */
315
+ public function getMiscSkipHeadingText()
316
+ {
317
+ return (string)$this->getValue('misc', 'skipHeadingText', false);
318
+ }
319
+
320
  /**
321
  * @param string $value
322
  * @return string
plugin/Shortcode.php CHANGED
@@ -29,6 +29,11 @@ class Shortcode extends BaseObject
29
  */
30
  protected $headers;
31
 
 
 
 
 
 
32
  /**
33
  * @var int
34
  */
@@ -89,6 +94,8 @@ class Shortcode extends BaseObject
89
  'hoverLinkColor',
90
  'visitedLinkColor',
91
  'wrapNoindex',
 
 
92
  ] as $var) {
93
  if (!array_key_exists(strtolower($var), $attrs)) {
94
  $attrs[strtolower($var)] = $postSettings->$var;
@@ -112,6 +119,14 @@ class Shortcode extends BaseObject
112
  return $this->_tag;
113
  }
114
 
 
 
 
 
 
 
 
 
115
  /**
116
  * @param string $content
117
  * @return string
@@ -122,12 +137,80 @@ class Shortcode extends BaseObject
122
  $this->idCounter = 0;
123
  $this->ids = [];
124
  $this->headers = [];
125
- $content = preg_replace_callback('#<h([1-6])(.*?)>(.*?)</h\d>#', [$this, 'processHeaders'], $content);
126
- $content = preg_replace_callback('/' . get_shortcode_regex() . '/s', [$this, 'doShortcode'], $content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
  return $content;
129
  }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  /**
132
  * Выводить ли содержание?
133
  * @param string $content
@@ -142,10 +225,16 @@ class Shortcode extends BaseObject
142
  /**
143
  * Сбор данных и добавление якорей к заголовкам
144
  * @param array $m
 
145
  * @return string
146
  */
147
- public function processHeaders($m)
148
  {
 
 
 
 
 
149
  switch (Core::$plugin->settings->getMiscHashFormat()) {
150
  case 'counter':
151
  $id = 'lwptoc' . ++$this->idCounter;
@@ -166,7 +255,7 @@ class Shortcode extends BaseObject
166
  $header = [
167
  'id' => $id,
168
  'index' => (int)$m[1],
169
- 'label' => strip_tags($m[3]),
170
  ];
171
  $this->headers[] = $header;
172
 
@@ -198,19 +287,6 @@ class Shortcode extends BaseObject
198
  return $id ? $id : 'lwptoc';
199
  }
200
 
201
- /**
202
- * Заменить шорткод на блок с содержанием
203
- * @param array $m
204
- * @return string
205
- */
206
- public function doShortcode($m)
207
- {
208
- if ($m[2] == $this->getTag()) {
209
- return $this->shortcode(shortcode_parse_atts($m[3]));
210
- }
211
- return $m[0];
212
- }
213
-
214
  /**
215
  * @param array $attrs
216
  * @return string
@@ -229,9 +305,17 @@ class Shortcode extends BaseObject
229
  return '';
230
  }
231
 
 
 
 
232
  $items = [];
233
  $tree = [];
234
  foreach ($this->headers as $header) {
 
 
 
 
 
235
  $node = null;
236
  while (count($tree) && ($node === null)) {
237
  end($tree);
@@ -472,7 +556,7 @@ class Shortcode extends BaseObject
472
  foreach ($attrs as $k => $v) {
473
  if ($v !== null) {
474
  if (is_string($v)) {
475
- $v = str_replace('"', '&quot;', $v);
476
  } elseif (is_bool($v)) {
477
  $v = $v ? 1 : 0;
478
  }
29
  */
30
  protected $headers;
31
 
32
+ /**
33
+ * @var array
34
+ */
35
+ protected $shortcodesAttrs;
36
+
37
  /**
38
  * @var int
39
  */
94
  'hoverLinkColor',
95
  'visitedLinkColor',
96
  'wrapNoindex',
97
+ 'skipHeadingLevel',
98
+ 'skipHeadingText',
99
  ] as $var) {
100
  if (!array_key_exists(strtolower($var), $attrs)) {
101
  $attrs[strtolower($var)] = $postSettings->$var;
119
  return $this->_tag;
120
  }
121
 
122
+ /**
123
+ * @return string
124
+ */
125
+ protected function getShortcodeRegex()
126
+ {
127
+ return '/' . get_shortcode_regex([$this->getTag()]) . '/s';
128
+ }
129
+
130
  /**
131
  * @param string $content
132
  * @return string
137
  $this->idCounter = 0;
138
  $this->ids = [];
139
  $this->headers = [];
140
+
141
+ $this->shortcodesAttrs = [];
142
+ preg_match_all($this->getShortcodeRegex(), $content, $matches);
143
+ foreach ($matches[3] as $match) {
144
+ $this->shortcodesAttrs[] = shortcode_parse_atts($match);
145
+ }
146
+
147
+ $headingsRegex = $this->makeHeadingsRegex();
148
+ if ($headingsRegex) {
149
+ $skipText = [];
150
+ foreach ($this->shortcodesAttrs as $attrs) {
151
+ if (array_key_exists('skipheadingtext', $attrs)) {
152
+ $skipText[] = Core::$plugin->skipHeadingTextToArray($attrs['skipheadingtext']);
153
+ } else {
154
+ $skipText[] = Core::$plugin->skipHeadingTextToArray(Core::$plugin->settings->getMiscSkipHeadingText());
155
+ }
156
+ }
157
+ if (!$skipText) {
158
+ $skipText[] = Core::$plugin->skipHeadingTextToArray(Core::$plugin->settings->getMiscSkipHeadingText());
159
+ }
160
+ if (count($skipText) > 1) {
161
+ $skipText = call_user_func_array('array_intersect', $skipText);
162
+ } else {
163
+ $skipText = reset($skipText);
164
+ }
165
+ $skipRegex = Core::$plugin->skipHeadingTextToRegex($skipText);
166
+ $content = preg_replace_callback($headingsRegex, function ($m) use ($skipRegex) {
167
+ return $this->processHeaders($m, $skipRegex);
168
+ }, $content);
169
+ }
170
+
171
+ $content = preg_replace_callback($this->getShortcodeRegex(), function ($m) {
172
+ return $this->shortcode(shortcode_parse_atts($m[3]));
173
+ }, $content);
174
  }
175
  return $content;
176
  }
177
 
178
+ /**
179
+ * @return string|false
180
+ */
181
+ protected function makeHeadingsRegex()
182
+ {
183
+ $skipLevels = [];
184
+ foreach ($this->shortcodesAttrs as $attrs) {
185
+ if (array_key_exists('skipheadinglevel', $attrs)) {
186
+ $skipLevels[] = Core::$plugin->skipHeadingLevelToArray($attrs['skipheadinglevel']);
187
+ } else {
188
+ $skipLevels[] = Core::$plugin->skipHeadingLevelToArray(Core::$plugin->settings->getMiscSkipHeadingLevel());
189
+ }
190
+ }
191
+ if (!$skipLevels) {
192
+ $skipLevels[] = Core::$plugin->skipHeadingLevelToArray(Core::$plugin->settings->getMiscSkipHeadingLevel());
193
+ }
194
+ if (count($skipLevels) > 1) {
195
+ $skipLevels = call_user_func_array('array_intersect', $skipLevels);
196
+ } else {
197
+ $skipLevels = reset($skipLevels);
198
+ }
199
+
200
+ $levels = [];
201
+ foreach ([1, 2, 3, 4, 5, 6] as $level) {
202
+ if (in_array('h' . $level, $skipLevels)) {
203
+ continue;
204
+ }
205
+ $levels[] = $level;
206
+ }
207
+ if (!$levels) {
208
+ return false;
209
+ }
210
+
211
+ return '#<h([' . implode('', $levels) . '])(.*?)>(.*?)</h\d>#';
212
+ }
213
+
214
  /**
215
  * Выводить ли содержание?
216
  * @param string $content
225
  /**
226
  * Сбор данных и добавление якорей к заголовкам
227
  * @param array $m
228
+ * @param string|false $skipRegex
229
  * @return string
230
  */
231
+ public function processHeaders($m, $skipRegex)
232
  {
233
+ $label = trim(strip_tags($m[3]));
234
+ if ($skipRegex && preg_match($skipRegex, $label)) {
235
+ return $m[0];
236
+ }
237
+
238
  switch (Core::$plugin->settings->getMiscHashFormat()) {
239
  case 'counter':
240
  $id = 'lwptoc' . ++$this->idCounter;
255
  $header = [
256
  'id' => $id,
257
  'index' => (int)$m[1],
258
+ 'label' => $label,
259
  ];
260
  $this->headers[] = $header;
261
 
287
  return $id ? $id : 'lwptoc';
288
  }
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  /**
291
  * @param array $attrs
292
  * @return string
305
  return '';
306
  }
307
 
308
+ $skipHeadingLevels = Core::$plugin->skipHeadingLevelToArray(ArrayHelper::getValue($attrs, 'skipheadinglevel', Core::$plugin->settings->getMiscSkipHeadingLevel()));
309
+ $skipHeadingRegex = Core::$plugin->skipHeadingTextToRegex(ArrayHelper::getValue($attrs, 'skipheadingtext', Core::$plugin->settings->getMiscSkipHeadingText()));
310
+
311
  $items = [];
312
  $tree = [];
313
  foreach ($this->headers as $header) {
314
+ if (in_array('h' . $header['index'], $skipHeadingLevels) ||
315
+ ($skipHeadingRegex && preg_match($skipHeadingRegex, $header['label']))
316
+ ) {
317
+ continue;
318
+ }
319
  $node = null;
320
  while (count($tree) && ($node === null)) {
321
  end($tree);
556
  foreach ($attrs as $k => $v) {
557
  if ($v !== null) {
558
  if (is_string($v)) {
559
+ $v = wp_slash(str_replace('"', '&quot;', $v));
560
  } elseif (is_bool($v)) {
561
  $v = $v ? 1 : 0;
562
  }
plugin/editorBlock/editorBlock.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){var o={};function e(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}e.m=t,e.c=o,e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,o){if(1&o&&(t=e(t)),8&o)return t;if(4&o&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&o&&"string"!=typeof t)for(var r in t)e.d(n,r,function(o){return t[o]}.bind(null,r));return n},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,o){return Object.prototype.hasOwnProperty.call(t,o)},e.p="",e(e.s=1)}([function(t,o){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(o){return"function"==typeof Symbol&&"symbol"===e(Symbol.iterator)?t.exports=n=function(t){return e(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)},n(o)}t.exports=n},function(t,o,e){"use strict";e.r(o);var n=e(0),r=e.n(n),i=wp.blocks.registerBlockType,l=wp.element,c=l.createElement,u=l.Fragment,p=wp.editor.BlockControls,s=wp.components,a=s.Toolbar,y=s.IconButton,f=0,d={};i("luckywp/tableofcontents",{title:lwptocMain.tableOfContents,icon:"list-view",category:"common",supports:{customClassName:!1,html:!1},attributes:{min:{type:"integer"},depth:{type:"integer"},hierarchical:{type:"boolean"},numeration:{type:"string"},title:{type:"string"},toggle:{type:"boolean"},labelShow:{type:"string"},labelHide:{type:"string"},hideItems:{type:"boolean"},smoothScroll:{type:"boolean"},smoothScrollOffset:{type:"integer"},width:{type:"string"},float:{type:"string"},titleFontSize:{type:"string"},titleFontWeight:{type:"string"},itemsFontSize:{type:"string"},colorScheme:{type:"string"},backgroundColor:{type:"string"},borderColor:{type:"string"},titleColor:{type:"string"},linkColor:{type:"string"},hoverLinkColor:{type:"string"},visitedLinkColor:{type:"string"},wrapNoindex:{type:"boolean"}},edit:function(t){var o=t.attributes,e=t.setAttributes,n={};$.each(o,function(t,o){r()(o)==r()(!0)&&(o=o?1:0),n[t]=o});var i="lwptocEditorBlock"+ ++f,l=JSON.stringify(o);return void 0===d[l]&&($.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_block_view",attrs:n},success:function(t){d[l]=t,$("#"+i).replaceWith(t)}}),d[l]='<div class="lwptocEditorBlock_title lwptocEditorBlock_title-loading" id="'+i+'">'+lwptocMain.tableOfContents+"</div>"),c(u,null,c(p,null,c(a,null,c(y,{label:lwptocMain.Edit,icon:"edit",onClick:function(){$(document).one("lwptocEditorBlockChanged",function(t,o){_.each(o,function(t,e){null===t&&(o[e]=void 0)}),e(o)}),$.lwptocCustomize.show({action:"lwptoc_block_edit",attrs:n,postId:lwptocMain.postId},function(){$(document).off("lwptocEditorBlockChanged")})}}))),c("div",{class:"lwptocEditorBlock",dangerouslySetInnerHTML:{__html:d[l]}}))},save:function(t){return t.attributes.shortcode}})}]);
1
+ !function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=1)}([function(t,e){function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(e){return"function"==typeof Symbol&&"symbol"===o(Symbol.iterator)?t.exports=n=function(t){return o(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":o(t)},n(e)}t.exports=n},function(t,e,o){"use strict";o.r(e);var n=o(0),r=o.n(n),i=wp.blocks.registerBlockType,l=wp.element,c=l.createElement,p=l.Fragment,u=wp.editor.BlockControls,s=wp.components,a=s.Toolbar,y=s.IconButton,f=0,d={};i("luckywp/tableofcontents",{title:lwptocMain.tableOfContents,icon:"list-view",category:"common",supports:{customClassName:!1,html:!1},attributes:{min:{type:"integer"},depth:{type:"integer"},hierarchical:{type:"boolean"},numeration:{type:"string"},title:{type:"string"},toggle:{type:"boolean"},labelShow:{type:"string"},labelHide:{type:"string"},hideItems:{type:"boolean"},smoothScroll:{type:"boolean"},smoothScrollOffset:{type:"integer"},width:{type:"string"},float:{type:"string"},titleFontSize:{type:"string"},titleFontWeight:{type:"string"},itemsFontSize:{type:"string"},colorScheme:{type:"string"},backgroundColor:{type:"string"},borderColor:{type:"string"},titleColor:{type:"string"},linkColor:{type:"string"},hoverLinkColor:{type:"string"},visitedLinkColor:{type:"string"},wrapNoindex:{type:"boolean"},skipHeadingLevel:{type:"string"},skipHeadingText:{type:"string"}},edit:function(t){var e=t.attributes,o=t.setAttributes,n={};$.each(e,function(t,e){r()(e)==r()(!0)&&(e=e?1:0),n[t]=e});var i="lwptocEditorBlock"+ ++f,l=JSON.stringify(e);return void 0===d[l]&&($.ajax({url:lwptocMain.ajaxUrl,data:{_ajax_nonce:lwptocMain.nonce,action:"lwptoc_block_view",attrs:n},success:function(t){d[l]=t,$("#"+i).replaceWith(t)}}),d[l]='<div class="lwptocEditorBlock_title lwptocEditorBlock_title-loading" id="'+i+'">'+lwptocMain.tableOfContents+"</div>"),c(p,null,c(u,null,c(a,null,c(y,{label:lwptocMain.Edit,icon:"edit",onClick:function(){$(document).one("lwptocEditorBlockChanged",function(t,e){_.each(e,function(t,o){null===t&&(e[o]=void 0)}),o(e)}),$.lwptocCustomize.show({action:"lwptoc_block_edit",attrs:n,postId:lwptocMain.postId},function(){$(document).off("lwptocEditorBlockChanged")})}}))),c("div",{class:"lwptocEditorBlock",dangerouslySetInnerHTML:{__html:d[l]}}))},save:function(t){return t.attributes.shortcode}})}]);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: theluckywp
3
  Donate link: https://theluckywp.com/product/table-of-contents/
4
  Tags: table of contents, toc, navigation, links, heading
5
  Requires at least: 4.7
6
- Tested up to: 5.1.1
7
- Stable tag: 1.2.2
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -23,6 +23,7 @@ Creates a table of contents for your posts, pages or custom post types. Great cu
23
  * Gutenberg block into "Common Blocks".
24
  * Setting the minimum number of headings to display table of contents.
25
  * Setting the depth of headings for table of contents.
 
26
  * Hierarchical or linear view.
27
  * Numeration items: decimal or roman numbers in order or nested.
28
  * Customizable appearance: width, float, title font size and weight, items font size, colors.
@@ -124,6 +125,9 @@ For non-English websites it is recommended to enable the `Intl` PHP extension.
124
 
125
  == Changelog ==
126
 
 
 
 
127
  = 1.2.2 =
128
  * Bug fix
129
 
3
  Donate link: https://theluckywp.com/product/table-of-contents/
4
  Tags: table of contents, toc, navigation, links, heading
5
  Requires at least: 4.7
6
+ Tested up to: 5.2
7
+ Stable tag: 1.3.0
8
  Requires PHP: 5.6.20
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
23
  * Gutenberg block into "Common Blocks".
24
  * Setting the minimum number of headings to display table of contents.
25
  * Setting the depth of headings for table of contents.
26
+ * Skip headings by level or text.
27
  * Hierarchical or linear view.
28
  * Numeration items: decimal or roman numbers in order or nested.
29
  * Customizable appearance: width, float, title font size and weight, items font size, colors.
125
 
126
  == Changelog ==
127
 
128
+ = 1.3.0 =
129
+ + Skip headings by level or text.
130
+
131
  = 1.2.2 =
132
  * Bug fix
133