Changeset 3267685
- Timestamp:
- 04/07/2025 07:53:30 AM (12 months ago)
- Location:
- storecontrl-wp-connection/trunk
- Files:
-
- 5 edited
-
includes/admin/class-storecontrl-wp-connection-admin.php (modified) (3 diffs)
-
includes/admin/partials/storecontrl_wp_connection_settings_page.php (modified) (1 diff)
-
includes/woocommerce/class-storecontrl-woocommerce-functions.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
storecontrl-wp-connection.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
storecontrl-wp-connection/trunk/includes/admin/class-storecontrl-wp-connection-admin.php
r3258641 r3267685 10 10 $plugin_basename = STORECONTRL_WP_CONNECTION_PLUGIN_BASENAME; 11 11 add_filter( "plugin_action_links_$plugin_basename", array( $this, 'plugin_add_settings_link') ); 12 13 if(isset($_POST['btnDownloadLog'])) { 14 $this->downloadLogFile(); 15 } 16 } 12 add_filter('cron_schedules', array( $this, 'storecontrl_connect_cron_schedules') ); 13 add_action('admin_post_download_log', array($this, 'handle_log_download_request')); 14 } 15 16 public function handle_log_download_request() { 17 if ( 18 isset($_POST['btnDownloadLog']) && 19 current_user_can('manage_options') && 20 check_admin_referer('download_log_action', 'download_log_nonce') 21 ) { 22 $this->downloadLogFile(); 23 } 24 } 25 26 public function downloadLogFile() { 27 if ( ! current_user_can( 'manage_options' ) ) { 28 wp_die( 'Unauthorized', '403 Forbidden', array( 'response' => 403 ) ); 29 } 30 31 $filename = isset($_POST['btnDownloadLog']) ? sanitize_file_name($_POST['btnDownloadLog']) : ''; 32 33 $basedir = wp_upload_dir(); 34 $log_dir = $basedir['basedir'] . '/storecontrl/logs/'; 35 $full_path = realpath( $log_dir . $filename ); 36 37 if ( 38 ! $full_path || 39 strpos($full_path, realpath($log_dir)) !== 0 || 40 ! file_exists($full_path) 41 ) { 42 wp_die( 'Invalid file requested.', '403 Forbidden', array( 'response' => 403 ) ); 43 } 44 45 header('Content-Description: File Transfer'); 46 header('Content-Type: application/octet-stream'); 47 header('Content-Disposition: attachment; filename="' . basename($full_path) . '"'); 48 header('Expires: 0'); 49 header('Cache-Control: must-revalidate'); 50 header('Pragma: public'); 51 header('Content-Length: ' . filesize($full_path)); 52 readfile($full_path); 53 exit; 54 } 55 56 public function storecontrl_connect_cron_schedules($schedules) 57 { 58 if (!isset($schedules['storecontrl_connect'])) { 59 $schedules['storecontrl_connect'] = array( 60 'interval' => 300, 61 'display' => 'StoreContrl Connect | Every 5 minutes' 62 ); 63 } 64 return $schedules; 65 } 17 66 18 67 public function plugin_add_settings_link( $links ) { … … 404 453 $selectBox .= "</select>"; 405 454 406 // Display the form for selecting and downloading log files 407 echo "<form method='post' action='class-storecontrl-wp-connection-admin.php'>" . $selectBox . "<button type='submit' class='button button-primary' id='btnDownloadLog' name='btnDownloadLog' value='" . $firstReadFile . "' style='margin-left: 10px;'>".__('Download Log File', 'storecontrl-wp-connection-plugin')."</button>"; 455 echo $selectBox; 456 457 echo '<input type="hidden" name="action" value="download_log">'; 458 echo '<input id="btnDownloadLog" type="hidden" name="btnDownloadLog" value="' . $firstReadFile . '">'; 459 echo wp_nonce_field( 'download_log_action', 'download_log_nonce' ); 460 echo '<button style="margin-left: 10px;" type="submit" class="button button-primary">Download Log File</button>'; 408 461 409 462 // Make some space … … 1173 1226 } 1174 1227 1175 public function downloadLogFile() {1176 // Get information from the button1177 $basedir = wp_upload_dir();1178 $directory = $basedir['basedir'];1179 $directory = $directory . '/storecontrl/logs';1180 $file = sanitize_text_field($_POST['btnDownloadLog']);1181 $file = $directory . "/" . $file;1182 1183 header('Content-Description: File Transfer');1184 header('Content-Type: application/octet-stream');1185 header('Content-Disposition: attachment; filename="'.basename($file).'"');1186 header('Expires: 0');1187 header('Cache-Control: must-revalidate');1188 header('Pragma: public');1189 header('Content-Length: ' . filesize($file));1190 readfile($file);1191 exit;1192 }1193 1194 1228 public function resend_new_order_to_storecontrl() { 1195 1229 if (isset($_POST['order_id'])) { -
storecontrl-wp-connection/trunk/includes/admin/partials/storecontrl_wp_connection_settings_page.php
r2868726 r3267685 76 76 77 77 <div role="tabpanel" class="tab-pane fade" id="debug_section"> 78 <form method='post' action= 'options.php'>78 <form method='post' action="<?php echo admin_url('admin-post.php'); ?>"> 79 79 <?php 80 80 settings_fields( 'storecontrl_debug_options' ); -
storecontrl-wp-connection/trunk/includes/woocommerce/class-storecontrl-woocommerce-functions.php
r3226914 r3267685 888 888 } 889 889 890 //$order = wc_get_order( $post->ID );891 890 if (strlen(get_post_meta($order_id, 'order_returned_successfully_to_storecontrl', true)) > 0) { 892 891 //ORDER HAS BEEN SENT TO STORECONTRL -
storecontrl-wp-connection/trunk/readme.txt
r3258641 r3267685 5 5 Requires at least: 1.6.1 6 6 Tested up to: 6.7.2 7 Stable tag: 4.1. 37 Stable tag: 4.1.4 8 8 Requires PHP: 0.0 9 9 License: GPLv2 or later … … 93 93 == Changelog == 94 94 95 = 4.1.4 = 96 * Improved and secure log file download function 97 95 98 = 4.1.3 = 96 99 * New feature for cronjobs status -
storecontrl-wp-connection/trunk/storecontrl-wp-connection.php
r3258641 r3267685 4 4 Plugin URI: http://www.arture.nl/storecontrl 5 5 Description: The Wordpress plugin for connecting Woocommerce with StoreContrl Cloud. With the synchronizing cronjobs your products will be automatically processed, images added, and the categories set. Every 5 minutes all stock changes are processed. We provide a up-to-date plugin, easy setup and always the best support. 6 Version: 4.1. 36 Version: 4.1.4 7 7 Requires Plugins: woocommerce 8 8 Author: Arture
Note: See TracChangeset
for help on using the changeset viewer.