Get the url to view a post in the context of the rest of the discussion.

@param post_entity $post The post
@return moodle_url
490999
public function get_view_post_url_from_post(post_entity $post) : moodle_url {
        return $this->get_view_post_url_from_post_id($post->get_discussion_id(), $post->get_id());
    }
761480
public function get_forum_view_url_from_course_module_id(int $coursemoduleid, ?int $pageno = null,
            ?int $sortorder = null) : moodle_url {

        $url = new moodle_url('/mod/forum/view.php', [
            'id' => $coursemoduleid,
        ]);

        if (null !== $pageno) {
            $url->param('p', $pageno);
        }

        if (null !== $sortorder) {
            $url->param('o', $sortorder);
        }

        return $url;
    }
1133491
public function get_doc_url(\core_search\document $doc) {
        // The post is already in static cache, we fetch it in self::search_access.
        $post = $this->get_post($doc->get('itemid'));
        return new \moodle_url('/mod/forum/discuss.php', array('d' => $post->discussion));
    }
1298563
public function get_mark_post_as_read_url_from_post(post_entity $post, int $displaymode = FORUM_MODE_THREADED) : moodle_url {
        $params = [
            'd' => $post->get_discussion_id(),
            'postid' => $post->get_id(),
            'mark' => 'read'
        ];

        $url = new moodle_url('/mod/forum/discuss.php', $params);

        if ($displaymode == FORUM_MODE_THREADED) {
            $url->param('parent', $post->get_parent_id());
        } else {
            $url->set_anchor('p' . $post->get_id());
        }

        return $url;
    }
958045
public function get_url() {

        $url = new \moodle_url('/mod/forum/user.php', array('id' => $this->relateduserid,
            'mode' => $this->other['reportmode']));

        if ($this->courseid != SITEID) {
            $url->param('course', $this->courseid);
        }

        return $url;
    }
1034411
public function get_context_url(\core_search\document $doc) {
        $users = $this->get_current_other_users($doc);
        return new \moodle_url('/message/index.php', array('user1' => $users['currentuserid'], 'user2' => $users['otheruserid']));
    }
380795
public function getTermsForPost(AbstractPost $post)
    {
        $terms = array();

        if ($dbTerms = get_the_terms($post->getId(), $this->getName())) {
            foreach ($dbTerms as $termData) {
                $terms[] = $this->termFactory->create($termData, $this);
            }
        }

        return $terms;
    }
686522
public function indexAction($postid)
    {
        $post = $this->getPost($postid);

        $entities = $post->getComments()->toArray();
        usort($entities, function (Comment $a, Comment $b) {
            return $a->getDateCreated() < $b->getDateCreated();
        });

        return array(
            'post'     => $post,
            'entities' => $entities,
        );
    }
1324969
protected function get_field( \WP_Post $post ){
        $html = parent::get_field($post);
        return $html.sprintf('<p class="inline-error"><i class="dashicons dashicons-location-alt"></i> %s</p>', $this->__('Can\'t find map point. Try another string'));
    }
744965
public function getEntityUrl() : string
    {
        $result = Router::url(
            [
                'prefix' => false,
                'controller' => $this->table->getTable(),
                'action' => 'view',
                $this->entity->id
            ],
            true
        );

        return $result;
    }
981167
protected function prepare_links( $post ) {
		$base = sprintf( '%s/%s', $this->namespace, $this->rest_base );

		// Entity meta.
		$links = array(
			'self' => array(
				'href'   => rest_url( trailingslashit( $base ) . $post->ID ),
			),
			'collection' => array(
				'href'   => rest_url( $base ),
			),
			'about'      => array(
				'href'   => rest_url( 'wp/v2/types/' . $this->post_type ),
			),
		);

		if ( ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'author' ) )
			&& ! empty( $post->post_author ) ) {
			$links['author'] = array(
				'href'       => rest_url( 'wp/v2/users/' . $post->post_author ),
				'embeddable' => true,
			);
		}

		if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'comments' ) ) {
			$replies_url = rest_url( 'wp/v2/comments' );
			$replies_url = add_query_arg( 'post', $post->ID, $replies_url );
			$links['replies'] = array(
				'href'         => $replies_url,
				'embeddable'   => true,
			);
		}

		if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'revisions' ) ) {
			$links['version-history'] = array(
				'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions' ),
			);
		}
		$post_type_obj = get_post_type_object( $post->post_type );
		if ( $post_type_obj->hierarchical && ! empty( $post->post_parent ) ) {
			$links['up'] = array(
				'href'       => rest_url( trailingslashit( $base ) . (int) $post->post_parent ),
				'embeddable' => true,
			);
		}

		// If we have a featured media, add that.
		if ( $featured_media = get_post_thumbnail_id( $post->ID ) ) {
			$image_url = rest_url( 'wp/v2/media/' . $featured_media );
			$links['https://api.w.org/featuredmedia'] = array(
				'href'       => $image_url,
				'embeddable' => true,
			);
		}
		if ( ! in_array( $post->post_type, array( 'attachment', 'nav_menu_item', 'revision' ), true ) ) {
			$attachments_url = rest_url( 'wp/v2/media' );
			$attachments_url = add_query_arg( 'parent', $post->ID, $attachments_url );
			$links['https://api.w.org/attachment'] = array(
				'href'       => $attachments_url,
			);
		}

		$taxonomies = get_object_taxonomies( $post->post_type );
		if ( ! empty( $taxonomies ) ) {
			$links['https://api.w.org/term'] = array();

			foreach ( $taxonomies as $tax ) {
				$taxonomy_obj = get_taxonomy( $tax );
				// Skip taxonomies that are not public.
				if ( empty( $taxonomy_obj->show_in_rest ) ) {
					continue;
				}

				$tax_base = ! empty( $taxonomy_obj->rest_base ) ? $taxonomy_obj->rest_base : $tax;
				$terms_url = add_query_arg(
					'post',
					$post->ID,
					rest_url( 'wp/v2/' . $tax_base )
				);

				$links['https://api.w.org/term'][] = array(
					'href'       => $terms_url,
					'taxonomy'   => $tax,
					'embeddable' => true,
				);
			}
		}

		return $links;
	}
810571
public static function ltiLinkUrl($postdata=false) {
        if ( $postdata === false ) $postData = $_POST;
        if ( ! isset($postdata['content_item_return_url']) ) return false;
        if ( isset($postdata['accept_media_types']) ) {
            $ltilink_mimetype = 'application/vnd.ims.lti.v1.ltilink';
            $m = new Mimeparse;
            $ltilink_allowed = $m->best_match(array($ltilink_mimetype), $postdata['accept_media_types']);
            if ( $ltilink_mimetype != $ltilink_allowed ) return false;
            return $postdata['content_item_return_url'];
        }
        return false;
    }
1070934
protected function get_field( \WP_Post $post ){
        $fields = [];
        foreach( $this->get_field_arguments() as $key => $val ){
            $fields[] = sprintf('%s="%s"', $key, esc_attr($val));
        }
        return $this->build_input($this->get_data($post), $fields);
    }
125110
public static function get_post_meta_description( $post ) {
		$description = get_post_meta( $post->ID, '_yoast_wpseo_metadesc', true );

		if ( empty( $description ) ) {
			$description = Text::trim_to_nearest_word( wp_strip_all_tags( $post->post_content ), 160 );
		}

		return $description;
	}
1303287
public function get_context_url(\core_search\document $doc) {
        $cminfo = $this->get_cm($this->get_module_name(), strval($doc->get('itemid')), $doc->get('courseid'));
        return new \moodle_url('/mod/' . $this->get_module_name() . '/view.php', array('id' => $cminfo->id));
    }
1102755
public function get_discussion_subscribe_url(discussion_entity $discussion) : moodle_url {
        return new moodle_url('/mod/forum/subscribe.php', [
            'sesskey' => sesskey(),
            'id' => $discussion->get_forum_id(),
            'd' => $discussion->get_id()
        ]);
    }
1077119
public function convertPostContent($post) {
		$content = $post->Content;
		
		$lines = explode("\n", $content);
		
		$newContent = array();
		$title = '';
		$converted = false;
		
		// store the converted items
		$convertedLinks = array();
		
		foreach ($lines as $line) {
			$url = trim($line);
			if (strlen($url) && $this->isWebpage($url)) {
				$convertedContent = $this->convertUrl($url);
				if ($convertedContent) {
					$converted = true;
					$line = 'CONVERTEDCONTENT:' . count($convertedLinks);
					$convertedLinks[] = $convertedContent;
					$title = strlen($convertedContent['Title']) ? $convertedContent['Title'] : '';
				}
			} 
			$newContent[] = $line;
		}

		$newContent = implode("\n", $newContent);
		$newContent = RestrictedMarkdown::create($newContent)->parse();
		
		// replace the converted bits
		$newContent = preg_replace_callback('/CONVERTEDCONTENT:(\d+)/is', function ($bit) use ($convertedLinks) {
			return isset($convertedLinks[$bit[1]]) ? $convertedLinks[$bit[1]]['Content'] : '';
		}, $newContent);
		
		if ($converted) {
			$post->IsOembed = true;
			$post->OriginalContent = $post->Content;
			$post->Content = $newContent;
			$post->Title = $title;
		}

		return $post;
	}