Plugin Directory

Changeset 3135951


Ignore:
Timestamp:
08/15/2024 06:10:08 AM (20 months ago)
Author:
jamesdlow
Message:

1.0.8

  • Correctly set author in translated post
Location:
ai-translate-for-polylang
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • ai-translate-for-polylang/trunk/ai-translate-polylang.php

    r3135327 r3135951  
    44Plugin URI: https://wordpress.org/plugins/ai-translate-polylang/
    55Description: Add auto AI translation caperbility to Polylang
    6 Version: 1.0.7
     6Version: 1.0.8
    77Author: James Low
    88Author URI: http://jameslow.com
     
    177177        }
    178178    }
     179    public static $author = 0;
     180    public static function wp_insert_post_data($data , $postarr) {
     181        $data['post_author'] = self::$author;
     182        self::$author = 0;
     183        remove_filter('wp_insert_post_data', array(static::class, 'wp_insert_post_data'), 99);
     184        return $data;
     185    }
    179186    public static function translate_post($post_id, $to, $status = 'publish') {
    180187        $from = pll_get_post_language($post_id);
     
    182189        if (!$translation || get_post_status($translation) !== false) {
    183190            $post = get_post($post_id);
    184 
     191           
     192            self::$author = $post->post_author;
     193            add_filter('wp_insert_post_data', array(static::class, 'wp_insert_post_data'), '99', 2);
    185194            // Create a new post with the same content
    186195            $new_post_id = wp_insert_post([
     
    190199                'post_status'       => $status,
    191200                'post_type'         => $post->post_type,
    192                 'post_author'       => $post->post_author,
     201                'post_author'       => $post->post_author, //Wordpress overrides author to 0, hence hook
    193202                'post_date'         => $post->post_date,
    194203                'post_date_gmt'     => $post->post_date_gmt,
  • ai-translate-for-polylang/trunk/readme.txt

    r3135327 r3135951  
    55Requires at least: 3.0
    66Tested up to: 6.6.1
    7 Stable tag: 1.0.7
     7Stable tag: 1.0.8
    88License: MIT
    99License URI: https://opensource.org/licenses/MIT
     
    3434== Changelog ==
    3535
     36= 1.0.8 =
     37* Correctly set author in translated post
     38
    3639= 1.0.7 =
    37 * Copy author and dates when translation post
     40* Copy author and dates when translating post
    3841
    3942= 1.0.6 =
Note: See TracChangeset for help on using the changeset viewer.