. * * @param int $post_parent The post parent. * @param array $exclude_ids The id's to exclude. * * @return Indexable[] array of indexables. */ public function get_subpages_by_post_parent( $post_parent, $exclude_ids = [] ) { $query = $this->query() ->where( 'post_parent', $post_parent ) ->where( 'object_type', 'post' ) ->where( 'post_status', 'publish' ); if ( ! empty( $exclude_ids ) ) { $query->where_not_in( 'object_id', $exclude_ids ); } return $query->find_many(); } /** * Updates the incoming link count for an indexable without first fetching it. * * @param int $indexable_id The indexable id. * @param int $count The incoming link count. * * @return bool Whether or not the update was succeful. */ public function update_incoming_link_count( $indexable_id, $count ) { return (bool) $this->query() ->set( 'incoming_link_count', $count ) ->where( 'id', $indexable_id ) ->update_many(); } /** * Ensures that the given indexable has a permalink. * * @param Indexable $indexable The indexable. * * @return bool|Indexable The indexable. */ protected function ensure_permalink( $indexable ) { if ( $indexable && $indexable->permalink === null ) { $indexable->permalink = $this->permalink_helper->get_permalink_for_indexable( $indexable ); // Only save if changed. if ( $indexable->permalink !== null ) { $indexable->save(); } } return $indexable; } /* ********************* DEPRECATED METHODS ********************* */ /** * Returns all children of a given indexable. * * @deprecated 15.0 * @codeCoverageIgnore * * @param Indexable $indexable The indexable to find the children of. * * @return Indexable[] All children of the given indexable. */ public function get_children( Indexable $indexable ) { \_deprecated_function( __METHOD__, 'WPSEO 15.0' ); $indexable_ids = $this->hierarchy_repository->find_children( $indexable ); return $this->find_by_ids( $indexable_ids ); } /** * Resets the permalinks of the passed object type and subtype. * * @param string $type The type of the indexable. Can be null. * @param null|string $subtype The subtype. Can be null. * * @return int|bool The number of permalinks changed if the query was succesful. False otherwise. */ public function reset_permalink( $type = null, $subtype = null ) { $query = $this->query()->set( [ 'permalink' => null, 'permalink_hash' => null, ] ); if ( $type !== null ) { $query->where( 'object_type', $type ); } if ( $type !== null && $subtype !== null ) { $query->where( 'object_sub_type', $subtype ); } return $query->update_many(); } }