Plugin Directory

Changeset 2885100


Ignore:
Timestamp:
03/22/2023 04:37:23 PM (3 years ago)
Author:
husobj
Message:

Version 1.4.2

Location:
page-parts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • page-parts/trunk/CHANGELOG.md

    r2650675 r2885100  
    44
    55## [Unreleased]
     6
     7## [1.4.2] - 2023-03-22
     8
     9### Fixed
     10- Fix compatibility with WPML plugin where page part translations are duplicated.
    611
    712## [1.4.1] - 2021-12-29
     
    135140- First public release.
    136141
    137 [Unreleased]: https://github.com/benhuson/page-parts/compare/1.4.1...HEAD
     142[Unreleased]: https://github.com/benhuson/page-parts/compare/1.4.2...HEAD
     143[1.4.2]: https://github.com/benhuson/page-parts/compare/1.4.1...1.4.2
    138144[1.4.1]: https://github.com/benhuson/page-parts/compare/1.4...1.4.1
    139145[1.4]: https://github.com/benhuson/page-parts/compare/1.3.1...1.4
  • page-parts/trunk/admin/admin.php

    r2650675 r2885100  
    745745            if ( isset( $_POST['parent_id'] ) && current_user_can( 'edit_page', $post_id ) ) {
    746746
    747                 $parent_id = absint( $_POST['parent_id'] );
    748                 $post_type_object = get_post_type_object( get_post_type( $parent_id ) );
    749 
    750                 if ( 0 == $parent_id || ( $post_type_object && current_user_can( $post_type_object->cap->edit_post, $post_id ) ) ) {
    751                     $wpdb->update( $wpdb->posts, array( 'post_parent' => $parent_id ), array( 'ID' => $post_id ) );
     747                // For WPML compatibility, check this is not a duplicate translation
     748                if ( ! $this->is_post_a_wpml_duplicate( $post_id ) ) {
     749
     750                    $parent_id = absint( $_POST['parent_id'] );
     751                    $post_type_object = get_post_type_object( get_post_type( $parent_id ) );
     752
     753                    if ( 0 == $parent_id || ( $post_type_object && current_user_can( $post_type_object->cap->edit_post, $post_id ) ) ) {
     754                        $wpdb->update( $wpdb->posts, array( 'post_parent' => $parent_id ), array( 'ID' => $post_id ) );
     755                    }
     756
    752757                }
    753758
     
    841846
    842847        <?php
     848    }
     849
     850    /**
     851     * Check if post is a WPML duplicate.
     852     * Used to prevent overriding post parent for duplicate translations.
     853     *
     854     * Note:
     855     * WPML_ELEMENT_IS_NOT_TRANSLATED  = 0
     856     * WPML_ELEMENT_IS_TRANSLATED      = 1
     857     * WPML_ELEMENT_IS_DUPLICATED      = 2
     858     * WPML_ELEMENT_IS_A_DUPLICATE     = 3
     859     *
     860     * @param   integer  $post_id
     861     * @return  boolean
     862     */
     863    protected function is_post_a_wpml_duplicate( $post_id ) {
     864
     865        $translation_type = apply_filters( 'wpml_element_translation_type', NULL, $post_id, get_post_type( $post_id ) );
     866
     867        return 3 === $translation_type;
     868
    843869    }
    844870
  • page-parts/trunk/page-parts.php

    r2650675 r2885100  
    55Plugin URI: https://github.com/benhuson/page-parts
    66Description: Manage subsections of a page.
    7 Version: 1.4.1
     7Version: 1.4.2
    88Author: Ben Huson
    99Author URI: https://github.com/benhuson
     
    1111*/
    1212
    13 define( 'PAGE_PARTS_VERSION', '1.4.1' );
     13define( 'PAGE_PARTS_VERSION', '1.4.2' );
    1414define( 'PAGE_PARTS_FILE', __FILE__ );
    1515
  • page-parts/trunk/readme.txt

    r2650675 r2885100  
    33Tags: pages, cms
    44Requires at least: 3.9
    5 Tested up to: 5.8.2
    6 Stable tag: 1.4.1
     5Tested up to: 6.1.1
     6Stable tag: 1.4.2
    77License: GPL2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3838
    3939= Unreleased =
     40
     41= 1.4.2 =
     42
     43__Fixed__
     44- Fix compatibility with WPML plugin where page part translations are duplicated.
    4045
    4146= 1.4.1 =
Note: See TracChangeset for help on using the changeset viewer.