10up / distributor

Share content between your websites.
https://distributorplugin.com
GNU General Public License v2.0
637 stars 156 forks source link

Author override fails in the block theme author block. #1015

Closed peterwilsoncc closed 1 year ago

peterwilsoncc commented 1 year ago

Describe the bug

Distributor offers a setting to replace the author of a post with a link to the original site.

The author details for a current post can be altered via a number of hooks

Author display name

Author link

In the hooks used by Distributor to filter the author details, they are only replaced if the functions were called without specifying a particular author. Without a particular author specified, WordPress returns the author of the current global post object.

https://github.com/10up/distributor/blob/753c32541ebed15eddf1f9f56e7aae7cb732177d/includes/hooks.php#L130-L137

https://github.com/10up/distributor/blob/753c32541ebed15eddf1f9f56e7aae7cb732177d/includes/hooks.php#L168-L175

In block themes, WordPress specified an author ID when rendering the author block, thereby causing the data not to be filtered by Distributor. (Source code reference)

Steps to Reproduce

  1. Create a network install of WordPress and activate Distributor
  2. Distribute a post from one site to another
  3. On the site the post was distributed to (ie the duplicate), activate Twenty Twenty, a classic theme.
  4. Visit the distributed post, observe the author is replaced with the original site's details
  5. On the site the post was distributed to (ie, the duplicate), activate Twenty Twenty Two, a block theme
  6. Visit the distributed post, observe the author is not replaced with the original site's details

Screenshots, screen recording, code snippet

Meta data for a distributed post with a block theme

Screen Shot 2023-02-10 at 1 17 20 pm

Meta data for a distributed post with a classic theme

Screen Shot 2023-02-10 at 1 17 59 pm

Environment information

WordPress information

WordPress Information ### wp-core ### version: 6.1.1 site_language: en_US user_language: en_US timezone: +00:00 permalink: /%year%/%monthnum%/%day%/%postname%/ https_status: false multisite: true user_registration: false blog_public: 1 default_comment_status: open environment_type: local site_count: 3 network_count: 1 user_count: 1 dotorg_communication: true ### wp-dropins (1) ### db.php: true ### wp-active-theme ### name: Twenty Twenty (twentytwenty) version: 2.1 author: the WordPress team author_website: https://wordpress.org/ parent_theme: none theme_features: core-block-patterns, widgets-block-editor, automatic-feed-links, custom-background, post-thumbnails, custom-logo, title-tag, html5, align-wide, responsive-embeds, customize-selective-refresh-widgets, editor-color-palette, editor-font-sizes, editor-styles, widgets, menus, editor-style theme_path: /vagrant/wp/wp-content/themes/twentytwenty ### wp-themes-inactive (12) ### Twenty Eleven: version: 4.2, author: the WordPress team Twenty Fifteen: version: 3.3, author: the WordPress team Twenty Fourteen: version: 3.5, author: the WordPress team Twenty Nineteen: version: 2.4, author: the WordPress team Twenty Seventeen: version: 3.1, author: the WordPress team Twenty Sixteen: version: 2.8, author: the WordPress team Twenty Ten: version: 3.7, author: the WordPress team Twenty Thirteen: version: 3.7, author: the WordPress team Twenty Twelve: version: 3.8, author: the WordPress team Twenty Twenty-One: version: 1.7, author: the WordPress team Twenty Twenty-Three: version: 1.0, author: the WordPress team Twenty Twenty-Two: version: 1.3, author: the WordPress team ### wp-mu-plugins (15) ### custom-taxo.php: author: (undefined), version: (undefined) Featured Image block bugfix for WP 6.0.3: author: (undefined), version: (undefined) filter.php: author: (undefined), version: (undefined) log-requests.php: author: (undefined), version: (undefined) meta-data.php: author: (undefined), version: (undefined) no-canon.php: author: (undefined), version: (undefined) no-rest-for-the-wicked.php: author: (undefined), version: (undefined) nope-call-magic-method.php: author: (undefined), version: (undefined) nope-perf-test-multisite-stuff.php: author: (undefined), version: (undefined) nope-post-abstraction-dumps.php: author: (undefined), version: (undefined) plugin-api.php: author: (undefined), version: (undefined) query-monitor-file-mappings.php: author: (undefined), version: (undefined) switch-site-test.php: author: (undefined), version: (undefined) unsafe-app-passwords.php: author: (undefined), version: (undefined) wp-git-branch.php: author: (undefined), version: (undefined) ### wp-plugins-active (4) ### Classic Editor: version: 1.6.2, author: WordPress Contributors Distributor: version: 1.9.0, author: 10up Inc. Query Monitor: version: 3.11.1, author: John Blackbourn User Switching: version: 1.7.0, author: John Blackbourn & contributors ### wp-plugins-inactive (5) ### Distributor - Edit Remote Post Meta: version: 0.2.1, author: 10up Newspack Image Credits: version: 1.0.1, author: Automattic, INN Labs, Project Argo Restricted Site Access: version: 7.3.5, author: Jake Goldman, 10up, Oomph Test block: author: (undefined), version: (undefined) Yoast SEO: version: 19.12, author: Team Yoast (latest version: 20.1) ### wp-media ### image_editor: WP_Image_Editor_GD imagick_module_version: Not available imagemagick_version: Not available imagick_version: Not available file_uploads: File uploads is turned off post_max_size: 1024M upload_max_filesize: 1024M max_effective_size: 1 GB max_file_uploads: 20 gd_version: 2.3.3 gd_formats: GIF, JPEG, PNG, WebP, BMP, XPM ghostscript_version: not available ### wp-server ### server_architecture: Linux 5.15.0-30-generic x86_64 httpd_software: nginx/1.18.0 php_version: 7.4.30 64bit php_sapi: fpm-fcgi max_input_variables: 1000 time_limit: 900 memory_limit: 128M admin_memory_limit: 256M max_input_time: 900 upload_max_filesize: 1024M php_post_max_size: 1024M curl_version: 7.81.0 OpenSSL/3.0.2 suhosin: false imagick_availability: false pretty_permalinks: true ### wp-database ### extension: mysqli server_version: 8.0.30-0ubuntu0.22.04.1 client_version: mysqlnd 7.4.30 max_allowed_packet: 16777216 max_connections: 151 ### wp-constants ### WP_HOME: http://ms-distributor.local WP_SITEURL: http://ms-distributor.local/wp WP_CONTENT_DIR: /vagrant/content WP_PLUGIN_DIR: /vagrant/content/plugins WP_MEMORY_LIMIT: 64M WP_MAX_MEMORY_LIMIT: 256M WP_DEBUG: true WP_DEBUG_DISPLAY: false WP_DEBUG_LOG: true SCRIPT_DEBUG: true WP_CACHE: false CONCATENATE_SCRIPTS: undefined COMPRESS_SCRIPTS: undefined COMPRESS_CSS: undefined WP_ENVIRONMENT_TYPE: local DB_CHARSET: utf8 DB_COLLATE: undefined ### wp-filesystem ### wordpress: writable wp-content: writable uploads: writable plugins: writable themes: writable mu-plugins: writable ### distributor ### 0: 1.9.0 1: Override Author Byline: Yes Media Handling: Featured image only 2: 10up Distributor Multisite: - Blog ID: 1 - URL: http://ms-distributor.local - Registered: 2023-01-24 02:49:19 - Last updated: 2023-02-10 00:43:11 MS Distributor Site Three: - Blog ID: 3 - URL: http://ms-distributor.local/three - Registered: 2023-01-24 02:50:28 - Last updated: 2023-01-24 04:16:46 3: N/A

Code of Conduct

peterwilsoncc commented 1 year ago

I've created https://github.com/WordPress/gutenberg/issues/47951 as an alternative approach to fixing this issue.

ravinderk commented 1 year ago

@peterwilsoncc I found that https://github.com/10up/distributor/issues/989 (file) causes regression, and before that It was working fine. Can you check?

Let me know if you have any questions.