pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

REST API interfering with WYSIWYG field updates #5133

Open ghost opened 6 years ago

ghost commented 6 years ago

Issue Overview

After enabling the REST API on a Custom Post Type Pod, WYSIWYG fields no longer update properly.

Expected Behavior

After selecting the 'Enable' checkbox on the REST API tab for my Pod and saving, I should still be able to update existing WYSIWYG fields in my pods.

Current Behavior

After enabling the REST API for a Pod, updates to WYSIWYG fields are no longer saved to the database. Other types of fields seem to be unaffected. If I change the WYSIWYG field to a "Plain Paragraph Text" field, it can then be updated. If I change it back to a WYSIWYG field, it can no longer be updated. If I leave it as a WYSIWYG field and uncheck the 'Enable' checkbox on the REST API tab for my Pod, it can then be updated.

By 'updated', I mean my changes are saved to the database. Also, I see no errors in my web server's logs or in the javascript console of my browser.

Steps to Reproduce (for bugs)

  1. Fresh install of Wordpress 4.9.8 using twentyseventeen theme
  2. Install Gutenberg plugin (v 3.6.2)
  3. Install Pods plugin (v 2.7.9)
  4. Activate both plugins
  5. Create CPT Pod with a single WYSIWYG field
  6. On the 'REST API' tab of the field, enable both read and write via REST API
  7. On the REST API tab of the Pod, enable it and check 'Show all fields' and 'Allow all fields to be updated'
  8. Create a new pod and try saving something to the WYSIWYG field.

Possible Solution

WordPress Environment

``` Copy and paste your System Details from **Pods Admin > Settings > Debug Information** in WordPress admin here. Debug Information WordPress Version: 4.9.8 PHP Version: 7.1.7 MySQL Version: 5.6.37 Server Software: nginx/1.10.1 Your User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:61.0) Gecko/20100101 Firefox/61.0 Session Save Path: /tmp Session Save Path Exists: Yes Session Save Path Writeable: Yes Session Max Lifetime: 1440 Opcode Cache: • Apc: No • Memcached: No • OPcache: Yes • Redis: No Object Cache: • APC: No • APCu: No • Memcache: No • Memcached: No • Redis: No WPDB Prefix: wp_ WP Multisite Mode: No WP Memory Limit: 40M Pods Network-Wide Activated: No Pods Install Location: /app/public/wp-content/plugins/pods/ Pods Tableless Mode Activated: No Pods Light Mode Activated: No Currently Active Theme: Twenty Seventeen Currently Active Plugins: • Gutenberg: 3.6.2 • Pods - Custom Content Types and Fields: 2.7.9 ```

Pods Package Export (helpful!)

{"meta":{"version":"2.7.9","build":1535381376},"pods":{"5":{"id":5,"name":"test_post_type_1","label":"Test Post Type 1","description":"","type":"post_type","storage":"meta","object":"","alias":"","fields":{"test_wysiwyg_field":{"id":6,"name":"test_wysiwyg_field","label":"Test Wysiwyg Field","description":"","help":"","class":"","type":"wysiwyg","weight":0,"pick_object":"","pick_val":"","sister_id":"","required":"0","wysiwyg_editor":"tinymce","wysiwyg_media_buttons":"1","wysiwyg_oembed":"0","wysiwyg_wptexturize":"1","wysiwyg_convert_chars":"1","wysiwyg_wpautop":"1","wysiwyg_allow_shortcode":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"rest_read":"1","rest_write":"1","rest_pick_response":"array","rest_pick_depth":"2","unique":"0","wysiwyg_repeatable":"0","wysiwyg_allowed_html_tags":""}},"show_in_menu":"1","label_singular":"Test Post Type 1","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"test_post_type_1","capability_type_extra":"1","has_archive":"0","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"0","pfat_run_outside_loop":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"1","read_all":"1","write_all":"1"}}}

Workaround or Alternate Solution Until Bug is Addressed

I'm not using Gutenberg in production, so I'm not worried about a workaround.

Related Issues and/or PRs

oldlastman commented 6 years ago

Actually if you modify your WYSIWYG, change the editor to HTML tab and update it's looks work fine

ghost commented 6 years ago

I don't seen an 'HTML' tab, but there is a 'Visual' and a 'Text' tab on the WYSIWYG editor for that field. 'Visual' was selected. I switched to 'Text' and the content I entered was saved. If I switch back to 'Visual' though, I still can't seem to save anything I enter. Thanks though, this at least lets me add content.

JoryHogeveen commented 4 years ago

I believe this issue was fixed in one of the latest releases. @mr-king can you confirm?

ledjay commented 3 years ago

Hi there, I have the same issue, do you have someone on it ?

sc0ttkclark commented 3 years ago

@ledjay can you let us know what WP version you're using? I also assume you're using the normal Block Editor, correct? Are you using the Gutenberg plugin?

JoryHogeveen commented 3 years ago

I cannot reproduce this issue in the block editor.

spektrumede commented 3 years ago

Happens to me too. Using WP 5.6.2, CPT with Pods, Rest API is enabled and TinyMCE is added as additional field. The TinyMCE is empty and uneditable on load. You can get around it by changing the TinyMCE to HTML mode and reloading the page. It will then load fine and you can then switch to the visual editing mode and edit away.

But if I load the page while the TinyMCE is still in visual editing mode, the visual editor content is empty and uneditable. It is only the visual editor mode of TinyMCE though. If I switch to HTML mode I can see the content as HTML, but switching back to visual editor mode still shows the empty uneditable editor.