Changeset 3360514
- Timestamp:
- 09/12/2025 12:24:15 PM (5 months ago)
- Location:
- sirv/trunk
- Files:
-
- 7 edited
-
plugdata/css/wp-options.css (modified) (1 diff)
-
plugdata/includes/classes/exclude.class.php (modified) (5 diffs)
-
plugdata/js/wp-options.js (modified) (5 diffs)
-
plugdata/submenu_pages/settings.php (modified) (3 diffs)
-
plugdata/woo_templates/woo-product-template.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
sirv.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sirv/trunk/plugdata/css/wp-options.css
r3342799 r3360514 2339 2339 gap: 5px; 2340 2340 } 2341 2342 ul.sirv-option-folder-issues { 2343 color: red; 2344 margin-top: 0; 2345 } 2346 2347 ul.sirv-option-folder-issues li { 2348 margin-bottom: 0; 2349 } -
sirv/trunk/plugdata/includes/classes/exclude.class.php
r2934979 r3360514 12 12 13 13 $excludeInput = get_option($excludeType); 14 if ($excludeType == 'SIRV_EXCLUDE_FILES'){14 if ( $excludeType == 'SIRV_EXCLUDE_FILES' ) { 15 15 $currentPath = self::clearCurrentPath($currentPath); 16 } else if ($excludeType == 'SIRV_EXCLUDE_RESPONSIVE_FILES'){16 } else if ( $excludeType == 'SIRV_EXCLUDE_RESPONSIVE_FILES' ) { 17 17 $currentPath['src'] = self::clearCurrentPath($currentPath['src']); 18 18 } … … 42 42 protected static function loop($excludePaths, $currentPath){ 43 43 for ($i=0; $i < count($excludePaths); $i++) { 44 if (! is_array($currentPath)){45 if ( self::singleCheck($excludePaths[$i], $currentPath)) return true;46 } else{47 if( self::multipleCheck($excludePaths[$i], $currentPath)) return true;44 if ( ! is_array($currentPath) ) { 45 if ( self::singleCheck($excludePaths[$i], $currentPath) ) return true; 46 } else { 47 if( self::multipleCheck($excludePaths[$i], $currentPath) ) return true; 48 48 } 49 49 } … … 56 56 $expression = self::convertExcludeStrToRegEx($excludePath); 57 57 58 if ( $excludePath == '/' ) return self::is_homepage($currentPath); 59 58 60 return self::check($currentPath, $expression); 59 61 } … … 62 64 protected static function multipleCheck($excludePath, $currentPath){ 63 65 foreach ($currentPath as $attrName => $attrVal) { 64 if ($attrName == 'src'){66 if ( $attrName == 'src' ) { 65 67 $result = self::singleCheck($excludePath, $attrVal); 66 } else if($attrName == 'class'){68 } else if ( $attrName == 'class' ) { 67 69 $explodedClasses = explode(" ", $attrVal); 68 70 $result = in_array($excludePath, $explodedClasses); 69 } else{71 } else { 70 72 $result = $excludePath == $attrVal; 71 73 } 72 74 73 if( $result) return true;75 if( $result ) return true; 74 76 } 75 77 … … 81 83 return preg_match('/' . $expression . '/', $path) != false; 82 84 } 85 86 public static function is_homepage($currentPath){ 87 if ($currentPath == '/' || is_home() || is_front_page() ) return true; 88 89 $home_url = get_home_url(); 90 91 if ( $home_url === "" || $home_url === false ) return false; 92 93 $home_url .= Utils::endsWith($home_url, '/') ? '' : '/'; 94 95 $currentPathInfo = parse_url($currentPath); 96 $home_url_info = parse_url($home_url); 97 98 $checkCurrentPath = isset($currentPathInfo['query']) ? $currentPathInfo['path'] . '?' . $currentPathInfo['query'] : $currentPathInfo['path']; 99 100 101 if ( $checkCurrentPath == $home_url_info['path'] ) return true; 102 103 return false; 104 } 105 83 106 } -
sirv/trunk/plugdata/js/wp-options.js
r3342799 r3360514 38 38 39 39 Validator.prototype.email = function(fieldValue){ 40 //let regex = /^((?!\.)[\w-_.]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$/i;41 //let regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/i;42 40 let regex = /^[a-z0-9!#$%&'"*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'"*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i; 43 41 return !regex.test(fieldValue); … … 63 61 result = stringsArr.filter(function(str){return fieldValue.indexOf(str) !== -1}); 64 62 return result.length > 0; 63 } 64 65 66 Validator.prototype.url = function(fieldValue){ 67 const regex = /^http(s)?:\/\//i; 68 return regex.test(fieldValue); 69 } 70 71 72 Validator.prototype.folder = function(fieldValue){ 73 const regex = /^[a-zA-Z0-9\-\+\_\.\!\*\'\( \)\/\s]+$/i; 74 75 return !regex.test(fieldValue); 65 76 } 66 77 … … 811 822 //sanitize folder name on sirv 812 823 $('#sirv-save-options').on('submit', function () { 813 let folderOnSirv = $("[name='SIRV_FOLDER']").val(); 814 let sanitizedFolderOnSirv = folderOnSirv == '' ? 'WP_' + get_current_domain() : folderOnSirv.replace(/^[\/]*(.*?)[\/]*$/ig, '$1'); 815 if(sanitizedFolderOnSirv == '') sanitizedFolderOnSirv = 'WP_' + get_current_domain(); 816 $("[name='SIRV_FOLDER']").val(sanitizedFolderOnSirv); 824 const folderOnSirv = $("[name='SIRV_FOLDER']").val().trim(); 825 const $folderOptionIssuesBlock = $(".sirv-option-folder-issues"); 826 const validator = new Validator(); 827 const issues = []; 828 829 $folderOptionIssuesBlock.empty(); 830 831 if(validator.invalidValidate(folderOnSirv, validator.empty)){ 832 issues.push("Folder cannot be empty"); 833 } 834 835 if (folderOnSirv.startsWith("/") || folderOnSirv.endsWith("/")) { 836 issues.push("Folder cannot start or end with /"); 837 } 838 839 if(validator.invalidValidate(folderOnSirv, validator.url)){ 840 issues.push("Folder cannot be a URL"); 841 } 842 843 if (validator.invalidValidate(folderOnSirv, validator.folder)) { 844 issues.push("Folder can contain only letters, numbers, - + _ . ! * ' ( ) / or space."); 845 } 846 847 if (issues.length > 0) { 848 showInputIssues($folderOptionIssuesBlock, issues); 849 850 return false 851 } 852 853 /* let sanitizedFolderOnSirv = folderOnSirv == '' ? 'WP_' + get_current_domain() : folderOnSirv.replace(/^[\/]*(.*?)[\/]*$/ig, '$1'); 854 if(sanitizedFolderOnSirv == '') sanitizedFolderOnSirv = 'WP_' + get_current_domain(); */ 855 $("[name='SIRV_FOLDER']").val(folderOnSirv); 817 856 818 857 return true; 819 858 }); 859 860 //event listener for option sirv-text-to-input-option-text-cancel 861 $(document).on('sirv-text-to-input-option-text-cancel', function(e) { 862 const id = e.detail.id; 863 864 switch (id) { 865 case "foldername": 866 $(".sirv-option-folder-issues").empty(); 867 $(".sirv-warning-on-folder-change").addClass("sirv-hide"); 868 break; 869 870 default: 871 break; 872 } 873 }); 874 875 876 function showInputIssues(element, issues) { 877 const documentFragment = $(document.createDocumentFragment()); 878 879 issues.forEach(issue => { 880 documentFragment.append($(`<li>${issue}</li>`)); 881 }); 882 883 element.append(documentFragment); 884 } 820 885 821 886 … … 855 920 856 921 const $button = $(this); 922 const id = $button.attr('data-id') || ""; 857 923 const type = $button.attr('data-type') 858 924 const $showValuePart = $(this).parent().find('.sirv-text-to-input-option-text-part'); … … 873 939 $showValuePart.show(); 874 940 $inputValuePart.hide(); 941 942 if (id){ 943 document.dispatchEvent( 944 new CustomEvent('sirv-text-to-input-option-text-cancel', { 945 detail: { 946 id 947 }, 948 }) 949 ); 950 } 875 951 } 876 952 } -
sirv/trunk/plugdata/submenu_pages/settings.php
r3342799 r3360514 70 70 <?php 71 71 if ($is_accountInfo_muted) { 72 //$domains_mute_message = 'Option is disabled due to exceeding API usage rate limit. Refresh this page in <b>' . Utils::get_minutes(sirv_get_mute_expired_at($accountInfoEndpoint)) . ' minutes</b>';73 72 $domains_mute_message = 'You\'ve exceeded your hourly API limit. This option is temporarily inaccessible for <b>' . Utils::get_minutes(sirv_get_mute_expired_at($accountInfoEndpoint)) . ' minutes</b>. Please try again after that or inform the <a href="https://sirv.com/help/support/#support" target="_blank">Sirv support team</a> if you keep seeing this message.'; 74 73 echo '<div class="sirv-message-container">' . Utils::showMessage($domains_mute_message, 'warning') . '</div>'; … … 90 89 ?> 91 90 </select> 91 92 <?php if ($is_accountInfo_muted || count($domains) <= 1) { ?> 93 <input type="hidden" id="sirv_choose_domain" name="SIRV_CDN_URL" value="<?php echo $sirvCDNurl; ?>"> 94 <?php } ?> 95 92 96 </td> 93 97 </tr> … … 114 118 type="text" 115 119 style="min-width: auto;" 116 placeholder=" <?php echo htmlspecialchars($sirv_folder); ?>"120 placeholder="e.g. WordPress or WP/media" 117 121 value="<?php echo htmlspecialchars($sirv_folder); ?>" 118 name="SIRV_FOLDER" data-restore-value="<?php echo htmlspecialchars($sirv_folder); ?>" 119 > 122 name="SIRV_FOLDER" data-restore-value="<?php echo htmlspecialchars($sirv_folder); ?>"> 120 123 </div> 121 <a class="sirv-option-edit" href="#" data-type="render" >Change</a>124 <a class="sirv-option-edit" href="#" data-type="render" data-id="foldername">Change</a> 122 125 </div> 123 126 </div> 127 <ul class="sirv-option-folder-issues"></ul> 124 128 <div class="sirv-push-message-container sirv-push-message-warning sirv-hide sirv-warning-on-folder-change"> 125 129 <div class="sirv-push-message sirv-push-message-warning-icon"> -
sirv/trunk/plugdata/woo_templates/woo-product-template.php
r3332255 r3360514 5 5 * This template for displaying Sirv Media Viewer in WC product pages 6 6 * 7 * @version 9. 0.07 * @version 9.7.0 8 8 */ 9 9 -
sirv/trunk/readme.txt
r3342799 r3360514 6 6 Requires at least: 3.0.1 7 7 Tested up to: 6.8.2 8 Stable tag: 8.0. 18 Stable tag: 8.0.2 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html … … 224 224 == Changelog == 225 225 226 = 8.0.2 (2025-09-12) = 227 * Fixed issue with incorrect display of "Folder name on Sirv". 228 * Added validation for option "Folder name on Sirv". 229 * Added option to use "/" to exclude home page from image replacement. 230 226 231 = 8.0.1 (2025-08-11) = 227 232 * Fixed issue that could prevent "Folder name on Sirv" from working. -
sirv/trunk/sirv.php
r3342799 r3360514 5 5 * Plugin URI: http://sirv.com 6 6 * Description: Fully-automatic image optimization, next-gen formats (WebP), responsive resizing, lazy loading and CDN delivery. Every best-practice your website needs. Use "Add Sirv Media" button to embed images, galleries, zooms, 360 spins and streaming videos in posts / pages. Stunning media viewer for WooCommerce. Watermarks, text titles... every WordPress site deserves this plugin! <a href="admin.php?page=sirv/data/options.php">Settings</a> 7 * Version: 8.0. 17 * Version: 8.0.2 8 8 * Requires PHP: 5.6 9 9 * Requires at least: 3.0.1 … … 16 16 17 17 18 define('SIRV_PLUGIN_VERSION', '8.0. 1');18 define('SIRV_PLUGIN_VERSION', '8.0.2'); 19 19 define('SIRV_PLUGIN_DIR', 'sirv'); 20 20 define('SIRV_PLUGIN_SUBDIR', 'plugdata'); … … 2024 2024 $exclude_str = ''; 2025 2025 2026 if( !empty($new_data)){2026 if( !empty($new_data) ){ 2027 2027 $data = Exclude::parseExcludePaths($new_data); 2028 2028 $home_url = home_url(); … … 6069 6069 6070 6070 $email = trim(strtolower($_POST['email'])); 6071 $a lias= $_POST['sirv_account'];6071 $account_token = $_POST['sirv_account']; 6072 6072 6073 6073 $sirvAPIClient = sirv_getAPIClient(); 6074 6074 6075 if ( !empty($a lias) ) {6076 $response = $sirvAPIClient->setupClientCredentials($a lias);6075 if ( !empty($account_token) ) { 6076 $response = $sirvAPIClient->setupClientCredentials($account_token); 6077 6077 if ( $response['status'] ) { 6078 6078 update_option('SIRV_ACCOUNT_EMAIL', sanitize_email($email));
Note: See TracChangeset
for help on using the changeset viewer.