<commit_before><?php

if ( ! class_exists( 'WMobilePack_Admin' ) ) {

    /**
     *
     * WMobilePack_Admin class for managing the admin area for the Wordpress Mobile Pack plugin
     *
     */
    class WMobilePack_Admin
    {

        /**
         *
         * Method used to render the main admin page
         *
         */
        public function whatsnew() {

            WMobilePack_Options::update_settings('whats_new_updated', 0);

            include(WMP_PLUGIN_PATH.'admin/pages/whats-new.php');
        }


        /**
         *
         * Method used to render the themes selection page from the admin area
         *
         */
        public function theme() {

            include(WMP_PLUGIN_PATH.'admin/pages/theme.php');
        }


        /**
         * Build tree hierarchy for the pages array
         *
         * @param $all_pages
         * @return array
         */
        protected function build_pages_tree($all_pages){

            $nodes_pages = array();

            foreach ($all_pages as $p) {

                $nodes_pages[$p->ID] = array(
                    'id' => $p->ID,
                    'parent_id' => intval($p->post_parent),
                    'obj' => clone $p
                );
            }

            $pages_tree = array(0 => array());

            foreach ($nodes_pages as $n) {

                $pid = $n['parent_id'];
                $id = $n['id'];

                if (!isset($pages_tree[$pid]))
                    $pages_tree[$pid] = array('child' => array());

                if (isset($pages_tree[$id]))
                    $child = &$pages_tree[$id]['child'];
                else
                    $child = array();

                $pages_tree[$id] = $n;
                $pages_tree[$id]['child'] = &$child;
                unset($pages_tree[$id]['parent_id']);
                unset($child);

                $pages_tree[$pid]['child'][] = &$pages_tree[$id];
            }

            $nodes_pages = $pages_tree['0']['child'];
            unset($pages_tree);

            return $nodes_pages;

        }


        /**
         *
         * Method used to render the content selection page from the admin area
         *
         */
        public function content() {

            $all_pages = get_pages(array('sort_column' => 'menu_order,post_title'));
            $pages = $this->build_pages_tree($all_pages);

            include(WMP_PLUGIN_PATH.'admin/pages/content.php');
        }


        /**
         *
         * Method used to render the settings page from the admin area
         *
         */
        public function settings() {

            include(WMP_PLUGIN_PATH.'admin/pages/settings.php');
        }
<commit_msg>Solve PHP notice (if there are no pages)<commit_after><?php

if ( ! class_exists( 'WMobilePack_Admin' ) ) {

    /**
     *
     * WMobilePack_Admin class for managing the admin area for the Wordpress Mobile Pack plugin
     *
     */
    class WMobilePack_Admin
    {

        /**
         *
         * Method used to render the main admin page
         *
         */
        public function whatsnew() {

            WMobilePack_Options::update_settings('whats_new_updated', 0);

            include(WMP_PLUGIN_PATH.'admin/pages/whats-new.php');
        }


        /**
         *
         * Method used to render the themes selection page from the admin area
         *
         */
        public function theme() {

            include(WMP_PLUGIN_PATH.'admin/pages/theme.php');
        }


        /**
         * Build tree hierarchy for the pages array
         *
         * @param $all_pages
         * @return array
         */
        protected function build_pages_tree($all_pages){

            $nodes_pages = array();

            foreach ($all_pages as $p) {

                $nodes_pages[$p->ID] = array(
                    'id' => $p->ID,
                    'parent_id' => intval($p->post_parent),
                    'obj' => clone $p
                );
            }

            $pages_tree = array(0 => array());

            foreach ($nodes_pages as $n) {

                $pid = $n['parent_id'];
                $id = $n['id'];

                if (!isset($pages_tree[$pid]))
                    $pages_tree[$pid] = array('child' => array());

                if (isset($pages_tree[$id]))
                    $child = &$pages_tree[$id]['child'];
                else
                    $child = array();

                $pages_tree[$id] = $n;
                $pages_tree[$id]['child'] = &$child;
                unset($pages_tree[$id]['parent_id']);
                unset($child);

                $pages_tree[$pid]['child'][] = &$pages_tree[$id];
            }

            if (!empty($pages_tree) && !empty($pages_tree[0])) {
                $nodes_pages = $pages_tree[0]['child'];
                unset($pages_tree);
                return $nodes_pages;
            }
            
            return array();
        
        }


        /**
         *
         * Method used to render the content selection page from the admin area
         *
         */
        public function content() {

            $all_pages = get_pages(array('sort_column' => 'menu_order,post_title'));
            $pages = $this->build_pages_tree($all_pages);

            include(WMP_PLUGIN_PATH.'admin/pages/content.php');
        }


        /**
         *
         * Method used to render the settings page from the admin area
         *
         */
        public function settings() {

            include(WMP_PLUGIN_PATH.'admin/pages/settings.php');
        }

{'fraction_non_alphanumeric': 0.12786944045911047, 'fraction_numerical': 0.001255380200860832, 'mean_word_length': 1.3812980358667806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1418710', 'n_tokens_mistral': 1577, 'n_tokens_neox': 1477, 'n_words': 312}