Plugin Directory

Changeset 2942170


Ignore:
Timestamp:
07/23/2023 04:32:02 PM (3 years ago)
Author:
seindal
Message:

Version 0.19

Location:
planetplanet/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • planetplanet/trunk/planetplanet-cli.php

    r2828210 r2942170  
    281281     * : Update given posts
    282282     *
     283     * [--force]
     284     * : Force the change
     285     *
    283286     * [--log-level=<level>]
    284287     * : Change the log-level from what is configured in the plugin
     
    303306            $planetplanet->set_loglevel( $assoc['log-level']);
    304307
     308        $force = false;
     309        if ( isset( $assoc['force'] ) )
     310            $force = true;
     311
    305312        foreach ( $args as $arg ) {
    306313            WP_CLI::log( sprintf( __("Updating thumbnail for post %d", 'planetplanet' ), $arg ) );
    307             $planetplanet->add_featured_image( (int)$arg );
     314
     315            $post_id = (int)$arg;
     316            $image_url = NULL;
     317
     318            $cats = wp_get_post_categories( $post_id, [ 'fields' => 'all'] );
     319            if ( ! is_wp_error( $cats ) ) {
     320                $link = $planetplanet->get_category_link_object( $cats[0] );
     321
     322                if ( isset( $link ) )
     323                    $image_url = $link->link_image;
     324            }
     325
     326            if ( $force )
     327                delete_post_thumbnail( $post_id );
     328
     329            $planetplanet->add_featured_image( $post_id, $image_url );
    308330        }
    309331    }
  • planetplanet/trunk/planetplanet.php

    r2871308 r2942170  
    88 * Text Domain:     planetplanet
    99 * Domain Path:     /languages
    10  * Version:         0.18
     10 * Version:         0.19
    1111 *
    1212 * @package         Planetplanet
     
    124124    function get_option( $name ) {
    125125        $options = get_option( 'planetplanet_options' );
     126        if ( empty( $options ) ) return NULL;
    126127        if ( array_key_exists( $name, $options ) ) return $options[$name];
    127128        if ( array_key_exists( "planetplanet_$name", $options ) ) return $options["planetplanet_$name"];
     
    720721    }
    721722
    722     function get_category_link( $cat ) {
     723    function get_category_link_object( $cat ) {
    723724        $linkmap = get_transient( 'planetplanet_category_linkmap' );
    724725
    725         if ( isset( $linkmap ) and isset( $linkmap[$cat->term_id] ) )
    726             return $linkmap[$cat->term_id];
     726        $cat_id = $cat->term_id;
     727
     728        if ( isset( $linkmap ) and isset( $linkmap[$cat_id] ) )
     729            return $linkmap[$cat_id];
    727730
    728731        $linkmap = [];
     
    732735
    733736            if ( $linkcat )
    734                 $linkmap[$linkcat->term_id] = $link->link_url;
     737                $linkmap[$linkcat->term_id] = $link;
    735738        }
    736739        set_transient( 'planetplanet_category_linkmap', $linkmap );
    737740
    738         return isset( $linkmap[$cat->term_id] ) ? $linkmap[$cat->term_id] : NULL;
     741        return isset( $linkmap[$cat_id] ) ? $linkmap[$cat_id] : NULL;
     742    }
     743
     744    function get_category_link( $cat ) {
     745        $link = $this->get_category_link_object( $cat );
     746        return isset( $link ) ? $link->link_url : NULL;
    739747    }
    740748
     
    805813
    806814            // Add feature image if found
    807             $this->add_featured_image( $post_id );
     815            $this->add_featured_image( $post_id, $link->link_image );
    808816        }
    809817
     
    817825    }
    818826
    819     function add_featured_image( $post_id ) {
     827    function add_featured_image( $post_id, $image_url = NULL ) {
    820828        $post = get_post( (int)$post_id );
    821829
     
    823831        if ( has_post_thumbnail( $post ) ) return;
    824832
    825         $image_url = $this->get_featured_image_from_content( $post );
     833        if ( empty( $image_url ) )
     834            $image_url = $this->get_featured_image_from_content( $post );
    826835        if ( empty( $image_url ) )
    827836            $image_url = $this->get_featured_image_from_original_post( $post );
  • planetplanet/trunk/readme.txt

    r2942102 r2942170  
    55Tested up to: 6.3
    66Requires PHP: 7.4
    7 Stable tag: 0.18
     7Stable tag: 0.19
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    3030
    3131Implementation notes: feeds errors are counted in the link_rating field, and the feed is marked not visible if it generates too many errors.
     32
     33The fields in the Links section are used like this:
     34* Name: site title
     35* Web address: main site url
     36* Advanced / Image Address: featured image override url
     37* Advanced / RSS Address: site feed url
     38* Advanced / Notes: last update time or last error message
     39* Advanced / Rating: error count
     40* Keep this link private: private links are ignored
    3241
    3342== Installation ==
     
    7988== Changelog ==
    8089
     90= 0.19 =
     91* Tested with WP 6.3rc1
     92* Fixed a bug in first time activation
     93* Link field 'link_image' can be used to override site thumbnail
     94
    8195= 0.13 =
    8296* First published version.
Note: See TracChangeset for help on using the changeset viewer.