Load post data to the template.

@param IPost $post
161186
public function load(IPost $post)
    {
        $this->template->set('title', $post->getTitle());
        $this->template->set('meta_title', $post->metaTitle());
        $this->template->set('meta_keywords', $post->metaKeywords());
        $this->template->set('meta_description', $post->metaDescription());
    }
1168538
public function setPostParameters(array $postParameters)
    {
        foreach ($postParameters as $k => $v) {
            $this->_postParams[$k] = $v;
        }
    }
83828
public static function loadAllData($p, $profile_table, $post) {
        global $CFG;
        $PDOX = self::getConnection();
        $errormode = $PDOX->getAttribute(\PDO::ATTR_ERRMODE);
        $PDOX->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        // Add the fields
        // TODO: Add user_locale
        $sql = "SELECT k.key_id, k.key_key, k.secret, k.new_secret, k.settings_url AS key_settings_url,
            k.login_at AS key_login_at, k.lti13_client_id,
            n.nonce,
            c.context_id, c.title AS context_title, context_sha256, c.settings_url AS context_settings_url,
            c.ext_memberships_id AS ext_memberships_id, c.ext_memberships_url AS ext_memberships_url,
            c.lineitems_url AS lineitems_url, c.memberships_url AS memberships_url,
            c.lti13_lineitems AS lti13_lineitems, c.lti13_membership_url AS lti13_membership_url,
            l.link_id, l.path AS link_path, l.title AS link_title, l.settings AS link_settings, l.settings_url AS link_settings_url,
            l.lti13_lineitem AS lti13_lineitem,
            u.user_id, u.displayname AS user_displayname, u.email AS user_email, user_key, u.image AS user_image,
            u.locale AS user_locale,
            u.subscribe AS subscribe, u.user_sha256 AS user_sha256,
            m.membership_id, m.role, m.role_override,
            r.result_id, r.grade, r.result_url, r.sourcedid";

        if ( $profile_table ) {
            $sql .= ",
            p.profile_id, p.displayname AS profile_displayname, p.email AS profile_email,
            p.subscribe AS profile_subscribe";
        }

        if ( isset($post['service']) ) {
            $sql .= ",
            s.service_id, s.service_key AS service";
        }

        if ( $CFG->launchactivity ) {
            $sql .= ",
                a.link_count, a.activity AS link_activity,
                au.link_user_count, au.activity AS link_user_activity";
        }

        // Add the JOINs
        $sql .="\nFROM {$p}lti_key AS k
            LEFT JOIN {$p}lti_nonce AS n ON k.key_id = n.key_id AND n.nonce = :nonce
            LEFT JOIN {$p}lti_context AS c ON k.key_id = c.key_id AND c.context_sha256 = :context
            LEFT JOIN {$p}lti_link AS l ON c.context_id = l.context_id AND l.link_sha256 = :link
            LEFT JOIN {$p}lti_user AS u ON k.key_id = u.key_id AND u.user_sha256 = :user
            LEFT JOIN {$p}lti_membership AS m ON u.user_id = m.user_id AND c.context_id = m.context_id
            LEFT JOIN {$p}lti_result AS r ON u.user_id = r.user_id AND l.link_id = r.link_id";

        if ( $profile_table ) {
            $sql .= "
            LEFT JOIN {$profile_table} AS p ON u.profile_id = p.profile_id";
        }

        if ( isset($post['service']) ) {
            $sql .= "
            LEFT JOIN {$p}lti_service AS s ON k.key_id = s.key_id AND s.service_sha256 = :service";
        }

        if ( $CFG->launchactivity ) {
            $sql .= "
            LEFT JOIN {$p}lti_link_activity AS a ON a.link_id = l.link_id AND a.event = 0
            LEFT JOIN {$p}lti_link_user_activity AS au ON au.link_id = l.link_id AND au.user_id = u.user_id AND au.event = 0";
        }

        // Add the WHERE clause
        // TODO: Fix this per SO - but wait until the migrations have run in production
        // https://stackoverflow.com/questions/44474250/which-is-better-in-mysql-an-ifnull-or-or-logic/44474286
        $sql .= "\nWHERE k.key_sha256 = :key
            AND (k.deleted IS NULL OR k.deleted = 0)
            AND (c.deleted IS NULL OR c.deleted = 0)
            AND (l.deleted IS NULL OR l.deleted = 0)
            AND (u.deleted IS NULL OR u.deleted = 0)
            AND (m.deleted IS NULL OR m.deleted = 0)
            AND (r.deleted IS NULL OR r.deleted = 0)";

        if ( $profile_table ) {
            $sql .= "
            AND (p.deleted IS NULL OR p.deleted = 0)";
        }

        if ( isset($post['service']) ) {
            $sql .= "
            AND (s.deleted IS NULL OR s.deleted = 0)";
        }

        // There should only be one :)

        $sql .= "
            LIMIT 1\n";

        // ContentItem does not neet link_id
        if ( ! isset($post['link_id']) ) $post['link_id'] = null;
        $parms = array(
            ':key' => lti_sha256($post['key']),
            ':nonce' => substr($post['nonce'],0,128),
            ':context' => lti_sha256($post['context_id']),
            ':link' => lti_sha256($post['link_id']),
            ':user' => lti_sha256($post['user_id']));

        if ( isset($post['service']) ) {
            $parms[':service'] = lti_sha256($post['service']);
        }

        // die($sql);
        $row = $PDOX->rowDie($sql, $parms);

        // Restore ERRMODE
        $PDOX->setAttribute(\PDO::ATTR_ERRMODE, $errormode);

        return $row;
    }
1017586
public static function loadThemeTemplates($post_templates, $object = null, $post = null, $post_type = null)
    {
        $blades = self::getAllBlades();
        foreach ($blades as $blade) {
            if (preg_match('/{{--\s*Template Name:(.*)--}}/mi', file_get_contents($blade), $header)) {

                $post_templates[basename($blade, ".blade.php")] = $header[1];
            }
        }
        return $post_templates;
    }
779023
public static function create($post)
    {
        // If numeric, create the post
        if (is_numeric($post)) {
            // Retrieve the transient
            $transientKey = sprintf('WPMVC\Models\Post(%d)', $post);
            $storedData = WP::getTransient($transientKey);
            // If the transient doesn't yet exist, query for it!
            if ($storedData === false) {
                // Retrieve the post object
                $post = WP::getPost(intval($post));
                // Store the transient
                WP::setTransient($transientKey, $post, static::$transientTimeout);
            } else {
                $post = $storedData;
            }
        } elseif (is_array($post)) {
            // Convert array into object
            $post = (object) $post;
        }
        return new static($post);
    }
515921
public function elasticPressPreIndex($post)
    {
        $rendered = $this->getRenderedPostModules($post);

        if (is_array($post)) {
            $post['post_content'] .= $rendered;
        } else {
            $post->post_content .= $rendered;
        }

        return $post;
    }
154966
public function savePost(DataObject $post, $data) {
		if ($post->checkPerm('Write') && isset($data['Content'])) {
			$post->Content = $data['Content'];
			if ($this->securityContext->getMember()->Balance >= MicroBlogMember::BALANCE_THRESHOLD) {
				$post->analyseContent();
				$post->write();
			} else {
				$this->queuedJobService->queueJob(new ProcessPostJob($post));
			}
			$html = $post->renderWith('PostContent');
			return $post;
		}
	}
437512
public function setupPost($post)
    {

        $user    = new User($this->db);
        $comment = new Comment($this->db);
        $vote    = new Vote($this->db);

        $post->img      = $user->getGravatar($post->user);
        $post->comments = $comment->getComments("parentId = ?", [$post->id]);
        $post->vote     = $vote->getVote("parentId = ? AND parentType = ?", [$post->id, "post"]);
        $post->markdown = $this->getMD($post->text);

        return $post;
    }
285359
public function render(\WP_Post $post, array $args)
    {
        $args = array_merge($args['args'], [
            'metabox' => $this,
            'post' => $post,
            'screen' => $this->getScreen()
        ]);

        $response = $this->handleCallback($this->getCallback(), $args);

        if ($response instanceof Renderable) {
            echo $response->render();
        } elseif ($response instanceof Response) {
            echo $response->getContent();
        }
    }
649931
public function output_edit_form( $post ) {
		$params = $this->get_edit_form_params( $post );
		$this->before_output_edit_form( $post, $params );
		$this->add_style_view( 'admin/style/custom_post', $params );
		$this->add_style_view( 'admin/style/custom_post/' . $this->get_post_type_slug(), $params );
		$this->add_script_view( 'admin/script/custom_post', $params );
		$this->add_script_view( 'admin/script/custom_post/' . $this->get_post_type_slug(), $params );
		if ( ! $this->get_view( 'admin/custom_post/' . $this->get_post_type_slug(), $params, true, false ) ) {
			$columns = $this->app->utility->array_pluck( $params['columns'], 'is_user_defined' );
			unset( $columns['post_id'] );
			if ( ! empty( array_filter( $columns ) ) ) {
				$this->get_view( 'admin/custom_post', $params, true, false );
			}
		}
		$this->after_output_edit_form( $post, $params );
	}
790623
protected function add_data_for_post($post) {
        if (!isset($this->adhocdata[$post->course])) {
            $this->adhocdata[$post->course] = [];
        }

        if (!isset($this->adhocdata[$post->course][$post->forum])) {
            $this->adhocdata[$post->course][$post->forum] = [];
        }

        if (!isset($this->adhocdata[$post->course][$post->forum][$post->discussion])) {
            $this->adhocdata[$post->course][$post->forum][$post->discussion] = [];
        }

        $this->adhocdata[$post->course][$post->forum][$post->discussion][$post->id] = $post->id;
    }
46079
protected function addPostMedias(&$post, $data)
    {

        // we fetch standard_resolution image
        $imageData = $data['images']['standard_resolution'];
        $media = new Media();

        $media
            ->setUrl($imageData['url'])
            ->setLink($data['link'])
            ->setWidth($imageData['width'])
            ->setHeight($imageData['height'])
        ;

        $post->addMedia($media);
    }
873825
protected function prepareRawPayload($data)
    {
        $this->clearRequestParams();
        $this->addHeader('Content-Length', strlen($data));
        $this->addOption(CURLOPT_POSTFIELDS, $data);
    }
565887
public function load($input)
    {
        $this->position = 0;
        $this->previous = 0;

        if (ord($input) < 32) {
            $this->input  = $input;
            $this->length = strlen($input);

            return;
        }

        $position = stripos($input, 'x');

        if (false !== $position) {
            $input = substr($input, $position + 1);
        }

        $this->input  = pack('H*', $input);
        $this->length = strlen($this->input);
    }
774569
private function setPostFields(array $post_data)
    {
        $pd = [];
        foreach ($post_data as $k => $v) {
            $pd[] = "$k=$v";
        }
        $pd = implode("&", $pd);
        \Unirest\Request::curlOpt(CURLOPT_POST, true);
        \Unirest\Request::curlOpt(CURLOPT_POSTFIELDS, $pd);
        \Unirest\Request::curlOpt(CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
    }
926338
public function setPostData($post): HttpParser
    {
        if (is_array($post)) {
            $post = http_build_query($post);
        }

        $this
            ->setHeadersParam('Content-Type', 'application/x-www-form-urlencoded')
            ->setHeadersParam('Content-Length', (string)strlen($post));

        $this->headers_is_post = $post;

        return $this;
    }
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;
	}