Changeset 3379262
- Timestamp:
- 10/16/2025 06:49:28 AM (5 months ago)
- Location:
- export-wp-page-to-static-html/trunk
- Files:
-
- 7 edited
-
README.txt (modified) (1 diff)
-
admin/includes/AjaxRequests/assetsExporter.php (modified) (2 diffs)
-
admin/includes/AjaxRequests/exportLogPercentage.php (modified) (1 diff)
-
admin/includes/data/data.php (modified) (1 diff)
-
admin/partials/sections/hidden-fields-and-js.php (modified) (1 diff)
-
export-wp-page-to-static-html.php (modified) (4 diffs)
-
includes/class-export-wp-page-to-static-html-activator.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
export-wp-page-to-static-html/trunk/README.txt
r3358063 r3379262 4 4 Requires at least: 4.1 5 5 Tested up to: 6.8 6 Stable tag: 4.3. 26 Stable tag: 4.3.3 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
export-wp-page-to-static-html/trunk/admin/includes/AjaxRequests/assetsExporter.php
r3350057 r3379262 25 25 public function assets_exporter() { 26 26 27 \rcCheckNonce(); 28 29 $asset_type = isset($_POST['asset_type']) ? \sanitize_text_field($_POST['asset_type']) : ""; 30 31 include __DIR__ . '/../class-ExtractorHelpers.php'; 32 $extractorHelpers = new \ExtractorHelpers(); 33 34 $asset_type = isset($_POST['asset_type']) ? sanitize_text_field($_POST['asset_type']) : null; 35 $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1; 36 37 $assets = $extractorHelpers->get_next_export_asset($asset_type, $limit); 38 39 // Normalize to array 40 if ($limit === 1) { 41 $assets = $assets ? [$assets] : []; 27 \rcCheckNonce(); 28 29 $asset_type = isset($_POST['asset_type']) ? \sanitize_text_field($_POST['asset_type']) : ""; 30 31 include __DIR__ . '/../class-ExtractorHelpers.php'; 32 $extractorHelpers = new \ExtractorHelpers(); 33 34 $asset_type = isset($_POST['asset_type']) ? sanitize_text_field($_POST['asset_type']) : null; 35 $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1; 36 37 $assets = $extractorHelpers->get_next_export_asset($asset_type, $limit); 38 39 // Normalize to array 40 if ($limit === 1) { 41 $assets = $assets ? [$assets] : []; 42 } 43 44 $results = [ 45 'css' => [], 46 'js' => [], 47 'image' => [], 48 'url' => [], 49 'skipped' => [], 50 ]; 51 52 foreach ($assets as $asset) { 53 54 $id = isset($asset['id']) ? (int) $asset['id'] : 0; 55 $url = isset($asset['url']) ? $asset['url'] : ''; 56 $found_on = isset($asset['found_on']) ? $asset['found_on'] : ''; 57 $type = isset($asset['type']) ? $asset['type'] : ''; 58 $status = isset($asset['status']) ? $asset['status'] : ''; 59 $new_name = isset($asset['new_file_name']) ? $asset['new_file_name'] : ''; 60 61 if (!$id || !$url || !$type) { 62 $results['skipped'][] = ['id' => $id, 'reason' => 'missing_required_fields']; 63 continue; 64 } 65 66 if ($status === 'processing') { 67 $results[$type][] = [ 68 'id' => $id, 69 'url' => $url, 70 'asset_status' => $status, 71 'handled' => false, 72 'message' => 'Already processing', 73 ]; 74 continue; 75 } 76 77 $extractorHelpers->update_asset_url_status($url, 'processing'); 78 79 try { 80 switch ($type) { 81 case 'css': 82 $extractorHelpers->save_stylesheet($url, $found_on, $new_name); 83 break; 84 85 case 'js': 86 $extractorHelpers->save_scripts($url, $found_on, $new_name); 87 break; 88 89 case 'url': 90 $endpoint = rest_url('ewptshp/v1/run'); 91 $token = get_option('ewptshp_worker_token'); 92 93 wp_remote_post($endpoint, [ 94 'timeout' => 5, 95 'blocking' => false, 96 'sslverify' => false, 97 'body' => [ 98 'token' => $token, 99 'url' => $url, 100 ], 101 ]); 102 103 error_log('[URL DOne] onAssetsExporter'. $url); 104 break; 105 106 case 'image': 107 if (method_exists($extractorHelpers, 'save_image')) { 108 $extractorHelpers->save_image($url, $found_on, $new_name); 109 } else { 110 } 111 break; 112 113 default: 114 $results['skipped'][] = ['id' => $id, 'reason' => 'unknown_type', 'type' => $type]; 115 continue 2; 116 } 117 118 $results[$type][] = [ 119 'id' => $id, 120 'url' => $url, 121 'asset_status' => 'processed', 122 'handled' => true, 123 ]; 124 125 } catch (Exception $e) { 126 $extractorHelpers->update_asset_url_status($url, 'failed'); 127 128 $results[$type][] = [ 129 'id' => $id, 130 'url' => $url, 131 'asset_status' => 'failed', 132 'handled' => false, 133 'error' => $e->getMessage(), 134 ]; 135 } 136 } 137 138 139 echo wp_json_encode([ 140 'success' => true, 141 'status' => 'success', 142 'fetched' => count($assets), 143 'grouped' => [ 144 'css' => $results['css'], 145 'js' => $results['js'], 146 'image' => $results['image'], 147 'url' => $results['url'], 148 ], 149 'skipped' => $results['skipped'], 150 ], JSON_UNESCAPED_SLASHES); 151 152 $status = (string) $this->getSettings('creating_zip'); 153 $proc = (string) $this->getSettings('creating_zip_process'); 154 $creatingHtmlProcess = $this->getSettings('creating_html_process', 'running'); 155 156 157 if ($creatingHtmlProcess === 'completed' && $this->are_all_assets_exported() && $status !== 'running') { 158 $this->setSettings('creating_zip', 'running'); 159 } 160 elseif ($status === 'running' && $proc !== 'running' && $proc !== 'completed') { 161 do_action('assets_files_exporting_completed'); 162 } 163 164 165 wp_die(); 42 166 } 43 44 $results = [45 'css' => [],46 'js' => [],47 'image' => [],48 'url' => [],49 'skipped' => [],50 ];51 52 foreach ($assets as $asset) {53 54 $id = isset($asset['id']) ? (int) $asset['id'] : 0;55 $url = isset($asset['url']) ? $asset['url'] : '';56 $found_on = isset($asset['found_on']) ? $asset['found_on'] : '';57 $type = isset($asset['type']) ? $asset['type'] : '';58 $status = isset($asset['status']) ? $asset['status'] : '';59 $new_name = isset($asset['new_file_name']) ? $asset['new_file_name'] : '';60 61 if (!$id || !$url || !$type) {62 $results['skipped'][] = ['id' => $id, 'reason' => 'missing_required_fields'];63 continue;64 }65 66 if ($status === 'processing') {67 $results[$type][] = [68 'id' => $id,69 'url' => $url,70 'asset_status' => $status,71 'handled' => false,72 'message' => 'Already processing',73 ];74 continue;75 }76 77 $extractorHelpers->update_asset_url_status($url, 'processing');78 79 try {80 switch ($type) {81 case 'css':82 $extractorHelpers->save_stylesheet($url, $found_on, $new_name);83 break;84 85 case 'js':86 $extractorHelpers->save_scripts($url, $found_on, $new_name);87 break;88 89 case 'url':90 $endpoint = rest_url('ewptshp/v1/run');91 $token = get_option('ewptshp_worker_token');92 93 wp_remote_post($endpoint, [94 'timeout' => 5,95 'blocking' => false,96 'sslverify' => false,97 'body' => [98 'token' => $token,99 'url' => $url,100 ],101 ]);102 103 error_log('[URL DOne] onAssetsExporter'. $url);104 break;105 106 case 'image':107 if (method_exists($extractorHelpers, 'save_image')) {108 $extractorHelpers->save_image($url, $found_on, $new_name);109 } else {110 }111 break;112 113 default:114 $results['skipped'][] = ['id' => $id, 'reason' => 'unknown_type', 'type' => $type];115 continue 2;116 }117 118 $results[$type][] = [119 'id' => $id,120 'url' => $url,121 'asset_status' => 'processed',122 'handled' => true,123 ];124 125 } catch (Exception $e) {126 $extractorHelpers->update_asset_url_status($url, 'failed');127 128 $results[$type][] = [129 'id' => $id,130 'url' => $url,131 'asset_status' => 'failed',132 'handled' => false,133 'error' => $e->getMessage(),134 ];135 }136 }137 138 139 echo wp_json_encode([140 'success' => true,141 'status' => 'success',142 'fetched' => count($assets),143 'grouped' => [144 'css' => $results['css'],145 'js' => $results['js'],146 'image' => $results['image'],147 'url' => $results['url'],148 ],149 'skipped' => $results['skipped'],150 ], JSON_UNESCAPED_SLASHES);151 152 $status = (string) $this->getSettings('creating_zip');153 $proc = (string) $this->getSettings('creating_zip_process');154 $creatingHtmlProcess = $this->getSettings('creating_html_process', 'running');155 156 157 if ($creatingHtmlProcess === 'completed' && $this->are_all_assets_exported() && $status !== 'running') {158 $this->setSettings('creating_zip', 'running');159 }160 elseif ($status === 'running' && $proc !== 'running' && $proc !== 'completed') {161 do_action('assets_files_exporting_completed');162 }163 164 165 wp_die();166 }167 167 168 168 … … 171 171 $table = $wpdb->prefix . 'export_urls_logs'; 172 172 173 // Count total css/js assets 173 // Build dynamic type condition 174 $types = []; 175 176 $skip = (array) $this->getSettings('skipAssetsFiles', array()); 177 178 if (!array_key_exists('stylesheets', $skip)) { 179 $types[] = "'css'"; 180 } 181 182 if (!array_key_exists('scripts', $skip)) { 183 $types[] = "'js'"; 184 } 185 186 // If both skipped, nothing to check 187 if (empty($types)) { 188 return true; 189 } 190 191 $types_in = implode(',', $types); 192 193 // Count total assets 174 194 $total = $wpdb->get_var(" 175 195 SELECT COUNT(*) 176 196 FROM {$table} 177 WHERE type IN ( 'css', 'js')197 WHERE type IN ({$types_in}) 178 198 "); 179 199 180 // If no css/js assets exist, return false (or change this to true if preferred)200 // If no matching assets exist 181 201 if ((int) $total === 0) { 182 202 return false; 183 203 } 184 204 185 // Count how many of those have been exported205 // Count exported assets 186 206 $exported = $wpdb->get_var(" 187 207 SELECT COUNT(*) 188 208 FROM {$table} 189 WHERE type IN ( 'css', 'js') AND exported = 1209 WHERE type IN ({$types_in}) AND exported = 1 190 210 "); 191 211 192 // Return true only if all css/jsassets are exported212 // Return true only if all assets are exported 193 213 return ((int) $total === (int) $exported); 194 214 } -
export-wp-page-to-static-html/trunk/admin/includes/AjaxRequests/exportLogPercentage.php
r3350057 r3379262 262 262 return $wpdb->query($sql); // Returns number of affected rows 263 263 } 264 264 265 public function are_all_assets_exported() { 265 266 global $wpdb; 266 267 $table = $wpdb->prefix . 'export_urls_logs'; 267 268 268 // Count total css/js assets 269 // Build dynamic type condition 270 $types = []; 271 272 $skip = (array) $this->getSettings('skipAssetsFiles', array()); 273 274 if (!array_key_exists('stylesheets', $skip)) { 275 $types[] = "'css'"; 276 } 277 278 if (!array_key_exists('scripts', $skip)) { 279 $types[] = "'js'"; 280 } 281 282 // If both skipped, nothing to check 283 if (empty($types)) { 284 return true; 285 } 286 287 $types_in = implode(',', $types); 288 289 // Count total assets 269 290 $total = $wpdb->get_var(" 270 291 SELECT COUNT(*) 271 292 FROM {$table} 272 WHERE type IN ( 'css', 'js')293 WHERE type IN ({$types_in}) 273 294 "); 274 295 275 // If no css/js assets exist, return false (or change this to true if preferred)296 // If no matching assets exist 276 297 if ((int) $total === 0) { 277 298 return false; 278 299 } 279 300 280 // Count how many of those have been exported301 // Count exported assets 281 302 $exported = $wpdb->get_var(" 282 303 SELECT COUNT(*) 283 304 FROM {$table} 284 WHERE type IN ( 'css', 'js') AND exported = 1305 WHERE type IN ({$types_in}) AND exported = 1 285 306 "); 286 307 287 // Return true only if all css/jsassets are exported308 // Return true only if all assets are exported 288 309 return ((int) $total === (int) $exported); 289 310 } 290 311 291 312 313 292 314 } -
export-wp-page-to-static-html/trunk/admin/includes/data/data.php
r3335694 r3379262 90 90 91 91 public function handle_ajax() { 92 $reason_key = isset($_POST['reason_key']) ? sanitize_text_field($_POST['reason_key']) : ''; 93 92 94 $data = [ 93 95 'site_url' => get_site_url(), 94 'reason_key' => sanitize_text_field($_POST['reason_key']),96 'reason_key' => $reason_key, 95 97 'feedback' => sanitize_textarea_field($_POST['feedback']), 96 98 'wp_version' => get_bloginfo('version'), -
export-wp-page-to-static-html/trunk/admin/partials/sections/hidden-fields-and-js.php
r3350057 r3379262 35 35 36 36 selectBox.select2({ 37 placeholder: "Choose up to 3pages",37 placeholder: "Choose up to 6 pages", 38 38 dropdownParent: selectDropdown, 39 maximumSelectionLength: 3,39 maximumSelectionLength: 6, 40 40 language: { 41 41 maximumSelected: function (args) { 42 return "Maximum 3pages can be selected. Upgrade to pro version to select unlimited pages.";42 return "Maximum 6 pages can be selected. Upgrade to pro version to select unlimited pages."; 43 43 } 44 44 }, -
export-wp-page-to-static-html/trunk/export-wp-page-to-static-html.php
r3358063 r3379262 10 10 * Plugin URI: https://myrecorp.com 11 11 * Description: Seamlessly export any WordPress page or post into lightweight, fully responsive static HTML/CSS and print-ready PDF with a single click. Boost your site’s performance and security by serving pre-rendered pages, create offline-friendly backups. Perfect for developers, content creators, and businesses needing fast, reliable exports of WordPress content. 12 * Version: 4.3. 212 * Version: 4.3.3 13 13 * Author: ReCorp 14 14 * Author URI: https://www.upwork.com/fl/rayhan1 … … 50 50 register_activation_hook( __FILE__, 'activate_export_wp_page_to_static_html' ); 51 51 52 if (!function_exists('run_export_wp_page_to_static_html ')){52 if (!function_exists('run_export_wp_page_to_static_html_pro')){ 53 53 54 54 /** … … 57 57 * Rename this for your plugin and update it as you release new versions. 58 58 */ 59 define( 'EXPORT_WP_PAGE_TO_STATIC_HTML_VERSION', '4.3. 2' );59 define( 'EXPORT_WP_PAGE_TO_STATIC_HTML_VERSION', '4.3.3' ); 60 60 define( 'EWPPTSH_PLUGIN_DIR_URL', plugin_dir_url(__FILE__) ); 61 61 define( 'EWPPTSH_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__) ); … … 118 118 } 119 119 run_export_wp_page_to_static_html(); 120 121 122 function wpptsh_error_log($log){ 123 if (EWPPTSH_DEVELOPER_MODE) { 124 error_log($log); 125 } 126 } 127 // On plugin activation (once), create/store a token 128 register_activation_hook(__FILE__, function(){ 129 if (!get_option('ewptshp_worker_token')) { 130 add_option('ewptshp_worker_token', wp_generate_password(32, false, false)); 131 } 132 }); 133 134 // Runs on every load, no __FILE__ here 135 function wpptsh_update_db_check() { 136 $installed_ver = get_option('wpptsh_db_version'); 137 138 if ($installed_ver !=WPPTSH_DB_VERSION) { 139 global $wpdb; 140 $table_name = $wpdb->prefix . 'export_urls_logs'; 141 142 // Add only missing column(s) 143 $wpdb->query("ALTER TABLE $table_name ADD COLUMN type TINYTEXT NOT NULL"); 144 145 146 update_option('wpptsh_db_version', WPPTSH_DB_VERSION); 147 } 148 149 } 150 add_action('plugins_loaded', 'wpptsh_update_db_check'); 120 151 } 121 152 122 153 //} 123 function wpptsh_error_log($log){124 if (EWPPTSH_DEVELOPER_MODE) {125 error_log($log);126 }127 }128 // On plugin activation (once), create/store a token129 register_activation_hook(__FILE__, function(){130 if (!get_option('ewptshp_worker_token')) {131 add_option('ewptshp_worker_token', wp_generate_password(32, false, false));132 }133 });134 135 // Runs on every load, no __FILE__ here136 function wpptsh_update_db_check() {137 $installed_ver = get_option('wpptsh_db_version');138 139 if ($installed_ver !=WPPTSH_DB_VERSION) {140 global $wpdb;141 $table_name = $wpdb->prefix . 'export_urls_logs';142 143 // Add only missing column(s)144 $wpdb->query("ALTER TABLE $table_name ADD COLUMN type TINYTEXT NOT NULL");145 146 147 update_option('wpptsh_db_version', WPPTSH_DB_VERSION);148 }149 150 }151 add_action('plugins_loaded', 'wpptsh_update_db_check'); -
export-wp-page-to-static-html/trunk/includes/class-export-wp-page-to-static-html-activator.php
r3357379 r3379262 32 32 public static function activate() { 33 33 34 if ( is_plugin_active( 'export-wp-page-to-static-html-pro-premium/export-wp-page-to-static-html.php' ) ) {35 deactivate_plugins( 'export-wp-page-to-static-html-pro-premium/export-wp-page-to-static-html.php' );36 }37 34 38 35 global $wpdb; … … 105 102 } 106 103 104 if ( is_plugin_active( 'export-wp-page-to-static-html-pro-premium/export-wp-page-to-static-html.php' ) ) { 105 deactivate_plugins( 'export-wp-page-to-static-html-pro-premium/export-wp-page-to-static-html.php' ); 106 } 107 elseif ( is_plugin_active( 'export-wp-page-to-static-html-pro/export-wp-page-to-static-html.php' ) ) { 108 deactivate_plugins( 'export-wp-page-to-static-html-pro/export-wp-page-to-static-html.php' ); 109 } 107 110 108 111
Note: See TracChangeset
for help on using the changeset viewer.