Repository navigation
Conversation
Extends Publicize module to add a REST endpoint where a post can be published
without triggering social sharing with Publicize. This is accomplished by
marking the post with a meta key ("_NO_PUBLICIZE") which is used to later filter
out post so it's not publicized. This commit adds back-end PHP to expose
endpoint along with a new JavaScript file that exposes this functionality in a
function call.
Corrects meta key name stored to PUBLICIZE_BLOCK_META_KEY.
publicize/posts/<post_id>/publish-wo-publicize endpoint being replaced with publicize/posts/<post_id>/flag-no-publicize endpoint. The new endpoint removes the publish action and simply flags a post so that it will not be later publicized. This removes the need to replace the Gutenberg publish endpoint, and will simply need to be called JUST before Gutenberg publish instead.
Normal conventions appear to be lower case for WordPress meta key names. _NO_PUBLICIZE becomes _no_publicize. Simple as that.
To support asynchronous (publish a post and then possibly later publicizing it), a custom REST endpoint is being created from the Publicize module that submits a publicize request to the WPCOM REST API.
Makes a trivial whitespace/punctuation change to a function header Docblock to make phpcs happy.
…g posts Experimental Gutenberg editor update in c-shultz:try/publicize-integration provides X-WP-Source='Gutenberg' HTTP header to differentiate posts. This vastly simplifies the task of detecting if post came from Gutenberg. Removing publicize/posts/<post_id>/flag-no-publicize because there's no longer a need for it with this approach.
Hooking into Gutenberg newly created post-publish sidebar slot to display simple form for sharing a post after it is published. The JavaScript/HTML for the form is just a rough prototype to prove that the hook functions. Currently, the button does not trigger a post to be shared. That will have to come later.
This is a significant iteration on the client-side of Publicize for Gutenberg. This modularizes the UI into several React components to eventually allow the user to view/edit sharing message text, view/edit connection list, and view sharing results. The UX is currently very rough: no loading indication is yet provided, and results are not yet available, but the basic foundation is there.
This moves the Gutenberg extensiblity to Gutenberg's pre-publish flow. File/class names are updated accordingly. This change ports over the classic editor's Publicize form into React components. Basic Publicize functionality is now available (title edit and connection selection). Additional styling is still required and dynamic connection creation is not yet supported.
Removes current list of connections from Publicize panel title bar. This functionality was a carry over from classic editor, but did not display well in Gutenberg UI. props @eliorivero
Porting over another classic editor Publicize feature to Gutenberg: social connections are now tested on page load via an AJAX request. Any failed tests will result in a display to the user that allows them to click to refresh the connection before publishing.
Adding list of services which is displayed instead of sharing form for when user does not have any services connected. Separates out higher level PublicizePanel from notification and form components to keep things somewhat modular.
Previously, publicize title/connections were passed from the editor to the backend via $_POST (for Gutenberg and classic editor). This allowed the back-end handling to be the same for both Gutenberg and classic editor Publicize. A recent Gutenberg PR (#5971) changed the api request format so that post data was passed in HTTP payload instead of $_POST. Which broke the Publicize form in Gutenberg. This commit registers a new 'publicize' REST field for the 'post' endpoint. The update callback for the 'publicize' field handles the Publicize logic directly instead of relying on legacy $_POST processing that classic editor uses. The state handling for PublicizeForm component is totally revamped in support of this change. As part of the data handling improvement, the form state is now stored only in editor only. withState and withDispatch are utilized to prevent state data duplication within PublicizeForm component. props @youknowriad
Gutenberg client .jsx files previously failed numerous eslint checks. This change enables eslint for modules/**/*.jsx and subsequently fixes the JS to pass all linting checks. There should be no functional differences after making this change.
Creates new 'wp_ajax_get_publicize_connections' Ajax endpoint to allow connections to be refreshed by the client. Adds "refresh" button in UI to trigger the refresh manually, and also adds "settings" button to pop-up a window and open the settings page. Closing this pop-up will trigger an automatic connection list refresh.
Publicize request processing was on a register_rest_field callback. This callback occurred right after a post is published, which is too late because Publicize actions occur when post is published. This resulted in missed Publicize settings if a post was not lucky enough to be saved just before it was published. This change moves the 'publicize' request field processing to a 'rest_pre_insert_post' filter hook, which occurs right before a post is saved/published.
Fixing an indentation error in Publicize_UI::get_filtered_connection_data(). Adding some missing DocBlocks and cleaning up some minor ESLint issues.
Connection request Ajax endpoint didn't have the current $post in context, so it couldn't properly check if the post was already shared. This caused the Publicize form on the front end to not be disabled after a post was already published. This commit adds the post id to the 'wp_admin_get_publicize_connections' Ajax endpoint to remedy this issue.
Deleting some PHP commented out lines that were accidentally left in the code.
Adds test coverage for Jetpack_Publicize_Gutenberg::process_publicize_from_rest() which is the callback that processes the 'publicize' field when it is added to the 'post' endpoint by the Publicize front-end in Gutenberg.
- Changes 'Settings' link text to 'Connect another service' and moves to below connection list. - Adds sharing sub-title. - Moves character count to below message text area. - Adds styling to textarea. props @MichaelArestad
Adds 'modules' directory to linting path so ESLint will run checks against any .jsx in 'modules'
…enberg. - Adds service icon to connection list. - Modifies connection text so it shows only connection username. - Add '+' icon to connection add link. - Adds styling to truncate long connection names. - Improves spacing/layout. props @MichaelArestad
Makes Publicize form values (connection enable/disable, title) persistent so that closing and then opening the pre-publish panel does not clear out all user entries.
Sets maximum character limit in Publicize message to 256. Also makes character limit count down instead of up and highlights the count message if it reaches zero.
Adds a little padding around the 'characters remaining' count to give it a little space and make it vertically centered in gray footer bar.
Adding simple Readme to explain how Publicize flags posts to be shared not shared by WP.com.
Expose helper method done_sharing_post as a public method to support direct unit testing (and planned rework).
Adding test coverage for: - done_sharing_post: testing flagged and published posts - get_services_connected: testing service list - get_filtered_connection_data: testing simple connection data with no filtering
Contributor
|
@c-shultz please rebase your PR and make sure the tests are passing in CI |
Author
|
@brbrr, I don't have the extra time to support this PR right now, as I'm focused on efforts on my new team. |
This was referenced Jul 30, 2018
tyxla
added a commit
to Automattic/wp-calypso
that referenced
this pull request
Jul 31, 2018
This PR adds the Jetpack Publicize extension to the set of Gutenberg extensions, based on the previous work done by @c-shultz in: Automattic/jetpack#9934. Co-authored-by: Chris Shultz <cs.shultz@gmail.com>
Contributor
|
Since our plan is to build JS (and maybe CSS) within Calypso env - we shouldn't merge this PR as is. JS/CSS part already merged here: Automattic/wp-calypso#26389, the remaining part is to ship PHP code for this block. Moving this PR into next release. |
Member
|
@simison Should this remain opened now that the work moved to Automattic/wp-calypso#26389 ? |
Member
|
Yeah, I think this can be closed. There might be something that we'd still want to port but it'll remain here safe if we need to. This PR as is won't be merged anyway so no point keeping it open. cc @tyxla |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Pull Request contains the changes from #9144 but on a branch local to this repo.
==== Original description follows ===
Fixes #9039 (No Publicize form in Gutenberg)
Dependencies:
Changes proposed in this Pull Request:
Summary
Bringing Jetpack's Publicize feature to the Gutenberg editor! ---

Without this PR, Publicize invisibly shares all new Gutenberg posts to all connected social accounts.
Front-End Design Note
The design is based heavily on @MichaelArestad's post-publish design concept. The desired long-term direction for Publicize is to incorporate it in the post-publish panel (after the user publishes the post), but on this PR, as a first iteration, it is being placed in the pre-publish panel.
Architecture Notes
This PR touches a lot of files and there's several early commits that were taking the design in a different direction. In an effort to make review easier, I'll try to distill the list changes into the most important new content and describe how that's hooked into existing content:
modules\publicize\assets\gutenberg_clientdirectoryFillUI is created on this PR (inpublicize-gutenberg-plugin.jsx) and the pre-publishSlotis created in Gutenberg PR #5795jetpack\modules\publicize\class-jetpack-publicize-gutenberg.phpdoes the setup for the new UI.postendpoint to pass in Publicizetitleandconnectionsform options when saving post:wp_ajax_get_publicize_connectionsto expose connection list so client can refresh connectionstry/publicize-decouple-ui(PR Decouple Publicize connection list access from UI scripts #9466) to expose connection data access methodsTesting instructions:
git checkout add/gutenberg-publicize && git merge try/publicize-decouple-ui --no-commit