Plugin Directory

Changeset 2246760


Ignore:
Timestamp:
02/19/2020 10:33:54 AM (6 years ago)
Author:
allthecontent
Message:

update to 0.1.5

Location:
allthecontent/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • allthecontent/trunk/includes/ATCDB.php

    r1133539 r2246760  
    126126
    127127        $ids = array();
    128         if (count($inthemes) > 0) {
     128        if (strlen($inthemes) > 0) {
    129129            $sql = "SELECT wp_category_id FROM " . $wpdb->prefix . self::$TABLE_CATEGORY_MAPPING_NAME .
    130130                   " WHERE atc_theme_code in (" . $inthemes . ");";
  • allthecontent/trunk/includes/ATCImporterProcess.php

    r2246203 r2246760  
    2121    public $successCount = 0;
    2222
     23    public function log($message) {
     24        error_log($message, 3, ABSPATH . 'atc_importer_log.txt');
     25    }
     26
    2327    public function error($message) {
    2428        error_log($message);
     
    5155
    5256        // update last run
    53         update_option('atc_importer_last_run', ""+time());
     57        update_option('atc_importer_last_run', "" . time());
    5458
    5559        // set as not running
     
    97101        // check if the content delivery has already been imported
    98102        $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);
    100105            return;
    101 
     106        }
    102107        ATCDB::create_default_mapping_for_themes($content['themes']);
    103108
     
    113118            // check if we need to update
    114119            $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);
    116122                return;
     123            }
    117124
    118125            // update existing post
     
    408415
    409416        // captions
    410         if (count($captions > 1)) {
     417        if (count($captions) > 1) {
    411418            $formated .= "\n\n<div class='container'>";
    412419            for($i = 1; $i < count($captions); $i++) {
     
    455462
    456463        } 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>";
    458465            $credits = str_replace("/ATCNA", $sr, $credits);
    459466            $credits = str_replace("/ATC", $sr, $credits);
     
    469476     */
    470477    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;
    487487    }
    488488
     
    491491     */
    492492    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;
    509502    }
    510503
     
    513506     */
    514507    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;
    524515    }
    525516
  • allthecontent/trunk/index.php

    r2246203 r2246760  
    55 * Plugin URI: http://www.allthecontent.com/
    66 * Description: AllTheContent for wordpress is an importer for ATCML format. Get all your content imported into your Wordpress automatically.
    7  * Version: 0.1.4
     7 * Version: 0.1.5
    88 * Author: AllTheContent, Vincent Buzzano
    99 * Author URI: http://www.allthecontent.com
  • allthecontent/trunk/readme.txt

    r2246203 r2246760  
    44Requires at least: 4.0
    55Tested up to: 5.3.2
    6 Stable tag: 0.1.4
     6Stable tag: 0.1.5
    77License: GPLv2
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4444
    4545== Changelog ==
     46= 0.1.5 (2020-02-19)
     47* Fix importation process
     48* Fix already imported log
    4649
    4750= 0.1.1 (2015-04-15) =
Note: See TracChangeset for help on using the changeset viewer.