inpsyde / MultilingualPress-Yoast-SEO-Sync

This is a simple add-on for the MultilingualPress plugin to synchronize the post metadata of the Yoast SEO plugin between translated posts.
GNU General Public License v2.0
7 stars 3 forks source link

Add Yoast SEO tab to translation term metabox #7

Closed Dinamiko closed 5 years ago

Dinamiko commented 5 years ago

This pull request adds a new Yoast SEO tab to translation term metabox, it also fixes the issue about automatic synchronization of Yoast SEO values across connected sites.

We had to include a new action (multilingualpress.metabox_after_relate_terms) in MultingualPress 3, it will be included in the next release, in the meantime here is what we´ve just included:

In src/multilingualpress/TranslationUi/Term/MetaboxAction.php at the very top add this new line: const ACTION_METABOX_AFTER_RELATE_TERMS = 'multilingualpress.metabox_after_relate_terms';

Then in doSaveOperation replace this: $termTaxonomyId = $this->saveTerm($termData, $relationshipHelper); for this:

        $termTaxonomyId = $this->saveTerm(
            $termData,
            $relationshipHelper,
            $request,
            $notices
        );

Finally change saveTerm method signature from this: private function saveTerm(array $termData, TermRelationSaveHelper $helper): int to this:

    private function saveTerm(
        array $termData,
        TermRelationSaveHelper $helper,
        Request $request,
        PersistentAdminNotices $notices
    ): int {

and add the action just before last line in the method (return (int)$remoteTerm->term_taxonomy_id;):

        do_action(
            self::ACTION_METABOX_AFTER_RELATE_TERMS,
            $this->relationshipContext,
            $request,
            $notices
        );