Changeset 3213045
- Timestamp:
- 12/25/2024 04:38:17 PM (15 months ago)
- Location:
- import-kintone
- Files:
-
- 4 added
- 6 edited
- 1 copied
-
tags/1.14.0 (copied) (copied from import-kintone/trunk)
-
tags/1.14.0/admin/class-admin.php (modified) (34 diffs)
-
tags/1.14.0/batch (added)
-
tags/1.14.0/batch/run-update-books.php (added)
-
tags/1.14.0/publish-kintone-data.php (modified) (4 diffs)
-
tags/1.14.0/readme.txt (modified) (2 diffs)
-
trunk/admin/class-admin.php (modified) (34 diffs)
-
trunk/batch (added)
-
trunk/batch/run-update-books.php (added)
-
trunk/publish-kintone-data.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
import-kintone/tags/1.14.0/admin/class-admin.php
r3007573 r3213045 1 1 <?php 2 /** 3 * Admin class 4 * 5 * @package import-kintone 6 */ 7 2 8 namespace publish_kintone_data; 3 9 4 class Admin{ 5 6 private $nonce = 'kintone_to_wp_'; 7 8 public function __construct(){ 10 /** 11 * Admin class 12 * 13 * @package import-kintone 14 */ 15 class Admin { 16 17 /** 18 * Nonce 19 * 20 * @var string 21 */ 22 private $nonce = 'kintone_to_wp_'; 23 24 /** 25 * Constructor 26 * 27 * @return void 28 */ 29 public function __construct() { 9 30 // Create Admin Menu. 10 31 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 11 32 add_action( 'save_post', array( $this, 'update_post_kintone_data' ), 10, 3 ); 12 33 } 34 /** 35 * Admin menu 36 * 37 * @return void 38 */ 13 39 public function admin_menu() { 14 add_submenu_page( 'options-general.php', 'Publish kintone data', 'Publish kintone data', 'manage_options', 'publish-kintone-data-setting', array( 15 $this, 16 'kintone_to_wp_setting' 17 ) ); 18 } 40 add_submenu_page( 41 'options-general.php', 42 'Publish kintone data', 43 'Publish kintone data', 44 'manage_options', 45 'publish-kintone-data-setting', 46 array( 47 $this, 48 'kintone_to_wp_setting', 49 ) 50 ); 51 } 52 /** 53 * Kintone to WP setting 54 * 55 * @return void 56 */ 19 57 public function kintone_to_wp_setting() { 20 58 … … 25 63 $kintone_basci_information = array(); 26 64 27 $kintone_basci_information['domain'] = sanitize_text_field( trim( $_POST['kintone_to_wp_kintone_url'] ) );28 $kintone_basci_information['app_id'] = sanitize_text_field( trim( $_POST['kintone_to_wp_target_appid'] ) );65 $kintone_basci_information['domain'] = isset( $_POST['kintone_to_wp_kintone_url'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_url'] ) ) : ''; 66 $kintone_basci_information['app_id'] = isset( $_POST['kintone_to_wp_target_appid'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_target_appid'] ) ) : ''; 29 67 $kintone_basci_information['url'] = 'https://' . $kintone_basci_information['domain'] . '/k/v1/form.json?app=' . $kintone_basci_information['app_id']; 30 $kintone_basci_information['token'] = sanitize_text_field( trim( $_POST['kintone_to_wp_kintone_api_token'] ) );31 $kintone_basci_information['post_type'] = sanitize_text_field( trim( $_POST['kintone_to_wp_reflect_post_type'] ) );68 $kintone_basci_information['token'] = isset( $_POST['kintone_to_wp_kintone_api_token'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_api_token'] ) ) : ''; 69 $kintone_basci_information['post_type'] = isset( $_POST['kintone_to_wp_reflect_post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_reflect_post_type'] ) ) : ''; 32 70 33 71 $error_flg = false; … … 35 73 echo '<div class="error notice is-dismissible"><p><strong>Domain is required</strong></p></div>'; 36 74 $error_flg = true; 37 } else if ( ! $kintone_basci_information['post_type'] ) {75 } elseif ( ! $kintone_basci_information['post_type'] ) { 38 76 echo '<div class="error notice is-dismissible"><p><strong>Post type is required</strong></p></div>'; 39 77 $error_flg = true; … … 52 90 $kintone_app_fields_code_for_wp = array(); 53 91 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_post_title'] ) ) { 54 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_title'] = sanitize_text_field( $_POST['kintone_to_wp_kintone_field_code_for_post_title']);92 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_title'] = sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_field_code_for_post_title'] ) ); 55 93 } 56 94 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_post_contents'] ) ) { 57 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_contents'] = sanitize_text_field( $_POST['kintone_to_wp_kintone_field_code_for_post_contents']);95 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_contents'] = sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_field_code_for_post_contents'] ) ); 58 96 } 59 97 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_terms'] ) && is_array( $_POST['kintone_to_wp_kintone_field_code_for_terms'] ) ) { 60 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_terms'] = $_POST['kintone_to_wp_kintone_field_code_for_terms']; 98 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_terms'] = array_map( 99 'sanitize_text_field', 100 array_map( 'wp_unslash', $_POST['kintone_to_wp_kintone_field_code_for_terms'] ) 101 ); 61 102 } 62 103 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_featured_image'] ) ) { 63 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_featured_image'] = sanitize_text_field( $_POST['kintone_to_wp_kintone_field_code_for_featured_image']);104 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_featured_image'] = sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_field_code_for_featured_image'] ) ); 64 105 } 65 106 66 107 if ( isset( $_POST['kintone_to_wp_setting_custom_fields'] ) && is_array( $_POST['kintone_to_wp_setting_custom_fields'] ) ) { 67 $kintone_app_fields_code_for_wp['kintone_to_wp_setting_custom_fields'] = $_POST['kintone_to_wp_setting_custom_fields']; 68 } 69 108 $kintone_app_fields_code_for_wp['kintone_to_wp_setting_custom_fields'] = array_map( 109 'sanitize_text_field', 110 array_map( 'wp_unslash', $_POST['kintone_to_wp_setting_custom_fields'] ) 111 ); 112 } 70 113 71 114 $this->update_kintone_app_fields_code_for_wp( $kintone_app_fields_code_for_wp ); … … 76 119 77 120 } 78 79 121 } 80 122 81 123 $wp_n = wp_nonce_field( $this->nonce ); 82 83 124 84 125 $kintone_url = get_option( 'kintone_to_wp_kintone_url' ); … … 92 133 echo '<h2>Setting Publish kintone data</h2>'; 93 134 echo '<form method="post" action="">'; 135 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 94 136 echo $wp_n; 95 137 … … 97 139 echo ' <tr valign="top">'; 98 140 echo ' <th scope="row"><label for="add_text">kintone domain</label></th>'; 99 echo ' <td><input name="kintone_to_wp_kintone_url" type="text" id="kintone_to_wp_kintone_url" value="' . ( $kintone_url == "" ? "": esc_textarea( $kintone_url ) ) . '" class="regular-text" /></td>';141 echo ' <td><input name="kintone_to_wp_kintone_url" type="text" id="kintone_to_wp_kintone_url" value="' . ( '' === $kintone_url ? '' : esc_textarea( $kintone_url ) ) . '" class="regular-text" /></td>'; 100 142 echo ' </tr>'; 101 143 echo ' <tr valign="top">'; 102 144 echo ' <th scope="row"><label for="add_text">API Token</label><br><span style="font-size:10px;">Permission: show record</span></th>'; 103 echo ' <td><input name="kintone_to_wp_kintone_api_token" type="text" id="kintone_to_wp_kintone_api_token" value="' . ( $api_token == "" ? "": esc_textarea( $api_token ) ) . '" class="regular-text" /></td>';145 echo ' <td><input name="kintone_to_wp_kintone_api_token" type="text" id="kintone_to_wp_kintone_api_token" value="' . ( '' === $api_token ? '' : esc_textarea( $api_token ) ) . '" class="regular-text" /></td>'; 104 146 echo ' </tr>'; 105 147 echo ' <tr valign="top">'; 106 148 echo ' <th scope="row"><label for="add_text">Reflect kintone to post_type</label></th>'; 107 149 echo ' <td>'; 108 echo ' kintone APP ID:<input name="kintone_to_wp_target_appid" type="text" id="kintone_to_wp_target_appid" value="' . ( $target_appid == "" ? "": esc_textarea( $target_appid ) ) . '" class="small-text" /> ->';150 echo ' kintone APP ID:<input name="kintone_to_wp_target_appid" type="text" id="kintone_to_wp_target_appid" value="' . ( '' === $target_appid ? '' : esc_textarea( $target_appid ) ) . '" class="small-text" /> ->'; 109 151 echo ' WordPress Post Type:<select name="kintone_to_wp_reflect_post_type">'; 110 152 echo ' <option value=""></option>'; 111 echo ' <option ' . selected( $reflect_post_type, "post", false ) . ' value="post">post</option>';112 echo ' <option ' . selected( $reflect_post_type, "page", false ) . ' value="page">page</option>';113 echo $this->get_html_post_type_form_slect_option( $reflect_post_type ); 153 echo ' <option ' . selected( $reflect_post_type, 'post', false ) . ' value="post">post</option>'; 154 echo ' <option ' . selected( $reflect_post_type, 'page', false ) . ' value="page">page</option>'; 155 echo $this->get_html_post_type_form_slect_option( $reflect_post_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 114 156 echo ' </select>'; 115 157 echo ' </td>'; … … 126 168 127 169 if ( is_wp_error( $kintone_form_data ) ) { 128 // Error 170 // Error. 129 171 if ( ! empty( $old_kintone_data ) ) { 130 172 $disp_data = $old_kintone_data; 131 173 } 132 174 } else { 133 // Success 175 // Success. 134 176 $disp_data = $kintone_form_data; 135 177 } 136 } else { 137 // Nothing 138 if ( ! empty( $old_kintone_data ) ) { 139 $disp_data = $old_kintone_data; 140 } 178 } elseif ( ! empty( $old_kintone_data ) ) { 179 // Nothing. 180 $disp_data = $old_kintone_data; 141 181 } 142 182 143 183 if ( ! empty( $disp_data ) ) { 144 184 145 146 185 echo '<form method="post" action="">'; 147 186 187 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 148 188 echo $wp_n; 149 189 150 echo 'Please set this URL to kintone\'s WEBHOOK-><strong>' . site_url( '/wp-admin/admin-ajax.php?action=kintone_to_wp_start') . '</strong><br><span style="font-size:10px;">Permission: post record, update record, delete record</span>';190 echo 'Please set this URL to kintone\'s WEBHOOK-><strong>' . esc_url( site_url( '/wp-admin/admin-ajax.php?action=kintone_to_wp_start' ) ) . '</strong><br><span style="font-size:10px;">Permission: post record, update record, delete record</span>'; 151 191 echo '<br/>'; 152 192 echo '<br/>'; … … 156 196 echo ' <td>'; 157 197 echo ' <select name="kintone_to_wp_kintone_field_code_for_post_title">'; 158 echo $this->get_html_post_title_form_select_option( $disp_data ); 198 echo $this->get_html_post_title_form_select_option( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 159 199 echo ' </select>'; 160 200 echo ' </td>'; … … 164 204 echo ' <td>'; 165 205 echo ' <select name="kintone_to_wp_kintone_field_code_for_post_contents">'; 166 echo $this->get_html_post_contents_form_select_option( $disp_data ); 206 echo $this->get_html_post_contents_form_select_option( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 167 207 echo ' </select>'; 168 208 echo ' </td>'; … … 171 211 echo ' <th scope="row"><label for="add_text">Select Term</label></th>'; 172 212 echo ' <td>'; 173 echo $this->get_html_taxonomy_form_select( $disp_data, $reflect_post_type ); 213 echo $this->get_html_taxonomy_form_select( $disp_data, $reflect_post_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 174 214 echo ' </td>'; 175 215 echo ' </tr>'; … … 178 218 echo ' <td>'; 179 219 echo ' <select name="kintone_to_wp_kintone_field_code_for_featured_image">'; 180 echo $this->get_html_featured_image_form_select_option( $disp_data ); 220 echo $this->get_html_featured_image_form_select_option( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 181 221 echo ' </select>'; 182 222 echo ' </td>'; … … 185 225 echo ' <th scope="row"><label for="add_text">Setting Custom Field</label></th>'; 186 226 echo ' <td>'; 187 echo $this->get_html_custom_field_form_input( $disp_data ); 227 echo $this->get_html_custom_field_form_input( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 188 228 echo ' </td>'; 189 229 echo ' </tr>'; … … 197 237 198 238 echo '</div>'; 199 200 239 } 201 240 /** … … 246 285 $retun_data = Kintone_Utility::kintone_api( $url, get_option( 'kintone_to_wp_kintone_api_token' ) ); 247 286 $retun_data['kintone_to_wp_status'] = 'normal'; 248 $publish_kintone_data = new Publish_Kintone_Data();287 $publish_kintone_data = new Publish_Kintone_Data(); 249 288 $publish_kintone_data->sync( $retun_data ); 250 251 } 252 private function bulk_update() { 253 254 // 一旦全記事を下書きにする 289 } 290 /** 291 * Bulk update. 292 * 293 * @return void 294 */ 295 public function bulk_update() { 296 297 // 一旦全記事を下書きにする. 255 298 $post_type = apply_filters( 'publish_kintone_data_reflect_post_type', get_option( 'kintone_to_wp_reflect_post_type' ), 'bulk_update' ); 256 299 $args = array( … … 259 302 'post_status' => 'publish', 260 303 ); 261 // The Query 304 262 305 $the_query = new \WP_Query( $args ); 263 306 if ( $the_query->have_posts() ) { 264 307 while ( $the_query->have_posts() ) { 265 308 $the_query->the_post(); 266 // 下書きに更新する 309 // 下書きに更新する. 267 310 wp_update_post( 268 311 array( … … 277 320 278 321 $kintone_data['records'] = array(); 279 $last_id = 0;280 $reacquisition_flag = true;322 $last_id = 0; 323 $reacquisition_flag = true; 281 324 282 325 while ( $reacquisition_flag ) { 283 326 284 $query = apply_filters( 'import_kintone_change_bulk_update_query', '$id > ' . $last_id . ' order by $id asc limit 500' );327 $query = apply_filters( 'import_kintone_change_bulk_update_query', '$id > ' . $last_id . ' order by $id asc limit 500' ); 285 328 286 329 $url = 'https://' . get_option( 'kintone_to_wp_kintone_url' ) . '/k/v1/records.json?app=' . get_option( 'kintone_to_wp_target_appid' ) . '&query=' . $query; … … 292 335 $reacquisition_flag = false; 293 336 } else { 294 $last_id = end( $retun_data['records'])['$id']['value'];337 $last_id = end( $retun_data['records'] )['$id']['value']; 295 338 } 296 339 } … … 302 345 $data['record'] = $value; 303 346 $data['kintone_to_wp_status'] = 'normal'; 304 $data['type'] = 'UPDATE_RECORD';305 $data['app'] = array(306 'id' => get_option( 'kintone_to_wp_target_appid' ) 347 $data['type'] = 'UPDATE_RECORD'; 348 $data['app'] = array( 349 'id' => get_option( 'kintone_to_wp_target_appid' ), 307 350 ); 308 351 $data = apply_filters( 'kintone_to_wp_kintone_data', $data ); 309 $publish_kintone_data = new Publish_Kintone_Data();352 $publish_kintone_data = new Publish_Kintone_Data(); 310 353 $publish_kintone_data->sync( $data ); 311 354 } 312 355 313 356 echo '<div class="updated fade"><p><strong>Updated</strong></p></div>'; 314 315 } 357 } 358 /** 359 * Update kintone app fields code for wp 360 * 361 * @param array $kintone_app_fields_code_for_wp . 362 * 363 * @return void 364 */ 316 365 private function update_kintone_app_fields_code_for_wp( $kintone_app_fields_code_for_wp ) { 317 366 … … 345 394 update_option( 'kintone_to_wp_kintone_field_code_for_featured_image', $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_featured_image'] ); 346 395 } 347 348 } 349 350 396 } 397 398 /** 399 * Update kintone basci information 400 * 401 * @param array $kintone_basci_information . 402 * @param array $kintone_form_data . 403 * 404 * @return void 405 */ 351 406 private function update_kintone_basci_information( $kintone_basci_information, $kintone_form_data ) { 352 353 407 354 408 if ( empty( $kintone_basci_information['url'] ) ) { … … 375 429 update_option( 'kintone_to_wp_reflect_post_type', $kintone_basci_information['post_type'] ); 376 430 } 377 378 431 379 432 if ( ! is_wp_error( $kintone_form_data ) ) { … … 387 440 echo '<div class="updated notice is-dismissible"><p><strong>Success</strong></p></div>'; 388 441 } 389 390 } 391 442 } 443 444 /** 445 * Get html custom field form input 446 * 447 * @param array $kintone_app_form_data . 448 * 449 * @return string 450 */ 392 451 private function get_html_custom_field_form_input( $kintone_app_form_data ) { 393 452 394 $html_setting_custom_fields = "";453 $html_setting_custom_fields = ''; 395 454 $html_setting_custom_fields .= '<table>'; 396 $setting_custom_fields = get_option( 'kintone_to_wp_setting_custom_fields' );455 $setting_custom_fields = get_option( 'kintone_to_wp_setting_custom_fields' ); 397 456 398 457 foreach ( $kintone_app_form_data['properties'] as $kintone_form_value ) { … … 411 470 if ( array_key_exists( 'code', $kintone_form_value ) ) { 412 471 $html_setting_custom_fields .= '<tr>'; 413 if ( $kintone_form_value['type'] == 'RECORD_NUMBER') {414 415 $html_setting_custom_fields .= '<th>' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ') ' . '</th><td><input readonly="readonly" type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="kintone_record_id" class="regular-text" /></td>';472 if ( 'RECORD_NUMBER' === $kintone_form_value['type'] ) { 473 474 $html_setting_custom_fields .= '<th>' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</th><td><input readonly="readonly" type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="kintone_record_id" class="regular-text" /></td>'; 416 475 417 476 } else { … … 422 481 } 423 482 424 $html_setting_custom_fields .= '<th>' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ') ' . '</th><td><input type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="' . esc_attr( $input_val ) . '" class="regular-text" /></td>';483 $html_setting_custom_fields .= '<th>' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</th><td><input type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="' . esc_attr( $input_val ) . '" class="regular-text" /></td>'; 425 484 426 485 } 427 486 $html_setting_custom_fields .= '</tr>'; 428 487 } 429 430 488 } 431 489 $html_setting_custom_fields .= '</table>'; 432 490 433 491 return $html_setting_custom_fields; 434 435 } 436 492 } 493 494 /** 495 * Get html post type form slect option 496 * 497 * @param string $reflect_post_type . 498 * 499 * @return string 500 */ 437 501 private function get_html_post_type_form_slect_option( $reflect_post_type ) { 438 502 439 503 $args = array( 440 504 'public' => true, 441 '_builtin' => false 505 '_builtin' => false, 442 506 ); 443 507 $post_types = get_post_types( $args, 'names' ); … … 449 513 450 514 return $html_option; 451 452 } 453 515 } 516 517 /** 518 * Get html featured image form select option 519 * 520 * @param array $kintone_app_form_data . 521 * 522 * @return string 523 */ 454 524 private function get_html_featured_image_form_select_option( $kintone_app_form_data ) { 455 525 … … 468 538 } 469 539 470 $html_select_featured_image .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_featured_image, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')' . '</option>'; 471 } 472 540 $html_select_featured_image .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_featured_image, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 541 } 473 542 } 474 543 … … 476 545 } 477 546 547 /** 548 * Get html post title form select option 549 * 550 * @param array $kintone_app_form_data . 551 * 552 * @return string 553 */ 478 554 private function get_html_post_title_form_select_option( $kintone_app_form_data ) { 479 555 … … 492 568 } 493 569 494 $html_select_post_title .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_title, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')' . '</option>'; 495 } 496 570 $html_select_post_title .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_title, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 571 } 497 572 } 498 573 499 574 return $html_select_post_title; 500 501 } 502 575 } 576 577 /** 578 * Get html post contents form select option 579 * 580 * @param array $kintone_app_form_data . 581 * 582 * @return string 583 */ 503 584 private function get_html_post_contents_form_select_option( $kintone_app_form_data ) { 504 585 $html_select_post_contents = ''; … … 516 597 } 517 598 518 $html_select_post_contents .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_contents, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')' . '</option>'; 519 } 520 599 $html_select_post_contents .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_contents, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 600 } 521 601 } 522 602 … … 525 605 526 606 607 /** 608 * Get html taxonomy form select 609 * 610 * @param array $kintone_app_form_data . 611 * @param string $reflect_post_type . 612 * 613 * @return string 614 */ 527 615 private function get_html_taxonomy_form_select( $kintone_app_form_data, $reflect_post_type ) { 528 616 529 // Category 617 // Category. 530 618 $terms = get_taxonomies( 531 619 array(), … … 539 627 if ( in_array( $reflect_post_type, $term->object_type ) ) { 540 628 541 $html_select_term .= $term->label . '-><select name="kintone_to_wp_kintone_field_code_for_terms[' . $term->name . ']">';629 $html_select_term .= $term->label . '-><select name="kintone_to_wp_kintone_field_code_for_terms[' . $term->name . ']">'; 542 630 $kintone_field_code_for_terms = get_option( 'kintone_to_wp_kintone_field_code_for_terms' ); 543 631 … … 557 645 558 646 if ( array_key_exists( 'code', $kintone_form_value ) ) { 559 $html_select_term .= '<option ' . selected( $kintone_form_value['code'], $input_val, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ') ' . '</option>';647 $html_select_term .= '<option ' . selected( $kintone_form_value['code'], $input_val, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 560 648 } 561 649 } … … 566 654 567 655 return $html_select_term; 568 569 } 656 } 657 658 /** 659 * Get kintone id without appcode 660 * 661 * @param string $id . 662 * 663 * @return string 664 */ 570 665 private function get_kintone_id_without_appcode( $id ) { 571 666 … … 582 677 583 678 return $id; 584 585 679 } 586 680 } -
import-kintone/tags/1.14.0/publish-kintone-data.php
r3007573 r3213045 4 4 * Plugin URI: 5 5 * Description: The data of kintone can be reflected on WordPress. 6 * Version: 1.1 3.16 * Version: 1.14.0 7 7 * Author: Takashi Hosoya 8 8 * Author URI: http://ht79.info/ … … 10 10 * Text Domain: kintone-to-wp 11 11 * Domain Path: /languages 12 * 13 * @package import-kintone 12 14 */ 13 15 … … 33 35 34 36 define( 'KINTONE_TO_WP_URL', plugins_url( '', __FILE__ ) ); 35 define( 'KINTONE_TO_WP_PATH', dirname( __FILE__ ));37 define( 'KINTONE_TO_WP_PATH', __DIR__ ); 36 38 37 $data = get_file_data(39 $data = get_file_data( 38 40 __FILE__, 39 array( 'ver' => 'Version', 'langs' => 'Domain Path' ) 41 array( 42 'ver' => 'Version', 43 'langs' => 'Domain Path', 44 ) 40 45 ); 41 46 … … 48 53 ); 49 54 50 51 function init(){ 55 /** 56 * Initialize the plugin. 57 * 58 * @return void 59 */ 60 function init() { 52 61 require_once KINTONE_TO_WP_PATH . '/inc/class-kintone-utility.php'; 53 62 -
import-kintone/tags/1.14.0/readme.txt
r3007573 r3213045 4 4 Requires at least: 4.9 5 5 Tested up to: 6.4.2 6 Stable tag: 1.1 3.16 Stable tag: 1.14.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 60 60 61 61 == Changelog == 62 63 = 1.14.0 (2024-12-26) = 64 * [Added] Support executing bulk update from PHP command line 65 * Code forma 62 66 63 67 = 1.13.1 (2023-12-09) = -
import-kintone/trunk/admin/class-admin.php
r3007573 r3213045 1 1 <?php 2 /** 3 * Admin class 4 * 5 * @package import-kintone 6 */ 7 2 8 namespace publish_kintone_data; 3 9 4 class Admin{ 5 6 private $nonce = 'kintone_to_wp_'; 7 8 public function __construct(){ 10 /** 11 * Admin class 12 * 13 * @package import-kintone 14 */ 15 class Admin { 16 17 /** 18 * Nonce 19 * 20 * @var string 21 */ 22 private $nonce = 'kintone_to_wp_'; 23 24 /** 25 * Constructor 26 * 27 * @return void 28 */ 29 public function __construct() { 9 30 // Create Admin Menu. 10 31 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 11 32 add_action( 'save_post', array( $this, 'update_post_kintone_data' ), 10, 3 ); 12 33 } 34 /** 35 * Admin menu 36 * 37 * @return void 38 */ 13 39 public function admin_menu() { 14 add_submenu_page( 'options-general.php', 'Publish kintone data', 'Publish kintone data', 'manage_options', 'publish-kintone-data-setting', array( 15 $this, 16 'kintone_to_wp_setting' 17 ) ); 18 } 40 add_submenu_page( 41 'options-general.php', 42 'Publish kintone data', 43 'Publish kintone data', 44 'manage_options', 45 'publish-kintone-data-setting', 46 array( 47 $this, 48 'kintone_to_wp_setting', 49 ) 50 ); 51 } 52 /** 53 * Kintone to WP setting 54 * 55 * @return void 56 */ 19 57 public function kintone_to_wp_setting() { 20 58 … … 25 63 $kintone_basci_information = array(); 26 64 27 $kintone_basci_information['domain'] = sanitize_text_field( trim( $_POST['kintone_to_wp_kintone_url'] ) );28 $kintone_basci_information['app_id'] = sanitize_text_field( trim( $_POST['kintone_to_wp_target_appid'] ) );65 $kintone_basci_information['domain'] = isset( $_POST['kintone_to_wp_kintone_url'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_url'] ) ) : ''; 66 $kintone_basci_information['app_id'] = isset( $_POST['kintone_to_wp_target_appid'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_target_appid'] ) ) : ''; 29 67 $kintone_basci_information['url'] = 'https://' . $kintone_basci_information['domain'] . '/k/v1/form.json?app=' . $kintone_basci_information['app_id']; 30 $kintone_basci_information['token'] = sanitize_text_field( trim( $_POST['kintone_to_wp_kintone_api_token'] ) );31 $kintone_basci_information['post_type'] = sanitize_text_field( trim( $_POST['kintone_to_wp_reflect_post_type'] ) );68 $kintone_basci_information['token'] = isset( $_POST['kintone_to_wp_kintone_api_token'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_api_token'] ) ) : ''; 69 $kintone_basci_information['post_type'] = isset( $_POST['kintone_to_wp_reflect_post_type'] ) ? sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_reflect_post_type'] ) ) : ''; 32 70 33 71 $error_flg = false; … … 35 73 echo '<div class="error notice is-dismissible"><p><strong>Domain is required</strong></p></div>'; 36 74 $error_flg = true; 37 } else if ( ! $kintone_basci_information['post_type'] ) {75 } elseif ( ! $kintone_basci_information['post_type'] ) { 38 76 echo '<div class="error notice is-dismissible"><p><strong>Post type is required</strong></p></div>'; 39 77 $error_flg = true; … … 52 90 $kintone_app_fields_code_for_wp = array(); 53 91 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_post_title'] ) ) { 54 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_title'] = sanitize_text_field( $_POST['kintone_to_wp_kintone_field_code_for_post_title']);92 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_title'] = sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_field_code_for_post_title'] ) ); 55 93 } 56 94 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_post_contents'] ) ) { 57 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_contents'] = sanitize_text_field( $_POST['kintone_to_wp_kintone_field_code_for_post_contents']);95 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_post_contents'] = sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_field_code_for_post_contents'] ) ); 58 96 } 59 97 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_terms'] ) && is_array( $_POST['kintone_to_wp_kintone_field_code_for_terms'] ) ) { 60 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_terms'] = $_POST['kintone_to_wp_kintone_field_code_for_terms']; 98 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_terms'] = array_map( 99 'sanitize_text_field', 100 array_map( 'wp_unslash', $_POST['kintone_to_wp_kintone_field_code_for_terms'] ) 101 ); 61 102 } 62 103 if ( isset( $_POST['kintone_to_wp_kintone_field_code_for_featured_image'] ) ) { 63 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_featured_image'] = sanitize_text_field( $_POST['kintone_to_wp_kintone_field_code_for_featured_image']);104 $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_featured_image'] = sanitize_text_field( wp_unslash( $_POST['kintone_to_wp_kintone_field_code_for_featured_image'] ) ); 64 105 } 65 106 66 107 if ( isset( $_POST['kintone_to_wp_setting_custom_fields'] ) && is_array( $_POST['kintone_to_wp_setting_custom_fields'] ) ) { 67 $kintone_app_fields_code_for_wp['kintone_to_wp_setting_custom_fields'] = $_POST['kintone_to_wp_setting_custom_fields']; 68 } 69 108 $kintone_app_fields_code_for_wp['kintone_to_wp_setting_custom_fields'] = array_map( 109 'sanitize_text_field', 110 array_map( 'wp_unslash', $_POST['kintone_to_wp_setting_custom_fields'] ) 111 ); 112 } 70 113 71 114 $this->update_kintone_app_fields_code_for_wp( $kintone_app_fields_code_for_wp ); … … 76 119 77 120 } 78 79 121 } 80 122 81 123 $wp_n = wp_nonce_field( $this->nonce ); 82 83 124 84 125 $kintone_url = get_option( 'kintone_to_wp_kintone_url' ); … … 92 133 echo '<h2>Setting Publish kintone data</h2>'; 93 134 echo '<form method="post" action="">'; 135 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 94 136 echo $wp_n; 95 137 … … 97 139 echo ' <tr valign="top">'; 98 140 echo ' <th scope="row"><label for="add_text">kintone domain</label></th>'; 99 echo ' <td><input name="kintone_to_wp_kintone_url" type="text" id="kintone_to_wp_kintone_url" value="' . ( $kintone_url == "" ? "": esc_textarea( $kintone_url ) ) . '" class="regular-text" /></td>';141 echo ' <td><input name="kintone_to_wp_kintone_url" type="text" id="kintone_to_wp_kintone_url" value="' . ( '' === $kintone_url ? '' : esc_textarea( $kintone_url ) ) . '" class="regular-text" /></td>'; 100 142 echo ' </tr>'; 101 143 echo ' <tr valign="top">'; 102 144 echo ' <th scope="row"><label for="add_text">API Token</label><br><span style="font-size:10px;">Permission: show record</span></th>'; 103 echo ' <td><input name="kintone_to_wp_kintone_api_token" type="text" id="kintone_to_wp_kintone_api_token" value="' . ( $api_token == "" ? "": esc_textarea( $api_token ) ) . '" class="regular-text" /></td>';145 echo ' <td><input name="kintone_to_wp_kintone_api_token" type="text" id="kintone_to_wp_kintone_api_token" value="' . ( '' === $api_token ? '' : esc_textarea( $api_token ) ) . '" class="regular-text" /></td>'; 104 146 echo ' </tr>'; 105 147 echo ' <tr valign="top">'; 106 148 echo ' <th scope="row"><label for="add_text">Reflect kintone to post_type</label></th>'; 107 149 echo ' <td>'; 108 echo ' kintone APP ID:<input name="kintone_to_wp_target_appid" type="text" id="kintone_to_wp_target_appid" value="' . ( $target_appid == "" ? "": esc_textarea( $target_appid ) ) . '" class="small-text" /> ->';150 echo ' kintone APP ID:<input name="kintone_to_wp_target_appid" type="text" id="kintone_to_wp_target_appid" value="' . ( '' === $target_appid ? '' : esc_textarea( $target_appid ) ) . '" class="small-text" /> ->'; 109 151 echo ' WordPress Post Type:<select name="kintone_to_wp_reflect_post_type">'; 110 152 echo ' <option value=""></option>'; 111 echo ' <option ' . selected( $reflect_post_type, "post", false ) . ' value="post">post</option>';112 echo ' <option ' . selected( $reflect_post_type, "page", false ) . ' value="page">page</option>';113 echo $this->get_html_post_type_form_slect_option( $reflect_post_type ); 153 echo ' <option ' . selected( $reflect_post_type, 'post', false ) . ' value="post">post</option>'; 154 echo ' <option ' . selected( $reflect_post_type, 'page', false ) . ' value="page">page</option>'; 155 echo $this->get_html_post_type_form_slect_option( $reflect_post_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 114 156 echo ' </select>'; 115 157 echo ' </td>'; … … 126 168 127 169 if ( is_wp_error( $kintone_form_data ) ) { 128 // Error 170 // Error. 129 171 if ( ! empty( $old_kintone_data ) ) { 130 172 $disp_data = $old_kintone_data; 131 173 } 132 174 } else { 133 // Success 175 // Success. 134 176 $disp_data = $kintone_form_data; 135 177 } 136 } else { 137 // Nothing 138 if ( ! empty( $old_kintone_data ) ) { 139 $disp_data = $old_kintone_data; 140 } 178 } elseif ( ! empty( $old_kintone_data ) ) { 179 // Nothing. 180 $disp_data = $old_kintone_data; 141 181 } 142 182 143 183 if ( ! empty( $disp_data ) ) { 144 184 145 146 185 echo '<form method="post" action="">'; 147 186 187 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 148 188 echo $wp_n; 149 189 150 echo 'Please set this URL to kintone\'s WEBHOOK-><strong>' . site_url( '/wp-admin/admin-ajax.php?action=kintone_to_wp_start') . '</strong><br><span style="font-size:10px;">Permission: post record, update record, delete record</span>';190 echo 'Please set this URL to kintone\'s WEBHOOK-><strong>' . esc_url( site_url( '/wp-admin/admin-ajax.php?action=kintone_to_wp_start' ) ) . '</strong><br><span style="font-size:10px;">Permission: post record, update record, delete record</span>'; 151 191 echo '<br/>'; 152 192 echo '<br/>'; … … 156 196 echo ' <td>'; 157 197 echo ' <select name="kintone_to_wp_kintone_field_code_for_post_title">'; 158 echo $this->get_html_post_title_form_select_option( $disp_data ); 198 echo $this->get_html_post_title_form_select_option( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 159 199 echo ' </select>'; 160 200 echo ' </td>'; … … 164 204 echo ' <td>'; 165 205 echo ' <select name="kintone_to_wp_kintone_field_code_for_post_contents">'; 166 echo $this->get_html_post_contents_form_select_option( $disp_data ); 206 echo $this->get_html_post_contents_form_select_option( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 167 207 echo ' </select>'; 168 208 echo ' </td>'; … … 171 211 echo ' <th scope="row"><label for="add_text">Select Term</label></th>'; 172 212 echo ' <td>'; 173 echo $this->get_html_taxonomy_form_select( $disp_data, $reflect_post_type ); 213 echo $this->get_html_taxonomy_form_select( $disp_data, $reflect_post_type ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 174 214 echo ' </td>'; 175 215 echo ' </tr>'; … … 178 218 echo ' <td>'; 179 219 echo ' <select name="kintone_to_wp_kintone_field_code_for_featured_image">'; 180 echo $this->get_html_featured_image_form_select_option( $disp_data ); 220 echo $this->get_html_featured_image_form_select_option( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 181 221 echo ' </select>'; 182 222 echo ' </td>'; … … 185 225 echo ' <th scope="row"><label for="add_text">Setting Custom Field</label></th>'; 186 226 echo ' <td>'; 187 echo $this->get_html_custom_field_form_input( $disp_data ); 227 echo $this->get_html_custom_field_form_input( $disp_data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 188 228 echo ' </td>'; 189 229 echo ' </tr>'; … … 197 237 198 238 echo '</div>'; 199 200 239 } 201 240 /** … … 246 285 $retun_data = Kintone_Utility::kintone_api( $url, get_option( 'kintone_to_wp_kintone_api_token' ) ); 247 286 $retun_data['kintone_to_wp_status'] = 'normal'; 248 $publish_kintone_data = new Publish_Kintone_Data();287 $publish_kintone_data = new Publish_Kintone_Data(); 249 288 $publish_kintone_data->sync( $retun_data ); 250 251 } 252 private function bulk_update() { 253 254 // 一旦全記事を下書きにする 289 } 290 /** 291 * Bulk update. 292 * 293 * @return void 294 */ 295 public function bulk_update() { 296 297 // 一旦全記事を下書きにする. 255 298 $post_type = apply_filters( 'publish_kintone_data_reflect_post_type', get_option( 'kintone_to_wp_reflect_post_type' ), 'bulk_update' ); 256 299 $args = array( … … 259 302 'post_status' => 'publish', 260 303 ); 261 // The Query 304 262 305 $the_query = new \WP_Query( $args ); 263 306 if ( $the_query->have_posts() ) { 264 307 while ( $the_query->have_posts() ) { 265 308 $the_query->the_post(); 266 // 下書きに更新する 309 // 下書きに更新する. 267 310 wp_update_post( 268 311 array( … … 277 320 278 321 $kintone_data['records'] = array(); 279 $last_id = 0;280 $reacquisition_flag = true;322 $last_id = 0; 323 $reacquisition_flag = true; 281 324 282 325 while ( $reacquisition_flag ) { 283 326 284 $query = apply_filters( 'import_kintone_change_bulk_update_query', '$id > ' . $last_id . ' order by $id asc limit 500' );327 $query = apply_filters( 'import_kintone_change_bulk_update_query', '$id > ' . $last_id . ' order by $id asc limit 500' ); 285 328 286 329 $url = 'https://' . get_option( 'kintone_to_wp_kintone_url' ) . '/k/v1/records.json?app=' . get_option( 'kintone_to_wp_target_appid' ) . '&query=' . $query; … … 292 335 $reacquisition_flag = false; 293 336 } else { 294 $last_id = end( $retun_data['records'])['$id']['value'];337 $last_id = end( $retun_data['records'] )['$id']['value']; 295 338 } 296 339 } … … 302 345 $data['record'] = $value; 303 346 $data['kintone_to_wp_status'] = 'normal'; 304 $data['type'] = 'UPDATE_RECORD';305 $data['app'] = array(306 'id' => get_option( 'kintone_to_wp_target_appid' ) 347 $data['type'] = 'UPDATE_RECORD'; 348 $data['app'] = array( 349 'id' => get_option( 'kintone_to_wp_target_appid' ), 307 350 ); 308 351 $data = apply_filters( 'kintone_to_wp_kintone_data', $data ); 309 $publish_kintone_data = new Publish_Kintone_Data();352 $publish_kintone_data = new Publish_Kintone_Data(); 310 353 $publish_kintone_data->sync( $data ); 311 354 } 312 355 313 356 echo '<div class="updated fade"><p><strong>Updated</strong></p></div>'; 314 315 } 357 } 358 /** 359 * Update kintone app fields code for wp 360 * 361 * @param array $kintone_app_fields_code_for_wp . 362 * 363 * @return void 364 */ 316 365 private function update_kintone_app_fields_code_for_wp( $kintone_app_fields_code_for_wp ) { 317 366 … … 345 394 update_option( 'kintone_to_wp_kintone_field_code_for_featured_image', $kintone_app_fields_code_for_wp['kintone_to_wp_kintone_field_code_for_featured_image'] ); 346 395 } 347 348 } 349 350 396 } 397 398 /** 399 * Update kintone basci information 400 * 401 * @param array $kintone_basci_information . 402 * @param array $kintone_form_data . 403 * 404 * @return void 405 */ 351 406 private function update_kintone_basci_information( $kintone_basci_information, $kintone_form_data ) { 352 353 407 354 408 if ( empty( $kintone_basci_information['url'] ) ) { … … 375 429 update_option( 'kintone_to_wp_reflect_post_type', $kintone_basci_information['post_type'] ); 376 430 } 377 378 431 379 432 if ( ! is_wp_error( $kintone_form_data ) ) { … … 387 440 echo '<div class="updated notice is-dismissible"><p><strong>Success</strong></p></div>'; 388 441 } 389 390 } 391 442 } 443 444 /** 445 * Get html custom field form input 446 * 447 * @param array $kintone_app_form_data . 448 * 449 * @return string 450 */ 392 451 private function get_html_custom_field_form_input( $kintone_app_form_data ) { 393 452 394 $html_setting_custom_fields = "";453 $html_setting_custom_fields = ''; 395 454 $html_setting_custom_fields .= '<table>'; 396 $setting_custom_fields = get_option( 'kintone_to_wp_setting_custom_fields' );455 $setting_custom_fields = get_option( 'kintone_to_wp_setting_custom_fields' ); 397 456 398 457 foreach ( $kintone_app_form_data['properties'] as $kintone_form_value ) { … … 411 470 if ( array_key_exists( 'code', $kintone_form_value ) ) { 412 471 $html_setting_custom_fields .= '<tr>'; 413 if ( $kintone_form_value['type'] == 'RECORD_NUMBER') {414 415 $html_setting_custom_fields .= '<th>' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ') ' . '</th><td><input readonly="readonly" type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="kintone_record_id" class="regular-text" /></td>';472 if ( 'RECORD_NUMBER' === $kintone_form_value['type'] ) { 473 474 $html_setting_custom_fields .= '<th>' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</th><td><input readonly="readonly" type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="kintone_record_id" class="regular-text" /></td>'; 416 475 417 476 } else { … … 422 481 } 423 482 424 $html_setting_custom_fields .= '<th>' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ') ' . '</th><td><input type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="' . esc_attr( $input_val ) . '" class="regular-text" /></td>';483 $html_setting_custom_fields .= '<th>' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</th><td><input type="text" name="kintone_to_wp_setting_custom_fields[' . esc_attr( $kintone_form_value['code'] ) . ']" value="' . esc_attr( $input_val ) . '" class="regular-text" /></td>'; 425 484 426 485 } 427 486 $html_setting_custom_fields .= '</tr>'; 428 487 } 429 430 488 } 431 489 $html_setting_custom_fields .= '</table>'; 432 490 433 491 return $html_setting_custom_fields; 434 435 } 436 492 } 493 494 /** 495 * Get html post type form slect option 496 * 497 * @param string $reflect_post_type . 498 * 499 * @return string 500 */ 437 501 private function get_html_post_type_form_slect_option( $reflect_post_type ) { 438 502 439 503 $args = array( 440 504 'public' => true, 441 '_builtin' => false 505 '_builtin' => false, 442 506 ); 443 507 $post_types = get_post_types( $args, 'names' ); … … 449 513 450 514 return $html_option; 451 452 } 453 515 } 516 517 /** 518 * Get html featured image form select option 519 * 520 * @param array $kintone_app_form_data . 521 * 522 * @return string 523 */ 454 524 private function get_html_featured_image_form_select_option( $kintone_app_form_data ) { 455 525 … … 468 538 } 469 539 470 $html_select_featured_image .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_featured_image, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')' . '</option>'; 471 } 472 540 $html_select_featured_image .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_featured_image, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 541 } 473 542 } 474 543 … … 476 545 } 477 546 547 /** 548 * Get html post title form select option 549 * 550 * @param array $kintone_app_form_data . 551 * 552 * @return string 553 */ 478 554 private function get_html_post_title_form_select_option( $kintone_app_form_data ) { 479 555 … … 492 568 } 493 569 494 $html_select_post_title .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_title, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')' . '</option>'; 495 } 496 570 $html_select_post_title .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_title, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 571 } 497 572 } 498 573 499 574 return $html_select_post_title; 500 501 } 502 575 } 576 577 /** 578 * Get html post contents form select option 579 * 580 * @param array $kintone_app_form_data . 581 * 582 * @return string 583 */ 503 584 private function get_html_post_contents_form_select_option( $kintone_app_form_data ) { 504 585 $html_select_post_contents = ''; … … 516 597 } 517 598 518 $html_select_post_contents .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_contents, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')' . '</option>'; 519 } 520 599 $html_select_post_contents .= '<option ' . selected( $kintone_form_value['code'], $kintone_field_code_for_post_contents, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $label ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 600 } 521 601 } 522 602 … … 525 605 526 606 607 /** 608 * Get html taxonomy form select 609 * 610 * @param array $kintone_app_form_data . 611 * @param string $reflect_post_type . 612 * 613 * @return string 614 */ 527 615 private function get_html_taxonomy_form_select( $kintone_app_form_data, $reflect_post_type ) { 528 616 529 // Category 617 // Category. 530 618 $terms = get_taxonomies( 531 619 array(), … … 539 627 if ( in_array( $reflect_post_type, $term->object_type ) ) { 540 628 541 $html_select_term .= $term->label . '-><select name="kintone_to_wp_kintone_field_code_for_terms[' . $term->name . ']">';629 $html_select_term .= $term->label . '-><select name="kintone_to_wp_kintone_field_code_for_terms[' . $term->name . ']">'; 542 630 $kintone_field_code_for_terms = get_option( 'kintone_to_wp_kintone_field_code_for_terms' ); 543 631 … … 557 645 558 646 if ( array_key_exists( 'code', $kintone_form_value ) ) { 559 $html_select_term .= '<option ' . selected( $kintone_form_value['code'], $input_val, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ') ' . '</option>';647 $html_select_term .= '<option ' . selected( $kintone_form_value['code'], $input_val, false ) . ' value="' . esc_attr( $kintone_form_value['code'] ) . '">' . esc_html( $kintone_form_value['label'] ) . '(' . esc_html( $kintone_form_value['code'] ) . ')</option>'; 560 648 } 561 649 } … … 566 654 567 655 return $html_select_term; 568 569 } 656 } 657 658 /** 659 * Get kintone id without appcode 660 * 661 * @param string $id . 662 * 663 * @return string 664 */ 570 665 private function get_kintone_id_without_appcode( $id ) { 571 666 … … 582 677 583 678 return $id; 584 585 679 } 586 680 } -
import-kintone/trunk/publish-kintone-data.php
r3007573 r3213045 4 4 * Plugin URI: 5 5 * Description: The data of kintone can be reflected on WordPress. 6 * Version: 1.1 3.16 * Version: 1.14.0 7 7 * Author: Takashi Hosoya 8 8 * Author URI: http://ht79.info/ … … 10 10 * Text Domain: kintone-to-wp 11 11 * Domain Path: /languages 12 * 13 * @package import-kintone 12 14 */ 13 15 … … 33 35 34 36 define( 'KINTONE_TO_WP_URL', plugins_url( '', __FILE__ ) ); 35 define( 'KINTONE_TO_WP_PATH', dirname( __FILE__ ));37 define( 'KINTONE_TO_WP_PATH', __DIR__ ); 36 38 37 $data = get_file_data(39 $data = get_file_data( 38 40 __FILE__, 39 array( 'ver' => 'Version', 'langs' => 'Domain Path' ) 41 array( 42 'ver' => 'Version', 43 'langs' => 'Domain Path', 44 ) 40 45 ); 41 46 … … 48 53 ); 49 54 50 51 function init(){ 55 /** 56 * Initialize the plugin. 57 * 58 * @return void 59 */ 60 function init() { 52 61 require_once KINTONE_TO_WP_PATH . '/inc/class-kintone-utility.php'; 53 62 -
import-kintone/trunk/readme.txt
r3007573 r3213045 4 4 Requires at least: 4.9 5 5 Tested up to: 6.4.2 6 Stable tag: 1.1 3.16 Stable tag: 1.14.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 60 60 61 61 == Changelog == 62 63 = 1.14.0 (2024-12-26) = 64 * [Added] Support executing bulk update from PHP command line 65 * Code forma 62 66 63 67 = 1.13.1 (2023-12-09) =
Note: See TracChangeset
for help on using the changeset viewer.