PluginProbe
codoc / 0.9.59
codoc v0.9.59
0.9.8.8 0.9.8.9 0.9.9 0.9.9.1 trunk 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.8.1 0.8.2 0.8.3 0.8.4 0.8.6 0.8.7 0.8.8 0.8.9 0.9 0.9.1 0.9.10 0.9.11 All 114 releases
← All changes | class-codoc.php +0 -47 trunk0.9.59 View file →
@@ -45,10 +45,8 @@
45 45 add_action( 'save_post', [$this,'save_post'], 20, 3 );
46 46 add_action( 'added_post_meta', [$this,'updated_post_meta'], 10, 3 );
47 47 add_action( 'updated_post_meta',[$this,'updated_post_meta'], 10, 3 );
48 48 add_action( 'deleted_post_meta',[$this,'deleted_post_meta'], 10, 4 );
49 - // 文字数バリデーションエラーの管理画面通知
50 - add_action( 'admin_notices', [$this,'show_validation_notices'] );
51 49 }
52 50 global $pagenow;
53 51 //管理画面でcodoc認証があり投稿画面の場合
54 52 if (is_admin() and $auth_info and preg_match('/^post/',$pagenow)) {
@@ -1012,39 +1010,8 @@
1012 1010 }
1013 1011 $codoc_settings = get_option(CODOC_SETTINGS_OPTION_NAME);
1014 1012 $post_content = (isset($codoc_settings['do_not_filter_the_content']) and $codoc_settings['do_not_filter_the_content']) ?
1015 1013 $post->post_content : $this->get_filtered_content($post);
1016 -
1017 - // codoc タグ(span/div または Gutenberg ブロック)が含まれていれば API側と統一した文字数検証を行う
1018 - $has_codoc_tag = preg_match('/<(?:span|div)[^>]+data-id="codoc-tag"/', $post_content)
1019 - || preg_match('/wp:codoc\/codoc-block/', $post_content);
1020 - if ($has_codoc_tag) {
1021 - // codoc タグ位置で free / paywalled を分割
1022 - $gutenberg_split = '/(?:<(?:div|p)(?:[^>]+|)>|)<\!-- +wp:codoc\/codoc-block .*<\!-- +\/wp:codoc\/codoc-block +-->(?:<\/(?:div|p)>|)/s';
1023 - $tag_split = '/<(?:span|div)[^>]+data-id="codoc-tag"(?:[^>]+|)>(?:.+|)<\/(?:span|div)>/';
1024 - $end_tag_regex = '/<(?:div|p)>::CODOC_WP_END_PAYWALL::<\/(?:div|p)>/';
1025 - $for_split = preg_split($end_tag_regex, $post_content);
1026 - $for_split = $for_split[0];
1027 - if (preg_match('/wp:codoc\/codoc-block/', $for_split)) {
1028 - $splited = preg_split($gutenberg_split, $for_split);
1029 - } else {
1030 - $splited = preg_split($tag_split, $for_split);
1031 - }
1032 - $body_free = isset($splited[0]) ? $splited[0] : '';
1033 - $body_paywalled = isset($splited[1]) ? $splited[1] : '';
1034 - $errors = $this->util->validate_entry_lengths([
1035 - 'title' => $post->post_title,
1036 - 'body_free' => $body_free,
1037 - 'body_paywalled' => $body_paywalled,
1038 - 'binded_url' => get_permalink($post_ID),
1039 - ]);
1040 - if ($errors) {
1041 - set_transient('codoc_entry_validation_errors', $errors, MINUTE_IN_SECONDS * 5);
1042 - // 同期はスキップ
1043 - return true;
1044 - }
1045 - }
1046 -
1047 1014 $res = $this->util->sync_entry([
1048 1015 "post_title" => $post->post_title,
1049 1016 "post_content" => $post_content,
1050 1017 // password が設定されてる場合は限定公開にする
@@ -1178,22 +1145,8 @@
1178 1145 if (is_array($allowed_block_types) && !in_array('codoc/codoc-block', $allowed_block_types)) {
1179 1146 $allowed_block_types[] = 'codoc/codoc-block';
1180 1147 }
1181 1148 return $allowed_block_types;
1182 - }
1183 -
1184 - function show_validation_notices() {
1185 - $errors = get_transient('codoc_entry_validation_errors');
1186 - if (!$errors || !is_array($errors)) {
1187 - return;
1188 - }
1189 - delete_transient('codoc_entry_validation_errors');
1190 - $header = __('codoc could not sync this entry due to length limits:', 'codoc');
1191 - echo '<div class="notice notice-error is-dismissible"><p><strong>' . esc_html($header) . '</strong></p><ul>';
1192 - foreach ($errors as $message) {
1193 - echo '<li>' . esc_html($message) . '</li>';
1194 - }
1195 - echo '</ul></div>';
1196 1149 }
1197 1150
1198 1151 function show_tadv_notice() {
1199 1152 // API からの notification を表示