Get attachment permalink for search result
@param  string  $permalink
@param  WP_Post $post
@return string            Url
432263
public function searchAttachmentPermalink($permalink, $post)
    {
        if (isset($post->post_type) && $post->post_type == 'attachment') {
            return wp_get_attachment_url($post->ID);
        } else {
            return $permalink;
        }
    }
706214
public function get_export_attachment_url_from_post_and_attachment(post_entity $post, stored_file $attachment) : ?moodle_url {
        global $CFG;

        require_once($CFG->libdir . '/portfoliolib.php');
        $button = new \portfolio_add_button();
        $button->set_callback_options(
            'forum_portfolio_caller',
            ['postid' => $post->get_id(), 'attachment' => $attachment->get_id()],
            'mod_forum'
        );
        $button->set_format_by_file($attachment);
        $url = $button->to_html(PORTFOLIO_ADD_MOODLE_URL);
        return $url ?: null;
    }
832200
function ctc_get_posts() {

		$posts = array();

		// Base arguments
		$args = array(
			'post_type'			=> 'attachment',
			'post_status'		=> 'inherit', // for attachments
			'post_mime_type'	=> 'image',
			'posts_per_page'	=> $this->ctc_instance['limit'],
			'orderby'			=> $this->ctc_instance['orderby'],
			'order'				=> $this->ctc_instance['order'],
			'no_found_rows'		=> true // faster
		);

		// All Galleries - get images attached to Gallery posts/pages
		if ( 'all' == $this->ctc_instance['post_id'] || empty( $this->ctc_instance['post_id'] ) ) {
			$args['post_parent__in'] = ctc_gallery_posts_ids(); // get all Gallery post IDs into array
		}

		// Specififc Gallery - get images used in shortcodes on post/page
		// Getting IDs from shortcode attributes since post may have images not attached to it
		else {

			// Get data for one post
			$posts = ctc_gallery_posts( array(
				'post_id' => $this->ctc_instance['post_id']
			) );

			// Use ID's from shortcode attributes
			if ( ! empty( $posts[$this->ctc_instance['post_id']]['image_ids'] ) ) {
				$args['post__in'] = $posts[$this->ctc_instance['post_id']]['image_ids'];
			}

		}

		// Get gallery images
		if ( ! empty( $args['post_parent__in'] ) || ! empty( $args['post__in'] ) ) { // if have something to search for
			$images_query = new WP_Query( $args );
			$posts = ! empty( $images_query->posts ) ? $images_query->posts : array();
		}

		// Return filtered
		return apply_filters( 'ctc_gallery_widget_get_posts', $posts );

	}
1049394
public function get_permalink() {
        $link = $this->_get_discussionlink();
        $link->set_anchor($this->get_postanchor());

        return $link->out(false);
    }
555626
private function get_modules_content( \WP_Post $post ) : string {
		$flexible_content = $this->_flexible_content[ $post->ID ] ?? null;

		if ( empty( $flexible_content ) ) {
			$layouts = $this->get_current_post_layouts( $post );

			foreach ( $layouts as $layout ) {

				if ( ! isset( $layout['acf_fc_layout'] ) || empty( $layout['acf_fc_layout'] ) ) {
					continue;
				}

				ob_start();
				$this->render_module_template( $layout['acf_fc_layout'], $layout );
				$flexible_content .= ob_get_clean();
			}

			/*
			 * Store the flexible content to reuse it if `the_content` is
			 * runned more than once.
			 */
			$this->_flexible_content[ $post->ID ] = $flexible_content;
		}

		return (string) $flexible_content;
	}
1368366
public static function get_post_meta_title( $post ) {
		$title = get_post_meta( $post->ID, '_yoast_wpseo_title', true );

		if ( empty( $title ) ) {
			if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
				$title = get_bloginfo( 'title' );
			} else {
				$title = $post->post_title . ' - ' . get_bloginfo( 'title' );
			}
		}

		return $title;
	}
857836
protected function get_data( \WP_Post $post ){
        switch( $this->field ){
            case 'post_meta':
                return get_posts([
                    'posts__in' => explode(',', get_post_meta($post->ID, $this->name, true)),
                    'post_type' => $this->post_type,
                    'author' => $post->post_author,
                    'suppress_filters' => false,
                ]);
                break;
            default:
                if( $post->post_parent ){
                    return get_posts([
                        'p' => $post->post_parent,
                        'post_type' => $this->post_type,
                        'author' => $post->post_author,
                        'suppress_filters' => false,
                        'post_status' => array('publish', 'future', 'pending', 'draft', 'private')
                    ]);
                }else{
                    return [];
                }
                break;
        }
    }
1115984
def find_by_permalink!(permalink)
      result = scoped_by_permalink(permalink).first
      raise ActiveRecord::RecordNotFound.new "Could not find Content for Permalink id=#{permalink.id}" if result.nil?
      result
    end
272054
public function get_view_isolated_post_url_from_post(post_entity $post) : moodle_url {
        return $this->get_view_isolated_post_url_from_post_id($post->get_discussion_id(), $post->get_id());
    }
1258289
public function filterPostTypeLink($permalink, $item, $leavename)
    {
        if (get_post_type($item->ID) == $this->singular)
        {
            $terms = wp_get_post_terms($item->ID, $this->taxonomy);
            $term = ($terms) ? $terms[0]->term_id : false;
            $permalink = $this->postTypePermalink($item->ID, $term, $leavename, false);
        }

        return $permalink;
    }
759744
public function lookForBrokenLinks($postId = null, $url = null)
    {
        \BrokenLinkDetector\App::checkInstall();
        $foundUrls = array();

        if ($url) {
            $url = "REGEXP ('.*(href=\"{$url}\").*')";
        } else {
            $url = "RLIKE ('href=*')";
        }

        global $wpdb;
        $sql = "
            SELECT ID, post_content
            FROM $wpdb->posts
            WHERE
                post_content {$url}
                AND post_type NOT IN ('attachment', 'revision', 'acf', 'acf-field', 'acf-field-group')
                AND post_status IN ('publish', 'private', 'password')
        ";

        if (is_numeric($postId)) {
            $sql .= " AND ID = $postId";
        }

        $posts = $wpdb->get_results($sql);

        if(is_array($posts) && !empty($posts)) {
            foreach ($posts as $post) {
                preg_match_all('/<a[^>]+href=([\'"])(http|https)(.+?)\1[^>]*>/i', $post->post_content, $m);

                if (!isset($m[3]) || count($m[3]) > 0) {
                    foreach ($m[3] as $key => $url) {
                        $url = $m[2][$key] . $url;

                        // Replace whitespaces in url
                        if (preg_match('/\s/', $url)) {
                            $newUrl = preg_replace('/ /', '%20', $url);
                            $wpdb->query(
                                $wpdb->prepare(
                                    "UPDATE $wpdb->posts
                                        SET post_content = REPLACE(post_content, %s, %s)
                                        WHERE post_content LIKE %s
                                        AND ID = %d",
                                    $url,
                                    $newUrl,
                                    '%' . $wpdb->esc_like($url) . '%',
                                    $post->ID
                                )
                            );
                            $url = $newUrl;
                        }

                        if ($postId !== 'internal' && !$this->isBroken($url)) {
                            continue;
                        }

                        $foundUrls[] = array(
                            'post_id' => $post->ID,
                            'url' => $url
                        );
                    }
                }
            }
        }

        $this->saveBrokenLinks($foundUrls, $postId);
    }
19304
func (api *Client) GetPermalink(params *PermalinkParameters) (string, error) {
	return api.GetPermalinkContext(context.Background(), params)
}
343870
function mf_get_post_values( $post_id ) {
    global $wpdb;

    $raw = $wpdb->get_results(
      "SELECT
        mfpm.meta_id,
        mfpm.field_name,
        mfpm.field_count,
        mfpm.group_count,
        pm.meta_value
      FROM
        ".MF_TABLE_POST_META." as mfpm
      LEFT JOIN
       ".$wpdb->postmeta." as pm
      ON
        ( mfpm.meta_id = pm.meta_id )
      WHERE
        mfpm.post_id = ".$post_id
    );

    $data = array();

    foreach( $raw as $key => $field ){
      $data[$field->field_name][$field->group_count][$field->field_count] = $field->meta_value;
    }

    return $data;
  }
327053
function get_result( $post, $field, $the_post, $options = array() ) {
		
		// right aligned info
		$title = '<span class="relationship-item-info">';
			
			if( in_array('post_type', $field['result_elements']) ) {
				
				$post_type_object = get_post_type_object( $post->post_type );
				$title .= $post_type_object->labels->singular_name;
				
			}
			
			
			// WPML
			if( !empty($options['lang']) ) {
				
				$title .= ' (' . $options['lang'] . ')';
				
			} elseif( defined('ICL_LANGUAGE_CODE') ) {
				
				$title .= ' (' . ICL_LANGUAGE_CODE . ')';
				
			}
			
		$title .= '</span>';
		
		
		// featured_image
		if( in_array('featured_image', $field['result_elements']) ) {
			
			$image = '';
			
			if( $post->post_type == 'attachment' ) {
				
				$image = wp_get_attachment_image( $post->ID, array(21, 21) );
				
			} else {
				
				$image = get_the_post_thumbnail( $post->ID, array(21, 21) );
				
			}
			
			$title .= '<div class="result-thumbnail">' . $image . '</div>';
			
		}
		
		
		// title
		$post_title = get_the_title( $post->ID );
		
		
		// empty
		if( $post_title === '' ) {
			
			$post_title = __('(no title)', 'acf');
			
		}
		
		
		$title .= $post_title;
		
		
		// status
		if( get_post_status( $post->ID ) != "publish" ) {
			
			$title .= ' (' . get_post_status( $post->ID ) . ')';
			
		}
			
		
		// filters
		$title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $the_post);
		$title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'] , $title, $post, $field, $the_post);
		$title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $the_post);
		
		
		// return
		return $title;
		
	}
316091
public function attachmentContent()
    {
        $output = [];

        if (wp_attachment_is_image()) {
            $output[] = sprintf(
                '<div class="attachment-image">%s</div>',
                wp_get_attachment_image(
                    get_the_ID(),
                    apply_filters('novusopress_view_attachment_image_size', 'medium')
                )
            );
        } else {
            $output[] = sprintf(
                '<div class="attachment-link"><a href="%s">%s</a></div>',
                wp_get_attachment_url(get_the_ID()),
                get_the_title()
            );
        }

        if (has_excerpt()) {
            $output[] = sprintf('<div class="entry-caption">%s</div>', get_the_excerpt());
        }

        return apply_filters('novusopress_view_attachment_content_output', implode('', $output));
    }
1211162
public function imageAttachmentLink()
    {
        $output = [];

        if (is_attachment() && wp_attachment_is_image()) {
            $metadata = wp_get_attachment_metadata();
            $output[] = sprintf(
                '<span class="full-size-link"><span class="sr-only">%s</span><a href="%s">%s &times; %s</a></span>',
                _x('Full size', 'Used before full size attachment link', 'novusopress'),
                esc_url(wp_get_attachment_url()),
                $metadata['width'],
                $metadata['height']
            );
        }

        return apply_filters('novusopress_view_image_attachment_link_output', implode('', $output));
    }
151478
public static function get( $post ) {
		$post = is_a( $post, 'WP_Post' ) ? $post : get_post( $post );

		$data = [
			'title' => get_the_title( $post ),
			'content' => apply_filters( 'the_content', get_post_field( 'post_content', $post->ID ) ),
		];

		return array_merge( $data, Acf::get_post_field( $post->ID, false ) );
	}