Changeset 2246760
- Timestamp:
- 02/19/2020 10:33:54 AM (6 years ago)
- Location:
- allthecontent/trunk
- Files:
-
- 4 edited
-
includes/ATCDB.php (modified) (1 diff)
-
includes/ATCImporterProcess.php (modified) (9 diffs)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
allthecontent/trunk/includes/ATCDB.php
r1133539 r2246760 126 126 127 127 $ids = array(); 128 if ( count($inthemes) > 0) {128 if (strlen($inthemes) > 0) { 129 129 $sql = "SELECT wp_category_id FROM " . $wpdb->prefix . self::$TABLE_CATEGORY_MAPPING_NAME . 130 130 " WHERE atc_theme_code in (" . $inthemes . ");"; -
allthecontent/trunk/includes/ATCImporterProcess.php
r2246203 r2246760 21 21 public $successCount = 0; 22 22 23 public function log($message) { 24 error_log($message, 3, ABSPATH . 'atc_importer_log.txt'); 25 } 26 23 27 public function error($message) { 24 28 error_log($message); … … 51 55 52 56 // update last run 53 update_option('atc_importer_last_run', "" +time());57 update_option('atc_importer_last_run', "" . time()); 54 58 55 59 // set as not running … … 97 101 // check if the content delivery has already been imported 98 102 $exists = $this->find_existing_post_for_delivery($content['_deliveryId']); 99 if (isset($exists)) 103 if (isset($exists)) { 104 ATCDB::createErrorLog($file, "Delivery " . $content['_deliveryId'] . " has already been imported!", null); 100 105 return; 101 106 } 102 107 ATCDB::create_default_mapping_for_themes($content['themes']); 103 108 … … 113 118 // check if we need to update 114 119 $existingVersion = intval(get_post_meta( $existingPost->ID, 'atc_version', true)); 115 if ($existingVersion >= intval($content['version'])) 120 if ($existingVersion >= intval($content['version'])) { 121 ATCDB::createErrorLog($file, "Content " . $existingPost->ID . " version " . $content['version'] . " has already been imported!", null); 116 122 return; 123 } 117 124 118 125 // update existing post … … 408 415 409 416 // captions 410 if (count($captions > 1)) {417 if (count($captions) > 1) { 411 418 $formated .= "\n\n<div class='container'>"; 412 419 for($i = 1; $i < count($captions); $i++) { … … 455 462 456 463 } else { 457 $sr = "<a href=\"http ://www.allthecontent.com\" target=\"_blank\">/AllTheContent</a>";464 $sr = "<a href=\"https://www.allthecontent.com\" target=\"_blank\">/AllTheContent</a>"; 458 465 $credits = str_replace("/ATCNA", $sr, $credits); 459 466 $credits = str_replace("/ATC", $sr, $credits); … … 469 476 */ 470 477 public function find_existing_post(array $content) { 471 $qargs = array( 472 'post_type' => 'post', 473 'post_status' => 'any', 474 'meta_query' => array( 475 'relation' => 'AND', // Optional, defaults to "AND", or set it to "OR" 476 array( 477 'key' => 'atc_refid', 478 'value' => $content['refid'], 479 'compare' => '=' 480 ) 481 ), 482 ); 483 $query = new WP_Query($qargs); 484 if ($query->have_posts()) 485 return $query->next_post(); 486 else return null; 478 global $wpdb; 479 $postTableName = $wpdb->prefix . "posts"; 480 $metaTableName = $wpdb->prefix . "postmeta"; 481 $query = "SELECT p.* FROM " . $postTableName . " p " 482 . " INNER JOIN " . $metaTableName . " pm ON p.ID = pm.post_id " 483 . " WHERE pm.meta_key = 'atc_refid' AND pm.meta_value = '" . $content['refid'] . "' " 484 . " AND p.post_type = 'post' AND p.post_status <> 'trash' AND p.post_status <> 'auto-draft'"; 485 $row = $wpdb->get_row($query, OBJECT); 486 return $row; 487 487 } 488 488 … … 491 491 */ 492 492 public function find_existing_post_for_delivery($delivery_id) { 493 $qargs = array( 494 'post_type' => 'post', 495 'post_status' => 'any', 496 'meta_query' => array( 497 'relation' => 'AND', // Optional, defaults to "AND", or set it to "OR" 498 array( 499 'key' => 'atc_delivery_id', 500 'value' => $delivery_id, 501 'compare' => '=' 502 ) 503 ), 504 ); 505 $query = new WP_Query($qargs); 506 if ($query->have_posts()) 507 return $query->next_post(); 508 else return null; 493 global $wpdb; 494 $postTableName = $wpdb->prefix . "posts"; 495 $metaTableName = $wpdb->prefix . "postmeta"; 496 $query = "SELECT p.* FROM " . $postTableName . " p " 497 . " INNER JOIN " . $metaTableName . " pm ON p.ID = pm.post_id " 498 . " WHERE pm.meta_key = 'atc_delivery_id' AND pm.meta_value = '" . $delivery_id . "' " 499 . " AND p.post_type = 'post' AND p.post_status <> 'trash' AND p.post_status <> 'auto-draft'"; 500 $row = $wpdb->get_row($query, OBJECT); 501 return $row; 509 502 } 510 503 … … 513 506 */ 514 507 public function find_existing_attachment(array $att) { 515 $qargs = array( 516 'post_type' => 'attachment', 517 'post_status' => 'any', 518 'name' => sanitize_text_field($att['uid']), 519 ); 520 $query = new WP_Query($qargs); 521 if ($query->have_posts()) 522 return $query->next_post(); 523 else return null; 508 global $wpdb; 509 $postTableName = $wpdb->prefix . "posts"; 510 $query = "SELECT p.* FROM " . $postTableName . " p " 511 . " WHERE p.post_name = '". sanitize_text_field($att['uid']) . "' " 512 . " AND p.post_type = 'attachment' AND p.post_status <> 'trash' AND p.post_status <> 'auto-draft'"; 513 $row = $wpdb->get_row($query, OBJECT); 514 return $row; 524 515 } 525 516 -
allthecontent/trunk/index.php
r2246203 r2246760 5 5 * Plugin URI: http://www.allthecontent.com/ 6 6 * Description: AllTheContent for wordpress is an importer for ATCML format. Get all your content imported into your Wordpress automatically. 7 * Version: 0.1. 47 * Version: 0.1.5 8 8 * Author: AllTheContent, Vincent Buzzano 9 9 * Author URI: http://www.allthecontent.com -
allthecontent/trunk/readme.txt
r2246203 r2246760 4 4 Requires at least: 4.0 5 5 Tested up to: 5.3.2 6 Stable tag: 0.1. 46 Stable tag: 0.1.5 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 44 44 45 45 == Changelog == 46 = 0.1.5 (2020-02-19) 47 * Fix importation process 48 * Fix already imported log 46 49 47 50 = 0.1.1 (2015-04-15) =
Note: See TracChangeset
for help on using the changeset viewer.