PluginProbe
codoc / 0.9.13
codoc v0.9.13
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 +139 -469 trunk0.9.13 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2 require_once(plugin_dir_path( __FILE__ ) .'class-codoc-util.php');
3 3 final class Codoc {
4 +
4 5 public function __construct() {
5 - add_action('plugins_loaded', [$this,'codoc_load_textdomain']);
6 6 if (is_admin()) {
7 7 // setting
8 8 $this->add_settings();
9 9 }
@@ -23,21 +23,12 @@
23 23 if (isset($params_decoded["the_content_filter_priority"])) {
24 24 $priority = $params_decoded["the_content_filter_priority"];
25 25 }
26 26 }
27 - // ショーココードの退避
28 - if (isset($CODOC_SETTINGS['shortcode_evacuation']) and $CODOC_SETTINGS['shortcode_evacuation']) {
29 - add_filter('the_content',[$this,'the_content_shortcode_evacuations'],0);
30 - }
31 27 add_filter('the_content',[$this,'the_content'],$priority);
32 - // 2021-09-24 the_content を利用しない場合は個別に呼び出ししてもらう
33 - add_filter('codoc_the_content',[$this,'the_content'],$priority);
34 28
35 29 // 2020-07-25 excerpt対応
36 30 add_filter('excerpt_allowed_blocks',[$this,'excerpt_allowed_blocks']);
37 -
38 - // テーマが allowed_block_types_all で制限している場合に codoc ブロックを許可リストに追加
39 - add_filter('allowed_block_types_all', [$this,'allowed_block_types_all'], 100, 2);
40 31
41 32 $auth_info = get_option(CODOC_AUTHINFO_OPTION_NAME);
42 33
43 34 if ($auth_info) {
@@ -45,42 +36,29 @@
45 36 add_action( 'save_post', [$this,'save_post'], 20, 3 );
46 37 add_action( 'added_post_meta', [$this,'updated_post_meta'], 10, 3 );
47 38 add_action( 'updated_post_meta',[$this,'updated_post_meta'], 10, 3 );
48 39 add_action( 'deleted_post_meta',[$this,'deleted_post_meta'], 10, 4 );
49 - // 文字数バリデーションエラーの管理画面通知
50 - add_action( 'admin_notices', [$this,'show_validation_notices'] );
51 40 }
52 - global $pagenow;
53 - //管理画面でcodoc認証があり投稿画面の場合
54 - if (is_admin() and $auth_info and preg_match('/^post/',$pagenow)) {
41 + if (is_admin() and $auth_info) { //管理画面
55 42 // Gutenberg のサポートがない場合は何もしない
56 43 if ( function_exists( 'register_block_type' ) ) {
57 - // gutenberg - init.php handles all block registration and script enqueuing
44 + // gutenberg
58 45 require_once 'src/init.php';
46 + add_action('wp_loaded', function() {
47 + wp_localize_script('wordpress-cgb-block-js', 'OPTIONS', array(
48 + 'codoc_url' => $this->get_codoc_url(),
49 + 'codoc_usercode' => get_option(CODOC_USERCODE_OPTION_NAME),
50 + 'codoc_plugin_version' => CODOC_PLUGIN_VERSION,
51 + 'codoc_sdk_path' => CODOC_SDK_PATH,
52 + ));
53 + });
59 54 }
60 55 // tinymce
61 56 $this->add_mce();
62 - } elseif(is_admin() and $auth_info and preg_match('/^edit/',$pagenow)) {
63 - // 記事編集ページ
64 - } elseif(!is_admin()) { // ブログ画面
57 + } else { // ブログ画面
65 58 // codocのJS登録
66 59 add_action( 'wp_enqueue_scripts', function() {
67 - $CODOC_SETTINGS = get_option(CODOC_SETTINGS_OPTION_NAME);
68 - $load_script_condition = '';
69 - if (isset($CODOC_SETTINGS["debug_params"]) and
70 - $params_decoded = json_decode($CODOC_SETTINGS["debug_params"],true) and
71 - isset($params_decoded["load_script_condition"])
72 - ) {
73 - $load_script_condition = $params_decoded["load_script_condition"];
74 - }
75 - if ($load_script_condition == 'not_list_page') {
76 - // not_list_pageの場合はトップページ等でスクリプトをロードしない
77 - if (!(is_archive() or is_category() or is_home() or is_front_page())) {
78 - wp_enqueue_script( 'codoc-injector-js', $this->get_codoc_url() . '/js/cms.js' );
79 - }
80 - } else {
81 - wp_enqueue_script( 'codoc-injector-js', $this->get_codoc_url() . '/js/cms.js' );
82 - }
60 + wp_enqueue_script( 'codoc-injector-js', $this->get_codoc_url() . '/js/cms.js' );
83 61 });
84 62 //登録したscriptタグに属性をつける
85 63 add_filter('script_loader_tag', [$this,'modifier_script_tag'],10,2);
86 64 // tinymce用のショートコード
@@ -87,10 +65,9 @@
87 65 add_shortcode('codoc', [$this, 'injector_shortcode']);
88 66 // テーマをbodyにも反映
89 67 add_filter('body_class', function($classes) {
90 68 $CODOC_SETTINGS = get_option(CODOC_SETTINGS_OPTION_NAME);
91 - // デフォルトを変更
92 - $css_path = 'rainbow-square';
69 + $css_path = 'blue';
93 70 if (isset($CODOC_SETTINGS["css_path"]) and $CODOC_SETTINGS["css_path"]) {
94 71 $css_path = $CODOC_SETTINGS["css_path"];
95 72 }
96 73 array_push($classes,sprintf( "codoc-theme-%s",$css_path));
@@ -99,11 +76,8 @@
99 76
100 77 }
101 78 return $this;
102 79 }
103 - function codoc_load_textdomain() {
104 - load_plugin_textdomain('codoc', false, dirname(plugin_basename( __FILE__ )) . '/languages/');
105 - }
106 80 public function get_codoc_url() {
107 81 $CODOC_SETTINGS = get_option(CODOC_SETTINGS_OPTION_NAME);
108 82 if (isset($CODOC_SETTINGS["debug_params"])) {
109 83 $params_decoded = json_decode($CODOC_SETTINGS["debug_params"],true);
@@ -140,9 +114,9 @@
140 114 $usercode_attributes = sprintf(' data-usercode="%s"',$user_code);
141 115 }
142 116
143 117 $setting_attributes = '';
144 - if (isset($CODOC_SETTINGS['codoc_script_tag_attributes']) and $CODOC_SETTINGS['codoc_script_tag_attributes']) {
118 + if ($CODOC_SETTINGS['codoc_script_tag_attributes']) {
145 119 $setting_attributes = $CODOC_SETTINGS['codoc_script_tag_attributes'];
146 120 }
147 121 //return str_replace(' src=', $data_css . ' defer src=', $tag);
148 122 return preg_replace('/(src=[^>]+)/',' ${1} ' . $data_css . $connect_attributes . $usercode_attributes . $setting_attributes . ' defer',$tag);
@@ -157,9 +131,9 @@
157 131 public function add_settings() {
158 132 global $CODOC_SETTINGS;
159 133 add_action( 'admin_menu' ,function(){
160 134 add_options_page(
161 - __('codoc Settings','codoc'), //ページタイトル
135 + 'codoc の設定', //ページタイトル
162 136 'codoc', //設定メニューに表示されるメニュータイトル
163 137 'edit_users', //権限
164 138 'codoc', //設定ページのURL。options-general.php?page=codoc
165 139 function() {
@@ -176,59 +150,20 @@
176 150 add_action('admin_print_styles', 'codoc_admin_styles');
177 151 function codoc_admin_styles($hook) {
178 152 wp_enqueue_style('codoc-options-style', plugins_url( 'codoc/css/codoc-options.css', __DIR__ ));
179 153 }
180 -
181 - // notification を削除する Ajax 処理
182 - add_action('wp_ajax_dismiss_codoc_notification', function() {
183 - delete_transient('codoc_api_notification');
184 - wp_die();
185 - });
186 -
187 - // 管理画面で notification の dismiss を処理する JavaScript
188 - add_action('admin_footer', function() {
189 - ?>
190 - <script type="text/javascript">
191 - jQuery(document).ready(function($) {
192 - // codoc notification の×ボタンがクリックされたときの処理
193 - $(document).on('click', '.codoc-notification .notice-dismiss', function() {
194 - $.post(ajaxurl, {
195 - action: 'dismiss_codoc_notification'
196 - });
197 - });
198 - });
199 - </script>
200 - <?php
201 - });
202 -
203 154 add_action( "admin_init", function() {
204 - global $CODOC_USERCODE;
205 - global $CODOC_SETTINGS;
206 - global $CODOC_TOKEN;
207 - global $CODOC_AUTHINFO;
208 155 // codocからの認証データ処理
209 - if (current_user_can('edit_posts') && !isset($_GET['confirm_token']) and isset($_GET['page']) and $_GET['page'] == 'codoc' and isset($_GET['fetch_token_key'])) {
210 - $current_url = admin_url('options-general.php') . '?page=codoc';
156 + if (isset($_GET['page']) and $_GET['page'] == 'codoc' and isset($_GET['fetch_token_key'])) {
211 157 $key = sanitize_text_field($_GET['fetch_token_key']);
212 158 $usercode = sanitize_text_field($_GET['usercode']);
213 -
214 - // 確認画面の表示
215 - if (
216 - !isset($_GET['_wpnonce']) or
217 - (isset($_GET['_wpnonce']) and !wp_verify_nonce($_GET['_wpnonce'],'fetch_token_nonce'))
218 - ) {
219 - wp_redirect($current_url .
220 - sprintf("&confirm_token=1&fetch_token_key=%s&usercode=%s",$key,$usercode));
221 - exit;
222 - }
223 159 update_option(CODOC_USERCODE_OPTION_NAME,$usercode);
224 160 //$data = $this->callAPI('GET','/token',[ "fetch_token_key" => $key ]);
225 161 $data = $this->util->get_token([ "fetch_token_key" => $key ],["usercode" => $usercode, "token" => "1"]);
226 - if ($data->status and property_exists($data,'token') and $token = $data->token) {
162 + if ($data->status and $token = $data->token) {
227 163 update_option(CODOC_TOKEN_OPTION_NAME,$token);
228 164 //$data = $this->callAPI('GET','');
229 165 $data = $this->util->get_user_info([],["usercode" => $usercode, "token" => $token]);
230 -
231 166 if ($data->status and $user = $data->user) {
232 167 $this->update_codoc_authinfo($user);
233 168 }
234 169 #$current_url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
@@ -233,14 +168,18 @@
233 168 }
234 169 #$current_url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
235 170 #$current_url = preg_replace('/(.*)fetch_token_key.*/','${1}&codoc_auth_finished=1',$current_url);
236 171 //add_settings_error( 'general', 'settings_updated', __( 'OK' ), 'success' );
172 + $current_url = admin_url('options-general.php') . '?page=codoc&codoc_auth_finished=1';
237 173
238 - $current_url = $current_url . '&codoc_auth_finished=1';
239 174 wp_redirect( $current_url);
240 175 exit;
241 176 }
242 177 }
178 + global $CODOC_USERCODE;
179 + global $CODOC_SETTINGS;
180 + global $CODOC_TOKEN;
181 + global $CODOC_AUTHINFO;
243 182 $CODOC_USERCODE = get_option(CODOC_USERCODE_OPTION_NAME);
244 183 $CODOC_SETTINGS = get_option(CODOC_SETTINGS_OPTION_NAME);
245 184 $CODOC_TOKEN = get_option(CODOC_TOKEN_OPTION_NAME);
246 185 $CODOC_AUTHINFO = get_option(CODOC_AUTHINFO_OPTION_NAME);
@@ -278,11 +217,8 @@
278 217 }
279 218 if (!isset($CODOC_SETTINGS['do_not_filter_the_content'])) {
280 219 $CODOC_SETTINGS['do_not_filter_the_content'] = '0';
281 220 }
282 - if (!isset($CODOC_SETTINGS['shortcode_evacuation'])) {
283 - $CODOC_SETTINGS['shortcode_evacuation'] = '0';
284 - }
285 221
286 222 if (!isset($CODOC_SETTINGS['entry_button_text'])) {
287 223 $CODOC_SETTINGS['entry_button_text'] = '';
288 224 }
@@ -306,14 +242,9 @@
306 242 }
307 243 if (!isset($CODOC_SETTINGS['show_powered_by'])) {
308 244 $CODOC_SETTINGS['show_powered_by'] = '1';
309 245 }
310 - if (!isset($CODOC_SETTINGS['show_created_by'])) {
311 - $CODOC_SETTINGS['show_created_by'] = '1';
312 - }
313 - if (!isset($CODOC_SETTINGS['show_copyright'])) {
314 - $CODOC_SETTINGS['show_copyright'] = '1';
315 - }
246 +
316 247 if (!isset($CODOC_SETTINGS['codoc_tag_attributes'])) {
317 248 $CODOC_SETTINGS['codoc_tag_attributes'] = '';
318 249 }
319 250 if (!isset($CODOC_SETTINGS['codoc_script_tag_attributes'])) {
@@ -327,18 +258,14 @@
327 258 }
328 259 if (!isset($CODOC_SETTINGS['debug_params'])) {
329 260 $CODOC_SETTINGS['debug_params'] = '';
330 261 }
331 - if (!isset($CODOC_SETTINGS['block_defaults'])) {
332 - $CODOC_SETTINGS['block_defaults'] = '';
333 - }
334 262 add_settings_section(
335 263 'setting_section_id', // id
336 - __('codoc Settings','codoc'), // title
337 - [$this,'show_tadv_notice'],
264 + 'codoc 設定ページ', // title
265 + function (){}, // callback
338 266 'codoc' // page
339 267 );
340 -
341 268 // 認証がある場合
342 269 if ($CODOC_AUTHINFO) {
343 270 // クリエイター情報だけ更新 (POST時に同期をとる)
344 271 if (isset($_GET['page']) and $_GET['page'] == 'codoc' and isset($_GET['settings-updated'])) {
@@ -347,38 +274,26 @@
347 274 "token" => get_option(CODOC_TOKEN_OPTION_NAME),
348 275 ]);
349 276 if ($data->status and $user = $data->user) {
350 277 $this->update_codoc_authinfo($user);
351 - // 一度get_optionしてるのでリロードする
352 - $CODOC_AUTHINFO = get_option(CODOC_AUTHINFO_OPTION_NAME);
353 278 }
354 279 }
355 280
356 281 register_setting(
357 282 'codoc_option_group', // option group
358 - CODOC_SETTINGS_OPTION_NAME, // option name(DB)
359 - array('sanitize_callback' => function($input) {
360 - if (isset($input['block_defaults']) && $input['block_defaults'] !== '') {
361 - if (json_decode($input['block_defaults'], true) === null && $input['block_defaults'] !== 'null') {
362 - $old = get_option(CODOC_SETTINGS_OPTION_NAME);
363 - $input['block_defaults'] = isset($old['block_defaults']) ? $old['block_defaults'] : '';
364 - add_settings_error('block_defaults', 'invalid_json', esc_html(__('Block Default Values: Invalid JSON format. The value was not saved.','codoc')), 'error');
365 - }
366 - }
367 - return $input;
368 - })
283 + CODOC_SETTINGS_OPTION_NAME // option name(DB)
369 284 );
370 285 add_settings_field(
371 286 'css_path', // id
372 - __('Theme','codoc'), // title
287 + 'テーマ', // title
373 288 function() {
374 289 global $CODOC_SETTINGS;
375 - echo '<div class="excerpt">' . esc_html(__('You can change the design of the paywall by specifying a theme.<br />You can also specify CSS directly by selecting "Path Specification"','codoc')) . '</div>';
376 - echo sprintf('<div class="inputGroup"><input type="text" name="%s[css_path]" value="%s" id="codoc_css_path" readonly>',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['css_path']));
290 + echo '<div class="excerpt">テーマを指定してペイウォールのデザインを変えることができます。<br>パスを指定を選択することでCSSを直接指定するこもと可能です。</div>';
291 + echo sprintf('<div class="inputGroup"><input type="text" name="%s[css_path]" value="%s" id="codoc_css_path" readonly>',CODOC_SETTINGS_OPTION_NAME,$CODOC_SETTINGS['css_path']);
377 292 echo '' .
378 293 '<script type="text/javascript"> ' .
379 294 ' function gen_css_path(select) { ' .
380 - ' if (select.value == "dark" || select.value == "dark-square") { ' .
295 + ' if (select.value == "dark") { ' .
381 296 ' document.getElementById("darkmode-caution").style.display="block";' .
382 297 ' } else { ' .
383 298 ' if (document.getElementById("darkmode-caution")) { ' .
384 299 ' document.getElementById("darkmode-caution").style.display="none";' .
@@ -396,50 +311,44 @@
396 311 ' } ' .
397 312 '</script> ' ;
398 313
399 314 echo sprintf('<select name="theme_name" onChange="gen_css_path(this)" id="codoc_theme_select">');
400 - foreach (["rainbow","blue","red","green","black","dark","rainbow-square","blue-square","red-square","green-square","black-square","dark-square"] as $theme) {
401 - if ($theme == "rainbow") {
402 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "rainbow" ? "selected" : ""),esc_attr(__('Rainbow colors','codoc')));
403 - }
315 + foreach (["blue","red","green","black","dark","blue-square","red-square","green-square","black-square","dark-square"] as $theme) {
404 316 if ($theme == "blue") {
405 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "blue" ? "selected" : ""),esc_attr(__('Blue','codoc')));
317 + echo sprintf('<option value="%s" %s>青</option>', $theme, ($CODOC_SETTINGS["css_path"] == "blue" ? "selected" : ""));
406 318 }
407 319 if ($theme == "red") {
408 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "red" ? "selected" : ""),esc_attr(__('Red','codoc')));
320 + echo sprintf('<option value="%s" %s>赤</option>', $theme, ($CODOC_SETTINGS["css_path"] == "red" ? "selected" : ""));
409 321 }
410 322 if ($theme == "green") {
411 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "green" ? "selected" : ""),esc_attr(__('Green','codoc')));
323 + echo sprintf('<option value="%s" %s>緑</option>', $theme, ($CODOC_SETTINGS["css_path"] == "green" ? "selected" : ""));
412 324 }
413 325 if ($theme == "black") {
414 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "black" ? "selected" : ""),esc_attr(__('Black','codoc')));
326 + echo sprintf('<option value="%s" %s>黒</option>', $theme, ($CODOC_SETTINGS["css_path"] == "black" ? "selected" : ""));
415 327 }
416 328 if ($theme == "dark") {
417 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "dark" ? "selected" : ""),esc_attr(__('Dark mode','codoc')));
329 + echo sprintf('<option value="%s" %s>ダークモード</option>', $theme, ($CODOC_SETTINGS["css_path"] == "dark" ? "selected" : ""));
418 330 }
419 - if ($theme == "rainbow-square") {
420 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "rainbow-square" ? "selected" : ""),esc_attr(__("Rainbow Colors / Square design",'codoc')));
421 - }
422 331 if ($theme == "blue-square") {
423 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "blue-square" ? "selected" : ""),esc_attr(__('Blue / Square design','codoc')));
332 + echo sprintf('<option value="%s" %s>青(四角)</option>', $theme, ($CODOC_SETTINGS["css_path"] == "blue-square" ? "selected" : ""));
424 333 }
425 334 if ($theme == "red-square") {
426 - echo sprintf('<option value="%s" %s>%s/option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "red-square" ? "selected" : ""),esc_attr(__('Red / Square design','codoc')));
335 + echo sprintf('<option value="%s" %s>赤(四角)</option>', $theme, ($CODOC_SETTINGS["css_path"] == "red-square" ? "selected" : ""));
427 336 }
428 337 if ($theme == "green-square") {
429 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "green-square" ? "selected" : ""),esc_attr(__('Green / Square design','codoc')));
338 + echo sprintf('<option value="%s" %s>緑(四角)</option>', $theme, ($CODOC_SETTINGS["css_path"] == "green-square" ? "selected" : ""));
430 339 }
431 340 if ($theme == "black-square") {
432 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "black-square" ? "selected" : ""),esc_attr(__('Black / Square design','codoc')));
341 + echo sprintf('<option value="%s" %s>黒(四角)</option>', $theme, ($CODOC_SETTINGS["css_path"] == "black-square" ? "selected" : ""));
433 342 }
434 343 if ($theme == "dark-square") {
435 - echo sprintf('<option value="%s" %s>%s</option>', esc_attr($theme), esc_attr($CODOC_SETTINGS["css_path"] == "dark-square" ? "selected" : ""),esc_attr(__('Dark mode / Square design','codoc')));
344 + echo sprintf('<option value="%s" %s>ダークモード(四角)</option>', $theme, ($CODOC_SETTINGS["css_path"] == "dark-square" ? "selected" : ""));
436 345 }
437 346 }
438 - echo sprintf('<option value="path" %s>%s</option>', esc_attr(preg_match("/\//",$CODOC_SETTINGS["css_path"]) ? "selected" : ""),esc_attr(__('Path Specification','codoc')));
347 + echo sprintf('<option value="path" %s>パス指定</option>', (preg_match("/\//",$CODOC_SETTINGS["css_path"]) ? "selected" : ""));
439 348 echo '<script type="text/javascript">gen_css_path(document.getElementById(\'codoc_theme_select\'))</script>';
440 349 echo sprintf('</select></div>');
441 - echo '<p id="darkmode-caution" style="display:none">' . esc_attr(__('Please note that the theme for dark mode has white text color, and depending on the background color, the text may not be visible.','codoc')). '</p>';
350 + echo '<p id="darkmode-caution" style="display:none">ダークモード向けテーマは文字色が白となり、背景色によっては文字が見えない状態となるためご注意ください。</p>';
442 351 },
443 352 'codoc', //page
444 353 'setting_section_id' //Section
445 354 );
@@ -444,49 +353,46 @@
444 353 'setting_section_id' //Section
445 354 );
446 355 add_settings_field(
447 356 'paywall_text', // id
448 - __('Texts in paywall','codoc'), // title
357 + '各種文言', // title
449 358 function() {
450 359 global $CODOC_SETTINGS;
451 - global $CODOC_AUTHINFO;
452 - echo '<div class="excerpt">' . esc_html(__('You can change, show and hide texts in your paywall.','codoc')) . '</div>';
360 + echo '<div class="excerpt">ペイウォール内の一部文言を変更できます。</div>';
453 361 echo '<table class="innerTable"><tbody>';
454 - echo '<tr><th>' . esc_html(__('Display of likes','codoc')) . '</th><td>';
455 - echo sprintf('<input type="radio" value="1" name="%s[show_like]" id="show_like_on" %s><label for="show_like_on">' . esc_html(__('Enable','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['show_like'] == '1' ? "checked" : ""));
456 - echo sprintf('<input type="radio" value="0" name="%s[show_like]" id="show_like_off" %s><label for="show_like_off">' . esc_html(__('Disable','codoc')) . '</label> <br / >',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['show_like'] == '0' ? "checked" : ""));
362 + echo '<tr><th>いいねの表示</th><td>';
363 + echo sprintf('<input type="radio" value="1" name="%s[show_like]" id="show_like_on" %s><label for="show_like_on">する</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_like'] == '1' ? "checked" : ""));
364 + echo sprintf('<input type="radio" value="0" name="%s[show_like]" id="show_like_off" %s><label for="show_like_off">しない</label> <br / >',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_like'] == '0' ? "checked" : ""));
457 365 echo '</td></tr>';
458 366
459 - echo '<tr><th>' . esc_html(__('Display of PoweredBy','codoc')) . '</th><td>';
460 - echo sprintf('<input type="hidden" value="1" name="%s[show_about_codoc]">',esc_attr(CODOC_SETTINGS_OPTION_NAME));
461 - echo sprintf('<input type="hidden" value="1" name="%s[show_created_by]">',esc_attr(CODOC_SETTINGS_OPTION_NAME));
462 - echo sprintf('<input type="hidden" value="1" name="%s[show_powered_by]">',esc_attr(CODOC_SETTINGS_OPTION_NAME));
463 - if (isset($CODOC_AUTHINFO['account_is_pro']) and $CODOC_AUTHINFO['account_is_pro']) {
464 - echo sprintf('<input type="radio" value="1" name="%s[show_copyright]" id="show_copyright_on" %s><label for="show_copyright_on">' . esc_html(__('Enable','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['show_copyright'] == '1' ? "checked" : ""));
465 - echo sprintf('<input type="radio" value="0" name="%s[show_copyright]" id="show_copyright_off" %s><label for="show_copyright_off">' . esc_html(__('Disable','codoc')) . '</label> <br / >',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['show_copyright'] == '0' ? "checked" : ""));
466 - } else {
467 - echo esc_html(__('Only PRO accounts can be disabled.','codoc'));
468 - }
367 + echo '<tr><th>codocについての表示</th><td>';
368 + echo sprintf('<input type="radio" value="1" name="%s[show_about_codoc]" id="show_about_codoc_on" %s><label for="show_about_codoc_on">する</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_about_codoc'] == '1' ? "checked" : ""));
369 + echo sprintf('<input type="radio" value="0" name="%s[show_about_codoc]" id="show_about_codoc_off" %s><label for="show_about_codoc_off">しない</label> <br / >',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_about_codoc'] == '0' ? "checked" : ""));
469 370 echo '</td></tr>';
470 371
471 - echo '<tr><th>' . esc_html(__('"Purchase Article" button text','codoc')) . '</th><td>';
472 - echo sprintf('<input type="text" name="%s[entry_button_text]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['entry_button_text']));
372 + echo '<tr><th>PoweredByの表示</th><td>';
373 + echo sprintf('<input type="radio" value="1" name="%s[show_powered_by]" id="show_powered_by_on" %s><label for="show_powered_by_on">する</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_powered_by'] == '1' ? "checked" : ""));
374 + echo sprintf('<input type="radio" value="0" name="%s[show_powered_by]" id="show_powered_by_off" %s><label for="show_powered_by_off">しない</label> <br / >',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_powered_by'] == '0' ? "checked" : ""));
473 375 echo '</td></tr>';
474 376
475 - echo '<tr><th>' . esc_html(__('"Purchase Subscription" button text.','codoc')) . '</th><td>';
476 - echo sprintf('<input type="text" name="%s[subscription_button_text]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['subscription_button_text']));
377 + echo '<tr><th>記事購入ボタンのテキスト</th><td>';
378 + echo sprintf('<input type="text" name="%s[entry_button_text]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['entry_button_text']));
477 379 echo '</td></tr>';
380 +
381 + echo '<tr><th>サブスクリプション購入ボタンのテキスト</th><td>';
382 + echo sprintf('<input type="text" name="%s[subscription_button_text]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['subscription_button_text']));
383 + echo '</td></tr>';
478 384
479 - echo '<tr><th>' . esc_html(__('Support button text','codoc')) . '</th><td>';
480 - echo sprintf('<input type="text" name="%s[support_button_text]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['support_button_text']));
385 + echo '<tr><th>サポートボタンのテキスト</th><td>';
386 + echo sprintf('<input type="text" name="%s[support_button_text]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['support_button_text']));
481 387 echo '</td></tr>';
482 388
483 - echo '<tr><th>' . esc_html(__('Text for "Articles Included in Subscription".','codoc')) . '</th><td>';
484 - echo sprintf('<input type="text" name="%s[subscription_message]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['subscription_message']));
389 + echo '<tr><th>「サブスクリプションに含まれる記事」のテキスト</th><td>';
390 + echo sprintf('<input type="text" name="%s[subscription_message]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['subscription_message']));
485 391 echo '</td></tr>';
486 392
487 - echo '<tr><th>' . esc_html(__('Text for support description','codoc')) . '</th><td>';
488 - echo sprintf('<input type="text" name="%s[support_message]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['support_message']));
393 + echo '<tr><th>サポート説明のテキスト</th><td>';
394 + echo sprintf('<input type="text" name="%s[support_message]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['support_message']));
489 395 echo '</td></tr>';
490 396
491 397 echo '</tbody></table>';
492 398 },
@@ -495,13 +401,13 @@
495 401 );
496 402
497 403 add_settings_field(
498 404 'codoc_tag_attributes', // id
499 - __('Attributes for codoc tag','codoc'), // title
405 + 'codocタグの属性', // title
500 406 function() {
501 407 global $CODOC_SETTINGS;
502 - echo '<div class="excerpt">' . esc_html(__('You can add specific attributes to codoc tags.','codoc')) . '</div>';
503 - echo sprintf('<input type="text" name="%s[codoc_tag_attributes]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['codoc_tag_attributes']));
408 + echo '<div class="excerpt">codocタグに特定の属性を追加することができます。</div>';
409 + echo sprintf('<input type="text" name="%s[codoc_tag_attributes]" value="%s">',CODOC_SETTINGS_OPTION_NAME,htmlspecialchars($CODOC_SETTINGS['codoc_tag_attributes']));
504 410 },
505 411 'codoc', //page
506 412 'setting_section_id' //Section
507 413 );
@@ -506,13 +412,13 @@
506 412 'setting_section_id' //Section
507 413 );
508 414 add_settings_field(
509 415 'codoc_script_tag_attributes', // id
510 - __('Attributes for codoc script tag','codoc'), // title
416 + 'codoc scriptタグの属性', // title
511 417 function() {
512 418 global $CODOC_SETTINGS;
513 - echo '<div class="excerpt">' . esc_html(__('You can add specific attributes to codoc script tags.','codoc')) . '</div>';
514 - echo sprintf('<input type="text" name="%s[codoc_script_tag_attributes]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['codoc_script_tag_attributes']));
419 + echo '<div class="excerpt">codoc scriptタグに特定の属性を追加することができます。</div>';
420 + echo sprintf('<input type="text" name="%s[codoc_script_tag_attributes]" value="%s">',CODOC_SETTINGS_OPTION_NAME,htmlspecialchars($CODOC_SETTINGS['codoc_script_tag_attributes']));
515 421 },
516 422 'codoc', //page
517 423 'setting_section_id' //Section
518 424 );
@@ -517,16 +423,16 @@
517 423 'setting_section_id' //Section
518 424 );
519 425 add_settings_field(
520 426 'str_replace_binded_url', // id
521 - __('Permalink','codoc'), // title
427 + 'パーマリンク', // title
522 428 function() {
523 429 global $CODOC_SETTINGS;
524 - echo '<div class="excerpt">' . esc_html(__('You can replace the part of permalink registered on the codoc.','codoc')) . '</div>';
525 - echo sprintf('<input type="text" name="%s[str_replace_binded_url_from]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['str_replace_binded_url_from']));
526 - echo ('<span class="suptext">→</span>');
527 - echo sprintf('<input type="text" name="%s[str_replace_binded_url_to]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['str_replace_binded_url_to']));
528 -
430 + echo '<div class="excerpt">codoc側に登録するパーマリンクを置換することができます。</div>';
431 + echo sprintf('<input type="text" name="%s[str_replace_binded_url_from]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['str_replace_binded_url_from']));
432 + echo ('<span class="suptext">を</span>');
433 + echo sprintf('<input type="text" name="%s[str_replace_binded_url_to]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['str_replace_binded_url_to']));
434 + echo ('に変換');
529 435 },
530 436 'codoc', //page
531 437 'setting_section_id' //Section
532 438 );
@@ -532,14 +438,16 @@
532 438 );
533 439
534 440 add_settings_field(
535 441 'str_around_codoc_tag', // id
536 - __('HTML insertion','codoc'), // title
442 + 'HTMLの挿入', // title
537 443 function() {
538 444 global $CODOC_SETTINGS;
539 - echo '<div class="excerpt">' . esc_html(__('You can insert HTML before and after the codoc tag.','codoc')) . '</div>';
540 - echo sprintf('<div class="inputRow"><p>%s</p><textarea name="%s[str_before_codoc_tag]" cols="40">%s</textarea></div>',esc_html(__('Before HTML','codoc')),esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_html($CODOC_SETTINGS['str_before_codoc_tag']));
541 - echo sprintf('<div class="inputRow"><p>%s</p><textarea name="%s[str_after_codoc_tag]" cols="40">%s</textarea></div>',esc_html(__('After HTML','codoc')),esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_html($CODOC_SETTINGS['str_after_codoc_tag']));
445 + echo '<div class="excerpt">codocタグの前後にHTMLを挿入することができます。</div>';
446 + echo sprintf('<div class="inputRow"><textarea name="%s[str_before_codoc_tag]" cols="40">%s</textarea>',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['str_before_codoc_tag']));
447 + echo ('を前に挿入</div>');
448 + echo sprintf('<div class="inputRow"><textarea name="%s[str_after_codoc_tag]" cols="40">%s</textarea>',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['str_after_codoc_tag']));
449 + echo ('を後に挿入</div>');
542 450
543 451 },
544 452 'codoc', //page
545 453 'setting_section_id' //Section
@@ -546,26 +454,26 @@
546 454 );
547 455
548 456 add_settings_field(
549 457 'always_show_support_tag', // id
550 - __('Automatic support insertion','codoc'), // title
458 + 'サポートの自動挿入', // title
551 459 function() {
552 460 global $CODOC_SETTINGS;
553 - echo '<div class="excerpt">' . esc_html(__('It adds support functions to the post without inserting a codoc block.','codoc')) . '</div>';
461 + echo '<div class="excerpt">codocブロックを挿入することなく投稿にサポート機能を追加します</div>';
554 462 echo '<table class="innerTable"><tbody>';
555 - echo '<tr><th>' . esc_html(__('Automatic insertion','codoc')) . '</th><td>';
556 - echo sprintf('<input type="radio" value="1" name="%s[always_show_support]" id="always_show_support_on" %s><label for="always_show_support_on">' . esc_html(__('Enable','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['always_show_support'] == '1' ? "checked" : ""));
557 - echo sprintf('<input type="radio" value="0" name="%s[always_show_support]" id="always_show_support_off" %s><label for="always_show_support_off">' . esc_html(__('Disable','codoc')) . '</label> <br / >',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['always_show_support'] == '0' ? "checked" : ""));
463 + echo '<tr><th>自動挿入</th><td>';
464 + echo sprintf('<input type="radio" value="1" name="%s[always_show_support]" id="always_show_support_on" %s><label for="always_show_support_on">する</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['always_show_support'] == '1' ? "checked" : ""));
465 + echo sprintf('<input type="radio" value="0" name="%s[always_show_support]" id="always_show_support_off" %s><label for="always_show_support_off">しない</label> <br / >',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['always_show_support'] == '0' ? "checked" : ""));
558 466 echo '</td></tr>';
559 - echo '<tr><th>'. esc_html(__('Position','codoc')) . '</th><td>';
560 - echo sprintf('<input type="radio" value="top" name="%s[show_support_location]" id="show_support_location_top" %s><label for="show_support_location_top">' . esc_html(__('TOP','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['show_support_location'] == 'top' ? "checked" : ""));
561 - echo sprintf('<input type="radio" value="bottom" name="%s[show_support_location]" id="show_support_location_bottom" %s><label for="show_support_location_bottom">' . esc_html(__('Bottom','codoc')) . '</label> <br / >',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['show_support_location'] == 'bottom' ? "checked" : ""));
467 + echo '<tr><th>表示位置</th><td>';
468 + echo sprintf('<input type="radio" value="top" name="%s[show_support_location]" id="show_support_location_top" %s><label for="show_support_location_top">冒頭</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_support_location'] == 'top' ? "checked" : ""));
469 + echo sprintf('<input type="radio" value="bottom" name="%s[show_support_location]" id="show_support_location_bottom" %s><label for="show_support_location_bottom">末尾</label> <br / >',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['show_support_location'] == 'bottom' ? "checked" : ""));
562 470 echo '</td></tr>';
563 - echo '<tr><th>' . esc_html(__('Description','codoc')) . '</th><td>';
564 - echo sprintf('<input type="text" placeholder="' . esc_html(__('You can customize the description of the support.','codoc')) . '" size="50%%" name="%s[show_support_message]" value="%s">',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_html($CODOC_SETTINGS['show_support_message']));
471 + echo '<tr><th>説明文</th><td>';
472 + echo sprintf('<input type="text" placeholder="サポートの説明文をカスタマイズできます" size="50%%" name="%s[show_support_message]" value="%s">',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['show_support_message']));
565 473 echo '</td></tr>';
566 - echo '<tr><th>' . esc_html(__('Category names','codoc')) . '</th><td>';
567 - echo sprintf('<input placeholder="' . esc_html(__('Inserted into articles of categories, divided by &quot;|&quot;','codoc')) . '" type="text" size="50%%" name="%s[show_support_categories]" value="%s"><br />',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_html($CODOC_SETTINGS['show_support_categories']));
474 + echo '<tr><th>対象カテゴリ名</th><td>';
475 + echo sprintf('<input placeholder="&quot;|&quot;区切りで複数指定できます" type="text" size="50%%" name="%s[show_support_categories]" value="%s"><br />',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['show_support_categories']));
568 476 echo '</td></tr>';
569 477 echo '</tbody></table>';
570 478
571 479 },
@@ -573,39 +481,25 @@
573 481 'setting_section_id' //Section
574 482 );
575 483 add_settings_field(
576 484 'do_not_filter_the_content', // id
577 - __('Disable plugin filter','codoc'), // title
485 + '支障が出る処理を無効化', // title
578 486 function() {
579 487 global $CODOC_SETTINGS;
580 - echo '<div class="excerpt">' . esc_html(__('You can disable filter processing that includes shortcodes from other plugins that interfere with the operation of codoc. Please use this only if codoc is not functioning properly.','codoc')) . '</div>';
581 - echo sprintf('<input type="radio" value="1" name="%s[do_not_filter_the_content]" id="do_not_filter_the_content_on" %s><label for="do_not_filter_the_content_on">' . esc_html(__('Enable','codoc')) .'</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['do_not_filter_the_content'] == '1' ? "checked" : ""));
582 - echo sprintf('<input type="radio" value="0" name="%s[do_not_filter_the_content]" id="do_not_filter_the_content_off" %s><label for="do_not_filter_the_content_off">' . esc_html(__('Disable','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['do_not_filter_the_content'] == '0' ? "checked" : ""));
488 + echo '<div class="excerpt">codocの動作に支障が出る他のプラグインによる<strong>フィルター処理</strong>を無効化できます。codocが上手く動かない場合のみ利用してください。</div>';
489 + echo sprintf('<input type="radio" value="1" name="%s[do_not_filter_the_content]" id="do_not_filter_the_content_on" %s><label for="do_not_filter_the_content_on">する</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['do_not_filter_the_content'] == '1' ? "checked" : ""));
490 + echo sprintf('<input type="radio" value="0" name="%s[do_not_filter_the_content]" id="do_not_filter_the_content_off" %s><label for="do_not_filter_the_content_off">しない</label> ',CODOC_SETTINGS_OPTION_NAME,($CODOC_SETTINGS['do_not_filter_the_content'] == '0' ? "checked" : ""));
583 491 },
584 492 'codoc', //page
585 493 'setting_section_id' //Section
586 494 );
587 -
588 495 add_settings_field(
589 - 'shortcode_evacuation', // id
590 - __('Shortcode evacuation','codoc'), // title
591 - function() {
592 - global $CODOC_SETTINGS;
593 - echo '<div class="excerpt">' . esc_html(__('The execution results of shortcodes written in the paid part are moved to the free part, and are used and displayed on the HTML during viewing of the paid part. Please use this if the shortcode does not work as expected in the paid part. Please note that the execution results of shortcodes in the paid part will be written in the source code.','codoc')). '</div>';
594 - echo sprintf('<input type="radio" value="1" name="%s[shortcode_evacuation]" id="shortcode_evacuation_on" %s><label for="shortcode_evacuation_on">' . esc_html(__('Enable','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['shortcode_evacuation'] == '1' ? "checked" : ""));
595 - echo sprintf('<input type="radio" value="0" name="%s[shortcode_evacuation]" id="shortcode_evacuation_off" %s><label for="shortcode_evacuation_off">' . esc_html(__('Disable','codoc')) . '</label> ',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_attr($CODOC_SETTINGS['shortcode_evacuation'] == '0' ? "checked" : ""));
596 - },
597 - 'codoc', //page
598 - 'setting_section_id' //Section
599 - );
600 -
601 - add_settings_field(
602 496 'debug_params', // id
603 - __('Debug Parameters','codoc'), // title
497 + 'デバック用', // title
604 498 function() {
605 499 global $CODOC_SETTINGS;
606 - echo '<div class="excerpt">' . esc_html(__('You can specify parameters for debugging. Please use this only upon request from codoc support.','codoc')) . '</div>';
607 - echo sprintf('<input placeholder="" type="text" size="50%%" name="%s[debug_params]" value="%s"><br />',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_html($CODOC_SETTINGS['debug_params']));
500 + echo '<div class="excerpt">デバック用のパラメーターを指定できます。codocサポートから依頼がある場合のみ利用してください。</div>';
501 + echo sprintf('<input placeholder="" type="text" size="50%%" name="%s[debug_params]" value="%s"><br />',CODOC_SETTINGS_OPTION_NAME,esc_html($CODOC_SETTINGS['debug_params']));
608 502 },
609 503 'codoc', //page
610 504 'setting_section_id' //Section
611 505 );
@@ -610,52 +504,26 @@
610 504 'setting_section_id' //Section
611 505 );
612 506
613 507 add_settings_field(
614 - 'block_defaults', // id
615 - __('Block Default Values','codoc'), // title
616 - function() {
617 - global $CODOC_SETTINGS;
618 - echo '<div class="excerpt">' . esc_html(__('You can specify default values for new codoc blocks in JSON format.','codoc')) . '</div>';
619 - echo sprintf('<textarea placeholder=\'{"showPrice":false,"price":300}\' rows="3" cols="50" name="%s[block_defaults]">%s</textarea>',esc_attr(CODOC_SETTINGS_OPTION_NAME),esc_html($CODOC_SETTINGS['block_defaults']));
620 - echo '<p class="description">'
621 - . 'showPrice (bool: true), '
622 - . 'price (int: 500), '
623 - . 'limited (bool: false), '
624 - . 'limitedCount (int: 10), '
625 - . 'affiliateMode (bool: false), '
626 - . 'affiliateRate (string: "0.0500"), '
627 - . 'showSupport (bool: false), '
628 - . 'showPaywalledSupport (bool: false), '
629 - . 'statusLimited (bool: false), '
630 - . 'subscriptions (object: {})'
631 - . '</p>';
632 - },
633 - 'codoc', //page
634 - 'setting_section_id' //Section
635 - );
636 -
637 - add_settings_field(
638 508 'cretor_info', // id
639 - __('Creator\'s Information','codoc'), // title
509 + 'クリエイター情報', // title
640 510 function() {
641 511 global $CODOC_SETTINGS;
642 512 global $CODOC_AUTHINFO;
643 513 echo sprintf('<p><font id="codoc-update-creator-info-message"></font></p>',"");
644 514 // 変更を保存時に常に同期するのでこの表示は必要ないがUI上保持しておく
645 - $script = "document.getElementById('codoc-update-creator-info-message').innerText='" . __("Please save changes to update the information.","codoc") . "';document.getElementById('codoc-update-creator-info-message').color='red';";
515 + $script = "document.getElementById('codoc-update-creator-info-message').innerText='情報を更新するには変更を保存してください';document.getElementById('codoc-update-creator-info-message').color='red';";
646 516 if (isset($CODOC_AUTHINFO['profile_image_url'])) {
647 - echo sprintf('<img src="%s" width="40" height="40" />',esc_attr($CODOC_AUTHINFO['profile_image_url']));
517 + echo sprintf('<img src="%s" width="40" height="40" />',$CODOC_AUTHINFO['profile_image_url']);
648 518 }
649 - echo sprintf('<p>%s %s %s</p>',esc_html($CODOC_AUTHINFO['name']),esc_html((isset($CODOC_AUTHINFO['account_is_pro']) and $CODOC_AUTHINFO['account_is_pro']) ? ' [PRO]' : ''),esc_html(isset($CODOC_AUTHINFO['country']) ? $CODOC_AUTHINFO['country'] : '' ));
519 + echo sprintf('<p>%s</p>',$CODOC_AUTHINFO['name']);
650 520 if ($connect_code = $CODOC_SETTINGS['codoc_connect_code']) {
651 - // Translators: %s is the integration code, and %s is additional information based on the registration mode.
652 - echo sprintf('<p>' . esc_html(__('Extensions integration completed (Extensions code: %1$s) %2$s','codoc')) . '</p>',
653 - esc_html($connect_code),
654 - esc_html($CODOC_SETTINGS['codoc_connect_registration_mode'] == 'dedicated' ? __('Set the audience as a private account.','codoc') : ''));
521 + echo sprintf('<p>%s外部サービス連携済(連携コード:%s)</p>',
522 + ($CODOC_SETTINGS['codoc_connect_registration_mode'] == 'dedicated' ? '専用ユーザーモードで' : ''),
523 + $connect_code);
655 524 }
656 - echo sprintf('<p><a href="javascript:void(0);" onClick="' . esc_attr($script) . '">' . esc_html(__('Update creator\'s Information','codoc')) . '</a></p>');
657 - echo ('<p>' . esc_html(__('Please update each time if you change the logo or cover image on the codoc side.','codoc')) . '</p>');
525 + echo sprintf('<p>情報を<a href="javascript:void(0);" onClick="' . $script . '">更新する</p>');
658 526 },
659 527 'codoc', //page
660 528 'setting_section_id' //Section
661 529 );
@@ -669,26 +537,25 @@
669 537 CODOC_TOKEN_OPTION_NAME
670 538 );
671 539
672 540 if (isset($_GET['codoc_auth_finished']) and $_GET['codoc_auth_finished']) {
673 - add_settings_error( 'general', 'settings_updated', esc_html(__( 'codoc authentication has been completed.' ,'codoc'), 'success' ));
541 + add_settings_error( 'general', 'settings_updated', __( 'codocの認証が完了しました' ), 'success' );
674 542 }
675 543
676 544 add_settings_field(
677 545 'codoc_auth',
678 - __('Authentication','codoc'),
546 + '認証',
679 547 function() {
680 548 global $CODOC_USERCODE;
681 549 global $CODOC_TOKEN;
682 550 global $CODOC_AUTHINFO;
683 - $script = "javascript:document.getElementById('codoc-usercode').value='-';document.getElementById('codoc-token').value='-';document.getElementById('codoc-auth-message').innerText='" . __('Please save changes to complete the unbinding.','codoc') . "';document.getElementById('codoc-auth-message').color='red';";
551 + $script = "javascript:document.getElementById('codoc-usercode').value='-';document.getElementById('codoc-token').value='-';document.getElementById('codoc-auth-message').innerText='解除を完了するには変更を保存してください';document.getElementById('codoc-auth-message').color='red';";
684 552
685 - // Translators: %s is the email address.
686 - echo sprintf('<p><font color="green" id="codoc-auth-message">' . esc_html(__('Authorized as %s','codoc')) . '</font></p>',esc_attr($CODOC_AUTHINFO['email']));
553 + echo sprintf('<p><font color="green" id="codoc-auth-message"><strong>%s</strong> で認証済</font></p>',$CODOC_AUTHINFO['email']);
687 554
688 - echo sprintf('<input id="codoc-usercode" type="hidden" name="%s" value="%s">',esc_attr(CODOC_USERCODE_OPTION_NAME),esc_attr($CODOC_USERCODE));
689 - echo sprintf('<input id="codoc-token" type="hidden" name="%s" value="%s">',esc_attr(CODOC_TOKEN_OPTION_NAME),esc_attr($CODOC_TOKEN));
690 - echo sprintf('<p><a href="javascript:void(0);" onClick="' . esc_attr($script) . '">' . esc_html(__('Unbind authorization','codoc')) . '</p>');
555 + echo sprintf('<input id="codoc-usercode" type="hidden" name="%s" value="%s">',CODOC_USERCODE_OPTION_NAME,$CODOC_USERCODE);
556 + echo sprintf('<input id="codoc-token" type="hidden" name="%s" value="%s">',CODOC_TOKEN_OPTION_NAME,$CODOC_TOKEN);
557 + echo sprintf('<p>認証を<a href="javascript:void(0);" onClick="' . $script . '">解除する</p>');
691 558 },
692 559 'codoc',
693 560 'setting_section_id'
694 561 );
@@ -698,40 +565,21 @@
698 565 // ない場合
699 566 if (!$CODOC_AUTHINFO and !isset($_GET['auth_by_myself'])) {
700 567 add_settings_field(
701 568 'codoc_auth',
702 - __('Authentication','codoc'),
569 + '認証',
703 570 function() {
704 - $theme = wp_get_theme();
705 - $from = 'wp';
706 - if ($theme->get('Name') === 'codoc') {
707 - $from = 'wp_codoc';
708 - }
709 571 //$current_url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
710 572 $current_url = admin_url('options-general.php') . '?page=codoc';
711 - $direct_url = sprintf("location.href='%s&auth_by_myself=1'",$current_url);
712 - $login_url = sprintf("location.href='%s'",$this->get_codoc_url() . '/me/token?from=' . $from . '&return_url=' . urlencode($current_url));
713 - $register_url = sprintf("location.href='%s'",$this->get_codoc_url() . '/register?from=' . $from . '&return_url=' . urlencode($current_url));
573 + $login_url = sprintf("location.href='%s'",$this->get_codoc_url() . '/me/token?from=wp&return_url=' . urlencode($current_url));
574 + $register_url = sprintf("location.href='%s'",$this->get_codoc_url() . '/register?from=wp&return_url=' . urlencode($current_url));
714 575 // submitを消しておく
715 - echo ('<script type="text/javascript">window.onload=function(){document.getElementById(\'submit\').style.display = \'none\'}</script>');
716 - if (isset($_GET['confirm_token'])) {
717 - $confirm_url = sprintf("location.href='%s&_wpnonce=%s&fetch_token_key=%s&usercode=%s'",$current_url,
718 - wp_create_nonce('fetch_token_nonce'),
719 - esc_attr($_GET['fetch_token_key']),
720 - esc_attr($_GET['usercode']));
721 - echo (esc_html(__('The authentication information has been obtained. Please click the confirmation button to complete the setup.','codoc')) . '<br />');
722 - echo sprintf('<input type="button" class="button button-primary" value="%s" onClick="%s"> ',esc_html(__('Confirm authentication','codoc')),esc_attr($confirm_url));
723 - } else {
724 -
725 - echo (esc_html(__('Authentication is required to use codoc on WordPress.','codoc')) . '<br />');
726 - echo (esc_html(__('You can authenticate by directly entering the user code and API token, or by logging in and registering with codoc.','codoc')) . '<br /><br />');
727 - echo sprintf('<input type="button" class="button button-primary" value="%s" onClick="%s"> ',esc_attr(__('Authenticate by direct input','codoc')),esc_attr($direct_url));
728 - echo sprintf('<input type="button" class="button button-primary" value="%s" onClick="%s"> <input type="button" class="button button-primary" value="%s" onClick="%s"><br /><br />',esc_attr(__('Login and authenticate','codoc')),esc_attr($login_url),esc_attr(__('Register and authenticate','codoc')),esc_attr($register_url));
729 - }
730 - if (!$this->util->health_check()) {
731 - echo sprintf('<p style="color: red;">Cannot communicate with the codoc server. Please allow communication to https://codoc.jp in your firewall settings on the server or WordPress side.</p>');
732 - }
576 + echo ('<script type="text/javascript">window.onload=function(){document.getElementById(\'submit\').style.display = \'none\'}</script>');
577 + echo ('codocをWordPressでご利用いただくには認証が必要です。<br />');
578 + echo sprintf('ユーザーコードとAPIトークンを<a href="%s&auth_by_myself=1">直接入力</a>することでも認証できます。<br /><br />',$current_url);
579 + echo sprintf('<input type="button" class="button button-primary" value="ログインして認証" onClick="%s"> <input type="button" class="button button-primary" value="登録して認証" onClick="%s"><br /><br />',$login_url,$register_url);
733 580
581 +
734 582 },
735 583 'codoc',
736 584 'setting_section_id'
737 585 );
@@ -754,9 +602,9 @@
754 602 'ユーザーコード',
755 603 function() {
756 604 global $CODOC_USERCODE;
757 605 echo '<input type="hidden" name="auth_by_myself" value="1">';
758 - echo sprintf('<input type="text" name="%s" value="%s">',esc_attr(CODOC_USERCODE_OPTION_NAME),esc_attr($CODOC_USERCODE));
606 + echo sprintf('<input type="text" name="%s" value="%s">',CODOC_USERCODE_OPTION_NAME,$CODOC_USERCODE);
759 607 },
760 608 'codoc',
761 609 'setting_section_id'
762 610 );
@@ -764,9 +612,9 @@
764 612 'codoc_token',
765 613 'APIトークン',
766 614 function() {
767 615 global $CODOC_TOKEN;
768 - echo sprintf('<input type="text" name="%s" value="%s">',esc_attr(CODOC_TOKEN_OPTION_NAME),esc_attr($CODOC_TOKEN));
616 + echo sprintf('<input type="text" name="%s" value="%s">',CODOC_TOKEN_OPTION_NAME,$CODOC_TOKEN);
769 617 },
770 618 'codoc',
771 619 'setting_section_id'
772 620 );
@@ -788,9 +636,9 @@
788 636 $data = $this->util->get_support_entry([],[
789 637 "usercode" => get_option(CODOC_USERCODE_OPTION_NAME),
790 638 "token" => get_option(CODOC_TOKEN_OPTION_NAME),
791 639 ]);
792 - if ($data and $data->status and $entry = $data->entry) {
640 + if ($data->status and $entry = $data->entry) {
793 641 update_option(CODOC_SUPPORT_ENTRYCODE_OPTION_NAME,$entry->code);
794 642 } else {
795 643 update_option(CODOC_SUPPORT_ENTRYCODE_OPTION_NAME,'');
796 644 }
@@ -818,9 +666,9 @@
818 666 });
819 667 // プラグイン一覧に設定のリンクをいれる
820 668 add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . 'codoc' . '.php' ),
821 669 function( $links ) {
822 - $setting_link = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( 'page', 'codoc', admin_url( 'options-general.php' ) ) ), esc_html( __('Settings') ) );
670 + $setting_link = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( 'page', 'codoc', admin_url( 'options-general.php' ) ) ), esc_html( '設定' ) );
823 671 array_unshift( $links, $setting_link );
824 672
825 673 return $links;
826 674 }
@@ -842,13 +690,8 @@
842 690 // プラグイン内で使うCSRF を生成
843 691 $path = plugins_url( 'codoc/src_mce/codoc-editor-onload.js', __DIR__ );
844 692 wp_enqueue_script( 'codoc-editor-onload', $path, array('jquery'), '', true );
845 693 // I just want to insert this global variables but i don't know how i can do it..
846 - $auth_info = get_option(CODOC_AUTHINFO_OPTION_NAME);
847 - $codoc_settings = get_option(CODOC_SETTINGS_OPTION_NAME);
848 - $block_defaults_raw = isset($codoc_settings['block_defaults']) ? $codoc_settings['block_defaults'] : '';
849 - $block_defaults_decoded = json_decode($block_defaults_raw, true);
850 - $block_defaults = is_array($block_defaults_decoded) ? $block_defaults_decoded : new stdClass();
851 694 wp_localize_script(
852 695 'codoc-editor-onload',
853 696 'CODOCEDITOR',
854 697 array(
@@ -858,12 +701,8 @@
858 701 'codoc_url' => $this->get_codoc_url(),
859 702 'codoc_usercode' => get_option(CODOC_USERCODE_OPTION_NAME),
860 703 'codoc_plugin_version' => CODOC_PLUGIN_VERSION,
861 704 'codoc_sdk_path' => CODOC_SDK_PATH,
862 - 'codoc_account_is_pro' => isset($auth_info['account_is_pro']) ? $auth_info['account_is_pro'] : 0,
863 - 'codoc_currency_code' => isset($auth_info['currency_code']) ? $auth_info['currency_code'] : 0,
864 - 'codoc_currency_decimal_places' => isset($auth_info['currency_decimal_places']) ? $auth_info['currency_decimal_places'] : 0,
865 - 'codoc_block_defaults' => $block_defaults,
866 705 )
867 706 );
868 707
869 708 // ここでtinymceのプラグイン追加
@@ -907,9 +746,9 @@
907 746 }
908 747 function update_codoc_authinfo($user) {
909 748 global $CODOC_SETTINGS;
910 749 global $CODOC_AUTHINFO;
911 - if (property_exists($user,'connect_code') and $user->connect_code) {
750 + if ($user->connect_code) {
912 751 $CODOC_SETTINGS = get_option(CODOC_SETTINGS_OPTION_NAME);
913 752 $CODOC_SETTINGS['codoc_connect_code'] = $user->connect_code;
914 753 $CODOC_SETTINGS['codoc_connect_registration_mode'] = $user->connect_has_permission_dedicated_account ? 'dedicated' : '';
915 754 update_option(CODOC_SETTINGS_OPTION_NAME,$CODOC_SETTINGS);
@@ -918,20 +757,13 @@
918 757 'email' => $user->email,
919 758 'name' => $user->name,
920 759 'profile_image_url' => $user->profile_image_url,
921 760 'cover_image_url' => $user->cover_image_url,
922 - 'connect_code' => property_exists($user,'connect_code') ? $user->connect_code : '',
923 - 'connect_image_url' => property_exists($user,'connect_image_url') ? $user->connect_image_url : '',
924 - 'account_is_pro' => property_exists($user,'account_is_pro') ? $user->account_is_pro : '',
925 - 'created_at' => property_exists($user,'created_at') ? $user->created_at : 0,
926 - 'country' => property_exists($user,'country') ? $user->country : '',
927 - 'currency_code' => property_exists($user,'currency_code') ? $user->currency_code : '',
928 - 'currency_decimal_places' => property_exists($user,'currency_decimal_places') ? $user->currency_decimal_places : '',
761 + 'connect_code' => $user->connect_code ? $user->connect_code : '',
762 + 'connect_image_url' => $user->connect_image_url ? $user->connect_image_url : '',
929 763 ]);
930 764 $CODOC_AUTHINFO = get_option(CODOC_AUTHINFO_OPTION_NAME);
931 - return $CODOC_AUTHINFO;
932 765 }
933 - // 保存用コンテンツにフィルターを実施する
934 766 public function get_filtered_content($post_emulated) {
935 767 // 記事ページであることをエミュレートしてフィルター実行
936 768 $post_backuped = null;
937 769 if (isset($GLOBALS['post'])) {
@@ -951,9 +783,9 @@
951 783 $wp_query->is_main_query = true;
952 784
953 785 $wp_query->post = $post_emulated;
954 786 $wp_query->queried_object = $post_emulated;
955 - $wp_query->queried_object_id = $post_emulated->ID;
787 + $wp_query->queried_object_id = $post_emulated->id;
956 788
957 789 $GLOBALS['wp_query'] = $wp_query;
958 790 }
959 791 // $this->the_content でオリジナルを返してもらうため
@@ -961,29 +793,8 @@
961 793 $content = preg_replace(
962 794 '/ (\/)?wp:codoc\/codoc-block /',' \\1wptmp:codoc/codoc-block ',
963 795 $post_emulated->post_content
964 796 );
965 - // post_metaに内容を保存し、無料パートにショートコードの退避をおこなう
966 - $codoc_settings = get_option(CODOC_SETTINGS_OPTION_NAME);
967 - if (isset($codoc_settings['shortcode_evacuation']) and $codoc_settings['shortcode_evacuation']) {
968 - $splited = preg_split('/\/wptmp:codoc\/codoc-block/s',$content);
969 - if (isset($splited[0]) and isset($splited[1])) {
970 - // すべてのショートコードを $match_all にいれる
971 - preg_match_all('/\[[^\[\]]+?\](.+\[\/[^\[\]]+?\])?/',$splited[1],$match_all);
972 - // ショートコードをURLエンコードしてdivタグの中にいれておく(後でmetaの中のショートコードと付け合せ)
973 - $replaced = preg_replace_callback('/\[[^\[\]]+?\](.+\[\/[^\[\]]+?\])?/',function($matches) {
974 - return sprintf ('<div class="codoc-evacuation-dests" data-shortcode="%s"></div>', urlencode($matches[0]));
975 - },$splited[1]);
976 - // 0番目に配列で入っているのでそこを退避対象の配列とする
977 - $evacuations = $match_all[0];
978 - // ショートコードの中身をタグに退避
979 - $content = $splited[0] . '/wptmp:codoc/codoc-block' . $replaced;
980 - // 無料パートでショートコードを実行できるようにする
981 - update_post_meta($post_emulated->ID,'codoc_shortcode_evacuations',join('**codoc**',$evacuations));
982 - } else {
983 - update_post_meta($post_emulated->id,'codoc_shortcode_evacuations',"");
984 - }
985 - }
986 797 #$content = do_shortcode( $content );
987 798 $content_filtered = apply_filters( 'the_content', $content);
988 799 $this->do_not_filter_the_content = false;
989 800
@@ -1004,47 +815,11 @@
1004 815 if (preg_match('/^(auto-draft|inherit)$/',$post->post_status)) {
1005 816 return;
1006 817 }
1007 818 $entryCode = get_post_meta($post_ID,'codoc_entry_code',true);
1008 - $postId = get_post_meta($post_ID,'codoc_saved_post_id',true);
1009 - // 保存されているIDと違う場合は破棄(duplicate pageなどでmeta情報をコピーされた可能性がある)
1010 - if ($postId and $postId != $post_ID) {
1011 - $entryCode = '';
1012 - }
1013 819 $codoc_settings = get_option(CODOC_SETTINGS_OPTION_NAME);
1014 820 $post_content = (isset($codoc_settings['do_not_filter_the_content']) and $codoc_settings['do_not_filter_the_content']) ?
1015 821 $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 822 $res = $this->util->sync_entry([
1048 823 "post_title" => $post->post_title,
1049 824 "post_content" => $post_content,
1050 825 // password が設定されてる場合は限定公開にする
@@ -1055,27 +830,11 @@
1055 830 ],[
1056 831 "usercode" => get_option(CODOC_USERCODE_OPTION_NAME),
1057 832 "token" => get_option(CODOC_TOKEN_OPTION_NAME),
1058 833 ]);
1059 - $prudent_update_post_meta_entry_code = null;
1060 - if (isset($codoc_settings["debug_params"])) {
1061 - $params_decoded = json_decode($codoc_settings["debug_params"],true);
1062 - if (isset($params_decoded["prudent_update_post_meta_entry_code"])) {
1063 - $prudent_update_post_meta_entry_code = $params_decoded["prudent_update_post_meta_entry_code"];
1064 - }
1065 - }
1066 - if ($prudent_update_post_meta_entry_code == 2) {
1067 - error_log('CODOC:: ' . sprintf ("%s : %s : %s : %s", $post_ID, (is_object($res) ? "1" : 0),$res->status,$entryCode));
1068 - }
834 +
1069 835 if (is_object($res) and $res->status and !$entryCode) {
1070 - // 20230222 https://stackoverflow.com/questions/26640785/update-post-meta-not-work-only-when-save-data-not-for-update
1071 - if ($prudent_update_post_meta_entry_code) {
1072 - add_post_meta($post_ID,'codoc_entry_code',$res->entry->code);
1073 - add_post_meta($post_ID,'codoc_saved_post_id',$post_ID);
1074 - } else {
1075 - update_post_meta($post_ID,'codoc_entry_code',$res->entry->code);
1076 - update_post_meta($post_ID,'codoc_saved_post_id',$post_ID);
1077 - }
836 + update_post_meta($post_ID,'codoc_entry_code',$res->entry->code);
1078 837 }
1079 838 return true;
1080 839 }
1081 840 function updated_post_meta( $meta_ID, $post_ID, $meta_key ) {
@@ -1080,8 +839,9 @@
1080 839 }
1081 840 function updated_post_meta( $meta_ID, $post_ID, $meta_key ) {
1082 841 // スルーされてる場合は他のメタ情報更新のタイミングにサムネイルをアップロード
1083 842 $has_to_resend = get_post_meta($post_ID,'codoc_post_thumbnail_invoking_entry_code',true);
843 + $has_to_resendi = get_post_meta($post_ID,'icodoc_post_thumbnail_invoking_entry_code',true);
1084 844 if ($has_to_resend != 1 and $meta_key != '_thumbnail_id') {
1085 845 return;
1086 846 }
1087 847 if ( has_post_thumbnail($post_ID) ) {
@@ -1117,25 +877,9 @@
1117 877 "token" => get_option(CODOC_TOKEN_OPTION_NAME),
1118 878 ]
1119 879 );
1120 880 }
1121 - // 退避されてるかどうかをmetaを使って確認し、無料エリアの一番最後にショートコードを追加
1122 - function the_content_shortcode_evacuations( $post_content ) {
1123 - if ($this->do_not_filter_the_content) {
1124 - return $post_content;
1125 - }
1126 - $post = get_post();
1127 - if (!$post) {
1128 - return $post_content;
1129 - }
1130 - $evacuations_meta = get_post_meta($post->ID,'codoc_shortcode_evacuations',true);
1131 - $evacuations = preg_split('/\*\*codoc\*\*/',$evacuations_meta);
1132 - foreach ($evacuations as $evacuation) {
1133 - $post_content = sprintf('<div class="codoc-evacuations" style="display:none;" data-shortcode="%s">%s</div>',
1134 - urlencode($evacuation),$evacuation) . $post_content;
1135 - }
1136 - return $post_content;
1137 - }
881 +
1138 882 function the_content( $post_content ) {
1139 883 if ( is_single() && in_the_loop() && is_main_query() ) {
1140 884 }
1141 885 // get_filtered_content から do_not_filter_the_contentを有効にされるパターン
@@ -1143,12 +887,8 @@
1143 887 if ($this->do_not_filter_the_content) {
1144 888 return $post_content;
1145 889 }
1146 890 $post = get_post();
1147 - // 20211215 null になる場合がある
1148 - if (!$post) {
1149 - return $post_content;
1150 - }
1151 891 # is_amp で実装しているテンプレート用
1152 892 $is_amp_endpoint = (function_exists('is_amp_endpoint') && is_amp_endpoint()) ? true :
1153 893 ((function_exists('is_amp') && is_amp()) ? true : false);
1154 894 return $this->util->filter_content([
@@ -1166,76 +906,6 @@
1166 906 if (is_array($allowed_blocks)) {
1167 907 array_push($allowed_blocks,'codoc/codoc-block');
1168 908 }
1169 909 return $allowed_blocks;
1170 - }
1171 -
1172 - function allowed_block_types_all ($allowed_block_types, $block_editor_context) {
1173 - // テーマ等がブロックを制限していない場合(true = 全ブロック許可)はそのまま返す
1174 - if ($allowed_block_types === true) {
1175 - return $allowed_block_types;
1176 - }
1177 - // 配列で制限されている場合、codoc ブロックを追加
1178 - if (is_array($allowed_block_types) && !in_array('codoc/codoc-block', $allowed_block_types)) {
1179 - $allowed_block_types[] = 'codoc/codoc-block';
1180 - }
1181 - 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 - }
1197 -
1198 - function show_tadv_notice() {
1199 - // API からの notification を表示
1200 - $api_notifications = get_transient('codoc_api_notification');
1201 - if ($api_notifications && is_array($api_notifications)) {
1202 - // notification 配列のキーと値を表示
1203 - foreach ($api_notifications as $key => $value) {
1204 - // 値が配列やオブジェクトの場合は json_encode で文字列化
1205 - if (is_array($value) || is_object($value)) {
1206 - $value = json_encode($value, JSON_UNESCAPED_UNICODE);
1207 - }
1208 - echo "<div class=\"notice notice-warning is-dismissible codoc-notification\"><p>" . esc_html($value) . "</p></div>";
1209 - }
1210 - //delete_transient('codoc_api_notification');
1211 - }
1212 -
1213 - $name = 'Advanced Editor Tools';
1214 - $name_escaped = preg_replace('/ /','+',$name);
1215 - $install_url = network_admin_url( "plugin-install.php?tab=search&s=" . $name );
1216 - $options_url = network_admin_url( "options-general.php?page=tinymce-advanced" );
1217 -
1218 - //<a href=\"%s\">%s</a> を有効にし、設定画面にて &quot;Keep paragraph tags in the Classic block and the Classic Editor&quot; を有効にしてください。
1219 - //<a href=\"%s\">%s</a> の設定画面にて &quot;Keep paragraph tags in the Classic block and the Classic Editor&quot; を有効にしてください。
1220 - // Translators: %s is a link to the installation page with the plugin name.
1221 - $tadv_message_for_install = sprintf(__("Please enable %s and enable &quot;Keep paragraph tags in the Classic block and the Classic Editor&quot; on the settings screen.","codoc"),sprintf("<a href=\"%s\">%s</a>",$install_url,$name));
1222 - // Translators: %s is a link to the options settings page with the plugin name.
1223 - $tadv_message_for_options = sprintf(__("Please enable &quot;Keep paragraph tags in the Classic block and the Classic Editor&quot; on the %s settings screen.","codoc"),sprintf("<a href=\"%s\">%s</a>",$options_url,$name));
1224 - // クラシックエディタで advanced editor tools を入れてない場合は notice
1225 - if (is_plugin_active('classic-editor/classic-editor.php') and
1226 - !is_plugin_active('tinymce-advanced/tinymce-advanced.php')) {
1227 - echo "<div class=\"notice notice-warning is-dismissible\"><p>" . esc_html($tadv_message_for_install) . "</p></div>";
1228 - }
1229 -
1230 - // advanced editor tools の設定を調査
1231 - $no_autop = false;
1232 - $tadv_admin_settings = get_option( 'tadv_admin_settings', false );
1233 - if (isset($tadv_admin_settings['options']) and preg_match('/no_autop/',$tadv_admin_settings['options'])) {
1234 - $no_autop = true;
1235 - }
1236 - // advanced editor tools が有効で no_autop (Keep paragraph tags in the Classic block and the Classic Editor) が無効
1237 - if (is_plugin_active('tinymce-advanced/tinymce-advanced.php') and !$no_autop) {
1238 - echo "<div class=\"notice notice-warning is-dismissible\"><p>" . esc_html($tadv_message_for_options) . "</p></div>";
1239 - }
1240 910 }
1241 911 }