/** * Save post hook. * * @param type $parent_post_id * @return string */ function wpcf_pr_admin_save_post_hook($parent_post_id) { global $wpcf; /* * TODO https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/159760120/comments#225005357 * Problematic This should be done once per save (on saving main post) * remove_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 11); */ static $cached = array(); /* * * TODO Monitor this */ // Remove main hook? // CHECKPOINT We remove temporarily main hook if (!isset($cached[$parent_post_id])) { if (isset($_POST['wpcf_post_relationship'][$parent_post_id])) { $wpcf->relationship->save_children($parent_post_id, (array) $_POST['wpcf_post_relationship'][$parent_post_id]); } // Save belongs if any if (isset($_POST['wpcf_pr_belongs'][intval($parent_post_id)])) { wpcf_pr_admin_update_belongs(intval($parent_post_id), $_POST['wpcf_pr_belongs'][intval($parent_post_id)]); } // WPML wpcf_wpml_relationship_save_post_hook($parent_post_id); /** * Temporary workaround until https://core.trac.wordpress.org/ticket/17817 is fixed. * * Saving child posts cancels all save_post actions for the parent post that would otherwise come * after this one. * * @since 2.2 */ do_action('types_finished_saving_child_posts', $parent_post_id); $cached[$parent_post_id] = true; } }
/** * Save post hook. * * @param type $parent_post_id * @return string */ function wpcf_pr_admin_save_post_hook($parent_post_id) { global $wpcf; /* * TODO https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/159760120/comments#225005357 * Problematic This should be done once per save (on saving main post) * remove_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 11); */ static $cached = array(); /* * * TODO Monitor this */ // Remove main hook? // CHECKPOINT We remove temporarily main hook if (!isset($cached[$parent_post_id])) { if (isset($_POST['wpcf_post_relationship'][$parent_post_id])) { $wpcf->relationship->save_children($parent_post_id, (array) $_POST['wpcf_post_relationship'][$parent_post_id]); } // Save belongs if any if (isset($_POST['wpcf_pr_belongs'][intval($parent_post_id)])) { wpcf_pr_admin_update_belongs(intval($parent_post_id), $_POST['wpcf_pr_belongs'][intval($parent_post_id)]); } // WPML wpcf_wpml_relationship_save_post_hook($parent_post_id); $cached[$parent_post_id] = true; } }
/** * Save post hook. * * @param type $parent_post_id * @return string */ function wpcf_pr_admin_save_post_hook($parent_post_id) { global $wpcf; /* * * TODO Monitor this */ // Remove main hook? // CHECKPOINT We remove temporarily main hook // remove_action( 'save_post', 'wpcf_admin_save_post_hook', 10, 2 ); // This should be done once per save remove_action('save_post', 'wpcf_pr_admin_save_post_hook', 11, 2); if (isset($_POST['wpcf_post_relationship'][$parent_post_id])) { $wpcf->relationship->save_children($parent_post_id, (array) $_POST['wpcf_post_relationship'][$parent_post_id]); } // Save belongs if any if (isset($_POST['wpcf_pr_belongs'][intval($parent_post_id)])) { wpcf_pr_admin_update_belongs(intval($parent_post_id), $_POST['wpcf_pr_belongs'][intval($parent_post_id)]); } // WPML wpcf_wpml_relationship_save_post_hook($parent_post_id); // Restore main hook? // add_action( 'save_post', 'wpcf_admin_save_post_hook', 10, 2 ); }