Changeset 3438430
- Timestamp:
- 01/13/2026 09:17:37 AM (2 months ago)
- Location:
- iflair-pwa-app
- Files:
-
- 32 added
- 5 edited
-
tags/1.1.5 (added)
-
tags/1.1.5/assets (added)
-
tags/1.1.5/assets/admin (added)
-
tags/1.1.5/assets/admin/css (added)
-
tags/1.1.5/assets/admin/css/jquery-ui.css (added)
-
tags/1.1.5/assets/admin/css/style.css (added)
-
tags/1.1.5/assets/admin/images (added)
-
tags/1.1.5/assets/admin/images/close.svg (added)
-
tags/1.1.5/assets/admin/images/default_pwa_img.png (added)
-
tags/1.1.5/assets/admin/images/tooltip_icon.png (added)
-
tags/1.1.5/assets/admin/js (added)
-
tags/1.1.5/assets/admin/js/custom.js (added)
-
tags/1.1.5/assets/frontend (added)
-
tags/1.1.5/assets/frontend/font-awesome.css (added)
-
tags/1.1.5/assets/frontend/style.css (added)
-
tags/1.1.5/assets/webfonts (added)
-
tags/1.1.5/assets/webfonts/fa-brands-400.ttf (added)
-
tags/1.1.5/assets/webfonts/fa-brands-400.woff2 (added)
-
tags/1.1.5/assets/webfonts/fa-regular-400.ttf (added)
-
tags/1.1.5/assets/webfonts/fa-regular-400.woff2 (added)
-
tags/1.1.5/assets/webfonts/fa-solid-900.ttf (added)
-
tags/1.1.5/assets/webfonts/fa-solid-900.woff2 (added)
-
tags/1.1.5/assets/webfonts/fa-v4compatibility.ttf (added)
-
tags/1.1.5/assets/webfonts/fa-v4compatibility.woff2 (added)
-
tags/1.1.5/iflair-pwa-app.php (added)
-
tags/1.1.5/includes (added)
-
tags/1.1.5/includes/admin (added)
-
tags/1.1.5/includes/admin/advanced.php (added)
-
tags/1.1.5/includes/admin/caching-strategies.php (added)
-
tags/1.1.5/includes/admin/settings_fields.php (added)
-
tags/1.1.5/includes/frontend (added)
-
tags/1.1.5/readme.txt (added)
-
trunk/iflair-pwa-app.php (modified) (14 diffs)
-
trunk/includes/admin/advanced.php (modified) (1 diff)
-
trunk/includes/admin/caching-strategies.php (modified) (1 diff)
-
trunk/includes/admin/settings_fields.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
iflair-pwa-app/trunk/iflair-pwa-app.php
r3433592 r3438430 4 4 Description: SiteEase Progressive Web App plugin transforms your website into a Progressive Web App (PWA), enhancing user experience with app-like features such as faster load times, offline accessibility, and the convenience of adding the site to a smartphone's home screen. It also offers customizable backend settings, allowing for modifications to the app's color, name, and more, ensuring a personalized and seamless integration. 5 5 Plugin URI: https://profiles.wordpress.org/iflairwebtechnologies 6 Version: 1.1. 46 Version: 1.1.5 7 7 Author: iFlair Web Technologies Pvt. Ltd. 8 8 Author URI: https://www.iflair.com/ … … 14 14 if ( ! defined( 'ABSPATH' ) ) { die(); } 15 15 // define plugin version 16 define( 'IFPWAP_VERSION' , '1.1. 4' );16 define( 'IFPWAP_VERSION' , '1.1.5' ); 17 17 define( 'IFPWAP_FILE', __FILE__ ); 18 18 define( 'IFPWAP_DIR', dirname(__FILE__)); 19 define( 'IFPWAP_DIR_PATH', plugin_dir_url( __FILE__ ) ); 19 20 define( 'IFPWAP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 21 define( 'IFPWAP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 20 22 21 23 $ifpwap_version = IFPWAP_VERSION; … … 79 81 return $links; 80 82 } 81 // Enqueue admin JS 82 add_action( 'admin_enqueue_scripts', 'ifpwap_include_js' ); 83 function ifpwap_include_js() { 84 wp_enqueue_script('jquery'); 85 // WordPress media uploader scripts 86 if ( ! did_action( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } 87 wp_enqueue_script('ifpwap-custom-js',plugin_dir_url( __FILE__ ). 'assets/admin/js/custom.js',array( 'wp-color-picker' ), false, true); 88 } 89 // Enqueue admin CSS 90 add_action( 'admin_enqueue_scripts', 'ifpwap_enqueue_color_picker' ); 91 function ifpwap_enqueue_color_picker( $hook_suffix ) { 92 wp_enqueue_style( 'wp-color-picker' ); 93 wp_enqueue_style( 'dashicons' ); 94 wp_enqueue_style( 'ifpwap-style', plugins_url( '/assets/admin/css/style.css', __FILE__ ), '', IFPWAP_VERSION ); 95 } 83 84 // Enqueue admin script 85 function ifpwap_enqueue_admin_assets( $hook_suffix ) { 86 // Load assets only on plugin admin pages (recommended) 87 if ( strpos( $hook_suffix, 'ifpwap' ) === false ) { 88 return; 89 } 90 // Media uploader (safe to call directly) 91 wp_enqueue_media(); 92 // Admin CSS 93 wp_enqueue_style( 94 'ifpwap-admin-style', 95 IFPWAP_PLUGIN_URL . 'assets/admin/css/style.css', 96 array( 'wp-color-picker', 'dashicons' ), 97 IFPWAP_VERSION 98 ); 99 // Admin JS 100 wp_enqueue_script( 101 'ifpwap-admin-js', 102 IFPWAP_PLUGIN_URL . 'assets/admin/js/custom.js', 103 array( 'jquery', 'wp-color-picker' ), 104 IFPWAP_VERSION, 105 true 106 ); 107 } 108 add_action( 'admin_enqueue_scripts', 'ifpwap_enqueue_admin_assets' ); 96 109 97 110 // Inside your plugin file or theme's functions.php file 98 111 function ifpwap_enqueue_install_prompt_script() { 99 wp_enqueue_script('jquery'); 100 // Ensure the URLs are from a secure source and properly formatted 101 $font_awesome_url = esc_url( plugins_url('assets/frontend/font-awesome.css', __FILE__) ); 102 $style_url = esc_url( plugins_url('assets/frontend/style.css', __FILE__) ); 103 wp_enqueue_style('ifpwap-font-awesome-style', $font_awesome_url); 104 wp_enqueue_style('ifpwap-style', $style_url); 105 } 106 add_action('wp_enqueue_scripts', 'ifpwap_enqueue_install_prompt_script'); 112 wp_enqueue_style( 113 'ifpwap-font-awesome-style', 114 IFPWAP_PLUGIN_URL . 'assets/frontend/font-awesome.css', 115 array(), 116 IFPWAP_VERSION 117 ); 118 wp_enqueue_style( 119 'ifpwap-style', 120 IFPWAP_PLUGIN_URL . 'assets/frontend/style.css', 121 array(), 122 IFPWAP_VERSION 123 ); 124 } 125 add_action( 'wp_enqueue_scripts', 'ifpwap_enqueue_install_prompt_script' ); 107 126 108 127 // default options values added while plugin active … … 126 145 add_action( 'wp_head', 'ifpwap_inc_manifest_link' ); 127 146 function ifpwap_inc_manifest_link() { 128 $ifpwap_theme_color = get_option( 'ifpwap_theme_color');147 $ifpwap_theme_color = get_option( 'ifpwap_theme_color', '#ffffff' ); 129 148 ?> 130 149 <meta name="theme-color" content="<?php echo esc_attr($ifpwap_theme_color);?>"> … … 132 151 } 133 152 134 add_action( 'wp_enqueue_scripts', 'ifpwap_enqueue_manifest_link' ); 135 function ifpwap_enqueue_manifest_link() { 136 // Get the URL for the manifest file 137 $manifest_url = esc_url( get_site_url() . '/ifpwap-manifest.json' ); 138 // Enqueue the manifest file as a style 139 wp_enqueue_style( 'ifpwap-manifest', $manifest_url, array(), null ); 140 } 153 function ifpwap_add_manifest_link() { 154 $manifest_url = home_url( '/ifpwap-manifest.json' ); 155 ?> 156 <link rel="manifest" href="<?php echo esc_url( $manifest_url ); ?>"> 157 <?php 158 } 159 add_action( 'wp_head', 'ifpwap_add_manifest_link' ); 160 141 161 add_filter( 'style_loader_tag', 'ifpwap_modify_manifest_link_tag', 10, 4 ); 142 162 function ifpwap_modify_manifest_link_tag( $html, $handle, $href, $media ) { … … 147 167 } 148 168 149 add_action( 'wp_enqueue_scripts', 'ifpwap_enqueue_prefetch_manifest_link' );150 function ifpwap_enqueue_prefetch_manifest_link() {151 // Get the URL for the manifest file152 $manifest_url = esc_url( get_site_url() . '/ifpwap-manifest.json' );153 // Enqueue the prefetch link154 wp_enqueue_script( 'ifpwap-prefetch-manifest', $manifest_url, array(), null, true );155 }156 169 add_filter( 'script_loader_tag', 'ifpwap_modify_prefetch_manifest_link_tag', 10, 3 ); 157 170 function ifpwap_modify_prefetch_manifest_link_tag( $tag, $handle, $src ) { … … 163 176 164 177 // Register JS files in footer 165 add_action('wp_enqueue_scripts', 'ifpwap_register_footer_js');166 178 function ifpwap_register_footer_js() { 167 wp_enqueue_script('ifpwap-footer-js', esc_url(get_site_url().'/ifpwap-register-sw.js'), array(), null, true); 168 } 179 wp_enqueue_script( 180 'ifpwap-footer-js', 181 home_url( '/ifpwap-register-sw.js' ), 182 array(), 183 IFPWAP_VERSION, 184 true 185 ); 186 } 187 add_action( 'wp_enqueue_scripts', 'ifpwap_register_footer_js' ); 169 188 170 189 function ifpwap_common_sanitize($input) { … … 272 291 // Remove the trailing comma after the last iteration 273 292 $ifpwap_start_page_name = get_the_title($ifpwap_select_start_page); 274 $base = plugin_dir_path(__FILE__); 275 $root_path = plugin_dir_path(dirname(dirname($base))); 293 // $base = plugin_dir_path(__FILE__); 294 // $root_path = plugin_dir_path(dirname(dirname($base))); 295 $root_path = IFPWAP_PLUGIN_DIR; 276 296 277 297 $offline_page_slug = get_post_field( 'post_name', $ifpwap_select_offline_page ); … … 289 309 // Check if the current page is the front page 290 310 if ( ! is_front_page() ) { 291 292 311 // Get front page ID and title 293 312 $front_page_id = (int) get_option( 'page_on_front' ); 294 313 $front_page_title = $front_page_id ? get_the_title( $front_page_id ) : ''; 295 296 314 if ( ! empty( $ifpwap_start_page_name ) && $ifpwap_start_page_name !== $front_page_title ) { 297 298 315 // Fetch page by title (replacement for deprecated get_page_by_title) 299 316 $pages = get_posts( [ … … 375 392 ); 376 393 $ifpwap_manifest_json = json_encode($ifpwap_manifest_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); 377 if ($wp_filesystem) { 378 $manifest_fp = trailingslashit($root_path) . "ifpwap-manifest.json"; 379 if (false === $wp_filesystem->put_contents($manifest_fp, $ifpwap_manifest_json, FS_CHMOD_FILE)) { 380 echo esc_html__('Failed to write the manifest file.', 'iflair-pwa-app'); 394 // Use the uploads directory instead of plugin folder 395 $upload_dir = wp_upload_dir(); 396 $plugin_upload_dir = trailingslashit( $upload_dir['basedir'] ) . 'iflair-pwa-app/'; 397 398 // Make sure the folder exists 399 if ( ! file_exists( $plugin_upload_dir ) ) { 400 wp_mkdir_p( $plugin_upload_dir ); 401 } 402 403 // Full file path 404 $manifest_fp = $plugin_upload_dir . 'ifpwap-manifest.json'; 405 406 // Write file using WP_Filesystem if available, fallback to PHP file_put_contents 407 if ( $wp_filesystem ) { 408 if ( false === $wp_filesystem->put_contents( $manifest_fp, $ifpwap_manifest_json, FS_CHMOD_FILE ) ) { 409 echo esc_html__( 'Failed to write the manifest file.', 'iflair-pwa-app' ); 381 410 } 382 411 } else { 383 echo esc_html__('Filesystem API not initialized.', 'iflair-pwa-app'); 412 if ( false === file_put_contents( $manifest_fp, $ifpwap_manifest_json ) ) { 413 echo esc_html__( 'Failed to write the manifest file.', 'iflair-pwa-app' ); 414 } 384 415 } 385 416 … … 427 458 } 428 459 });"; 429 if ($wp_filesystem) { 430 $registersw_fp = trailingslashit($root_path) . "ifpwap-register-sw.js"; // Ensure path is correctly formatted 460 461 // Use uploads folder instead of plugin folder 462 $upload_dir = wp_upload_dir(); 463 $plugin_upload_dir = trailingslashit( $upload_dir['basedir'] ) . 'iflair-pwa-app/'; 464 465 // Make sure the folder exists 466 if ( ! file_exists( $plugin_upload_dir ) ) { 467 wp_mkdir_p( $plugin_upload_dir ); 468 } 469 470 // Full file path 471 $registersw_fp = $plugin_upload_dir . 'ifpwap-register-sw.js'; 472 473 // Write file using WP_Filesystem if available, fallback to PHP file_put_contents 474 if ( $wp_filesystem ) { 431 475 $success = $wp_filesystem->put_contents( 432 476 $registersw_fp, 433 477 $ifpwap_register_service_worker_js, 434 FS_CHMOD_FILE // Set proper file permissions 435 ); 436 if (!$success) { 437 echo esc_html__('Failed to write the service worker file.', 'iflair-pwa-app'); 478 FS_CHMOD_FILE 479 ); 480 481 if ( ! $success ) { 482 echo esc_html__( 'Failed to write the service worker file.', 'iflair-pwa-app' ); 438 483 } 439 484 } else { 440 echo esc_html__('Filesystem API not initialized.', 'iflair-pwa-app'); 441 } 485 if ( false === file_put_contents( $registersw_fp, $ifpwap_register_service_worker_js ) ) { 486 echo esc_html__( 'Failed to write the service worker file.', 'iflair-pwa-app' ); 487 } 488 } 489 442 490 // analytics js code for append 443 491 $ifpwap_analytics_js_append = "importScripts(\"https://storage.googleapis.com/workbox-cdn/releases/6.0.2/workbox-sw.js\"); … … 467 515 // End get manual cache URLs code 468 516 $ifpwap_cache_external_urls = get_option('ifpwap_cache_external_urls'); 517 $ifpwap_external_url_cache_js = ''; 469 518 if($ifpwap_cache_external_urls == 'yes'){ 470 519 $ifpwap_external_url_cache_js = $ifpwap_external_url_cache_js_append; … … 667 716 }"; 668 717 // Append analytics code if enabled 669 if ( $ifpwap_offline_analytics == 'yes') {718 if ( $ifpwap_offline_analytics === 'yes' ) { 670 719 $ifpwap_final_sw_js = $ifpwap_sw_js . "\n" . $ifpwap_analytics_js_append; 671 720 } else { 672 721 $ifpwap_final_sw_js = $ifpwap_sw_js; 673 722 } 723 724 // Get the plugin upload directory 725 $upload_dir = wp_upload_dir(); 726 $plugin_upload_dir = trailingslashit( $upload_dir['basedir'] ) . 'iflair-pwa-app/'; 727 728 // Make sure the folder exists 729 if ( ! file_exists( $plugin_upload_dir ) ) { 730 wp_mkdir_p( $plugin_upload_dir ); 731 } 732 733 // Full file path 734 $sw_fp = $plugin_upload_dir . 'ifpwap-sw.js'; 735 736 // Write file using WP_Filesystem if available, fallback to PHP file_put_contents 674 737 if ( $wp_filesystem ) { 675 $sw_fp = trailingslashit($root_path) . "ifpwap-sw.js"; // Ensure path is correctly formatted676 738 $success = $wp_filesystem->put_contents( 677 739 $sw_fp, 678 740 $ifpwap_final_sw_js, 679 FS_CHMOD_FILE // Set proper file permissions 680 ); 681 if (!$success) { 682 echo esc_html__('Failed to write the service worker file.', 'iflair-pwa-app'); 741 FS_CHMOD_FILE 742 ); 743 744 if ( ! $success ) { 745 echo esc_html__( 'Failed to write the service worker file.', 'iflair-pwa-app' ); 683 746 } 684 747 } else { 685 echo esc_html__('Filesystem API not initialized.', 'iflair-pwa-app'); 748 if ( false === file_put_contents( $sw_fp, $ifpwap_final_sw_js ) ) { 749 echo esc_html__( 'Failed to write the service worker file.', 'iflair-pwa-app' ); 750 } 686 751 } 687 752 … … 802 867 // Action hook to execute the code within the WordPress environment 803 868 function ifpwap_check_files_and_https_status() { 804 // Check if WordPress environment is loaded 805 if (function_exists('get_site_url')) { 806 // Specify the files to check 807 $files_to_check = array( 808 'ifpwap-sw.js', 809 'ifpwap-register-sw.js', 810 'ifpwap-manifest.json' 811 ); 812 // Initialize array to store file URLs 813 $file_urls = array(); 814 // Check if files exist and get their URLs 815 foreach ($files_to_check as $file) { 816 $file_path = ABSPATH . $file; 817 if (file_exists($file_path)) { 818 $file_urls[$file] = get_site_url(null, '/' . $file); 819 } 869 // Get plugin uploads directory 870 $upload_dir = wp_upload_dir(); 871 $plugin_upload_dir = trailingslashit( $upload_dir['basedir'] ) . 'iflair-pwa-app/'; 872 $plugin_upload_url = trailingslashit( $upload_dir['baseurl'] ) . 'iflair-pwa-app/'; 873 874 $files_to_check = array( 875 'ifpwap-sw.js', 876 'ifpwap-register-sw.js', 877 'ifpwap-manifest.json' 878 ); 879 880 $file_urls = array(); 881 882 foreach ( $files_to_check as $file ) { 883 $file_path = $plugin_upload_dir . $file; // Check in uploads folder 884 if ( file_exists( $file_path ) ) { 885 $file_urls[ $file ] = $plugin_upload_url . $file; // URL from uploads folder 820 886 } 821 // Check if website is served over HTTPS 822 $https_status = (is_ssl()) ? 'Yes' : 'No'; 823 // Output HTML with file URLs and HTTPS status 824 ?> 825 <div class="ifpwap_files_url"> 826 <h3><?php echo esc_html__('Status','iflair-pwa-app');?></h3> 827 <?php 828 foreach ($file_urls as $file => $url) { ?> 829 <p class='ifpwap_<?php echo esc_attr($file);?>'><a class='ifpwap_icon-link' target='_blank' href='<?php echo esc_url($url);?>'><?php echo esc_html($file);?></a><?php echo esc_html__(' File successfully generated.','iflair-pwa-app');?></p> 830 <?php } ?> 831 <p class='ifpwap_https ifpwap_icon-link'><?php echo esc_html__('Website served over HTTPS:','iflair-pwa-app') . ' ' . esc_html($https_status);?></p> 832 </div> 833 <?php } else { 834 echo esc_html__('WordPress environment not found.','iflair-pwa-app'); 835 } 836 } 887 } 888 889 $https_status = is_ssl() ? 'Yes' : 'No'; 890 ?> 891 892 <div class="ifpwap_files_url"> 893 <h3><?php echo esc_html__( 'Status', 'iflair-pwa-app' ); ?></h3> 894 <?php foreach ( $file_urls as $file => $url ) : ?> 895 <p class="ifpwap_<?php echo esc_attr( $file ); ?>"> 896 <a class="ifpwap_icon-link" target="_blank" href="<?php echo esc_url( $url ); ?>"> 897 <?php echo esc_html( $file ); ?> 898 </a> 899 <?php echo esc_html__( ' File successfully generated.', 'iflair-pwa-app' ); ?> 900 </p> 901 <?php endforeach; ?> 902 <p class="ifpwap_https ifpwap_icon-link"> 903 <?php 904 echo esc_html__( 'Website served over HTTPS:', 'iflair-pwa-app' ) . ' ' . esc_html( $https_status ); 905 ?> 906 </p> 907 </div> 908 <?php 909 } -
iflair-pwa-app/trunk/includes/admin/advanced.php
r3433574 r3438430 6 6 $ifpwap_cache_external_urls = get_option('ifpwap_cache_external_urls'); 7 7 $ifpwap_exclude_urls_from_cache_list = get_option('ifpwap_exclude_urls_from_cache_list'); 8 $ifpwap_tooltip_url = plugins_url().'/iflair-pwa-app/assets/admin/images/tooltip_icon.png'; 8 // $ifpwap_tooltip_url = plugins_url().'/iflair-pwa-app/assets/admin/images/tooltip_icon.png'; 9 $ifpwap_tooltip_url = IFPWAP_PLUGIN_URL . 'assets/admin/images/tooltip_icon.png'; 10 9 11 ?> 10 12 <!-- Start form section --> -
iflair-pwa-app/trunk/includes/admin/caching-strategies.php
r3433574 r3438430 5 5 $ifpwap_caching_type = get_option('ifpwap_caching_type'); 6 6 $ifpwap_pre_caching_manual = get_option('ifpwap_pre_caching_manual'); 7 $ifpwap_tooltip_url = plugins_url().'/iflair-pwa-app/assets/admin/images/tooltip_icon.png'; 7 // $ifpwap_tooltip_url = plugins_url().'/iflair-pwa-app/assets/admin/images/tooltip_icon.png'; 8 $ifpwap_tooltip_url = IFPWAP_PLUGIN_URL.'assets/admin/images/tooltip_icon.png'; 8 9 ?> 9 10 <!-- Start form section --> -
iflair-pwa-app/trunk/includes/admin/settings_fields.php
r3433574 r3438430 16 16 $ifpwap_text_direction = get_option('ifpwap_text_direction'); 17 17 $ifpwap_custom_footer_btn = get_option('ifpwap_custom_footer_btn'); 18 $ifpwap_tooltip_url = plugins_url().'/iflair-pwa-app/assets/admin/images/tooltip_icon.png'; 18 //$ifpwap_tooltip_url = plugins_url().'/iflair-pwa-app/assets/admin/images/tooltip_icon.png'; 19 $ifpwap_tooltip_url = IFPWAP_PLUGIN_URL.'assets/admin/images/tooltip_icon.png'; 19 20 ?> 20 21 <!-- Start form section --> -
iflair-pwa-app/trunk/readme.txt
r3433574 r3438430 5 5 Requires at least: 4.7 6 6 Tested up to: 6.9 7 Stable tag: 1.1. 47 Stable tag: 1.1.5 8 8 Requires PHP: 5.6 9 9 License: GPLv2 or later … … 142 142 * Improved settings structure and labels 143 143 * Minor code cleanup and compatibility fixes 144 145 = 1.1.5 = 146 * Fixed hardcoded plugin paths and URLs for scripts, styles, and assets. 147 * Moved service worker, register JS, and manifest files to wp-content/uploads/iflair-pwa-app/. 148 * Updated all file URLs to use wp_upload_dir() dynamically. 149 * Added fallback to file_put_contents() if Filesystem API is not available. 150 * Status checker now correctly reads files from uploads folder. 151 * Plugin fully update-safe and multisite-compatible.
Note: See TracChangeset
for help on using the changeset viewer.