Changeset 3479687
- Timestamp:
- 03/11/2026 04:06:15 AM (3 weeks ago)
- Location:
- codequill-web-to-app/trunk
- Files:
-
- 3 added
- 3 edited
-
admin (added)
-
admin/admin.php (added)
-
assets/css/admin.css (added)
-
codequill-web-to-app.php (modified) (2 diffs)
-
function/function.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codequill-web-to-app/trunk/codequill-web-to-app.php
r3478841 r3479687 4 4 Plugin URI: https://wpcodequill.com/free-files/codequill-web-to-app/ 5 5 Description: Convert your WordPress site into a Progressive Web App (PWA). Add an Install App button and manage settings directly from the dashboard. 6 Version: 1.0. 46 Version: 1.0.5 7 7 Author: WPCodeQuill 8 8 Author URI: https://wpcodequill.com … … 21 21 22 22 // Include the functional logic from the function folder 23 require_once CODEQUILL_PWA_DIR . 'admin/admin.php'; 23 24 require_once CODEQUILL_PWA_DIR . 'function/function.php'; 24 25 25 26 // Initialize the plugin safely once all plugins have loaded 26 27 function codequill_pwa_initialize() { 27 new CodeQuill_Web_To_App_Managed(); 28 new CodeQuill_Web_To_App_Admin(); 29 new CodeQuill_Web_To_App_Function(); 28 30 } 29 31 add_action( 'plugins_loaded', 'codequill_pwa_initialize' ); -
codequill-web-to-app/trunk/function/function.php
r3478841 r3479687 2 2 if ( ! defined( 'ABSPATH' ) ) exit; 3 3 4 class CodeQuill_Web_To_App_ Managed{4 class CodeQuill_Web_To_App_Function { 5 5 6 6 public function __construct() { 7 // Admin Menu8 add_action('admin_menu', array($this, 'create_admin_menu'));9 add_action('admin_init', array($this, 'register_settings'));10 11 7 // Frontend PWA functionality 12 8 add_action('wp_head', array($this, 'add_manifest_link')); … … 18 14 } 19 15 20 // --- 1. ADMIN SETTINGS PAGE ---21 public function create_admin_menu() {22 add_menu_page(23 esc_html__('PWA Settings', 'codequill-web-to-app'),24 esc_html__('App Settings', 'codequill-web-to-app'),25 'manage_options',26 'codequill-pwa-settings',27 array($this, 'settings_page_html'),28 'dashicons-smartphone',29 10030 );31 }32 33 public function register_settings() {34 register_setting('codequill_pwa_settings_group', 'codequill_app_name', 'sanitize_text_field');35 register_setting('codequill_pwa_settings_group', 'codequill_short_name', 'sanitize_text_field');36 register_setting('codequill_pwa_settings_group', 'codequill_theme_color', 'sanitize_hex_color');37 register_setting('codequill_pwa_settings_group', 'codequill_bg_color', 'sanitize_hex_color');38 register_setting('codequill_pwa_settings_group', 'codequill_icon_192', 'esc_url_raw');39 register_setting('codequill_pwa_settings_group', 'codequill_icon_512', 'esc_url_raw');40 }41 42 public function settings_page_html() {43 if (!current_user_can('manage_options')) {44 return;45 }46 ?>47 <div class="wrap">48 <h1><?php echo esc_html__('Web to App (PWA) Settings', 'codequill-web-to-app'); ?></h1>49 <form method="post" action="options.php">50 <?php settings_fields('codequill_pwa_settings_group'); ?>51 <table class="form-table">52 <tr valign="top">53 <th scope="row"><?php echo esc_html__('App Name', 'codequill-web-to-app'); ?></th>54 <td><input type="text" name="codequill_app_name" value="<?php echo esc_attr(get_option('codequill_app_name', get_bloginfo('name'))); ?>" class="regular-text" /></td>55 </tr>56 <tr valign="top">57 <th scope="row"><?php echo esc_html__('Short Name', 'codequill-web-to-app'); ?></th>58 <td><input type="text" name="codequill_short_name" value="<?php echo esc_attr(get_option('codequill_short_name', 'MyApp')); ?>" class="regular-text" /></td>59 </tr>60 <tr valign="top">61 <th scope="row"><?php echo esc_html__('Theme Color', 'codequill-web-to-app'); ?></th>62 <td><input type="color" name="codequill_theme_color" value="<?php echo esc_attr(get_option('codequill_theme_color', '#0073aa')); ?>" /></td>63 </tr>64 <tr valign="top">65 <th scope="row"><?php echo esc_html__('Background Color', 'codequill-web-to-app'); ?></th>66 <td><input type="color" name="codequill_bg_color" value="<?php echo esc_attr(get_option('codequill_bg_color', '#ffffff')); ?>" /></td>67 </tr>68 <tr valign="top">69 <th scope="row"><?php echo esc_html__('Icon URL (192x192)', 'codequill-web-to-app'); ?></th>70 <td><input type="text" name="codequill_icon_192" value="<?php echo esc_attr(get_option('codequill_icon_192')); ?>" class="large-text" placeholder="https://..." /></td>71 </tr>72 <tr valign="top">73 <th scope="row"><?php echo esc_html__('Icon URL (512x512)', 'codequill-web-to-app'); ?></th>74 <td><input type="text" name="codequill_icon_512" value="<?php echo esc_attr(get_option('codequill_icon_512')); ?>" class="large-text" placeholder="https://..." /></td>75 </tr>76 </table>77 <?php submit_button(); ?>78 </form>79 </div>80 <?php81 }82 83 // --- 2. DYNAMIC MANIFEST & SERVICE WORKER GENERATOR ---84 16 public function serve_manifest() { 85 17 // 1. Serve Manifest … … 112 44 } 113 45 114 // 2. Serve Service Worker dynamically to fix scope issues46 // 2. Serve Service Worker dynamically 115 47 // phpcs:ignore WordPress.Security.NonceVerification.Recommended 116 48 if (isset($_GET['codequill_sw']) && $_GET['codequill_sw'] == '1') { … … 118 50 header('Service-Worker-Allowed: /'); 119 51 120 // ---> UPDATED: Look for sw.js in the new assets/js/ folder <---121 52 $sw_path = CODEQUILL_PWA_DIR . 'assets/js/sw.js'; 122 53 123 54 if (file_exists($sw_path)) { 124 // phpcs:ignore WordPress. Security.EscapeOutput.OutputNotEscaped55 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile, WordPress.Security.EscapeOutput.OutputNotEscaped 125 56 readfile($sw_path); 126 57 } … … 129 60 } 130 61 131 // --- 3. LINK MANIFEST IN HEADER ---132 62 public function add_manifest_link() { 133 63 $manifest_url = site_url('?codequill_manifest=1'); … … 136 66 } 137 67 138 // --- 4. INSTALL BUTTON HTML ---139 68 public function add_install_ui() { 140 69 ?> … … 145 74 } 146 75 147 // --- 5. ENQUEUE INLINE SCRIPTS ---148 76 public function enqueue_pwa_scripts() { 149 // Register a clean handle (no jQuery required) 150 wp_register_script('codequill-pwa-js', false); 151 wp_enqueue_script('codequill-pwa-js'); 77 wp_register_script('codequill-pwa-js', false, array(), '1.0.5', true); 152 78 153 79 $sw_url = esc_url(site_url('?codequill_sw=1')); 154 80 155 81 $js_code = " 156 if ('serviceWorker' in navigator) { 157 window.addEventListener('load', function() { 158 navigator.serviceWorker.register('" . $sw_url . "', { scope: '/' }) 159 .then(function(registration) { 160 console.log('PWA ServiceWorker registration successful with scope: ', registration.scope); 161 }).catch(function(err) { 162 console.log('PWA ServiceWorker registration failed: ', err); 163 }); 164 }); 165 } 166 167 let deferredPrompt; 168 window.addEventListener('beforeinstallprompt', (e) => { 169 e.preventDefault(); 170 deferredPrompt = e; 171 const installBtn = document.getElementById('codequill-pwa-install-btn'); 172 173 if(installBtn) { 174 installBtn.style.display = 'block'; 175 installBtn.addEventListener('click', (e) => { 176 installBtn.style.display = 'none'; 177 deferredPrompt.prompt(); 178 deferredPrompt.userChoice.then((choiceResult) => { 179 deferredPrompt = null; 82 (function() { 83 if ('serviceWorker' in navigator) { 84 window.addEventListener('load', function() { 85 navigator.serviceWorker.register('" . $sw_url . "', { scope: '/' }) 86 .then(function(registration) { 87 console.log('PWA ServiceWorker registration successful'); 88 }).catch(function(err) { 89 console.log('PWA ServiceWorker registration failed: ', err); 180 90 }); 181 91 }); 182 92 } 183 }); 93 94 let deferredPrompt; 95 window.addEventListener('beforeinstallprompt', (e) => { 96 e.preventDefault(); 97 deferredPrompt = e; 98 const installBtn = document.getElementById('codequill-pwa-install-btn'); 99 100 if(installBtn) { 101 installBtn.style.display = 'block'; 102 installBtn.addEventListener('click', (e) => { 103 installBtn.style.display = 'none'; 104 deferredPrompt.prompt(); 105 deferredPrompt.userChoice.then((choiceResult) => { 106 deferredPrompt = null; 107 }); 108 }); 109 } 110 }); 111 })(); 184 112 "; 185 113 -
codequill-web-to-app/trunk/readme.txt
r3478841 r3479687 4 4 Requires at least: 6.0 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 46 Stable tag: 1.0.5 7 7 Requires PHP: 8.0 8 8 License: GPLv2 or later … … 55 55 == Changelog == 56 56 57 = 1.0.5 = 58 * New: Completely redesigned the plugin settings dashboard with a premium, modern UI. 59 * New: Added a WPCodeQuill product showcase to discover more premium plugins and themes. 60 * Fix: Resolved a critical issue where the Service Worker was not properly caching pages for offline use. 61 * Fix: Corrected the dynamic manifest generation to ensure the "Install App" prompt triggers reliably. 62 * Tweak: Restructured plugin core files (separated admin and frontend code) for better performance and security. 63 * Tweak: Resolved WPCS strict coding standards warnings for script enqueuing. 64 65 = 1.0.4 = 66 * Resolved minor code standard warnings for WordPress Repository compliance. 67 * Fixed output escaping issues. 68 57 69 = 1.0.4 = 58 70 * Resolved minor code standard warnings for WordPress Repository compliance.
Note: See TracChangeset
for help on using the changeset viewer.