/** * When a bookmark is deleted, remove the related DB records. * * @param int $link_id * @return void */ function hook_delete_link($link_id) { //Get the container object. $container = blcContainerHelper::get_container(array($this->container_type, $link_id)); //Get the link(s) associated with it. $links = $container->get_links(); //Remove synch. record & instance records. $container->delete(); //Clean up links associated with this bookmark (there's probably only one) $link_ids = array(); foreach ($links as $link) { $link_ids[] = $link->link_id; } blc_cleanup_links($link_ids); }
/** * Get the container object associated with this link instance * * @return blcContainer|null */ function &get_container() { if (is_null($this->_container)) { $this->_container =& blcContainerHelper::get_container(array($this->container_type, $this->container_id)); } return $this->_container; }
function hook_untrash_post_comments($post_id) { //Unlike with the 'trashed_post_comments' hook, WP doesn't pass the list of (un)trashed //comments to callbacks assigned to the 'untrash_post_comments' and 'untrashed_post_comments' //actions. Therefore, we must read it from the appropriate metadata entry. $statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true); if (empty($statuses) || !is_array($statuses)) { return; } foreach ($statuses as $comment_id => $comment_status) { if ($comment_status == '1') { //if approved $container = blcContainerHelper::get_container(array($this->container_type, $comment_id)); $container->mark_as_unsynched(); } } }
/** * When a post is restored, mark all of its custom fields as unparsed. * Called via the 'untrashed_post' action. * * @param int $post_id * @return void */ function post_untrashed($post_id) { //Get the associated container object $container =& blcContainerHelper::get_container(array($this->container_type, intval($post_id))); $container->mark_as_unsynched(); }
/** * When a post is saved or modified, mark it as unparsed. * * @param int $post_id * @return void */ function post_saved($post_id) { //Get the container type matching the type of the deleted post $post = get_post($post_id); if (!$post) { return; } //Only check links in currently enabled post types if (!in_array($post->post_type, $this->enabled_post_types)) { return; } //Only check posts that have one of the allowed statuses if (!in_array($post->post_status, $this->enabled_post_statuses)) { return; } //Get the container & mark it as unparsed $args = array($post->post_type, intval($post_id)); $post_container = blcContainerHelper::get_container($args); $post_container->mark_as_unsynched(); }
public static function hook_post_deleted($post_id) { if (get_option('mainwp_linkschecker_ext_enabled') !== "Y") { return; } if (!defined('BLC_ACTIVE') || !function_exists('blc_init')) { return; } blc_init(); //Get the container type matching the type of the deleted post $post = get_post($post_id); if (!$post) { return; } //Get the associated container object $post_container = blcContainerHelper::get_container(array($post->post_type, intval($post_id))); if ($post_container) { //Delete it $post_container->delete(); //Clean up any dangling links blc_cleanup_links(); } }