<commit_before><?php

class TimberPost extends TimberCore implements TimberCoreInterface {

    public $ImageClass = 'TimberImage';
    public $PostClass = 'TimberPost';

    public $object_type = 'post';
    public static $representation = 'post';

    public $_can_edit;
    public $_custom_imported = false;
    public $_content;
    public $_get_terms;

    private $_next = array();
    private $_prev = array();

    public $class;
    public $display_date;
    public $id;
    public $ID;
    public $post_content;
    public $post_date;
    public $post_parent;
    public $post_title;
    public $post_type;
    public $slug;

    /**
     *  If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
     * @param mixed $pid
     * @return \TimberPost TimberPost object -- woo!
     */
    function __construct($pid = null) {
        global $wp_query;
        if ($pid === null && isset($wp_query->queried_object_id) && $wp_query->queried_object_id) {
            $pid = $wp_query->queried_object_id;
            $this->ID = $pid;
        } else if ($pid === null && get_the_ID()) {
            $pid = get_the_ID();
            $this->ID = $pid;
        } else if ($pid === null && ($pid_from_loop = TimberPostGetter::loop_to_id())) {
            $this->ID = $pid_from_loop;
        }
        if (is_numeric($pid)) {
            $this->ID = $pid;
        }
        $this->init($pid);
    }

     /**
     * @return string
     */
    function __toString() {
        return $this->title();
    }


    /**
     * @param int|bool $pid
     */
    function init($pid = false) {
		if ($pid === false) {
			$pid = get_the_ID();
		}
		$post_info = $this->get_info($pid);
		$this->import($post_info);
		/* deprecated, adding for support for older themes */
		$this->display_date = $this->date();
		//cant have a function, so gots to do it this way
		$post_class = $this->post_class();
		$this->class = $post_class;
	}

    /**
     * Get the URL that will edit the current post/object
     *
     * @return bool|string
     */
    function get_edit_url() {
        if ($this->can_edit()) {
            return get_edit_post_link($this->ID);
        }
        return false;
    }

    /**
     * updates the post_meta of the current object with the given value
     *
     * @param string $field
     * @param mixed $value
     */
    public function update($field, $value) {
        if (isset($this->ID)) {
            update_post_meta($this->ID, $field, $value);
            $this->$field = $value;
        }
    }


    /**
     *  takes a mix of integer (post ID), string (post slug), or object to return a WordPress post object from WP's built-in get_post() function
     *
     * @param mixed $pid
     * @return WP_Post on success
     */
    private function prepare_post_info($pid = 0) {
        if (is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0) {
            $pid = self::check_post_id($pid);
            $post = get_post($pid);
            if ($post) {
                return $post;
            } else {
                $post = get_page($pid);
                return $post;
            }
        }
        //we can skip if already is WP_Post
        return $pid;
    }


    /**
     *  helps you find the post id regardless of whetehr you send a string or whatever
     *
     * @param integer $pid ;
     * @return integer ID number of a post
     */
    private function check_post_id($pid) {
        if (is_numeric($pid) && $pid === 0) {
            $pid = get_the_ID();
            return $pid;
        }
        if (!is_numeric($pid) && is_string($pid)) {
            $pid = self::get_post_id_by_name($pid);
            return $pid;
        }
        if (!$pid) {
            return null;
        }
        return $pid;
    }


    /**
     *  get_post_id_by_name($post_name)<commit_msg>Changes visibility to protected on check_post_id()<commit_after><?php

class TimberPost extends TimberCore implements TimberCoreInterface {

    public $ImageClass = 'TimberImage';
    public $PostClass = 'TimberPost';

    public $object_type = 'post';
    public static $representation = 'post';

    public $_can_edit;
    public $_custom_imported = false;
    public $_content;
    public $_get_terms;

    private $_next = array();
    private $_prev = array();

    public $class;
    public $display_date;
    public $id;
    public $ID;
    public $post_content;
    public $post_date;
    public $post_parent;
    public $post_title;
    public $post_type;
    public $slug;

    /**
     *  If you send the constructor nothing it will try to figure out the current post id based on being inside The_Loop
     * @param mixed $pid
     * @return \TimberPost TimberPost object -- woo!
     */
    function __construct($pid = null) {
        global $wp_query;
        if ($pid === null && isset($wp_query->queried_object_id) && $wp_query->queried_object_id) {
            $pid = $wp_query->queried_object_id;
            $this->ID = $pid;
        } else if ($pid === null && get_the_ID()) {
            $pid = get_the_ID();
            $this->ID = $pid;
        } else if ($pid === null && ($pid_from_loop = TimberPostGetter::loop_to_id())) {
            $this->ID = $pid_from_loop;
        }
        if (is_numeric($pid)) {
            $this->ID = $pid;
        }
        $this->init($pid);
    }

     /**
     * @return string
     */
    function __toString() {
        return $this->title();
    }


    /**
     * @param int|bool $pid
     */
    function init($pid = false) {
		if ($pid === false) {
			$pid = get_the_ID();
		}
		$post_info = $this->get_info($pid);
		$this->import($post_info);
		/* deprecated, adding for support for older themes */
		$this->display_date = $this->date();
		//cant have a function, so gots to do it this way
		$post_class = $this->post_class();
		$this->class = $post_class;
	}

    /**
     * Get the URL that will edit the current post/object
     *
     * @return bool|string
     */
    function get_edit_url() {
        if ($this->can_edit()) {
            return get_edit_post_link($this->ID);
        }
        return false;
    }

    /**
     * updates the post_meta of the current object with the given value
     *
     * @param string $field
     * @param mixed $value
     */
    public function update($field, $value) {
        if (isset($this->ID)) {
            update_post_meta($this->ID, $field, $value);
            $this->$field = $value;
        }
    }


    /**
     *  takes a mix of integer (post ID), string (post slug), or object to return a WordPress post object from WP's built-in get_post() function
     *
     * @param mixed $pid
     * @return WP_Post on success
     */
    private function prepare_post_info($pid = 0) {
        if (is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0) {
            $pid = self::check_post_id($pid);
            $post = get_post($pid);
            if ($post) {
                return $post;
            } else {
                $post = get_page($pid);
                return $post;
            }
        }
        //we can skip if already is WP_Post
        return $pid;
    }


    /**
     *  helps you find the post id regardless of whether you send a string or whatever
     *
     * @param integer $pid ;
     * @return integer ID number of a post
     */
    protected function check_post_id($pid) {
        if (is_numeric($pid) && $pid === 0) {
            $pid = get_the_ID();
            return $pid;
        }
        if (!is_numeric($pid) && is_string($pid)) {
            $pid = self::get_post_id_by_name($pid);
            return $pid;
        }
        if (!$pid) {
            return null;
        }
        return $pid;
    }


    /**
     *  get_post_id_by_name($post_name)
{'fraction_non_alphanumeric': 0.13499427990339394, 'fraction_numerical': 0.0007626795474768018, 'mean_word_length': 1.9735449735449735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2838571', 'n_tokens_mistral': 2497, 'n_tokens_neox': 2431, 'n_words': 652}