# easy-hotel/2.0.2/admin/includes/activation.php

Easy Hotel – Powerful Hotel Booking, version 2.0.2. 39 lines.

- Page: https://pluginprobe.com/plugins/easy-hotel/2.0.2/code/admin/includes/activation.php
- Raw: https://pluginprobe.com/plugins/easy-hotel/2.0.2/raw/admin/includes/activation.php
- Modified: 2026-06-15T17:21:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-hotel/2.0.2/code/admin/includes/activation.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
function eshb_create_easy_hotel_pages() {

    // Define pages and templates
    $pages = [
        'Easy Hotel Archive' => array('title' => 'Easy Hotel Archive', 'shortcode' => '[eshb_accomodation_grid]'),
        'Easy Hotel Search' => array('title' => 'Easy Hotel Search', 'shortcode' => '[eshb_search_form]'),
        'Easy Hotel Search Result' => array('title' => 'Easy Hotel Search Result', 'shortcode' => '[eshb_accomodation_search_result]'),
    ];

    foreach ($pages as $page_title => $page_data) {
        // Check if the page already exists using WP_Query
        $query = new WP_Query([
            'post_type'   => 'page',
            'title'       => $page_title,
            'posts_per_page' => 1, // Only need one result
        ]);

        // If no page found, create it
        if (!$query->have_posts()) {
            // Create the page with the shortcode in the content
            $page_id = wp_insert_post([
                'post_title'   => $page_data['title'],
                'post_content' => $page_data['shortcode'], // Add shortcode as content
                'post_status'  => 'publish',
                'post_type'    => 'page',
            ]);

            // Check for errors in post creation
            if (is_wp_error($page_id)) {
                //error_log('Error creating page "' . $page_data['title'] . '": ' . $page_id->get_error_message());
            } else {
                // Assign the page template
                update_post_meta($page_id, '_wp_page_template', $page_data['title']);
            }
        }
    }
}
```
