Changeset 2310158
- Timestamp:
- 05/22/2020 12:08:56 PM (6 years ago)
- Location:
- experience-manager/trunk
- Files:
-
- 3 edited
-
experience-manager.php (modified) (2 diffs)
-
includes/backend/content/class.content-editor.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
experience-manager/trunk/experience-manager.php
r2310073 r2310158 5 5 Description: The integration for the experience platform. 6 6 Author: WP-DigitalExperience - Thorsten Marx 7 Version: 4. 2.47 Version: 4.3.0 8 8 Author URI: https://wp-digitalexperience.com/ 9 9 Text Domain: tma-webtools … … 14 14 } 15 15 16 define("TMA_EXPERIENCE_MANAGER_VERSION", "4. 2.4");16 define("TMA_EXPERIENCE_MANAGER_VERSION", "4.3.0"); 17 17 define("TMA_EXPERIENCE_MANAGER_SEGMENT_MATCHING_ALL", "all"); 18 18 define("TMA_EXPERIENCE_MANAGER_SEGMENT_MATCHING_ANY", "any"); -
experience-manager/trunk/includes/backend/content/class.content-editor.php
r2304154 r2310158 1 1 <?php 2 2 3 /* 3 4 * To change this license header, choose License Headers in Project Properties. … … 25 26 26 27 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 31 32 //add_action('edit_form_top', [$this, 'top_buttons']); 33 $this->enable_revision(); 32 34 } 33 35 34 36 function top_buttons($post) { 35 37 if ($post->post_type !== ContentType::$TYPE) { … … 37 39 } 38 40 echo "<a class='ui button primary' id='tma_content_library' href='#'>" . __("Open library", "tma-webtools") . "</a>"; 39 41 40 42 include 'content-library.php'; 41 43 } 42 43 44 44 45 function query_editor_scripts($hook_suffix) { … … 66 67 } 67 68 68 69 69 public function save($post_id) { 70 70 $content = new Flex_Content($post_id); … … 83 83 } 84 84 } 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 85 139 } -
experience-manager/trunk/readme.txt
r2310073 r2310158 4 4 Requires at least: 4.4.1 5 5 Tested up to: 5.4 6 Stable tag: 4. 2.47 Version: 4. 2.46 Stable tag: 4.3.0 7 Version: 4.3.0 8 8 License: GPLv2 or later 9 9 … … 69 69 == Changelog == 70 70 71 4. 2.472 * Enable revis oins for flex content71 4.3.0 72 * Enable revisions for flex content 73 73 74 74 4.2.3
Note: See TracChangeset
for help on using the changeset viewer.