public static function act_save_item($term_id, $tt_id, $taxonomy) { if (!in_array($taxonomy, pp_get_enabled_taxonomies())) { if (!empty($_REQUEST['pp_enable_taxonomy'])) { $enabled_taxonomies = get_option('pp_enabled_taxonomies'); $enabled_taxonomies[$taxonomy] = '1'; update_option('pp_enabled_taxonomies', $enabled_taxonomies); } return; } static $saved_terms; if (!isset($saved_terms)) { $saved_terms = array(); } // so this filter doesn't get called by hook AND internally if (isset($saved_terms[$taxonomy][$tt_id])) { return; } // parent settings can affect the auto-assignment of propagating exceptions $set_parent = is_taxonomy_hierarchical($taxonomy) && !empty($_REQUEST['parent']) ? (int) $_REQUEST['parent'] : 0; if ($set_parent < 0) { $set_parent = 0; } $saved_terms[$taxonomy][$tt_id] = 1; // Determine whether this object is new (first time this PP filter has run for it, though the object may already be inserted into db) $last_parent = 0; if (!($last_parents = get_option("pp_last_{$taxonomy}_parents"))) { $last_parents = array(); } if (!isset($last_parents[$tt_id])) { $is_new = true; $last_parents = array(); } else { $is_new = false; } if (isset($last_parents[$tt_id])) { $last_parent = $last_parents[$tt_id]; } if ($set_parent != $last_parent && ($set_parent || $last_parent)) { $last_parents[$tt_id] = $set_parent; update_option("pp_last_{$taxonomy}_parents", $last_parents); } $exceptions_customized = false; if (!$is_new) { if ($custom_exc_objects = get_option("pp_custom_{$taxonomy}")) { $exceptions_customized = isset($custom_exc_objects[$tt_id]); } } global $typenow; require_once dirname(__FILE__) . '/item-save_pp.php'; $args = compact('is_new', 'set_parent', 'last_parent', 'disallow_manual_entry'); $args['via_item_type'] = $taxonomy; PP_ItemSave::item_update_process_exceptions('term', 'post', $tt_id, $args); do_action('pp_update_item_exceptions', 'term', $tt_id, $args); }
public static function act_save_item($item_source, $post_id, $post) { if (!empty($_REQUEST['action']) && 'untrash' == $_REQUEST['action']) { return; } // WP always passes post object into do_action('save_post') if (!is_object($post)) { if (!($post = get_post($post_id))) { return; } } // operations in this function do not apply to revision save if ('revision' == $post->post_type) { return; } if (!in_array($post->post_type, pp_get_enabled_post_types())) { if (!empty($_REQUEST['pp_enable_post_type'])) { $enabled = get_option('pp_enabled_post_types'); $enabled[$post->post_type] = '1'; update_option('pp_enabled_post_types', $enabled); } return; } // don't execute this action handler more than one per post save static $saved_items; if (!isset($saved_items)) { $saved_items = array(); } if (isset($saved_items[$post_id])) { return; } $saved_items[$post_id] = 1; $is_new = self::is_new_post($post_id, $post); if (is_post_type_hierarchical($post->post_type)) { $parent_info = self::get_post_parent_info($post_id, $post, true); extract($parent_info, EXTR_SKIP); // $set_parent, $last_parent if (is_numeric($last_parent)) { // not theoretically necessary, but an easy safeguard to avoid re-inheriting parent roles $is_new = false; } } if (empty($_REQUEST['page']) || 'rvy-revisions' != $_REQUEST['page']) { usleep(5000); // Work around intermittent failure to propagate exceptions. Maybe storage of post row is delayed on some db servers. require_once dirname(__FILE__) . '/item-save_pp.php'; PP_ItemSave::item_update_process_exceptions('post', 'post', $post_id, compact('is_new', 'set_parent', 'last_parent', 'disallow_manual_entry', 'via_item_type')); } }