Plugin Directory

Changeset 2310158


Ignore:
Timestamp:
05/22/2020 12:08:56 PM (6 years ago)
Author:
thmarx
Message:

release 4.3.0

Location:
experience-manager/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • experience-manager/trunk/experience-manager.php

    r2310073 r2310158  
    55  Description: The integration for the experience platform.
    66  Author: WP-DigitalExperience - Thorsten Marx
    7   Version: 4.2.4
     7  Version: 4.3.0
    88  Author URI: https://wp-digitalexperience.com/
    99  Text Domain: tma-webtools
     
    1414}
    1515
    16 define("TMA_EXPERIENCE_MANAGER_VERSION", "4.2.4");
     16define("TMA_EXPERIENCE_MANAGER_VERSION", "4.3.0");
    1717define("TMA_EXPERIENCE_MANAGER_SEGMENT_MATCHING_ALL", "all");
    1818define("TMA_EXPERIENCE_MANAGER_SEGMENT_MATCHING_ANY", "any");
  • experience-manager/trunk/includes/backend/content/class.content-editor.php

    r2304154 r2310158  
    11<?php
     2
    23/*
    34 * To change this license header, choose License Headers in Project Properties.
     
    2526
    2627    public function register() {
    27         add_action('save_post_exm_content', [$this, 'save']);
    28         add_filter('gutenberg_can_edit_post_type', [$this, "disable_gutenberg"], 10, 2);
    29         add_action('admin_enqueue_scripts', [$this, "query_editor_scripts"]);
    30        
     28        add_action('save_post_exm_content', [$this, 'save'], 9);
     29        add_filter('gutenberg_can_edit_post_type', [$this, "disable_gutenberg"], 9, 2);
     30        add_action('admin_enqueue_scripts', [$this, "query_editor_scripts"], 9);
     31
    3132        //add_action('edit_form_top', [$this, 'top_buttons']);
     33        $this->enable_revision();
    3234    }
    33    
     35
    3436    function top_buttons($post) {
    3537        if ($post->post_type !== ContentType::$TYPE) {
     
    3739        }
    3840        echo "<a class='ui button primary' id='tma_content_library' href='#'>" . __("Open library", "tma-webtools") . "</a>";
    39        
     41
    4042        include 'content-library.php';
    4143    }
    42    
    4344
    4445    function query_editor_scripts($hook_suffix) {
     
    6667    }
    6768
    68 
    6969    public function save($post_id) {
    7070        $content = new Flex_Content($post_id);
     
    8383        }
    8484    }
     85
     86    private function enable_revision() {
     87        add_filter('_wp_post_revision_field_exm_content_editor_html', [$this, 'pmr_field'], 10, 3);
     88        add_filter('_wp_post_revision_field_exm_content_editor_js', [$this, 'pmr_field'], 10, 3);
     89        add_filter('_wp_post_revision_field_exm_content_editor_css', [$this, 'pmr_field'], 10, 3);
     90        add_filter('_wp_post_revision_field_exm_content_settings', [$this, 'pmr_field'], 10, 3);
     91        add_action('save_post', [$this, 'pmr_save_post'], 10, 2);
     92        add_action('wp_restore_post_revision', [$this, 'pmr_restore_revision'], 10, 2);
     93        add_filter('_wp_post_revision_fields', [$this, 'pmr_fields']);
     94    }
     95
     96    function pmr_fields($fields) {
     97        $fields['exm_content_editor_html'] = 'Flex Content HTML';
     98        $fields['exm_content_editor_js'] = 'Flex Content JS';
     99        $fields['exm_content_editor_css'] = 'Flex Content CSS';
     100        $fields['exm_content_settings'] = 'Flex Content Settings';
     101        return $fields;
     102    }
     103
     104// global $revision doesn't work, using third parameter $post instead
     105    function pmr_field($value, $field, $post) {
     106        return get_metadata('post', $post->ID, $field, true);
     107    }
     108
     109    function pmr_restore_revision($post_id, $revision_id) {
     110        $post = get_post($post_id);
     111        $revision = get_post($revision_id);
     112
     113        $fields = $this->pmr_fields([]);
     114        foreach ($fields AS $key => $value) {
     115            $meta = get_metadata('post', $revision->ID, $key, true);
     116
     117            if (false === $meta) {
     118                delete_post_meta($post_id, $key);
     119            } else {
     120                update_post_meta($post_id, $key, $meta);
     121            }
     122        }
     123    }
     124
     125    function pmr_save_post($post_id, $post) {
     126        if ($parent_id = wp_is_post_revision($post_id)) {
     127            $parent = get_post($parent_id);
     128            $fields = $this->pmr_fields([]);
     129            foreach ($fields AS $key => $value) {
     130                $meta = get_post_meta($parent->ID, $key, true);
     131
     132                if (false !== $meta) {
     133                    add_metadata('post', $post_id, $key, $meta);
     134                }
     135            }
     136        }
     137    }
     138
    85139}
  • experience-manager/trunk/readme.txt

    r2310073 r2310158  
    44Requires at least: 4.4.1
    55Tested up to: 5.4
    6 Stable tag: 4.2.4
    7 Version: 4.2.4
     6Stable tag: 4.3.0
     7Version: 4.3.0
    88License: GPLv2 or later
    99
     
    6969== Changelog ==
    7070
    71 4.2.4
    72  * Enable revisoins for flex content
     714.3.0
     72 * Enable revisions for flex content
    7373
    74744.2.3
Note: See TracChangeset for help on using the changeset viewer.