Changeset 3066207
- Timestamp:
- 04/07/2024 09:13:56 AM (4 months ago)
- Location:
- easy-pdf-restaurant-menu-upload
- Files:
-
- 27 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
easy-pdf-restaurant-menu-upload/tags/1.7.1/plugin-config.json
r3002932 r3066207 30 30 "pre_selected_value": false, 31 31 "additional_text": "Currently live:<span style='font-weight: bold'>{{current_lunch_menu_filename}}</span>", 32 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='lunch' linktext='Lunch menu'] ",32 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='lunch' linktext='Lunch menu']", 33 33 "name": "Lunch Menu", 34 34 "save_in_db": false … … 41 41 "pre_selected_value": false, 42 42 "additional_text": "Currently live:<span font-weight: bold'>{{current_general_menu_filename}}</span>", 43 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='general' linktext='General Menu'] ",43 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='general' linktext='General Menu']", 44 44 "name": "General Menu", 45 45 "save_in_db": false -
easy-pdf-restaurant-menu-upload/trunk/class/class-admin-html-formfields-nsc_eprm.php
r2533652 r3066207 13 13 case "checkbox": 14 14 return $this->create_checkbox(); 15 break;16 15 case "textarea": 17 16 return $this->create_textarea(); 18 break;19 17 case "text": 20 18 return $this->create_text(); 21 break;22 19 case "longtext": 23 20 return $this->create_text("long"); 24 break;25 21 case "select": 26 22 return $this->create_select(); 27 break;28 23 case "radio": 29 24 return $this->create_radio(); 30 break;31 25 case "button": 32 26 return $this->create_button(); 33 break;34 27 case "display": 35 28 return $this->create_display(); 36 break;37 29 case "file": 38 30 return $this->create_file(); 39 break;40 31 case "hidden": 41 32 return $this->create_hidden_field(); 42 break;43 33 default: 44 34 return $this->field->pre_selected_value; 45 break;46 35 } 47 36 } … … 97 86 foreach ($this->field->selectable_values as $selectable_value) { 98 87 $select = ""; 99 if ($selectable_value->value == $this->field->pre_selected_value) {$select = " selected";} 88 if ($selectable_value->value == $this->field->pre_selected_value) { 89 $select = " selected"; 90 } 100 91 $html .= '<option value="' . $selectable_value->value . '"' . $select . '>' . $selectable_value->name . '</option>'; 101 92 } … … 109 100 foreach ($this->field->selectable_values as $selectable_value) { 110 101 $select = ""; 111 if ($selectable_value->value == $this->field->pre_selected_value) {$select = " checked";} 102 if ($selectable_value->value == $this->field->pre_selected_value) { 103 $select = " checked"; 104 } 112 105 $html .= '<input id="ff_' . $this->prefix . $this->field->field_slug . '" type="radio" name="' . $this->prefix . $this->field->field_slug . '" value="' . $selectable_value->value . '"' . $select . '>' . $selectable_value->name . ' '; 113 106 } -
easy-pdf-restaurant-menu-upload/trunk/class/class_admin_easy_pdf_restaurant_menu.php
r3002932 r3066207 3 3 class nsc_easy_pdf_restaurant_menu 4 4 { 5 6 5 private $adminMessage = array('error' => array(), 'update' => array()); 7 6 private $pluginPath; … … 44 43 . implode(", ", array_keys($this->allowedExt)) 45 44 . ". You uploaded: " . $this->uploadedFileExt . "!"); 46 47 } else { 48 $upload_status = move_uploaded_file($uploadedFile['tmp_name'], $this->return_menu_upload_path() 49 . $this->return_menu_file_name_without_extension($type) 50 . "." . $this->uploadedFileExt 51 ); 52 if ($upload_status === true) { 53 update_option('nsc_eprm_' . $type . '_orifilename', $oriFileName); 54 $this->add_admin_message('update', "File " . $oriFileName . " successfully uploaded and already live!"); 55 } else { 56 $this->add_admin_message('error', "Not able to upload file!"); 57 } 58 } 45 return false; 46 47 } 48 49 $useOriFileName = $this->plugin_configs->get_option_nsc_eprm("orifilename_for_download") == true ? true : false; 50 $upload_status = move_uploaded_file( 51 $uploadedFile['tmp_name'], 52 $this->return_menu_upload_path() 53 . $this->return_menu_file_name_without_extension($type, $useOriFileName) 54 . "." . $this->uploadedFileExt 55 ); 56 57 if ($upload_status !== true) { 58 $this->add_admin_message('error', "Not able to upload file!"); 59 return false; 60 } 61 62 update_option('nsc_eprm_' . $type . '_orifilename', $oriFileName); 63 $this->add_admin_message('update', "File " . $oriFileName . " successfully uploaded and already live!"); 64 59 65 } 60 66 … … 63 69 $attr = $this->clean_input->sanitize_user_input_nsc_eprm($attr); 64 70 65 $atts = shortcode_atts(array( 66 'restaurant_menu_type' => 'general', 67 'linktext' => '', 68 'css_class' => 'nsc_eprm_download_link', 69 ), $attr); 71 $atts = shortcode_atts( 72 array( 73 'restaurant_menu_type' => 'general', 74 'linktext' => '', 75 'css_class' => 'nsc_eprm_download_link', 76 ), 77 $attr 78 ); 70 79 return $this->create_href_link($atts['restaurant_menu_type'], $atts['linktext'], array("class" => $atts['css_class'], "id" => "nsceprm_" . $atts['restaurant_menu_type'])); 71 80 } … … 75 84 $attr = $this->clean_input->sanitize_user_input_nsc_eprm($attr); 76 85 77 $atts = shortcode_atts(array( 78 'restaurant_menu_type' => 'general', 79 'cachebuster' => true, 80 ), $attr); 86 $atts = shortcode_atts( 87 array( 88 'restaurant_menu_type' => 'general', 89 'cachebuster' => true, 90 ), 91 $attr 92 ); 81 93 return $this->nsc_eprm_return_download_url($atts['restaurant_menu_type'], $atts['cachebuster']); 82 94 } … … 125 137 } 126 138 127 private function return_menu_file_name_without_extension($type) 128 { 139 private function return_menu_file_name_without_extension($type, $returnOriFilename) 140 { 141 if ($returnOriFilename == true) { 142 $orifilename = get_option('nsc_eprm_' . $type . '_orifilename'); 143 $orifilenameWithoutExtension = pathinfo($orifilename, PATHINFO_FILENAME); 144 $file_name = preg_replace('/[^a-z0-9\._-]+/', '-', strtolower($orifilenameWithoutExtension)); 145 $file_name = apply_filters('file_name_without_extension_nsc_eprm', $file_name, $type); 146 return $file_name; 147 } 148 129 149 $type = sanitize_file_name($type); 130 150 $file_name = preg_replace('/[^a-z0-9\._-]+/', '-', strtolower(get_bloginfo('name') . "-menu-" . $type)); … … 174 194 { 175 195 $files = $this->scan_dir($this->return_menu_upload_path()); 196 176 197 177 198 if (!is_array($files)) { … … 188 209 $original_file_name = $this->plugin_configs->get_option_nsc_eprm($type['menutype'] . "_orifilename", "none"); 189 210 $extension = pathinfo($original_file_name, PATHINFO_EXTENSION); 190 if ($file === $this->return_menu_file_name_without_extension($type['menutype']) . "." . $extension) { 211 $fileNameOfType = $this->return_menu_file_name_without_extension($type['menutype'], $useOriFileName) . "." . $extension; 212 213 if ($file === $fileNameOfType) { 214 $file_needed = true; 215 break; 216 } 217 218 // not found. maybe recently toggled "use orifilename". So try to migrate. 219 $fileNameOfTypeNoToggle = $this->return_menu_file_name_without_extension($type['menutype'], !$useOriFileName) . "." . $extension; 220 if ($file === $fileNameOfTypeNoToggle) { 221 $currentFilePath = $this->return_menu_upload_path() . $file; 222 $targetFilePath = $this->return_menu_upload_path() . $fileNameOfType; 223 rename( 224 $currentFilePath, 225 $targetFilePath 226 ); 191 227 $file_needed = true; 192 228 break; … … 237 273 $uploadDirArray = wp_upload_dir(); 238 274 239 $defaultUploadDirPath = realpath($uploadDirArray['basedir']);240 275 $defaultUploadDirURL = $uploadDirArray['baseurl']; 241 276 … … 248 283 private function return_menu_file_name_for_download($type) 249 284 { 250 $filename = "error_no_file_found_please_upload_in_MEDIA-EASY_PDF_MENU.";251 285 $files = $this->scan_dir($this->return_menu_upload_path()); 252 286 253 287 if (!is_array($files)) { 254 return $fileName; 255 } 288 return "error_files_is_not_an_array_should_not_happen"; 289 } 290 291 $useOriFileName = $this->plugin_configs->get_option_nsc_eprm("orifilename_for_download") == true ? true : false; 292 256 293 foreach ($files as $file) { 257 if (pathinfo($file, PATHINFO_FILENAME) == $this->return_menu_file_name_without_extension($type )) {258 $filename =$file;259 break;260 261 } 262 return $filename;294 if (pathinfo($file, PATHINFO_FILENAME) == $this->return_menu_file_name_without_extension($type)) { 295 $file; 296 297 } 298 299 return ; 263 300 } 264 301 … … 268 305 269 306 if (empty($anchorText)) { 270 $file Name = $this->plugin_configs->get_option_nsc_eprm($menuType . "_orifilename", "none");271 $file Name = pathinfo($fileName, PATHINFO_FILENAME);272 $anchorText = $file Name;307 $fileame = $this->plugin_configs->get_option_nsc_eprm($menuType . "_orifilename", "none"); 308 $fileame, PATHINFO_FILENAME); 309 $anchorText = $file; 273 310 } 274 311 -
easy-pdf-restaurant-menu-upload/trunk/nsc_easy-pdf-restaurant-menu.php
r3002932 r3066207 5 5 Author: Beautiful WP | made in Germany 6 6 Author URI: https://beautiful-wp.com/ 7 Version: 1. 7.17 Version: 1. 8 8 Text Domain: easy-pdf-restaurant-menu 9 9 License: GPL3 -
easy-pdf-restaurant-menu-upload/trunk/plugin-config.json
r2859208 r3066207 30 30 "pre_selected_value": false, 31 31 "additional_text": "Currently live:<span style='font-weight: bold'>{{current_lunch_menu_filename}}</span>", 32 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='lunch' linktext='Lunch menu'] ",32 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='lunch' linktext='Lunch menu']", 33 33 "name": "Lunch Menu", 34 34 "save_in_db": false … … 41 41 "pre_selected_value": false, 42 42 "additional_text": "Currently live:<span font-weight: bold'>{{current_general_menu_filename}}</span>", 43 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='general' linktext='General Menu'] ",43 "helpertext": "Shortcode: [nsc_eprm_menu_link restaurant_menu_type='general' linktext='General Menu']", 44 44 "name": "General Menu", 45 45 "save_in_db": false … … 65 65 "helpertext": "If you check this all admin users are redirected after login to the menu upload page. If unchecked, only users with role 'Restaurant Menu Uploader' are redirected.", 66 66 "name": "Force redirect for all after login", 67 68 69 70 71 72 73 74 75 76 77 67 78 "save_in_db": true 68 79 }, -
easy-pdf-restaurant-menu-upload/trunk/readme.txt
r3002932 r3066207 3 3 Requires at least: 4.0 4 4 Donate link: https://www.paypal.me/nikelschubert/6.00EUR 5 Tested up to: 6. 45 Tested up to: 6. 6 6 Requires PHP: 5.3 7 Stable tag: 1. 7.17 Stable tag: 1. 8 8 License: GPLv3 9 9 … … 62 62 63 63 == Changelog == 64 65 66 67 64 68 65 69 = 1.7.1 =
Note: See TracChangeset
for help on using the changeset viewer.