link_object = $link; $this->offset = $this->link_object->get_offset(); $this->limit = $this->link_object->get_limit(); $this->origins = $this->link_object->origins(); } /** * Runs the url process in origins * * @return array */ public function execute() { $notfound_in = array(); $new_offset = intval( $this->offset ); $origins = array_slice( $this->origins, $this->offset, $this->limit ); if ( ! empty( $origins ) ) { foreach ( $origins as $post_url ) { $new_offset ++; if ( $this->runtime_passed_limit() ) { break; } if ( ! $this->process_instance( null, $post_url ) ) { $notfound_in[] = $post_url; } } } $remaining_origins = array_slice( $this->origins, $this->offset + $this->limit ); return array( //'completed' => $status, 'completed' => empty( $remaining_origins ), 'notfound_in' => $notfound_in, 'offset' => $new_offset, 'break' => true, ); } /** * @param int|null $post_id * @param string|null $post_url * * @return bool */ public function process_instance( int $post_id = null, string $post_url = null ) { if ( empty( $post_url ) ) { return false; } if ( empty( $this->link_object ) ) { return false; } $processor = new Processor( $this->link_object ); if ( empty( $post_id ) ) { $author_page = Utilities::is_author_url( $post_url ); if ( $author_page instanceof WP_User || $author_page instanceof WP_User ) { return $processor->execute_in_user_author_meta( $author_page->ID ); } $post_id = url_to_postid( $post_url ); } return $processor->execute_url_in_post( $post_id ); } }