<commit_before><?php

if ( ! class_exists( 'WMobilePack_Formatter' ) ) {
    require_once(WMP_PLUGIN_PATH.'inc/class-wmp-formatter.php');
}

if ( ! class_exists( 'WMobilePack_Export' ) ) {

    /**
     * Class WMobilePack_Export
     *
     * Contains different methods for exporting categories, articles and comments
     *
     * @improvement - Move this class to the frontend folder (similar to the PRO version)?
     *
     * @todo (Future releases) Remove category_id and category_name from the exports after apps have been modified to use multiple categories per post
     *
     */
    class WMobilePack_Export
    {

        /* ----------------------------------*/
        /* Attributes						 */
        /* ----------------------------------*/

        public $purifier;
        private $inactive_categories = array();
        private $inactive_pages = array();

        /* ----------------------------------*/
        /* Methods							 */
        /* ----------------------------------*/


        /**
         *
         * Init purifier, inactive categories and pages properties
         *
         */
        public function __construct()
        {
            $this->purifier = WMobilePack_Formatter::init_purifier();
            $this->inactive_categories = WMobilePack_Options::get_setting('inactive_categories');
            $this->inactive_pages = WMobilePack_Options::get_setting('inactive_pages');
        }


        /**
         *
         * Create an uploads management object and return it
         *
         * @return object
         *
         */
        protected function get_uploads_manager()
        {
            return new WMobilePack_Uploads();
        }


        /**
         *
         * Verify if a post has a featured image and return it
         *
         * @param $post_id
         * @return array
         */
        protected function get_post_image($post_id)
        {

            $image_details = array();

            if (has_post_thumbnail($post_id)) {

                $post_thumbnail_id = get_post_thumbnail_id($post_id);
                $image_metadata = wp_get_attachment_metadata($post_thumbnail_id, true);

                if (is_array($image_metadata) && !empty($image_metadata)) {

                    if (isset($image_metadata['width']) && isset($image_metadata['height'])) {

                        $image_details = array(
                            "src" => wp_get_attachment_url($post_thumbnail_id),
                            "width" => $image_metadata['width'],
                            "height" => $image_metadata['height']
                        );
                    }
                }
            }

            return $image_details;
        }


        /**
         *
         * Compose array with a post's details for a posts list
         *
         * @param $post
         * @return array
         *
         */
        protected function format_post_short($post)
        {

            // check if the post has a post thumbnail assigned to it and save it in an array
            $image_details = $this->get_post_image($post->ID);

            // Build post array - get_the_title(), get_permalink() methods can be used inside or outside of The Loop.
            // If used outside the loop an ID must be specified.

            $arr_article = array(
                'id' => $post->ID,
                "title" => get_the_title(),
                "author" => get_the_author_meta('display_name'),<commit_msg>Fix resize featured images , closes #12<commit_after><?php

if ( ! class_exists( 'WMobilePack_Formatter' ) ) {
    require_once(WMP_PLUGIN_PATH.'inc/class-wmp-formatter.php');
}

if ( ! class_exists( 'WMobilePack_Export' ) ) {

    /**
     * Class WMobilePack_Export
     *
     * Contains different methods for exporting categories, articles and comments
     *
     * @improvement - Move this class to the frontend folder (similar to the PRO version)?
     *
     * @todo (Future releases) Remove category_id and category_name from the exports after apps have been modified to use multiple categories per post
     *
     */
    class WMobilePack_Export
    {

        /* ----------------------------------*/
        /* Attributes						 */
        /* ----------------------------------*/

        public $purifier;
        private $inactive_categories = array();
        private $inactive_pages = array();

        /* ----------------------------------*/
        /* Methods							 */
        /* ----------------------------------*/


        /**
         *
         * Init purifier, inactive categories and pages properties
         *
         */
        public function __construct()
        {
            $this->purifier = WMobilePack_Formatter::init_purifier();
            $this->inactive_categories = WMobilePack_Options::get_setting('inactive_categories');
            $this->inactive_pages = WMobilePack_Options::get_setting('inactive_pages');
        }


        /**
         *
         * Create an uploads management object and return it
         *
         * @return object
         *
         */
        protected function get_uploads_manager()
        {
            return new WMobilePack_Uploads();
        }


        /**
         *
         * Verify if a post has a featured image and return it
         *
         * @param $post_id
         * @return array
         */
        protected function get_post_image($post_id)
        {
            if (has_post_thumbnail($post_id)) {

				$post_thumbnail_id = get_post_thumbnail_id($post_id);
				$full_url  = wp_get_attachment_url($post_thumbnail_id);

				$image_metadata = wp_get_attachment_metadata($post_thumbnail_id, true);

				if ($full_url && is_array($image_metadata) && !empty($image_metadata)) {

					$thumbnail = isset($image_metadata['sizes']['medium_large']) ? $image_metadata['sizes']['medium_large'] : $image_metadata['sizes']['large'];

                    if (isset($thumbnail['file']) && isset($thumbnail['width']) && isset($thumbnail['height'])) {

						return array(
                            "src" => str_replace(basename($full_url), $thumbnail['file'], $full_url),
                            "width" => $thumbnail['width'],
                            "height" => $thumbnail['height']
                        );
					}

					if (isset($image_metadata['width']) && isset($image_metadata['height'])) {

                        return array(
                            "src" => $full_url,
                            "width" => $image_metadata['width'],
                            "height" => $image_metadata['height']
                        );
                    }
				}
            }

            return array();
        }


        /**
         *
         * Compose array with a post's details for a posts list
         *
         * @param $post
         * @return array
         *
         */
        protected function format_post_short($post)
        {

            // check if the post has a post thumbnail assigned to it and save it in an array
            $image_details = $this->get_post_image($post->ID);

            // Build post array - get_the_title(), get_permalink() methods can be used inside or outside of The Loop.
            // If used outside the loop an ID must be specified.

            $arr_article = array(
                'id' => $post->ID,
                "title" => get_the_title(),
                "author" => get_the_author_meta('display_name'),
{'fraction_non_alphanumeric': 0.14028969957081544, 'fraction_numerical': 0.0002682403433476395, 'mean_word_length': 1.5201081446434606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, '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': '2190680', 'n_tokens_mistral': 2000, 'n_tokens_neox': 1873, 'n_words': 441}