Klian
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Yoast SEO] Yoast plugin is not working on WordPress 4.9.8Same error here with WP 4.9.8 and Yoast 7.9
The problem is that the save_post action doesn’t fired up with the edit attachment page… so we have to add a new action to execute it.
I’ve fixed it editing cpt-onomies/admin.php file:
Below line 52:
add_action( 'save_post', array( &$this, 'save_post' ), 10, 2 );
Add this:
add_action( 'edit_attachment', array( &$this, 'save_attachment' ), 10, 2 );
At the end of the file add this function:
public function save_attachment($post_id){ global $cpt_onomies_manager, $cpt_onomy; // pointless if $_POST is empty (this happens on bulk edit) if ( empty( $_POST ) ){ return $post_id; } // verify nonce if ( ! ( isset( $_POST[ 'is_bulk_quick_edit' ] ) || ( isset( $_POST[ '_wpnonce' ] ) && wp_verify_nonce( $_POST[ '_wpnonce' ], 'update-' . $post->post_type . '_' . $post_id ) ) || ( isset( $_POST[ CPT_ONOMIES_UNDERSCORE . '_nonce' ] ) && wp_verify_nonce( $_POST[ CPT_ONOMIES_UNDERSCORE . '_nonce' ], 'assigning_' . CPT_ONOMIES_UNDERSCORE . '_taxonomy_relationships' ) ) ) ){ return $post_id; } // check autosave if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ return $post_id; } // dont save for revisions if ( isset( $post->post_type ) && $post->post_type == 'revision' ){ return $post_id; } $post = get_post($post_id); // check cpt-onomies foreach( get_object_taxonomies( $post->post_type, 'objects' ) as $taxonomy => $tax ) { // make sure cpt-onomy was visible, otherwise we might be deleting relationships for taxonomies that weren't even "editable" if ( isset( $_POST[ 'assign_cpt_onomies_' . $taxonomy . '_rel' ] ) && $cpt_onomies_manager->is_registered_cpt_onomy( $taxonomy ) ) { // check permissions if ( ! current_user_can( $tax->cap->assign_terms ) ) continue; // set object terms if ( isset( $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] ) ) { // need to make sure its an array if ( ! is_array( $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] ) ) $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] = explode( ',', $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ] ); $cpt_onomy->wp_set_object_terms( $post_id, $_POST[ CPT_ONOMIES_POSTMETA_KEY ][ $taxonomy ], $taxonomy ); } // delete taxonomy relationships else $cpt_onomy->wp_delete_object_term_relationships( $post_id, $taxonomy ); } } }
This method works for me.
Viewing 2 replies - 1 through 2 (of 2 total)