Changeset 3282279
- Timestamp:
- 04/26/2025 07:12:39 AM (11 months ago)
- Location:
- website-maintenance-pti/trunk
- Files:
-
- 1 added
- 5 edited
-
assets/css/template-style.css (modified) (3 diffs)
-
assets/js/website-maintenance-fornt-script.js (added)
-
readme.txt (modified) (1 diff)
-
templates/template1/index.php (modified) (1 diff)
-
templates/template3/index.php (modified) (1 diff)
-
website-maintenance-pti.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
website-maintenance-pti/trunk/assets/css/template-style.css
r3266757 r3282279 2 2 margin-top: 0px; 3 3 margin-bottom: 0px; 4 z-index: 1;4 z-index: 1; 5 5 } 6 6 .default p { 7 7 margin-bottom: 0px; 8 z-index: 1;8 z-index: 1; 9 9 } 10 10 .default:before { … … 42 42 margin-top: 0px; 43 43 margin-bottom: 0px; 44 z-index: 1;44 z-index: 1; 45 45 } 46 46 .default p { 47 47 margin-bottom: 0px; 48 z-index: 1;48 z-index: 1; 49 49 } 50 50 .default:before { … … 61 61 max-width: 80%; 62 62 } 63 64 /* Progress bar fill */ 65 #progress-bar { 66 height: 100%; 67 width: 0%; 68 background: linear-gradient(to right, #4caf50, #81c784); 69 transition: width 0.5s ease-in-out; 70 } 71 #progress-container { 72 width: 100%; 73 background: #eee; 74 height: 12px; 75 max-width: 400px; 76 border-radius: 10px; 77 overflow: hidden; 78 margin: 20px auto 0px; 79 z-index: 9999; 80 } 81 .default_templates2 img.custom-logo { 82 margin: 0px auto; 83 } -
website-maintenance-pti/trunk/readme.txt
r3264474 r3282279 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
website-maintenance-pti/trunk/templates/template1/index.php
r3264474 r3282279 2 2 <!DOCTYPE html> 3 3 <html lang="en"> 4 5 <head>4 5 <head> 6 6 <?php wp_head(); ?> 7 <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">8 <title><?php echo esc_html(get_option('ptiwmm_title', 'Maintenance Mode')) ?> </title>9 </head>10 <?php $ptiwmm_banner_id = attachment_url_to_postid(get_option('ptiwmm_banner_image', ''));11 if ($ptiwmm_banner_id) {7 <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"> 8 <title><?php echo esc_html(get_option('ptiwmm_title', 'Maintenance Mode')) ?> </title> 9 </head> 10 <?php $ptiwmm_banner_id = attachment_url_to_postid(get_option('ptiwmm_banner_image', '')); 11 if ($ptiwmm_banner_id) { 12 12 // echo wp_get_attachment_image($ptiwmm_banner_id, 'full', false, array('alt' => 'Banner Image')); 13 } ?> 14 <body> 15 <div class="default"> 16 <h1><?php echo esc_html(get_option('ptiwmm_headline', 'We will be back soon!')) ?> </h1> 17 <p><?php echo esc_html(get_option('ptiwmm_message', 'We are currently updating our website. Please check back later.')) ?> </p> 18 <?php if (get_option('ptiwmm_countdown_date')) { ?> 19 <p id="countdown"></p> 20 <?php }?> 21 </div> 22 <?php wp_footer(); ?> 23 </body> 13 } ?> 14 <body> 15 <div class="default"> 16 <h1><?php echo esc_html(get_option('ptiwmm_headline', 'We will be back soon!')) ?> </h1> 17 <p><?php echo esc_html(get_option('ptiwmm_message', 'We are currently updating our website. Please check back later.')) ?> </p> 18 <?php if (get_option('ptiwmm_countdown_date')) { ?> 19 <p id="countdown" data-start="<?php echo esc_attr(current_time('Y-m-d\TH:i:s')); ?>" data-end="<?php echo esc_html(get_option('ptiwmm_countdown_date', '')) ?>"></p> 20 <div id="progress-container"> 21 <div id="progress-bar"></div> 22 </div> 23 <p>Work in progress</p> 24 <?php }?> 25 </div> 26 <?php wp_footer(); ?> 27 </body> 24 28 </html> -
website-maintenance-pti/trunk/templates/template3/index.php
r3264474 r3282279 28 28 <h1><?php echo esc_html(get_option('ptiwmm_headline', 'We\'re Coming Soon..!')) ?> </h1> 29 29 <p><?php echo esc_html(get_option('ptiwmm_message', 'We are currently updating our website. Please check back later.')) ?></p> 30 <p id="countdown"></p> 30 <p id="countdown" data-start="<?php echo esc_attr(current_time('Y-m-d\TH:i:s')); ?>" data-end="<?php echo esc_html(get_option('ptiwmm_countdown_date', '')) ?>"></p> 31 <div id="progress-container"> 32 <div id="progress-bar"></div> 33 </div> 34 <p>Work progress</p> 31 35 <div class="footer_copyright"> <?php echo esc_html(get_option('ptiwmm_footer_copyright', '© 2025 Your Brand design')); ?> 32 36 by <b><?php echo esc_html(get_bloginfo('name')); ?></b></div> -
website-maintenance-pti/trunk/website-maintenance-pti.php
r3264474 r3282279 4 4 * Plugin URI: https://github.com/ptiwebtech/website-maintenance-pti 5 5 * Description: A website Maintenance - PTI plugin with advanced features, including a coming soon countdown. 6 * Version: 1.0. 16 * Version: 1.0.2 7 7 * Author: ptiwebtech2025 8 8 * Author URI: https://www.ptiwebtech.com/ … … 44 44 45 45 // Ensure the bypass key is generated if not already set 46 if (!get_option('ptiwmm_bypass_key')) {47 update_option('ptiwmm_bypass_key', wp_generate_password(12, false));48 }46 if (!get_option('ptiwmm_bypass_key')) { 47 update_option('ptiwmm_bypass_key', wp_generate_password(12, false)); 48 } 49 49 } 50 50 … … 57 57 58 58 function ptiwmm_enqueue_admin_scripts($hook) { 59 if ('settings_page_ptiwmm_settings' !== $hook) {60 return;61 }62 63 wp_enqueue_media();64 wp_enqueue_script('wp-color-picker');65 wp_enqueue_style('wp-color-picker');59 if ('settings_page_ptiwmm_settings' !== $hook) { 60 return; 61 } 62 63 wp_enqueue_media(); 64 wp_enqueue_script('wp-color-picker'); 65 wp_enqueue_style('wp-color-picker'); 66 66 67 67 // Register and enqueue styles 68 $css_version = filemtime(plugin_dir_path(__FILE__) . 'assets/css/website-maintenance-mode-style.css');69 wp_register_style('website-maintenance-mode-css', plugin_dir_url(__FILE__) . 'assets/css/website-maintenance-mode-style.css', array(), $css_version, 'all');70 wp_enqueue_style('website-maintenance-mode-css');68 $css_version = filemtime(plugin_dir_path(__FILE__) . 'assets/css/website-maintenance-mode-style.css'); 69 wp_register_style('website-maintenance-mode-css', plugin_dir_url(__FILE__) . 'assets/css/website-maintenance-mode-style.css', array(), $css_version, 'all'); 70 wp_enqueue_style('website-maintenance-mode-css'); 71 71 72 72 // Register and enqueue script 73 $js_version = filemtime(plugin_dir_path(__FILE__) . 'assets/js/website-maintenance-mode-script.js');74 wp_register_script('ptiwmm-website-maintenance-mode-js', plugin_dir_url(__FILE__) . 'assets/js/website-maintenance-mode-script.js', array('jquery', 'wp-color-picker'), $js_version, true);75 wp_enqueue_script('ptiwmm-website-maintenance-mode-js');73 $js_version = filemtime(plugin_dir_path(__FILE__) . 'assets/js/website-maintenance-mode-script.js'); 74 wp_register_script('ptiwmm-website-maintenance-mode-js', plugin_dir_url(__FILE__) . 'assets/js/website-maintenance-mode-script.js', array('jquery', 'wp-color-picker'), $js_version, true); 75 wp_enqueue_script('ptiwmm-website-maintenance-mode-js'); 76 76 } 77 77 add_action('admin_enqueue_scripts', 'ptiwmm_enqueue_admin_scripts'); … … 80 80 function ptiwmm_enqueue_wp_scripts() 81 81 { 82 $template_style_css_version = filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'); 83 wp_enqueue_style('website-maintenance-mode-css', plugin_dir_url(__FILE__) . 'assets/css/template-style.css', array(), $template_style_css_version, 'all'); 84 85 $font_awesome_css_version = filemtime(plugin_dir_path(__FILE__) . 'assets/css/font-awesome.css'); 86 wp_enqueue_style('website-maintenance-pti-css', plugin_dir_url(__FILE__) . 'assets/css/font-awesome.css', array(), $font_awesome_css_version, 'all'); 82 $template_style_css_version = filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'); 83 wp_enqueue_style('website-maintenance-mode-css', plugin_dir_url(__FILE__) . 'assets/css/template-style.css', array(), $template_style_css_version, 'all'); 84 85 $font_awesome_css_version = filemtime(plugin_dir_path(__FILE__) . 'assets/css/font-awesome.css'); 86 wp_enqueue_style('website-maintenance-pti-css', plugin_dir_url(__FILE__) . 'assets/css/font-awesome.css', array(), $font_awesome_css_version, 'all'); 87 88 $script_version = filemtime(plugin_dir_path(__FILE__) . 'assets/js/website-maintenance-pti-fornt-script.js'); 89 wp_enqueue_script('website-maintenance-pti-script', plugin_dir_url(__FILE__) . 'assets/js/website-maintenance-fornt-script.js', array('jquery'), $script_version, true); 90 87 91 } 88 92 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_wp_scripts'); … … 93 97 function ptiwmm_add_script_attributes($tag, $handle, $src) { 94 98 // Ensure script is enqueued before modifying 95 if ('ptiwmm-website-maintenance-mode-js' === $handle) {96 return str_replace(' src', ' defer src', $tag);97 }98 return $tag;99 if ('ptiwmm-website-maintenance-mode-js' === $handle) { 100 return str_replace(' src', ' defer src', $tag); 101 } 102 return $tag; 99 103 } 100 104 add_filter('script_loader_tag', 'ptiwmm_add_script_attributes', 10, 3); … … 146 150 <select name="ptiwmm_mode" id="ptiwmm_mode"> 147 151 <option value="entire" <?php selected(get_option('ptiwmm_mode', 'entire'), 'entire'); ?>>Entire 148 Website</option>152 Website</option> 149 153 <option value="specific" <?php selected(get_option('ptiwmm_mode', 'entire'), 'specific'); ?>> 150 Specific Pages</option>154 Specific Pages</option> 151 155 </select> 152 156 </td> … … 172 176 <th scope="row">Title</th> 173 177 <td><input type="text" name="ptiwmm_title" 174 value="<?php echo esc_attr(get_option('ptiwmm_title', 'Maintenance Mode')); ?>" /></td>175 </tr>176 <tr valign="top">177 <th scope="row">Headline</th>178 <td><input type="text" name="ptiwmm_headline"178 value="<?php echo esc_attr(get_option('ptiwmm_title', 'Maintenance Mode')); ?>" /></td> 179 </tr> 180 <tr valign="top"> 181 <th scope="row">Headline</th> 182 <td><input type="text" name="ptiwmm_headline" 179 183 value="<?php echo esc_attr(get_option('ptiwmm_headline', 'We will be back soon!')); ?>" /></td> 180 </tr> 181 <tr valign="top"> 182 <th scope="row">Maintenance Message</th> 183 <td> 184 <textarea name="ptiwmm_message" rows="5" 185 cols="50"><?php echo esc_textarea(get_option('ptiwmm_message', 'We are currently updating our website. Please check back later.')); ?></textarea> 186 </td> 187 </tr> 188 <tr valign="top"> 189 <th scope="row"> Footer Copyright </th> 190 <td> 191 <input type="text" name="ptiwmm_footer_copyright" value="<?php echo esc_attr(get_option('ptiwmm_footer_copyright', '© 2025 Your Brand design')); ?>" /> 192 </td> 193 </tr> 194 <tr valign="top"> 195 <th scope="row">Background Color</th> 196 <td><input type="text" name="ptiwmm_background_color" 197 value="<?php echo esc_attr(get_option('ptiwmm_background_color', '#ffffff')); ?>" 198 class="ptiwmm-color-picker" /></td> 199 </tr> 200 <tr valign="top"> 201 <th scope="row">Text Color</th> 202 <td><input type="text" name="ptiwmm_text_color" 203 value="<?php echo esc_attr(get_option('ptiwmm_text_color', '#000000')); ?>" 204 class="ptiwmm-color-picker" /></td> 205 </tr> 206 <tr valign="top"> 207 <th scope="row">Countdown Date</th> 208 <td><input type="datetime-local" name="ptiwmm_countdown_date" 209 value="<?php echo esc_attr(get_option('ptiwmm_countdown_date', '')); ?>" /></td> 210 </tr> 211 <tr valign="top"> 212 <th scope="row">Maintenance Banner Image</th> 213 <td> 214 <input type="hidden" name="ptiwmm_banner_image" id="ptiwmm_banner_image" 215 value="<?php echo esc_attr(get_option('ptiwmm_banner_image', '')); ?>" /> 216 <button type="button" class="button ptiwmm-upload-button">Select Image</button> 217 <?php 218 $ptiwmm_banner_id = attachment_url_to_postid(get_option('ptiwmm_banner_image', '')); 219 if ($ptiwmm_banner_id) { 220 echo "<div class='image-container'>"; 221 echo wp_get_attachment_image($ptiwmm_banner_id, 'medium', false, array('id' => 'ptiwmm_banner_preview', 'style' => 'max-width: 300px; display: block; margin-top: 10px;')); 222 echo '<button type="submit" class="ptiwmm-remove-button"> 223 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"> 224 <path d="M18 6L6 18M6 6l12 12" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> 225 </svg> 226 </button>'; 227 228 echo "</div>"; 184 </tr> 185 <tr valign="top"> 186 <th scope="row">Maintenance Message</th> 187 <td> 188 <textarea name="ptiwmm_message" rows="5" 189 cols="50"><?php echo esc_textarea(get_option('ptiwmm_message', 'We are currently updating our website. Please check back later.')); ?></textarea> 190 </td> 191 </tr> 192 <tr valign="top"> 193 <th scope="row"> Footer Copyright </th> 194 <td> 195 <input type="text" name="ptiwmm_footer_copyright" value="<?php echo esc_attr(get_option('ptiwmm_footer_copyright', '© 2025 Your Brand design')); ?>" /> 196 </td> 197 </tr> 198 <tr valign="top"> 199 <th scope="row">Background Color</th> 200 <td><input type="text" name="ptiwmm_background_color" 201 value="<?php echo esc_attr(get_option('ptiwmm_background_color', '#ffffff')); ?>" 202 class="ptiwmm-color-picker" /></td> 203 </tr> 204 <tr valign="top"> 205 <th scope="row">Text Color</th> 206 <td><input type="text" name="ptiwmm_text_color" 207 value="<?php echo esc_attr(get_option('ptiwmm_text_color', '#000000')); ?>" 208 class="ptiwmm-color-picker" /></td> 209 </tr> 210 <tr valign="top"> 211 <th scope="row">Countdown Date</th> 212 <td><input type="datetime-local" name="ptiwmm_countdown_date" 213 value="<?php echo esc_attr(get_option('ptiwmm_countdown_date', '')); ?>" /></td> 214 </tr> 215 <tr valign="top"> 216 <th scope="row">Maintenance Banner Image</th> 217 <td> 218 <input type="hidden" name="ptiwmm_banner_image" id="ptiwmm_banner_image" 219 value="<?php echo esc_attr(get_option('ptiwmm_banner_image', '')); ?>" /> 220 <button type="button" class="button ptiwmm-upload-button">Select Image</button> 221 <?php 222 $ptiwmm_banner_id = attachment_url_to_postid(get_option('ptiwmm_banner_image', '')); 223 if ($ptiwmm_banner_id) { 224 echo "<div class='image-container'>"; 225 echo wp_get_attachment_image($ptiwmm_banner_id, 'medium', false, array('id' => 'ptiwmm_banner_preview', 'style' => 'max-width: 300px; display: block; margin-top: 10px;')); 226 echo '<button type="submit" class="ptiwmm-remove-button"> 227 <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"> 228 <path d="M18 6L6 18M6 6l12 12" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> 229 </svg> 230 </button>'; 231 232 echo "</div>"; 233 } 234 235 ?> 236 </td> 237 </tr> 238 </table> 239 <?php submit_button(); ?> 240 </form> 241 </div> 242 <?php 243 function ptiwmm_upload_images_and_get_attachment_ids() { 244 $upload_dir = wp_upload_dir(); 245 $image_files = [ 246 'default-.jpg', 247 'template-1.jpg', 248 'template-2.jpg', 249 'template-3.jpg' 250 ]; 251 252 // Store previously uploaded images to avoid repeated lookups 253 $stored_attachment_ids = get_option('ptiwmm_uploaded_images', []); 254 255 $attachment_ids = []; 256 257 foreach ($image_files as $image_file) { 258 // If ID is already stored, reuse it 259 if (!empty($stored_attachment_ids[$image_file])) { 260 $attachment_ids[$image_file] = $stored_attachment_ids[$image_file]; 261 continue; 262 } 263 264 $plugin_image_path = plugin_dir_path(__FILE__) . 'images/' . $image_file; 265 $file_name = basename($plugin_image_path); 266 267 // Check if the file exists in the plugin directory 268 if (!file_exists($plugin_image_path)) { 269 continue; 270 } 271 272 // Move image to the uploads directory if not already moved 273 $new_file_path = $upload_dir['path'] . '/' . $file_name; 274 $new_file_url = $upload_dir['url'] . '/' . $file_name; 275 276 if (!file_exists($new_file_path)) { 277 copy($plugin_image_path, $new_file_path); 278 } 279 280 // Check if image is already an attachment 281 $attachment_id = attachment_url_to_postid($new_file_url); 282 if ($attachment_id) { 283 $attachment_ids[$image_file] = $attachment_id; 284 continue; 285 } 286 287 // Get file type 288 $file_type = wp_check_filetype($file_name); 289 $attachment = [ 290 'post_mime_type' => $file_type['type'], 291 'post_title' => sanitize_file_name($file_name), 292 'post_content' => '', 293 'post_status' => 'inherit' 294 ]; 295 296 // Insert attachment 297 $attach_id = wp_insert_attachment($attachment, $new_file_path); 298 require_once ABSPATH . 'wp-admin/includes/image.php'; 299 $attach_data = wp_generate_attachment_metadata($attach_id, $new_file_path); 300 wp_update_attachment_metadata($attach_id, $attach_data); 301 302 // Store new attachment ID 303 $attachment_ids[$image_file] = $attach_id; 304 $stored_attachment_ids[$image_file] = $attach_id; 305 } 306 307 // Save updated attachment IDs to avoid future queries 308 update_option('ptiwmm_uploaded_images', $stored_attachment_ids); 309 310 return $attachment_ids; 229 311 } 230 312 313 // Run function to get attachment IDs 314 $attachment_ids = ptiwmm_upload_images_and_get_attachment_ids(); 315 316 // Define templates with attachment IDs 317 $templates = [ 318 ['id' => 'template1', 'label' => 'Template 1', 'attachment_id' => $attachment_ids['default-.jpg'] ?? ''], 319 ['id' => 'template2', 'label' => 'Template 2', 'attachment_id' => $attachment_ids['template-1.jpg'] ?? ''], 320 ['id' => 'template3', 'label' => 'Template 3', 'attachment_id' => $attachment_ids['template-2.jpg'] ?? ''], 321 ['id' => 'template4', 'label' => 'Template 4', 'attachment_id' => $attachment_ids['template-3.jpg'] ?? ''] 322 ]; 323 324 // Get selected template option 325 $ptiwmm_selected_template = get_option('ptiwmm_selected_template', 'template1'); 231 326 ?> 232 </td> 233 </tr> 234 </table> 235 <?php submit_button(); ?> 236 </form> 237 </div> 238 <?php 239 function ptiwmm_upload_images_and_get_attachment_ids() { 240 $upload_dir = wp_upload_dir(); 241 $image_files = [ 242 'default-.jpg', 243 'template-1.jpg', 244 'template-2.jpg', 245 'template-3.jpg' 246 ]; 247 248 // Store previously uploaded images to avoid repeated lookups 249 $stored_attachment_ids = get_option('ptiwmm_uploaded_images', []); 250 251 $attachment_ids = []; 252 253 foreach ($image_files as $image_file) { 254 // If ID is already stored, reuse it 255 if (!empty($stored_attachment_ids[$image_file])) { 256 $attachment_ids[$image_file] = $stored_attachment_ids[$image_file]; 257 continue; 258 } 259 260 $plugin_image_path = plugin_dir_path(__FILE__) . 'images/' . $image_file; 261 $file_name = basename($plugin_image_path); 262 263 // Check if the file exists in the plugin directory 264 if (!file_exists($plugin_image_path)) { 265 continue; 266 } 267 268 // Move image to the uploads directory if not already moved 269 $new_file_path = $upload_dir['path'] . '/' . $file_name; 270 $new_file_url = $upload_dir['url'] . '/' . $file_name; 271 272 if (!file_exists($new_file_path)) { 273 copy($plugin_image_path, $new_file_path); 274 } 275 276 // Check if image is already an attachment 277 $attachment_id = attachment_url_to_postid($new_file_url); 278 if ($attachment_id) { 279 $attachment_ids[$image_file] = $attachment_id; 280 continue; 281 } 282 283 // Get file type 284 $file_type = wp_check_filetype($file_name); 285 $attachment = [ 286 'post_mime_type' => $file_type['type'], 287 'post_title' => sanitize_file_name($file_name), 288 'post_content' => '', 289 'post_status' => 'inherit' 290 ]; 291 292 // Insert attachment 293 $attach_id = wp_insert_attachment($attachment, $new_file_path); 294 require_once ABSPATH . 'wp-admin/includes/image.php'; 295 $attach_data = wp_generate_attachment_metadata($attach_id, $new_file_path); 296 wp_update_attachment_metadata($attach_id, $attach_data); 297 298 // Store new attachment ID 299 $attachment_ids[$image_file] = $attach_id; 300 $stored_attachment_ids[$image_file] = $attach_id; 301 } 302 303 // Save updated attachment IDs to avoid future queries 304 update_option('ptiwmm_uploaded_images', $stored_attachment_ids); 305 306 return $attachment_ids; 307 } 308 309 // Run function to get attachment IDs 310 $attachment_ids = ptiwmm_upload_images_and_get_attachment_ids(); 311 312 // Define templates with attachment IDs 313 $templates = [ 314 ['id' => 'template1', 'label' => 'Template 1', 'attachment_id' => $attachment_ids['default-.jpg'] ?? ''], 315 ['id' => 'template2', 'label' => 'Template 2', 'attachment_id' => $attachment_ids['template-1.jpg'] ?? ''], 316 ['id' => 'template3', 'label' => 'Template 3', 'attachment_id' => $attachment_ids['template-2.jpg'] ?? ''], 317 ['id' => 'template4', 'label' => 'Template 4', 'attachment_id' => $attachment_ids['template-3.jpg'] ?? ''] 318 ]; 319 320 // Get selected template option 321 $ptiwmm_selected_template = get_option('ptiwmm_selected_template', 'template1'); 322 ?> 323 <div class="ptiwmm-admin-container wrap"> 324 <h2>Template Settings</h2> 325 <hr> 326 <form method="post" action="options.php"> 327 <?php settings_fields('template_options_group'); ?> 328 <div class="template-selection"> 329 <?php foreach ($templates as $template) : ?> 330 <label class="template-option <?php echo ($ptiwmm_selected_template === $template['id']) ? 'selected' : ''; ?>" for="<?php echo esc_attr($template['id']); ?>"> 331 <input type="radio" id="<?php echo esc_attr($template['id']); ?>" name="ptiwmm_selected_template" value="<?php echo esc_attr($template['id']); ?>" <?php checked($ptiwmm_selected_template, $template['id']); ?> hidden> 327 <div class="ptiwmm-admin-container wrap"> 328 <h2>Template Settings</h2> 329 <hr> 330 <form method="post" action="options.php"> 331 <?php settings_fields('template_options_group'); ?> 332 <div class="template-selection"> 333 <?php foreach ($templates as $template) : ?> 334 <label class="template-option <?php echo ($ptiwmm_selected_template === $template['id']) ? 'selected' : ''; ?>" for="<?php echo esc_attr($template['id']); ?>"> 335 <input type="radio" id="<?php echo esc_attr($template['id']); ?>" name="ptiwmm_selected_template" value="<?php echo esc_attr($template['id']); ?>" <?php checked($ptiwmm_selected_template, $template['id']); ?> hidden> 336 <?php 337 if (!empty($template['attachment_id'])) { 338 echo wp_get_attachment_image($template['attachment_id'], 'medium', false, ['alt' => esc_attr($template['label'])]); 339 } 340 ?> 341 </label> 342 <?php endforeach; ?> 343 </div> 344 <p><input type="submit" value="Save Selection" class="button button-primary"></p> 345 </form> 346 </div> 347 348 332 349 <?php 333 if (!empty($template['attachment_id'])) { 334 echo wp_get_attachment_image($template['attachment_id'], 'medium', false, ['alt' => esc_attr($template['label'])]); 350 } 351 function ptiwmm_maintenance_mode() 352 { 353 if (!current_user_can('manage_options')) { 354 335 355 } 336 ?> 337 </label> 338 <?php endforeach; ?> 339 </div> 340 <p><input type="submit" value="Save Selection" class="button button-primary"></p> 341 </form> 342 </div> 343 344 345 <?php 346 } 347 function ptiwmm_maintenance_mode() 348 { 349 if (!current_user_can('manage_options')) { 350 351 } 352 if (!is_user_logged_in() && get_option('ptiwmm_enabled') == 1) { 353 $ptiwmm_enabled = get_option('ptiwmm_enabled', 0); 354 if ($ptiwmm_enabled != 1) { 355 return; 356 } 357 358 $mode = get_option('ptiwmm_mode', 'entire'); 359 $selected_pages = get_option('ptiwmm_selected_pages', []); 360 $current_page_title = get_the_title(); 361 $bypass_key = get_option('ptiwmm_bypass_key', ''); 362 363 /** PHPCS:disable WordPress.Security.NonceVerification.Recommended */ 364 if ( 365 isset($_REQUEST['bypass_maintenance_mode']) && 366 sanitize_text_field(wp_unslash($_REQUEST['bypass_maintenance_mode'])) == $bypass_key 367 ) { 368 setcookie('ptiwmm_bypass_cookie', $bypass_key, time() + 3600 * 24, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); 369 return; 370 } 371 /** PHPCS:enable */ 372 356 if (!is_user_logged_in() && get_option('ptiwmm_enabled') == 1) { 357 $ptiwmm_enabled = get_option('ptiwmm_enabled', 0); 358 if ($ptiwmm_enabled != 1) { 359 return; 360 } 361 362 $mode = get_option('ptiwmm_mode', 'entire'); 363 $selected_pages = get_option('ptiwmm_selected_pages', []); 364 $current_page_title = get_the_title(); 365 $bypass_key = get_option('ptiwmm_bypass_key', ''); 366 367 /** PHPCS:disable WordPress.Security.NonceVerification.Recommended */ 368 if ( 369 isset($_REQUEST['bypass_maintenance_mode']) && 370 sanitize_text_field(wp_unslash($_REQUEST['bypass_maintenance_mode'])) == $bypass_key 371 ) { 372 setcookie('ptiwmm_bypass_cookie', $bypass_key, time() + 3600 * 24, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); 373 return; 374 } 375 /** PHPCS:enable */ 376 373 377 // Check cookie for bypass 374 if (isset($_COOKIE['ptiwmm_bypass_cookie']) && $_COOKIE['ptiwmm_bypass_cookie'] === $bypass_key) { 375 return; 376 } 377 378 if ($mode === 'entire' || ($mode === 'specific' && in_array($current_page_title, (array) $selected_pages)) ) { 379 status_header(503); 380 function ptiwmm_enqueue_scripts() { 381 382 $inline_js = 'var countdownDateStr = "'. esc_js(get_option('ptiwmm_countdown_date')).'"; 383 var countdownDate = new Date(countdownDateStr).getTime(); 384 385 var x = setInterval(function() { 386 var now = new Date().getTime(); 387 var distance = countdownDate - now; 388 var days = Math.floor(distance / (1000 * 60 * 60 * 24)); 389 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 390 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 391 var seconds = Math.floor((distance % (1000 * 60)) / 1000); 392 document.getElementById("countdown").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s "; 393 if (distance < 0) { 394 clearInterval(x); 395 document.getElementById("countdown").innerHTML = "EXPIRED"; 396 } 397 }, 1000);'; 398 wp_add_inline_script('ptiwmm-inline-script', $inline_js); 399 } 400 401 if (get_option('ptiwmm_countdown_date')) { 402 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_scripts'); 403 } 404 405 378 if (isset($_COOKIE['ptiwmm_bypass_cookie']) && $_COOKIE['ptiwmm_bypass_cookie'] === $bypass_key) { 379 return; 380 } 381 382 if ($mode === 'entire' || ($mode === 'specific' && in_array($current_page_title, (array) $selected_pages)) ) { 383 status_header(503); 384 406 385 $template = get_option('ptiwmm_selected_template', 'template1'); // Get selected template 407 if ($template == 'template2') { 408 function ptiwmm_enqueue_styles() { 409 wp_enqueue_style( 410 'ptiwmm-inline-style', 411 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 412 array(), 413 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 414 'all' 415 ); 416 $banner_image = get_option('ptiwmm_banner_image', ''); 417 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 418 419 $inline_css = " .default_templates2 { 420 background: ". esc_attr(get_option('ptiwmm_background_color', '#ffffff')) . "no-repeat fixed; 421 background-size: cover; 422 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000')) ."; 423 {$background} 424 font-size: 20px; 425 font-family: Helvetica, sans-serif; 426 position: relative; 427 height: 100vh; 428 display: flex; 429 flex-direction: column; 430 justify-content: center; 431 align-items: center; 432 }"; 433 wp_add_inline_style('ptiwmm-inline-style', $inline_css); 434 } 435 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); 436 437 include plugin_dir_path(__FILE__) . 'templates/template2/index.php'; 438 } elseif ($template == 'template3') { 439 function ptiwmm_enqueue_styles() { 440 wp_enqueue_style( 441 'ptiwmm-inline-style', 442 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 443 array(), 444 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 445 'all' 446 ); 447 $banner_image = get_option('ptiwmm_banner_image', ''); 448 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 449 450 $inline_css = "body .default { 451 text-align: center; 452 font: 20px Helvetica, sans-serif;{$background} 453 } 454 .default { 455 background: no-repeat fixed ".esc_attr(get_option('ptiwmm_background_color', '#ffffff'))."; 456 background-size: cover; 457 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 458 font-size: 20px; 459 font-family: Helvetica, sans-serif; 460 position: relative; 461 height: 100vh; 462 display: flex; 463 ".$background." 464 flex-direction: column; 465 justify-content: center; 466 } 467 .default h1 { 468 margin-top: 0px; 469 margin-bottom: 0px; 470 z-index: 1; 471 } 472 .default p { 473 margin-bottom: 0px; 474 z-index: 1; 475 } 476 .default:before { 477 content: ''; 478 background: rgba(0,0,0,0.5); 479 width: 100%; 480 height: 100%; 481 position: absolute; 482 top: 0px; 483 left: 0px; 484 right: 0px; 485 bottom: 0px; 486 } 487 img { 488 max-width: 80%; 489 }"; 490 wp_add_inline_style('ptiwmm-inline-style', $inline_css); 491 } 492 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); 493 include plugin_dir_path(__FILE__) . 'templates/template3/index.php'; 494 } elseif ($template == 'template4') { 495 function ptiwmm_enqueue_styles() { 496 wp_enqueue_style( 497 'ptiwmm-inline-style', 498 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 499 array(), 500 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 501 'all' 502 ); 503 $banner_image = get_option('ptiwmm_banner_image', ''); 504 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 505 506 $inline_css = ".default_templates3 {{$background}} 507 .inner_pages_sec {max-width: 1200px;position: relative;width: 1200px;height: 100%;} 508 .footer_icon {position: absolute;bottom: 30px;z-index: 1;} 509 .footer_icon h6 {margin: 0px 0px 15px;} 510 .footer_icon ul {list-style: none;padding: 0px;margin: 0px;display: flex;gap: 10px;} 511 .footer_icon ul li a {font-size: 16px; 512 color: #000;width: 35px;height: 35px;display: flex;background: #fff;border-radius: 50%;text-decoration: none;align-items: center;justify-content: center;} 513 .main_header {z-index: 1;display: flex;justify-content: space-between;align-items: center;position: absolute;top: 15px;left: 0px;right: 0px;} 514 .header_right ul {list-style: none;padding: 0px;margin: 0px;display: flex;gap: 10px;} 515 .header_right ul li {margin-left: 20px;position: relative;} 516 .header_right ul li:before {content: '' ;background: #fff;width: 1px;height: 20px;position: absolute;top: 6px;right: -15px;} 517 .header_right ul li:last-child:before {display: none;} 518 .header_right ul li a { 519 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; text-decoration: none;} 520 .main_header img.custom-logo {width: 200px;height: 100px;object-fit: contain;} 521 .main_header .site-logo {margin: 0px;z-index: 1;} 522 .middle_part {position: absolute;z-index: 1;top: 50%;transform: translateY(-50%);} 523 .default { 524 background: no-repeat fixed ". esc_attr(get_option('ptiwmm_background_color', '#ffffff'))."; 525 background-size: cover; 526 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 527 {$background} 528 position: relative;height: 100vh;display: flex;flex-direction: column;justify-content: center;align-items: center;} 529 .default h1 {margin-top: 0px;margin-bottom: 0px;z-index: 1;} 530 .default p {margin-bottom: 0px;z-index: 1;} 531 .default:before {content: '';background: rgba(0,0,0,0.5);width: 100%;height: 100%;position: absolute;top: 0px;left: 0px;right: 0px;bottom: 0px;}"; 532 533 wp_add_inline_style('ptiwmm-inline-style', $inline_css); 534 } 535 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); include plugin_dir_path(__FILE__) . 'templates/template4/index.php'; 536 } else { 537 function ptiwmm_enqueue_styles() { 386 if ($template == 'template2') { 387 function ptiwmm_enqueue_styles() { 388 wp_enqueue_style( 389 'ptiwmm-inline-style', 390 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 391 array(), 392 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 393 'all' 394 ); 395 $banner_image = get_option('ptiwmm_banner_image', ''); 396 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 397 398 $inline_css = " .default_templates2 { 399 background: ". esc_attr(get_option('ptiwmm_background_color', '#ffffff')) . "no-repeat fixed; 400 background-size: cover; 401 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000')) ."; 402 {$background} 403 font-size: 20px; 404 font-family: Helvetica, sans-serif; 405 position: relative; 406 height: 100vh; 407 display: flex; 408 flex-direction: column; 409 justify-content: center; 410 align-items: center; 411 } 412 .default h1 { 413 margin-top: 0px; 414 margin-bottom: 0px; 415 z-index: 1; 416 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 417 } 418 "; 419 wp_add_inline_style('ptiwmm-inline-style', $inline_css); 420 } 421 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); 422 423 include plugin_dir_path(__FILE__) . 'templates/template2/index.php'; 424 } elseif ($template == 'template3') { 425 function ptiwmm_enqueue_styles() { 426 wp_enqueue_style( 427 'ptiwmm-inline-style', 428 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 429 array(), 430 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 431 'all' 432 ); 433 $banner_image = get_option('ptiwmm_banner_image', ''); 434 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 435 436 $inline_css = "body .default { 437 text-align: center; 438 font: 20px Helvetica, sans-serif;{$background} 439 } 440 .default { 441 background: no-repeat fixed ".esc_attr(get_option('ptiwmm_background_color', '#ffffff'))."; 442 background-size: cover; 443 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 444 font-size: 20px; 445 font-family: Helvetica, sans-serif; 446 position: relative; 447 height: 100vh; 448 display: flex; 449 ".$background." 450 flex-direction: column; 451 justify-content: center; 452 } 453 .default h1 { 454 margin-top: 0px; 455 margin-bottom: 0px; 456 z-index: 1; 457 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 458 } 459 .default p { 460 margin-bottom: 0px; 461 z-index: 1; 462 } 463 .default:before { 464 content: ''; 465 background: rgba(0,0,0,0.5); 466 width: 100%; 467 height: 100%; 468 position: absolute; 469 top: 0px; 470 left: 0px; 471 right: 0px; 472 bottom: 0px; 473 } 474 img { 475 max-width: 80%; 476 }"; 477 wp_add_inline_style('ptiwmm-inline-style', $inline_css); 478 } 479 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); 480 include plugin_dir_path(__FILE__) . 'templates/template3/index.php'; 481 } elseif ($template == 'template4') { 482 function ptiwmm_enqueue_styles() { 483 wp_enqueue_style( 484 'ptiwmm-inline-style', 485 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 486 array(), 487 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 488 'all' 489 ); 490 $banner_image = get_option('ptiwmm_banner_image', ''); 491 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 492 493 $inline_css = ".default_templates3 {{$background}} 494 .inner_pages_sec {max-width: 1200px;position: relative;width: 1200px;height: 100%;} 495 .footer_icon {position: absolute;bottom: 30px;z-index: 1;} 496 .footer_icon h6 {margin: 0px 0px 15px;} 497 .footer_icon ul {list-style: none;padding: 0px;margin: 0px;display: flex;gap: 10px;} 498 .footer_icon ul li a {font-size: 16px; 499 color: #000;width: 35px;height: 35px;display: flex;background: #fff;border-radius: 50%;text-decoration: none;align-items: center;justify-content: center;} 500 .main_header {z-index: 1;display: flex;justify-content: space-between;align-items: center;position: absolute;top: 15px;left: 0px;right: 0px;} 501 .header_right ul {list-style: none;padding: 0px;margin: 0px;display: flex;gap: 10px;} 502 .header_right ul li {margin-left: 20px;position: relative;} 503 .header_right ul li:before {content: '' ;background: #fff;width: 1px;height: 20px;position: absolute;top: 6px;right: -15px;} 504 .header_right ul li:last-child:before {display: none;} 505 .header_right ul li a { 506 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; text-decoration: none;} 507 .main_header img.custom-logo {width: 200px;height: 100px;object-fit: contain;} 508 .main_header .site-logo {margin: 0px;z-index: 1;} 509 .middle_part {position: absolute;z-index: 1;top: 50%;transform: translateY(-50%);} 510 .default { 511 background: no-repeat fixed ". esc_attr(get_option('ptiwmm_background_color', '#ffffff'))."; 512 background-size: cover; 513 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 514 {$background} 515 position: relative;height: 100vh;display: flex;flex-direction: column;justify-content: center;align-items: center;} 516 .default h1 {margin-top: 0px;margin-bottom: 0px;z-index: 1;} 517 .default p {margin-bottom: 0px;z-index: 1;} 518 .default:before {content: '';background: rgba(0,0,0,0.5);width: 100%;height: 100%;position: absolute;top: 0px;left: 0px;right: 0px;bottom: 0px;}"; 519 520 wp_add_inline_style('ptiwmm-inline-style', $inline_css); 521 } 522 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); include plugin_dir_path(__FILE__) . 'templates/template4/index.php'; 523 } else { 524 function ptiwmm_enqueue_styles() { 538 525 // Enqueue the main stylesheet 539 wp_enqueue_style(540 'ptiwmm-style',541 plugin_dir_url(__FILE__) . 'assets/css/template-style.css',542 array(),543 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'),544 'all'545 );546 526 wp_enqueue_style( 527 'ptiwmm-style', 528 plugin_dir_url(__FILE__) . 'assets/css/template-style.css', 529 array(), 530 filemtime(plugin_dir_path(__FILE__) . 'assets/css/template-style.css'), 531 'all' 532 ); 533 547 534 // Get options 548 $banner_image = get_option('ptiwmm_banner_image', '');549 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : '';550 535 $banner_image = get_option('ptiwmm_banner_image', ''); 536 $background = !empty($banner_image) ? 'background-image: url(' . esc_url($banner_image) . ');' : ''; 537 551 538 // Construct inline CSS using double quotes 552 $inline_css = " 553 body .default { 554 text-align: center; 555 font: 20px Helvetica, sans-serif; 556 {$background} 557 } 558 .default { 559 background: " . esc_attr(get_option('ptiwmm_background_color', '#ffffff')) . " no-repeat fixed; 560 background-size: cover; 561 color: " . esc_attr(get_option('ptiwmm_text_color', '#000000')) . "; 562 font-size: 20px; 563 font-family: Helvetica, sans-serif; 564 position: relative; 565 height: 100vh; 566 display: flex; 567 {$background} 568 flex-direction: column; 569 justify-content: center; 570 }"; 571 539 $inline_css = " 540 body .default { 541 text-align: center; 542 font: 20px Helvetica, sans-serif; 543 {$background} 544 } 545 .default { 546 background: " . esc_attr(get_option('ptiwmm_background_color', '#ffffff')) . " no-repeat fixed; 547 background-size: cover; 548 color: " . esc_attr(get_option('ptiwmm_text_color', '#000000')) . "; 549 font-size: 20px; 550 font-family: Helvetica, sans-serif; 551 position: relative; 552 height: 100vh; 553 display: flex; 554 {$background} 555 flex-direction: column; 556 justify-content: center; 557 } 558 .default h1 { 559 margin-top: 0px; 560 margin-bottom: 0px; 561 z-index: 1; 562 color: ". esc_attr(get_option('ptiwmm_text_color', '#000000'))."; 563 } 564 "; 565 572 566 // Add inline CSS to the enqueued style 573 wp_add_inline_style('ptiwmm-style', $inline_css);574 }575 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles');576 577 include plugin_dir_path(__FILE__) . 'templates/template1/index.php';578 }579 exit;580 }581 }582 }583 add_action('template_redirect', 'ptiwmm_maintenance_mode');584 567 wp_add_inline_style('ptiwmm-style', $inline_css); 568 } 569 add_action('wp_enqueue_scripts', 'ptiwmm_enqueue_styles'); 570 571 include plugin_dir_path(__FILE__) . 'templates/template1/index.php'; 572 } 573 exit; 574 } 575 } 576 } 577 add_action('template_redirect', 'ptiwmm_maintenance_mode'); 578
Note: See TracChangeset
for help on using the changeset viewer.