Changeset 3237856
- Timestamp:
- 02/10/2025 11:13:08 AM (14 months ago)
- Location:
- export-all-urls
- Files:
-
- 12 added
- 4 edited
-
tags/5.0 (added)
-
tags/5.0/assets (added)
-
tags/5.0/assets/css (added)
-
tags/5.0/assets/css/style.css (added)
-
tags/5.0/assets/js (added)
-
tags/5.0/assets/js/script.js (added)
-
tags/5.0/classes (added)
-
tags/5.0/classes/constants.php (added)
-
tags/5.0/eau_functions.php (added)
-
tags/5.0/extract-all-urls-settings.php (added)
-
tags/5.0/extract-all-urls.php (added)
-
tags/5.0/readme.txt (added)
-
trunk/eau_functions.php (modified) (11 diffs)
-
trunk/extract-all-urls-settings.php (modified) (3 diffs)
-
trunk/extract-all-urls.php (modified) (1 diff)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
export-all-urls/trunk/eau_functions.php
r2990491 r3237856 7 7 * Time: 9:01 AM 8 8 */ 9 9 10 namespace Export_All_URLs; 10 11 … … 13 14 require_once(plugin_dir_path(__FILE__) . 'classes/constants.php'); 14 15 15 class EAU_Functions{ 16 class EAU_Functions 17 { 16 18 public function Eau_Export_fields() 17 19 { 18 20 return array( 19 'p_id' => __('Post ID', Constants::PLUGIN_TEXT_DOMAIN), 20 'title' => __('Title', Constants::PLUGIN_TEXT_DOMAIN), 21 'url' => __('URL', Constants::PLUGIN_TEXT_DOMAIN), 22 'categories' => __('Categories', Constants::PLUGIN_TEXT_DOMAIN), 23 'tags' => __('Tags', Constants::PLUGIN_TEXT_DOMAIN), 24 'author' => __('Author', Constants::PLUGIN_TEXT_DOMAIN), 25 'p_date' => __('Published Date', Constants::PLUGIN_TEXT_DOMAIN), 26 'm_date' => __('Modified Date', Constants::PLUGIN_TEXT_DOMAIN), 21 'p_id' => __('Post ID', Constants::PLUGIN_TEXT_DOMAIN), 22 'title' => __('Title', Constants::PLUGIN_TEXT_DOMAIN), 23 'url' => __('URL', Constants::PLUGIN_TEXT_DOMAIN), 24 'categories' => __('Categories', Constants::PLUGIN_TEXT_DOMAIN), 25 'category_urls' => __('Category URLs', Constants::PLUGIN_TEXT_DOMAIN), 26 'tags' => __('Tags', Constants::PLUGIN_TEXT_DOMAIN), 27 'tag_urls' => __('Tag URLs', Constants::PLUGIN_TEXT_DOMAIN), 28 'author' => __('Author', Constants::PLUGIN_TEXT_DOMAIN), 29 'p_date' => __('Published Date', Constants::PLUGIN_TEXT_DOMAIN), 30 'm_date' => __('Modified Date', Constants::PLUGIN_TEXT_DOMAIN), 31 'status' => __('Status', Constants::PLUGIN_TEXT_DOMAIN), 27 32 ); 28 33 } 29 34 30 35 /** 31 36 * Returns an array of field labels for the selected fields. … … 39 44 $all_fields = self::Eau_Export_fields(); 40 45 $extracted_fields = $hash ? array('#') : array(); 41 46 42 47 foreach ($selected_fields as $key) { 43 48 if (array_key_exists($key, $all_fields)) { … … 45 50 } 46 51 } 47 52 48 53 return $extracted_fields; 49 54 } 50 55 51 56 public function eau_extract_relative_url($url) 52 57 { 53 58 return preg_replace('/^(http)?s?:?\/\/[^\/]*(\/?.*)$/i', '$2', '' . $url); 54 59 } 55 60 56 61 public function eau_is_checked($name, $value) 57 62 { … … 61 66 } 62 67 } 63 68 64 69 return false; 65 70 } 66 67 71 72 68 73 /** 69 74 * @param $selected_post_type … … 81 86 public function eau_generate_output($selected_post_type, $post_status, $post_author, $exclude_domain, $post_per_page, $offset, $export_type, $export_fields, $csv_name, $posts_from, $posts_upto) 82 87 { 83 88 84 89 $data_array = array(); 85 90 $html_row = ''; 86 91 $counter = 0; 87 92 88 93 if ($post_author == "all") { 89 94 $post_author = ""; 90 95 } 91 96 92 97 if ($post_per_page == "all" && $offset == "all") { 93 98 $post_per_page = -1; 94 99 $offset = ""; 95 100 } 96 97 switch ($post_status) { 98 case "all": 99 $post_status = array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'trash'); 100 break; 101 case 'publish': 102 $post_status = 'publish'; 103 break; 104 case 'pending': 105 $post_status = 'pending'; 106 break; 107 case 'draft': 108 $post_status = 'draft'; 109 break; 110 case 'future': 111 $post_status = 'future'; 112 break; 113 case 'private': 114 $post_status = 'private'; 115 break; 116 case 'trash': 117 $post_status = 'trash'; 118 break; 119 default: 120 $post_status = 'publish'; 121 break; 122 } 123 101 102 if (in_array("all", $post_status)) { 103 $post_status = array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'trash'); 104 } 105 if (in_array("draft", $post_status)) { 106 $post_status[] = 'auto-draft'; 107 } 108 124 109 $posts_query = new \WP_Query(array( 125 110 'post_type' => $selected_post_type, … … 138 123 ) 139 124 )); 140 125 141 126 if (!$posts_query->have_posts()) { 142 127 echo "<div class='notice notice-error' style='width: 93%'>" . __("no result found in that range, please <strong>reselect and try again</strong>!", Constants::PLUGIN_TEXT_DOMAIN) . "</div>"; 143 128 return; 144 129 } 145 130 146 131 $total_results = $posts_query->found_posts; 147 132 $counter = 1; 148 133 149 134 while ($posts_query->have_posts()) { 150 135 $posts_query->the_post(); … … 152 137 $post_type = get_post_type($post_id); 153 138 $taxonomies = get_object_taxonomies($post_type); 154 139 140 $post_terms = []; 141 foreach ($taxonomies as $taxonomy) { 142 if (strpos($taxonomy, 'cat') !== false || strpos($taxonomy, 'tag') !== false) { 143 $terms = get_the_terms($post_id, $taxonomy); 144 if ($terms && !is_wp_error($terms)) { 145 $post_terms[$taxonomy] = $terms; 146 } 147 } 148 } 149 155 150 $row = array(); 156 151 foreach ($export_fields as $field) { … … 167 162 case 'categories': 168 163 $categories = array(); 169 foreach ($ taxonomies as $taxonomy) {164 foreach ($post_terms as $taxonomy => $terms) { 170 165 if (strpos($taxonomy, 'cat') !== false) { 171 $categories[] = strip_tags(get_the_term_list($post_id, $taxonomy, '', ', ')); 166 foreach ($terms as $term) { 167 $categories[] = esc_html($term->name); 168 } 172 169 } 173 170 } 174 171 $row[] = implode(', ', $categories); 175 172 break; 173 case 'category_urls': 174 $categories_urls = array(); 175 foreach ($post_terms as $taxonomy => $terms) { 176 if (strpos($taxonomy, 'cat') !== false) { 177 foreach ($terms as $term) { 178 $category_url = get_term_link($term); 179 if (!is_wp_error($category_url)) { 180 $categories_urls[] = esc_url($category_url); 181 } 182 } 183 } 184 } 185 $row[] = implode(', ', $categories_urls); 186 break; 176 187 case 'tags': 177 188 $tags = array(); 178 foreach ($ taxonomies as $taxonomy) {189 foreach ($post_terms as $taxonomy => $terms) { 179 190 if (strpos($taxonomy, 'tag') !== false) { 180 $tags[] = strip_tags(get_the_term_list($post_id, $taxonomy, '', ', ')); 191 foreach ($terms as $term) { 192 $tags[] = esc_html($term->name); 193 } 181 194 } 182 195 } 183 196 $row[] = implode(', ', $tags); 184 197 break; 198 case 'tag_urls': 199 $tags_urls = array(); 200 foreach ($post_terms as $taxonomy => $terms) { 201 if (strpos($taxonomy, 'tag') !== false) { 202 foreach ($terms as $term) { 203 $tags_urls[] = esc_url(get_term_link($term)); 204 } 205 } 206 } 207 $row[] = implode(', ', $tags_urls); 208 break; 185 209 case 'author': 186 210 $row[] = htmlspecialchars_decode(get_the_author()); … … 192 216 $row[] = get_the_modified_date('Y-m-d H:i:s', $post_id); 193 217 break; 194 } 195 } 196 218 case 'status': 219 $row[] = ucfirst(get_post_status($post_id)); 220 break; 221 } 222 } 223 197 224 if ($export_type == 'text') { 198 225 $data_array[] = $row; 199 226 } else { 200 227 201 228 $html_row .= '<tr>'; 202 229 $html_row .= '<td>' . $counter . '</td>'; … … 209 236 } 210 237 wp_reset_postdata(); 211 238 212 239 self::eau_export_data($data_array, $html_row, $total_results, $export_fields, $export_type, $csv_name); 213 240 } 214 215 241 242 216 243 public function eau_export_data($data_array, $row, $total_results, $export_fields, $export_type, $csv_name) 217 244 { 218 245 219 246 $file_path = wp_upload_dir(); 220 247 221 248 switch ($export_type) { 222 249 223 250 case "text": 224 251 225 252 $file = $file_path['path'] . "/" . $csv_name . '.CSV'; 226 253 $myfile = @fopen($file, "w") or die("<div class='error' style='width: 95.3%; margin-left: 2px;'>" . __("Unable to create a file on your server! (either invalid name supplied or permission issue)", Constants::PLUGIN_TEXT_DOMAIN) . "</div>"); 227 254 fprintf($myfile, "\xEF\xBB\xBF"); 228 255 229 256 $csv_url = esc_url($file_path['url'] . "/" . $csv_name . ".CSV"); 230 257 231 258 $field_labels = self::eau_get_field_labels($export_fields); 232 259 233 260 fputcsv($myfile, $field_labels); 234 261 235 262 foreach ($data_array as $data_row) { 236 263 fputcsv($myfile, $data_row); 237 264 } 238 265 239 266 fclose($myfile); 240 267 241 268 echo "<div class='updated' style='width: 97%'>Data exported successfully! <a href='" . $csv_url . "' target='_blank'><strong>" . __('Click here', Constants::PLUGIN_TEXT_DOMAIN) . "</strong></a> " . __('to Download', Constants::PLUGIN_TEXT_DOMAIN) . ".</div>"; 242 269 echo "<div class='notice notice-warning' style='width: 97%'>" . __('Once you have downloaded the file, it is recommended to delete file from the server, for security reasons.', Constants::PLUGIN_TEXT_DOMAIN) . " <a href='" . wp_nonce_url(admin_url('tools.php?page=extract-all-urls-settings&del=y&f=') . base64_encode($file)) . "' ><strong>" . __('Click Here', Constants::PLUGIN_TEXT_DOMAIN) . "</strong></a> " . __('to delete the file. And don\'t worry, you can always regenerate anytime. :)', Constants::PLUGIN_TEXT_DOMAIN) . "</div>"; 243 270 echo "<div class='notice notice-info' style='width: 97%'><strong>" . __('Total', Constants::PLUGIN_TEXT_DOMAIN) . "</strong> " . __('number of links', Constants::PLUGIN_TEXT_DOMAIN) . ": <strong>" . esc_html($total_results,) . "</strong>.</div>"; 244 271 245 272 break; 246 273 247 274 case "here": 248 275 249 276 echo "<h1 align='center' style='padding: 10px 0;'><strong>" . __('Below is a list of Exported Data:', Constants::PLUGIN_TEXT_DOMAIN) . "</strong></h1>"; 250 277 echo "<h2 align='center' style='font-weight: normal;'>" . __('Total number of links', Constants::PLUGIN_TEXT_DOMAIN) . ": <strong>" . esc_html($total_results) . "</strong>.</h2>"; 251 278 252 279 echo '<table id="outputData" class="wp-list-table widefat fixed striped">'; 253 280 echo '<thead><tr>'; 254 281 255 282 $field_labels = self::eau_get_field_labels($export_fields, $hash = true); 256 283 257 284 foreach ($field_labels as $label) { 258 285 echo '<th>' . ucfirst($label) . '</th>'; 259 286 } 260 287 261 288 echo '</tr></thead><tbody>'; 262 289 echo $row; 263 290 echo '</tbody></table>'; 264 291 265 292 break; 266 293 267 294 default: 268 295 269 296 echo __('Sorry, you missed export type, Please', Constants::PLUGIN_TEXT_DOMAIN) . " <strong>" . __('Select Export Type', Constants::PLUGIN_TEXT_DOMAIN) . "</strong> " . __('and try again!', Constants::PLUGIN_TEXT_DOMAIN) . " :)"; 270 297 break; 271 298 } 272 299 } 273 274 300 } 275 301 -
export-all-urls/trunk/extract-all-urls-settings.php
r2990491 r3237856 72 72 $selected_post_type = isset($_POST['post-type']) ? $_POST['post-type'] : 'any'; 73 73 $selected_export_fields = isset($_POST['export_fields']) ? $_POST['export_fields'] : ($form_submitted ? array() : array('url', 'title')); 74 $selected_post_status = isset($_POST['post-status']) ? $_POST['post-status'] : 'publish';74 $selected_post_status = isset($_POST['post-status']) ? $_POST['post-status'] : ($form_submitted ? array() : array('publish')); 75 75 $selected_user = isset($_POST['post-author']) ? $_POST['post-author'] : 'all'; 76 76 $selected_export_type = isset($_POST['export-type']) ? $_POST['export-type'] : 'here'; … … 129 129 130 130 <?php foreach ($post_status as $value => $label) : ?> 131 <label><input type=" radio" name="post-status" value="<?php echo $value; ?>" <?php echo $value == $selected_post_status? 'checked' : ''; ?>> <?php echo $label; ?></label><br />131 <label><input type="checkbox" name="post-status[]" value="<?php echo $value; ?>" <?php echo in_array($value, $selected_post_status) ? 'checked' : ''; ?>> <?php echo $label; ?></label><br /> 132 132 <?php endforeach; ?> 133 133 … … 312 312 $export_type = sanitize_text_field($_POST['export-type']); 313 313 $export_fields = map_deep($_POST['export_fields'], 'sanitize_text_field'); 314 $post_status = sanitize_text_field($_POST['post-status']);314 $post_status = map_deep($_POST['post-status'], 'sanitize_text_field'); 315 315 $post_author = sanitize_text_field($_POST['post-author']); 316 316 $exclude_domain = isset($_POST['exclude-domain']) ? sanitize_text_field($_POST['exclude-domain']) : null; -
export-all-urls/trunk/extract-all-urls.php
r3112244 r3237856 5 5 Plugin URI: https://AtlasGondal.com/ 6 6 Description: This plugin enables you to extract information such as Title, URL, Categories, Tags, Author, as well as Published and Modified dates for built-in post types (e.g., post, page) or any other custom post types present on your site. You have the option to display the output in the dashboard or export it as a CSV file. This can be highly beneficial for tasks like migration, SEO analysis, and security audits. 7 Version: 4.7.17 Version: 5.0 8 8 Author: Atlas Gondal 9 9 Author URI: https://AtlasGondal.com/ -
export-all-urls/trunk/readme.txt
r3194637 r3237856 5 5 Requires at least: 3.1 6 6 Tested up to: 6.7.1 7 Stable tag: 4.7.17 Stable tag: 5.0 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later … … 20 20 * URL 21 21 * Categories 22 * Category URLs 22 23 * Tags 24 * Tag URLs 23 25 * Author 24 26 * Published Date 25 27 * Modified Date 28 * Status 26 29 27 30 The data can be filtered by post type, post status, date range, and author before extraction, and the plugin also provides the option to export using a specific post range. … … 134 137 135 138 == Changelog == 139 140 = 5.0 = 141 * New - additional export fields added (status, category urls, tag urls) 142 * New - allows multiple post status selection 143 * Improvement - few backend refinements to improve performance 144 * Compatibility - tested with Wordpress 6.7.1 136 145 137 146 = 4.7.1 = … … 233 242 == Upgrade Notice == 234 243 235 = 4.7.1 = 236 * Compatibility - tested with WordPress 6.7-alpha-58656 244 = 5.0 = 245 * New - additional export fields added (status, category urls, tag urls) 246 * New - allows multiple post status selection 247 * Improvement - few backend refinements to improve performance 248 * Compatibility - tested with Wordpress 6.7.1
Note: See TracChangeset
for help on using the changeset viewer.