Converter for Media – Optimize images | Convert WebP & AVIF - Version 3.2.0

Version Description

(2021-09-12) = * [Removed] Filter webpc_files_paths * [Removed] Filter webpc_dir_excluded * [Changed] Error handling when converting images * [Added] Filter webpc_supported_source_file to exclude paths to files from converting * [Added] Filter webpc_supported_source_directory to exclude paths to directories from converting * [Added] Modifications to appearance of plugin settings page

Download this release

Release Info

Developer mateuszgbiorczyk
Plugin Icon 128x128 Converter for Media – Optimize images | Convert WebP & AVIF
Version 3.2.0
Comparing to
See all releases

Code changes from version 3.1.1 to 3.2.0

Files changed (84) hide show
  1. assets/build/css/styles.css +1 -1
  2. assets/build/js/scripts.js +1 -1
  3. readme.txt +36 -6
  4. src/Action/ConvertAttachment.php +1 -4
  5. src/Action/ConvertDir.php +4 -4
  6. src/Action/ConvertPaths.php +13 -19
  7. src/Action/RegenerateAll.php +1 -4
  8. src/Conversion/Cron/Event.php +3 -5
  9. src/Conversion/Directory/DirectoryIntegration.php +0 -13
  10. src/Conversion/DirectoryFiles.php +19 -22
  11. src/Conversion/Endpoint/EndpointAbstract.php +1 -4
  12. src/Conversion/Endpoint/EndpointIntegration.php +0 -3
  13. src/Conversion/Endpoint/PathsEndpoint.php +10 -8
  14. src/Conversion/Endpoint/RegenerateEndpoint.php +1 -0
  15. src/Conversion/Format/FormatFactory.php +6 -2
  16. src/Conversion/Media/Attachment.php +4 -8
  17. src/Conversion/Media/Upload.php +3 -6
  18. src/Conversion/Method/GdMethod.php +6 -3
  19. src/Conversion/Method/ImagickMethod.php +7 -4
  20. src/Conversion/Method/LibraryMethodAbstract.php +70 -0
  21. src/Conversion/Method/LibraryMethodInterface.php +32 -0
  22. src/Conversion/Method/MethodAbstract.php +40 -61
  23. src/Conversion/Method/MethodIntegrator.php +3 -5
  24. src/Conversion/Method/MethodInterface.php +8 -71
  25. src/Conversion/OutputPath.php +8 -3
  26. src/Conversion/PathsValidator.php +33 -0
  27. src/Conversion/SkipConvertedPaths.php +75 -0
  28. src/Conversion/SkipExcludedPaths.php +44 -0
  29. src/Conversion/SkipExists.php +0 -81
  30. src/Conversion/SkipLarger.php +3 -5
  31. src/Error/Detector/LibsWithoutAvifSupportDetector.php +3 -5
  32. src/Error/Detector/PassthruExecutionDetector.php +9 -5
  33. src/Error/Detector/RewritesErrorsDetector.php +30 -24
  34. src/Error/Detector/SettingsIncorrectDetector.php +16 -9
  35. src/Error/ErrorDetectorAggregator.php +11 -7
  36. src/Error/Notice/BypassingApacheNotice.php +13 -2
  37. src/Helper/FileLoader.php +24 -9
  38. src/Helper/ViewLoader.php +12 -3
  39. src/Loader/HtaccessLoader.php +10 -6
  40. src/Loader/LoaderAbstract.php +10 -5
  41. src/Loader/LoaderIntegration.php +0 -3
  42. src/Loader/PassthruLoader.php +8 -4
  43. src/Notice/NoticeFactory.php +11 -1
  44. src/Notice/NoticeIntegration.php +11 -9
  45. src/Plugin/Activation.php +12 -2
  46. src/Plugin/Activation/DefaultSettings.php +12 -2
  47. src/Plugin/Deactivation.php +11 -1
  48. src/Plugin/Deactivation/Modal.php +15 -10
  49. src/Plugin/Links.php +12 -2
  50. src/Plugin/Uninstall.php +11 -1
  51. src/Plugin/Update.php +13 -3
  52. src/PluginData.php +3 -3
  53. src/PluginInfo.php +66 -0
  54. src/Settings/AdminAssets.php +22 -12
  55. src/Settings/Option/ConversionMethodOption.php +14 -4
  56. src/Settings/Option/ExtraFeaturesOption.php +32 -14
  57. src/Settings/Option/ImagesQualityOption.php +12 -3
  58. src/Settings/Option/LoaderTypeOption.php +12 -3
  59. src/Settings/Option/OptionAbstract.php +5 -4
  60. src/Settings/Option/OptionIntegration.php +28 -16
  61. src/Settings/Option/OptionInterface.php +23 -16
  62. src/Settings/Option/OptionsAggregator.php +57 -0
  63. src/Settings/Option/OutputFormatsOption.php +16 -5
  64. src/Settings/Option/SupportedDirectoriesOption.php +12 -3
  65. src/Settings/Option/SupportedExtensionsOption.php +12 -3
  66. src/Settings/Page/DebugPage.php +24 -11
  67. src/Settings/Page/PageAbstract.php +0 -14
  68. src/Settings/Page/PageIntegration.php +12 -2
  69. src/Settings/Page/SettingsPage.php +20 -3
  70. src/Settings/{Option/OptionFactory.php → PluginOptions.php} +8 -26
  71. src/Settings/SettingsSave.php +4 -7
  72. src/WebpConverter.php +16 -15
  73. templates/components/fields/checkbox.php +2 -4
  74. templates/components/fields/input.php +21 -0
  75. templates/components/fields/radio.php +2 -4
  76. templates/components/server/filters.php +0 -7
  77. templates/components/widgets/regenerate.php +5 -13
  78. templates/views/deactivation-modal.php +8 -9
  79. vendor/autoload.php +1 -1
  80. vendor/composer/autoload_classmap.php +8 -2
  81. vendor/composer/autoload_real.php +4 -4
  82. vendor/composer/autoload_static.php +12 -6
  83. vendor/composer/installed.php +2 -2
  84. webp-converter-for-media.php +5 -8
assets/build/css/styles.css CHANGED
@@ -1 +1 @@
1
- @charset "UTF-8";@keyframes dotsLoading{0%,to{content:"..."}25%{content:" .."}50%{content:". ."}75%{content:".. "}}@font-face{font-family:Exo\ 2;font-style:"normal";font-weight:400;src:url(../../fonts/Exo2/Exo2-Regular.woff2) format("woff2"),url(../../fonts/Exo2/Exo2-Regular.woff) format("woff"),url(../../fonts/Exo2/Exo2-Regular.ttf) format("truetype")}@font-face{font-family:Exo\ 2;font-style:"normal";font-weight:500;src:url(../../fonts/Exo2/Exo2-SemiBold.woff2) format("woff2"),url(../../fonts/Exo2/Exo2-SemiBold.woff) format("woff"),url(../../fonts/Exo2/Exo2-SemiBold.ttf) format("truetype")}.webpModal [hidden]{display:none!important}.webpModal *,.webpModal :after,.webpModal :before{box-sizing:border-box;margin:0;padding:0}.webpModal__outer{background-color:rgba(0,0,0,.75);height:100%;left:0;position:fixed;top:0;width:100%;z-index:9999}.webpModal__form{background-color:#fff;font-family:Exo\ 2,sans-serif;font-size:0;left:50%;max-width:calc(100vw - 40px);padding:20px 30px;position:absolute;top:50%;transform:translate(-50%,-50%);width:600px}.webpModal__headline{font-size:16px;font-weight:500;line-height:1.5;padding:4px 0}.webpModal__desc{font-size:14px;line-height:1.5714285714;padding:4px 0}.webpModal__options{padding:10px 0}.webpModal__textarea{border:1px solid #b4b9be!important;border-radius:0;display:none;font-size:14px;line-height:1.5714285714;margin-top:10px;padding:4px 10px;width:100%}.webpModal__textarea[placeholder]{display:block}.webpModal__textarea[placeholder=""]{display:none}.webpModal__buttons{align-items:center;display:flex;flex-wrap:wrap;margin:0 -5px;padding:5px 0}.webpModal__button{padding:5px;width:50%}.webpModal__buttonInner{width:100%}.webpPage{color:#444;font-family:Exo\ 2,sans-serif;margin:0;overflow:hidden;padding:0 20px 0 0}.webpPage *,.webpPage :after,.webpPage :before{box-sizing:border-box;margin:0;padding:0}.webpPage [hidden]{display:none!important}.webpPage .webpPage__headline{font-size:24px;line-height:1.2083333333;margin:0;padding:15px 0 23px}.webpPage__alert{background-color:#46b450;color:#fff;font-size:14px;line-height:1.5714285714;margin-bottom:30px;padding:15px 20px}.webpPage__columns{margin:0 -30px;overflow:hidden}.webpPage__column{float:left;padding:0 30px}.webpPage__column--large{width:66.666%}.webpPage__column--small{width:33.333%}.webpPage__widget{background-color:#fff}.webpPage__widget+.webpPage__widget{margin-top:60px}.webpPage__widgetTitle{background-color:#0073aa;color:#fff;font-size:16px;font-weight:400;line-height:1.5;padding:14px 30px}.webpPage__widgetTitle--second{background-color:#a0a5aa}.webpPage__widgetTitle--error{background-color:#dc3232}.webpPage__widgetRow{padding-bottom:10px}.webpPage__widgetRow:last-child{padding-bottom:0}.webpPage__widgetRow .webpButton{margin:10px 0}.webpPage__quality{border:1px solid #a0a5aa;display:flex;flex-wrap:wrap;margin:10px 0}.webpPage__qualityItem{border-left:1px solid #a0a5aa;flex:1;margin-left:-1px;text-align:center}.webpPage__qualityItemInput{display:none!important}.webpPage__qualityItemLabel{display:block;font-size:14px;line-height:1.5714285714;padding:14px 20px;position:relative;transition:color .3s,background-color .3s}.webpPage__qualityItemInput:checked+.webpPage__qualityItemLabel{background-color:#46b450;color:#fff;margin:-1px;padding:15px 21px}.webpPage__qualityItemInput[disabled]+.webpPage__qualityItemLabel{opacity:0;pointer-events:none}.notice[data-notice=webp-converter]{margin-top:20px;padding:0}.webpButton{background-color:#fff;border:1px solid transparent;box-shadow:none!important;box-sizing:border-box;cursor:pointer;display:inline-block;font-size:14px;font-weight:500;line-height:1.5714285714;min-width:180px;opacity:1!important;outline:none!important;padding:9px 30px;position:relative;text-align:center;text-decoration:none;text-decoration:none!important;transition:color .3s!important;z-index:10}p>.webpButton{margin:6px 0}.webpButton:before{float:left;font-family:dashicons;font-size:20px;line-height:1.1;margin-right:10px}.webpButton:after{content:"";height:100%;left:0;position:absolute;top:0;transition:width .3s;width:0;z-index:-1}.webpButton:hover:after{width:100%}.webpButton[disabled]{opacity:.5!important;pointer-events:none}.webpButton--blue:hover,.webpButton--green:hover{color:#fff!important}.webpButton--blue{border-color:#0073aa;color:#0073aa!important}.webpButton--blue:after{background-color:#0073aa}.webpButton--green{border-color:#46b450;color:#46b450!important}.webpButton--green:after{background-color:#46b450}.webpContent{font-family:Exo\ 2,sans-serif;padding:20px 30px}.webpContent p{font-size:14px;line-height:1.5714285714;max-width:800px}.webpContent p.center{text-align:center}.webpContent--wide p{max-width:100%}.webpContent a{box-shadow:none;color:#0073aa;outline:none;text-decoration:underline;transition:opacity .3s}.webpContent a:hover{opacity:.5}.webpContent h1,.webpContent h2,.webpContent h3,.webpContent h4,.webpContent h5,.webpContent h6{font-size:16px;font-weight:500;line-height:1.5}.webpContent h1,.webpContent h2,.webpContent h3,.webpContent h4,.webpContent h5,.webpContent h6,.webpContent p{margin:10px 0 0;padding:4px 0}.webpContent h1:first-child,.webpContent h2:first-child,.webpContent h3:first-child,.webpContent h4:first-child,.webpContent h5:first-child,.webpContent h6:first-child,.webpContent p:first-child{margin-top:0}.webpContent h1+p,.webpContent h2+p,.webpContent h3+p,.webpContent h4+p,.webpContent h5+p,.webpContent h6+p{font-size:12px;line-height:1.75;margin-top:0}.webpContent--notice h1+p,.webpContent--notice h2+p,.webpContent--notice h3+p,.webpContent--notice h4+p,.webpContent--notice h5+p,.webpContent--notice h6+p{font-size:14px;line-height:1.5714285714}.webpContent__buttons{margin-top:-10px;overflow:hidden;padding:10px 0}.webpContent__button{float:left;margin:20px 20px 0 0}.webpContent__button:last-child{margin-right:0}.webpField{padding:10px 0}.webpField+.webpField{margin-top:-12px}.webpField__input{display:none!important}.webpField__input[disabled]+label{pointer-events:none}.webpField__input[disabled]+label:after,.webpField__input[disabled]+label:before{opacity:.25}.webpField__input--checkbox+label,.webpField__input--radio+label{padding-left:42px}.webpField__input--checkbox+label:after,.webpField__input--checkbox+label:before,.webpField__input--radio+label:after,.webpField__input--radio+label:before{align-items:center;content:"";display:flex;height:22px;justify-content:center;left:0;position:absolute;top:0;width:22px}.webpField__input--checkbox+label:before,.webpField__input--radio+label:before{border:1px solid #b4b9be}.webpField__input--checkbox+label:after,.webpField__input--radio+label:after{position:absolute;transform:scale(0);transition:transform .3s}.webpField__input--checkbox:checked+label:after,.webpField__input--radio:checked+label:after{transform:scale(1)}.webpField__input--checkbox+label:after{color:#46b450;content:"\f147";font-family:dashicons;font-size:20px;line-height:1}.webpField__input--radio+label:before{border-radius:50%}.webpField__input--radio+label:after{background-color:#46b450;border-radius:50%;content:"";height:6px;left:8px;top:8px;width:6px}.webpField__input--toggle+label{padding-left:64px}.webpField__input--toggle+label:after,.webpField__input--toggle+label:before{content:"";position:absolute}.webpField__input--toggle+label:before{background-color:hsla(210,7%,73%,.5);border:1px solid #b4b9be;border-radius:11px;height:22px;left:0;top:0;transition:background-color .3s;width:44px}.webpField__input--toggle+label:after{background-color:#fff;border-radius:50%;height:16px;left:3px;position:absolute;top:3px;transition:transform .3s;width:16px}.webpField__input--toggle:checked+label:before{background-color:#46b450}.webpField__input--toggle:checked+label:after{transform:translateX(22px)}.webpField__label{display:inline-block;font-size:14px;line-height:1.5714285714;max-width:650px;position:relative}.webpLoader__status{padding:20px 0 10px;position:relative}.webpLoader__bar--hidden{display:none}.webpLoader__barProgress{font-size:0;height:20px;line-height:0;position:relative}.webpLoader__barProgress:before{background-color:#46b450;content:"";height:100%;left:0;position:absolute;top:0;transition:width .3s;width:0}.webpLoader__barProgress--error:before{background-color:#dc3232}.webpLoader__barProgress[data-percent="0"]:before{width:0}.webpLoader__barProgress[data-percent="1"]:before{width:1%}.webpLoader__barProgress[data-percent="2"]:before{width:2%}.webpLoader__barProgress[data-percent="3"]:before{width:3%}.webpLoader__barProgress[data-percent="4"]:before{width:4%}.webpLoader__barProgress[data-percent="5"]:before{width:5%}.webpLoader__barProgress[data-percent="6"]:before{width:6%}.webpLoader__barProgress[data-percent="7"]:before{width:7%}.webpLoader__barProgress[data-percent="8"]:before{width:8%}.webpLoader__barProgress[data-percent="9"]:before{width:9%}.webpLoader__barProgress[data-percent="10"]:before{width:10%}.webpLoader__barProgress[data-percent="11"]:before{width:11%}.webpLoader__barProgress[data-percent="12"]:before{width:12%}.webpLoader__barProgress[data-percent="13"]:before{width:13%}.webpLoader__barProgress[data-percent="14"]:before{width:14%}.webpLoader__barProgress[data-percent="15"]:before{width:15%}.webpLoader__barProgress[data-percent="16"]:before{width:16%}.webpLoader__barProgress[data-percent="17"]:before{width:17%}.webpLoader__barProgress[data-percent="18"]:before{width:18%}.webpLoader__barProgress[data-percent="19"]:before{width:19%}.webpLoader__barProgress[data-percent="20"]:before{width:20%}.webpLoader__barProgress[data-percent="21"]:before{width:21%}.webpLoader__barProgress[data-percent="22"]:before{width:22%}.webpLoader__barProgress[data-percent="23"]:before{width:23%}.webpLoader__barProgress[data-percent="24"]:before{width:24%}.webpLoader__barProgress[data-percent="25"]:before{width:25%}.webpLoader__barProgress[data-percent="26"]:before{width:26%}.webpLoader__barProgress[data-percent="27"]:before{width:27%}.webpLoader__barProgress[data-percent="28"]:before{width:28%}.webpLoader__barProgress[data-percent="29"]:before{width:29%}.webpLoader__barProgress[data-percent="30"]:before{width:30%}.webpLoader__barProgress[data-percent="31"]:before{width:31%}.webpLoader__barProgress[data-percent="32"]:before{width:32%}.webpLoader__barProgress[data-percent="33"]:before{width:33%}.webpLoader__barProgress[data-percent="34"]:before{width:34%}.webpLoader__barProgress[data-percent="35"]:before{width:35%}.webpLoader__barProgress[data-percent="36"]:before{width:36%}.webpLoader__barProgress[data-percent="37"]:before{width:37%}.webpLoader__barProgress[data-percent="38"]:before{width:38%}.webpLoader__barProgress[data-percent="39"]:before{width:39%}.webpLoader__barProgress[data-percent="40"]:before{width:40%}.webpLoader__barProgress[data-percent="41"]:before{width:41%}.webpLoader__barProgress[data-percent="42"]:before{width:42%}.webpLoader__barProgress[data-percent="43"]:before{width:43%}.webpLoader__barProgress[data-percent="44"]:before{width:44%}.webpLoader__barProgress[data-percent="45"]:before{width:45%}.webpLoader__barProgress[data-percent="46"]:before{width:46%}.webpLoader__barProgress[data-percent="47"]:before{width:47%}.webpLoader__barProgress[data-percent="48"]:before{width:48%}.webpLoader__barProgress[data-percent="49"]:before{width:49%}.webpLoader__barProgress[data-percent="50"]:before{width:50%}.webpLoader__barProgress[data-percent="51"]:before{width:51%}.webpLoader__barProgress[data-percent="52"]:before{width:52%}.webpLoader__barProgress[data-percent="53"]:before{width:53%}.webpLoader__barProgress[data-percent="54"]:before{width:54%}.webpLoader__barProgress[data-percent="55"]:before{width:55%}.webpLoader__barProgress[data-percent="56"]:before{width:56%}.webpLoader__barProgress[data-percent="57"]:before{width:57%}.webpLoader__barProgress[data-percent="58"]:before{width:58%}.webpLoader__barProgress[data-percent="59"]:before{width:59%}.webpLoader__barProgress[data-percent="60"]:before{width:60%}.webpLoader__barProgress[data-percent="61"]:before{width:61%}.webpLoader__barProgress[data-percent="62"]:before{width:62%}.webpLoader__barProgress[data-percent="63"]:before{width:63%}.webpLoader__barProgress[data-percent="64"]:before{width:64%}.webpLoader__barProgress[data-percent="65"]:before{width:65%}.webpLoader__barProgress[data-percent="66"]:before{width:66%}.webpLoader__barProgress[data-percent="67"]:before{width:67%}.webpLoader__barProgress[data-percent="68"]:before{width:68%}.webpLoader__barProgress[data-percent="69"]:before{width:69%}.webpLoader__barProgress[data-percent="70"]:before{width:70%}.webpLoader__barProgress[data-percent="71"]:before{width:71%}.webpLoader__barProgress[data-percent="72"]:before{width:72%}.webpLoader__barProgress[data-percent="73"]:before{width:73%}.webpLoader__barProgress[data-percent="74"]:before{width:74%}.webpLoader__barProgress[data-percent="75"]:before{width:75%}.webpLoader__barProgress[data-percent="76"]:before{width:76%}.webpLoader__barProgress[data-percent="77"]:before{width:77%}.webpLoader__barProgress[data-percent="78"]:before{width:78%}.webpLoader__barProgress[data-percent="79"]:before{width:79%}.webpLoader__barProgress[data-percent="80"]:before{width:80%}.webpLoader__barProgress[data-percent="81"]:before{width:81%}.webpLoader__barProgress[data-percent="82"]:before{width:82%}.webpLoader__barProgress[data-percent="83"]:before{width:83%}.webpLoader__barProgress[data-percent="84"]:before{width:84%}.webpLoader__barProgress[data-percent="85"]:before{width:85%}.webpLoader__barProgress[data-percent="86"]:before{width:86%}.webpLoader__barProgress[data-percent="87"]:before{width:87%}.webpLoader__barProgress[data-percent="88"]:before{width:88%}.webpLoader__barProgress[data-percent="89"]:before{width:89%}.webpLoader__barProgress[data-percent="90"]:before{width:90%}.webpLoader__barProgress[data-percent="91"]:before{width:91%}.webpLoader__barProgress[data-percent="92"]:before{width:92%}.webpLoader__barProgress[data-percent="93"]:before{width:93%}.webpLoader__barProgress[data-percent="94"]:before{width:94%}.webpLoader__barProgress[data-percent="95"]:before{width:95%}.webpLoader__barProgress[data-percent="96"]:before{width:96%}.webpLoader__barProgress[data-percent="97"]:before{width:97%}.webpLoader__barProgress[data-percent="98"]:before{width:98%}.webpLoader__barProgress[data-percent="99"]:before{width:99%}.webpLoader__barProgress[data-percent="100"]:before{width:100%}.webpLoader__barCount{background-color:#46b450;color:#fff;display:inline-block;font-family:monospace;font-size:12px;line-height:1.75;padding:0 5px;position:relative}.webpLoader__barProgress--error .webpLoader__barCount{background-color:#dc3232}.webpLoader__barCount:after{animation:dotsLoading 1s linear infinite;content:"...";margin-left:5px}.webpLoader__barProgress--error .webpLoader__barCount:after,.webpLoader__barProgress[data-percent="100"] .webpLoader__barCount:after{display:none}.webpLoader__barProgress[data-percent="0"] .webpLoader__barCount:before{content:"0%"}.webpLoader__barProgress[data-percent="1"] .webpLoader__barCount:before{content:"1%"}.webpLoader__barProgress[data-percent="2"] .webpLoader__barCount:before{content:"2%"}.webpLoader__barProgress[data-percent="3"] .webpLoader__barCount:before{content:"3%"}.webpLoader__barProgress[data-percent="4"] .webpLoader__barCount:before{content:"4%"}.webpLoader__barProgress[data-percent="5"] .webpLoader__barCount:before{content:"5%"}.webpLoader__barProgress[data-percent="6"] .webpLoader__barCount:before{content:"6%"}.webpLoader__barProgress[data-percent="7"] .webpLoader__barCount:before{content:"7%"}.webpLoader__barProgress[data-percent="8"] .webpLoader__barCount:before{content:"8%"}.webpLoader__barProgress[data-percent="9"] .webpLoader__barCount:before{content:"9%"}.webpLoader__barProgress[data-percent="10"] .webpLoader__barCount:before{content:"10%"}.webpLoader__barProgress[data-percent="11"] .webpLoader__barCount:before{content:"11%"}.webpLoader__barProgress[data-percent="12"] .webpLoader__barCount:before{content:"12%"}.webpLoader__barProgress[data-percent="13"] .webpLoader__barCount:before{content:"13%"}.webpLoader__barProgress[data-percent="14"] .webpLoader__barCount:before{content:"14%"}.webpLoader__barProgress[data-percent="15"] .webpLoader__barCount:before{content:"15%"}.webpLoader__barProgress[data-percent="16"] .webpLoader__barCount:before{content:"16%"}.webpLoader__barProgress[data-percent="17"] .webpLoader__barCount:before{content:"17%"}.webpLoader__barProgress[data-percent="18"] .webpLoader__barCount:before{content:"18%"}.webpLoader__barProgress[data-percent="19"] .webpLoader__barCount:before{content:"19%"}.webpLoader__barProgress[data-percent="20"] .webpLoader__barCount:before{content:"20%"}.webpLoader__barProgress[data-percent="21"] .webpLoader__barCount:before{content:"21%"}.webpLoader__barProgress[data-percent="22"] .webpLoader__barCount:before{content:"22%"}.webpLoader__barProgress[data-percent="23"] .webpLoader__barCount:before{content:"23%"}.webpLoader__barProgress[data-percent="24"] .webpLoader__barCount:before{content:"24%"}.webpLoader__barProgress[data-percent="25"] .webpLoader__barCount:before{content:"25%"}.webpLoader__barProgress[data-percent="26"] .webpLoader__barCount:before{content:"26%"}.webpLoader__barProgress[data-percent="27"] .webpLoader__barCount:before{content:"27%"}.webpLoader__barProgress[data-percent="28"] .webpLoader__barCount:before{content:"28%"}.webpLoader__barProgress[data-percent="29"] .webpLoader__barCount:before{content:"29%"}.webpLoader__barProgress[data-percent="30"] .webpLoader__barCount:before{content:"30%"}.webpLoader__barProgress[data-percent="31"] .webpLoader__barCount:before{content:"31%"}.webpLoader__barProgress[data-percent="32"] .webpLoader__barCount:before{content:"32%"}.webpLoader__barProgress[data-percent="33"] .webpLoader__barCount:before{content:"33%"}.webpLoader__barProgress[data-percent="34"] .webpLoader__barCount:before{content:"34%"}.webpLoader__barProgress[data-percent="35"] .webpLoader__barCount:before{content:"35%"}.webpLoader__barProgress[data-percent="36"] .webpLoader__barCount:before{content:"36%"}.webpLoader__barProgress[data-percent="37"] .webpLoader__barCount:before{content:"37%"}.webpLoader__barProgress[data-percent="38"] .webpLoader__barCount:before{content:"38%"}.webpLoader__barProgress[data-percent="39"] .webpLoader__barCount:before{content:"39%"}.webpLoader__barProgress[data-percent="40"] .webpLoader__barCount:before{content:"40%"}.webpLoader__barProgress[data-percent="41"] .webpLoader__barCount:before{content:"41%"}.webpLoader__barProgress[data-percent="42"] .webpLoader__barCount:before{content:"42%"}.webpLoader__barProgress[data-percent="43"] .webpLoader__barCount:before{content:"43%"}.webpLoader__barProgress[data-percent="44"] .webpLoader__barCount:before{content:"44%"}.webpLoader__barProgress[data-percent="45"] .webpLoader__barCount:before{content:"45%"}.webpLoader__barProgress[data-percent="46"] .webpLoader__barCount:before{content:"46%"}.webpLoader__barProgress[data-percent="47"] .webpLoader__barCount:before{content:"47%"}.webpLoader__barProgress[data-percent="48"] .webpLoader__barCount:before{content:"48%"}.webpLoader__barProgress[data-percent="49"] .webpLoader__barCount:before{content:"49%"}.webpLoader__barProgress[data-percent="50"] .webpLoader__barCount:before{content:"50%"}.webpLoader__barProgress[data-percent="51"] .webpLoader__barCount:before{content:"51%"}.webpLoader__barProgress[data-percent="52"] .webpLoader__barCount:before{content:"52%"}.webpLoader__barProgress[data-percent="53"] .webpLoader__barCount:before{content:"53%"}.webpLoader__barProgress[data-percent="54"] .webpLoader__barCount:before{content:"54%"}.webpLoader__barProgress[data-percent="55"] .webpLoader__barCount:before{content:"55%"}.webpLoader__barProgress[data-percent="56"] .webpLoader__barCount:before{content:"56%"}.webpLoader__barProgress[data-percent="57"] .webpLoader__barCount:before{content:"57%"}.webpLoader__barProgress[data-percent="58"] .webpLoader__barCount:before{content:"58%"}.webpLoader__barProgress[data-percent="59"] .webpLoader__barCount:before{content:"59%"}.webpLoader__barProgress[data-percent="60"] .webpLoader__barCount:before{content:"60%"}.webpLoader__barProgress[data-percent="61"] .webpLoader__barCount:before{content:"61%"}.webpLoader__barProgress[data-percent="62"] .webpLoader__barCount:before{content:"62%"}.webpLoader__barProgress[data-percent="63"] .webpLoader__barCount:before{content:"63%"}.webpLoader__barProgress[data-percent="64"] .webpLoader__barCount:before{content:"64%"}.webpLoader__barProgress[data-percent="65"] .webpLoader__barCount:before{content:"65%"}.webpLoader__barProgress[data-percent="66"] .webpLoader__barCount:before{content:"66%"}.webpLoader__barProgress[data-percent="67"] .webpLoader__barCount:before{content:"67%"}.webpLoader__barProgress[data-percent="68"] .webpLoader__barCount:before{content:"68%"}.webpLoader__barProgress[data-percent="69"] .webpLoader__barCount:before{content:"69%"}.webpLoader__barProgress[data-percent="70"] .webpLoader__barCount:before{content:"70%"}.webpLoader__barProgress[data-percent="71"] .webpLoader__barCount:before{content:"71%"}.webpLoader__barProgress[data-percent="72"] .webpLoader__barCount:before{content:"72%"}.webpLoader__barProgress[data-percent="73"] .webpLoader__barCount:before{content:"73%"}.webpLoader__barProgress[data-percent="74"] .webpLoader__barCount:before{content:"74%"}.webpLoader__barProgress[data-percent="75"] .webpLoader__barCount:before{content:"75%"}.webpLoader__barProgress[data-percent="76"] .webpLoader__barCount:before{content:"76%"}.webpLoader__barProgress[data-percent="77"] .webpLoader__barCount:before{content:"77%"}.webpLoader__barProgress[data-percent="78"] .webpLoader__barCount:before{content:"78%"}.webpLoader__barProgress[data-percent="79"] .webpLoader__barCount:before{content:"79%"}.webpLoader__barProgress[data-percent="80"] .webpLoader__barCount:before{content:"80%"}.webpLoader__barProgress[data-percent="81"] .webpLoader__barCount:before{content:"81%"}.webpLoader__barProgress[data-percent="82"] .webpLoader__barCount:before{content:"82%"}.webpLoader__barProgress[data-percent="83"] .webpLoader__barCount:before{content:"83%"}.webpLoader__barProgress[data-percent="84"] .webpLoader__barCount:before{content:"84%"}.webpLoader__barProgress[data-percent="85"] .webpLoader__barCount:before{content:"85%"}.webpLoader__barProgress[data-percent="86"] .webpLoader__barCount:before{content:"86%"}.webpLoader__barProgress[data-percent="87"] .webpLoader__barCount:before{content:"87%"}.webpLoader__barProgress[data-percent="88"] .webpLoader__barCount:before{content:"88%"}.webpLoader__barProgress[data-percent="89"] .webpLoader__barCount:before{content:"89%"}.webpLoader__barProgress[data-percent="90"] .webpLoader__barCount:before{content:"90%"}.webpLoader__barProgress[data-percent="91"] .webpLoader__barCount:before{content:"91%"}.webpLoader__barProgress[data-percent="92"] .webpLoader__barCount:before{content:"92%"}.webpLoader__barProgress[data-percent="93"] .webpLoader__barCount:before{content:"93%"}.webpLoader__barProgress[data-percent="94"] .webpLoader__barCount:before{content:"94%"}.webpLoader__barProgress[data-percent="95"] .webpLoader__barCount:before{content:"95%"}.webpLoader__barProgress[data-percent="96"] .webpLoader__barCount:before{content:"96%"}.webpLoader__barProgress[data-percent="97"] .webpLoader__barCount:before{content:"97%"}.webpLoader__barProgress[data-percent="98"] .webpLoader__barCount:before{content:"98%"}.webpLoader__barProgress[data-percent="99"] .webpLoader__barCount:before{content:"99%"}.webpLoader__barProgress[data-percent="100"] .webpLoader__barCount:before{content:"100%"}.webpLoader__size{font-size:14px;line-height:1.5714285714;margin-bottom:-10px;padding:4px 0}.webpLoader__sizeProgress{font-weight:500}.webpLoader__success{margin-top:20px;padding:4px 0 4px 20px;position:relative}.webpLoader__success:before{background-color:#46b450;content:"";height:100%;left:0;position:absolute;top:0;width:2px}.webpLoader__successContent{color:#46b450;font-size:14px;font-weight:500;line-height:1.5714285714}.webpLoader__successContent a{color:inherit}.webpLoader__errors{border-left:2px solid #a0a5aa;margin-top:20px}.webpLoader__errorsTitle{background-color:#a0a5aa;color:#fff;display:inline-block;font-size:14px;line-height:1.5714285714;padding:4px 22px}.webpLoader__errorsContent{font-size:12px;line-height:1.75;padding:14px 0 14px 20px}.webpLoader__errorsContentMessage{color:#dc3232;font-size:14px;font-weight:500;line-height:1.5714285714}.webpLoader__button--disabled{opacity:.25!important;pointer-events:none}.webpPopup{margin-top:20px}.webpPopup__inner{background-color:#fff;display:flex;flex-wrap:wrap}.webpPopup__image{background-image:url(../../img/author.jpg);background-position:50%;background-repeat:no-repeat;background-size:cover;width:152px}.webpPopup__content{border:1px solid #a0a5aa;border-left:0;flex:1;padding:10px 20px}.webpServerInfo{color:#222;text-align:center}.webpServerInfo pre{font-family:monospace;margin:0}.webpServerInfo h1,.webpServerInfo h2{display:none}.webpServerInfo p{max-width:100%}.webpServerInfo table{border:0;border-collapse:collapse;margin:10px auto;width:100%}.webpServerInfo td,.webpServerInfo th{border:1px solid #666;font-size:12px;line-height:1.75;padding:4px 5px;text-align:center;vertical-align:baseline}.webpServerInfo .p{text-align:left}.webpServerInfo .e{background-color:#ccf;font-weight:700;width:300px}.webpServerInfo .h{background-color:#99c;font-weight:700}.webpServerInfo .v{word-wrap:break-word;background-color:#ddd;max-width:300px;overflow-x:auto}.webpServerInfo .v i{color:#999}.webpServerInfo img{border:0;float:right}@media screen and (max-width:1024px){.webpPage__column--large{width:100%}.webpPage__column--small{margin-top:40px;width:100%}.webpPage__widget+.webpPage__widget{margin-top:40px}}@media screen and (max-width:782px){.webpModal__button{width:100%}.webpPage{padding-right:10px}.webpPopup__inner{border:1px solid #a0a5aa;display:block}.webpPopup__image{height:152px;margin:20px auto 0}.webpPopup__content{border:0}}@media screen and (max-width:768px){.webpPage__quality{display:block}.webpPage__qualityItem{border-left:0}.webpPage__qualityItem+.webpPage__qualityItem{border-top:1px solid #a0a5aa}}
1
+ @charset "UTF-8";@keyframes dotsLoading{0%,to{content:"..."}25%{content:" .."}50%{content:". ."}75%{content:".. "}}@font-face{font-family:Exo\ 2;font-style:"normal";font-weight:400;src:url(../../fonts/Exo2/Exo2-Regular.woff2) format("woff2"),url(../../fonts/Exo2/Exo2-Regular.woff) format("woff"),url(../../fonts/Exo2/Exo2-Regular.ttf) format("truetype")}@font-face{font-family:Exo\ 2;font-style:"normal";font-weight:500;src:url(../../fonts/Exo2/Exo2-SemiBold.woff2) format("woff2"),url(../../fonts/Exo2/Exo2-SemiBold.woff) format("woff"),url(../../fonts/Exo2/Exo2-SemiBold.ttf) format("truetype")}.webpModal [hidden]{display:none!important}.webpModal *,.webpModal :after,.webpModal :before{box-sizing:border-box;margin:0;padding:0}.webpModal__outer{background-color:rgba(0,0,0,.75);height:100%;left:0;position:fixed;top:0;width:100%;z-index:9999}.webpModal__form{background-color:#fff;font-family:Exo\ 2,sans-serif;font-size:0;left:50%;max-width:calc(100vw - 40px);padding:20px 30px;position:absolute;top:50%;transform:translate(-50%,-50%);width:600px}.webpModal__headline{font-size:16px;font-weight:500;line-height:1.5;padding:4px 0}.webpModal__desc{font-size:14px;line-height:1.5714285714;padding:4px 0}.webpModal__options{padding:10px 0}.webpModal__textarea{border:1px solid #b4b9be!important;border-radius:0;display:none;font-size:14px;line-height:1.5714285714;margin-top:10px;padding:4px 10px;width:100%}.webpModal__textarea[placeholder]{display:block}.webpModal__textarea[placeholder=""]{display:none}.webpModal__buttons{align-items:center;display:flex;flex-wrap:wrap;margin:0 -5px;padding:5px 0}.webpModal__button{padding:5px;width:50%}.webpModal__buttonInner{width:100%}.webpPage{color:#444;font-family:Exo\ 2,sans-serif;margin:0;overflow:hidden;padding:0 20px 0 0}.webpPage *,.webpPage :after,.webpPage :before{box-sizing:border-box;margin:0;padding:0}.webpPage [hidden]{display:none!important}.webpPage .webpPage__headline{font-size:24px;line-height:1.2083333333;margin:0;padding:15px 0 23px}.webpPage__alert{background-color:#46b450;color:#fff;font-size:14px;line-height:1.5714285714;margin-bottom:30px;padding:15px 20px}.webpPage__columns{margin:0 -30px;overflow:hidden}.webpPage__column{float:left;padding:0 30px}.webpPage__column--large{width:66.666%}.webpPage__column--small{width:33.333%}.webpPage__widget{background-color:#fff}.webpPage__widget+.webpPage__widget{margin-top:60px}.webpPage__widgetTitle{background-color:#0073aa;color:#fff;font-size:16px;font-weight:400;line-height:1.5;padding:14px 30px}.webpPage__widgetTitle--second{background-color:#a0a5aa}.webpPage__widgetTitle--error{background-color:#dc3232}.webpPage__widgetRow{padding-bottom:10px}.webpPage__widgetRow:last-child{padding-bottom:0}.webpPage__widgetRow .webpButton{margin:10px 0}.webpPage__quality{border:1px solid #a0a5aa;display:flex;flex-wrap:wrap;margin:10px 0}.webpPage__qualityItem{border-left:1px solid #a0a5aa;flex:1;margin-left:-1px;text-align:center}.webpPage__qualityItemInput{display:none!important}.webpPage__qualityItemLabel{display:block;font-size:14px;line-height:1.5714285714;padding:14px 20px;position:relative;transition:color .3s,background-color .3s}.webpPage__qualityItemInput:checked+.webpPage__qualityItemLabel{background-color:#46b450;color:#fff;margin:-1px;padding:15px 21px}.webpPage__qualityItemInput[disabled]+.webpPage__qualityItemLabel{opacity:0;pointer-events:none}.notice[data-notice=webp-converter]{margin-top:20px;padding:0}.webpButton{background-color:#fff;border:1px solid transparent;box-shadow:none!important;box-sizing:border-box;cursor:pointer;display:inline-block;font-size:14px;font-weight:500;line-height:1.5714285714;min-width:180px;opacity:1!important;outline:none!important;padding:9px 30px;position:relative;text-align:center;text-decoration:none;text-decoration:none!important;transition:color .3s!important;z-index:10}p>.webpButton{margin:6px 0}.webpButton:before{float:left;font-family:dashicons;font-size:20px;line-height:1.1;margin-right:10px}.webpButton:after{content:"";height:100%;left:0;position:absolute;top:0;transition:width .3s;width:0;z-index:-1}.webpButton:hover:after{width:100%}.webpButton[disabled]{opacity:.5!important;pointer-events:none}.webpButton--blue:hover,.webpButton--green:hover{color:#fff!important}.webpButton--blue{border-color:#0073aa;color:#0073aa!important}.webpButton--blue:after{background-color:#0073aa}.webpButton--green{border-color:#46b450;color:#46b450!important}.webpButton--green:after{background-color:#46b450}.webpContent{font-family:Exo\ 2,sans-serif;padding:20px 30px}.webpContent p{font-size:14px;line-height:1.5714285714;max-width:800px}.webpContent p.center{text-align:center}.webpContent--wide p{max-width:100%}.webpContent a{box-shadow:none;color:#0073aa;outline:none;text-decoration:underline;transition:opacity .3s}.webpContent a:hover{opacity:.5}.webpContent h1,.webpContent h2,.webpContent h3,.webpContent h4,.webpContent h5,.webpContent h6{font-size:16px;font-weight:500;line-height:1.5}.webpContent h1,.webpContent h2,.webpContent h3,.webpContent h4,.webpContent h5,.webpContent h6,.webpContent p{margin:10px 0 0;padding:4px 0}.webpContent h1:first-child,.webpContent h2:first-child,.webpContent h3:first-child,.webpContent h4:first-child,.webpContent h5:first-child,.webpContent h6:first-child,.webpContent p:first-child{margin-top:0}.webpContent h1+p,.webpContent h2+p,.webpContent h3+p,.webpContent h4+p,.webpContent h5+p,.webpContent h6+p{font-size:12px;line-height:1.75;margin-top:0}.webpContent--notice h1+p,.webpContent--notice h2+p,.webpContent--notice h3+p,.webpContent--notice h4+p,.webpContent--notice h5+p,.webpContent--notice h6+p{font-size:14px;line-height:1.5714285714}.webpContent__buttons{margin-top:-10px;overflow:hidden;padding:10px 0}.webpContent__button{float:left;margin:20px 20px 0 0}.webpContent__button:last-child{margin-right:0}.webpField{display:flex;padding:10px 0}.webpField+.webpField{margin-top:-12px}.webpField__input{display:none!important}.webpField__input+label{display:inline-block;position:relative}.webpField__input[disabled]+label{pointer-events:none}.webpField__input[disabled]+label:after,.webpField__input[disabled]+label:before{opacity:.25}.webpField__input--checkbox+label,.webpField__input--radio+label{height:22px;width:22px}.webpField__input--checkbox+label:after,.webpField__input--checkbox+label:before,.webpField__input--radio+label:after,.webpField__input--radio+label:before{align-items:center;content:"";display:flex;height:22px;justify-content:center;left:0;position:absolute;top:0;width:22px}.webpField__input--checkbox+label:before,.webpField__input--radio+label:before{border:1px solid #b4b9be}.webpField__input--checkbox+label:after,.webpField__input--radio+label:after{position:absolute;transform:scale(0);transition:transform .3s}.webpField__input--checkbox:checked+label:after,.webpField__input--radio:checked+label:after{transform:scale(1)}.webpField__input--checkbox+label:after{color:#46b450;content:"\f147";font-family:dashicons;font-size:20px;line-height:1}.webpField__input--radio+label:before{border-radius:50%}.webpField__input--radio+label:after{background-color:#46b450;border-radius:50%;content:"";height:6px;left:8px;top:8px;width:6px}.webpField__input--toggle+label{height:22px;width:44px}.webpField__input--toggle+label:after,.webpField__input--toggle+label:before{content:"";position:absolute}.webpField__input--toggle+label:before{background-color:hsla(210,7%,73%,.5);border:1px solid #b4b9be;border-radius:11px;height:22px;left:0;top:0;transition:background-color .3s;width:44px}.webpField__input--toggle+label:after{background-color:#fff;border-radius:50%;height:16px;left:3px;position:absolute;top:3px;transition:transform .3s;width:16px}.webpField__input--toggle:checked+label:before{background-color:#46b450}.webpField__input--toggle:checked+label:after{transform:translateX(22px)}.webpField__label{display:inline-block;font-size:14px;line-height:1.5714285714;margin-left:20px;max-width:650px;position:relative}.webpInput{padding:10px 0}.webpInput__field{border:1px solid #b4b9be!important;border-radius:0!important;box-shadow:none!important;font-size:14px!important;line-height:1.5714285714!important;padding:9px 15px!important;width:100%}.webpLoader__status{padding:20px 0 10px;position:relative}.webpLoader__bar--hidden{display:none}.webpLoader__barProgress{font-size:0;height:21px;line-height:0;position:relative}.webpLoader__barProgress:before{background-color:#46b450;content:"";height:100%;left:0;position:absolute;top:0;transition:width .3s;width:0}.webpLoader__barProgress--error:before{background-color:#dc3232}.webpLoader__barProgress[data-percent="0"]:before{width:0}.webpLoader__barProgress[data-percent="1"]:before{width:1%}.webpLoader__barProgress[data-percent="2"]:before{width:2%}.webpLoader__barProgress[data-percent="3"]:before{width:3%}.webpLoader__barProgress[data-percent="4"]:before{width:4%}.webpLoader__barProgress[data-percent="5"]:before{width:5%}.webpLoader__barProgress[data-percent="6"]:before{width:6%}.webpLoader__barProgress[data-percent="7"]:before{width:7%}.webpLoader__barProgress[data-percent="8"]:before{width:8%}.webpLoader__barProgress[data-percent="9"]:before{width:9%}.webpLoader__barProgress[data-percent="10"]:before{width:10%}.webpLoader__barProgress[data-percent="11"]:before{width:11%}.webpLoader__barProgress[data-percent="12"]:before{width:12%}.webpLoader__barProgress[data-percent="13"]:before{width:13%}.webpLoader__barProgress[data-percent="14"]:before{width:14%}.webpLoader__barProgress[data-percent="15"]:before{width:15%}.webpLoader__barProgress[data-percent="16"]:before{width:16%}.webpLoader__barProgress[data-percent="17"]:before{width:17%}.webpLoader__barProgress[data-percent="18"]:before{width:18%}.webpLoader__barProgress[data-percent="19"]:before{width:19%}.webpLoader__barProgress[data-percent="20"]:before{width:20%}.webpLoader__barProgress[data-percent="21"]:before{width:21%}.webpLoader__barProgress[data-percent="22"]:before{width:22%}.webpLoader__barProgress[data-percent="23"]:before{width:23%}.webpLoader__barProgress[data-percent="24"]:before{width:24%}.webpLoader__barProgress[data-percent="25"]:before{width:25%}.webpLoader__barProgress[data-percent="26"]:before{width:26%}.webpLoader__barProgress[data-percent="27"]:before{width:27%}.webpLoader__barProgress[data-percent="28"]:before{width:28%}.webpLoader__barProgress[data-percent="29"]:before{width:29%}.webpLoader__barProgress[data-percent="30"]:before{width:30%}.webpLoader__barProgress[data-percent="31"]:before{width:31%}.webpLoader__barProgress[data-percent="32"]:before{width:32%}.webpLoader__barProgress[data-percent="33"]:before{width:33%}.webpLoader__barProgress[data-percent="34"]:before{width:34%}.webpLoader__barProgress[data-percent="35"]:before{width:35%}.webpLoader__barProgress[data-percent="36"]:before{width:36%}.webpLoader__barProgress[data-percent="37"]:before{width:37%}.webpLoader__barProgress[data-percent="38"]:before{width:38%}.webpLoader__barProgress[data-percent="39"]:before{width:39%}.webpLoader__barProgress[data-percent="40"]:before{width:40%}.webpLoader__barProgress[data-percent="41"]:before{width:41%}.webpLoader__barProgress[data-percent="42"]:before{width:42%}.webpLoader__barProgress[data-percent="43"]:before{width:43%}.webpLoader__barProgress[data-percent="44"]:before{width:44%}.webpLoader__barProgress[data-percent="45"]:before{width:45%}.webpLoader__barProgress[data-percent="46"]:before{width:46%}.webpLoader__barProgress[data-percent="47"]:before{width:47%}.webpLoader__barProgress[data-percent="48"]:before{width:48%}.webpLoader__barProgress[data-percent="49"]:before{width:49%}.webpLoader__barProgress[data-percent="50"]:before{width:50%}.webpLoader__barProgress[data-percent="51"]:before{width:51%}.webpLoader__barProgress[data-percent="52"]:before{width:52%}.webpLoader__barProgress[data-percent="53"]:before{width:53%}.webpLoader__barProgress[data-percent="54"]:before{width:54%}.webpLoader__barProgress[data-percent="55"]:before{width:55%}.webpLoader__barProgress[data-percent="56"]:before{width:56%}.webpLoader__barProgress[data-percent="57"]:before{width:57%}.webpLoader__barProgress[data-percent="58"]:before{width:58%}.webpLoader__barProgress[data-percent="59"]:before{width:59%}.webpLoader__barProgress[data-percent="60"]:before{width:60%}.webpLoader__barProgress[data-percent="61"]:before{width:61%}.webpLoader__barProgress[data-percent="62"]:before{width:62%}.webpLoader__barProgress[data-percent="63"]:before{width:63%}.webpLoader__barProgress[data-percent="64"]:before{width:64%}.webpLoader__barProgress[data-percent="65"]:before{width:65%}.webpLoader__barProgress[data-percent="66"]:before{width:66%}.webpLoader__barProgress[data-percent="67"]:before{width:67%}.webpLoader__barProgress[data-percent="68"]:before{width:68%}.webpLoader__barProgress[data-percent="69"]:before{width:69%}.webpLoader__barProgress[data-percent="70"]:before{width:70%}.webpLoader__barProgress[data-percent="71"]:before{width:71%}.webpLoader__barProgress[data-percent="72"]:before{width:72%}.webpLoader__barProgress[data-percent="73"]:before{width:73%}.webpLoader__barProgress[data-percent="74"]:before{width:74%}.webpLoader__barProgress[data-percent="75"]:before{width:75%}.webpLoader__barProgress[data-percent="76"]:before{width:76%}.webpLoader__barProgress[data-percent="77"]:before{width:77%}.webpLoader__barProgress[data-percent="78"]:before{width:78%}.webpLoader__barProgress[data-percent="79"]:before{width:79%}.webpLoader__barProgress[data-percent="80"]:before{width:80%}.webpLoader__barProgress[data-percent="81"]:before{width:81%}.webpLoader__barProgress[data-percent="82"]:before{width:82%}.webpLoader__barProgress[data-percent="83"]:before{width:83%}.webpLoader__barProgress[data-percent="84"]:before{width:84%}.webpLoader__barProgress[data-percent="85"]:before{width:85%}.webpLoader__barProgress[data-percent="86"]:before{width:86%}.webpLoader__barProgress[data-percent="87"]:before{width:87%}.webpLoader__barProgress[data-percent="88"]:before{width:88%}.webpLoader__barProgress[data-percent="89"]:before{width:89%}.webpLoader__barProgress[data-percent="90"]:before{width:90%}.webpLoader__barProgress[data-percent="91"]:before{width:91%}.webpLoader__barProgress[data-percent="92"]:before{width:92%}.webpLoader__barProgress[data-percent="93"]:before{width:93%}.webpLoader__barProgress[data-percent="94"]:before{width:94%}.webpLoader__barProgress[data-percent="95"]:before{width:95%}.webpLoader__barProgress[data-percent="96"]:before{width:96%}.webpLoader__barProgress[data-percent="97"]:before{width:97%}.webpLoader__barProgress[data-percent="98"]:before{width:98%}.webpLoader__barProgress[data-percent="99"]:before{width:99%}.webpLoader__barProgress[data-percent="100"]:before{width:100%}.webpLoader__barCount{background-color:#46b450;color:#fff;display:inline-block;font-family:monospace;font-size:12px;line-height:1.75;padding:0 5px;position:relative}.webpLoader__barProgress--error .webpLoader__barCount{background-color:#dc3232}.webpLoader__barCount:after{animation:dotsLoading 1s linear infinite;content:"...";margin-left:5px}.webpLoader__barProgress--error .webpLoader__barCount:after,.webpLoader__barProgress[data-percent="100"] .webpLoader__barCount:after{display:none}.webpLoader__barProgress[data-percent="0"] .webpLoader__barCount:before{content:"0%"}.webpLoader__barProgress[data-percent="1"] .webpLoader__barCount:before{content:"1%"}.webpLoader__barProgress[data-percent="2"] .webpLoader__barCount:before{content:"2%"}.webpLoader__barProgress[data-percent="3"] .webpLoader__barCount:before{content:"3%"}.webpLoader__barProgress[data-percent="4"] .webpLoader__barCount:before{content:"4%"}.webpLoader__barProgress[data-percent="5"] .webpLoader__barCount:before{content:"5%"}.webpLoader__barProgress[data-percent="6"] .webpLoader__barCount:before{content:"6%"}.webpLoader__barProgress[data-percent="7"] .webpLoader__barCount:before{content:"7%"}.webpLoader__barProgress[data-percent="8"] .webpLoader__barCount:before{content:"8%"}.webpLoader__barProgress[data-percent="9"] .webpLoader__barCount:before{content:"9%"}.webpLoader__barProgress[data-percent="10"] .webpLoader__barCount:before{content:"10%"}.webpLoader__barProgress[data-percent="11"] .webpLoader__barCount:before{content:"11%"}.webpLoader__barProgress[data-percent="12"] .webpLoader__barCount:before{content:"12%"}.webpLoader__barProgress[data-percent="13"] .webpLoader__barCount:before{content:"13%"}.webpLoader__barProgress[data-percent="14"] .webpLoader__barCount:before{content:"14%"}.webpLoader__barProgress[data-percent="15"] .webpLoader__barCount:before{content:"15%"}.webpLoader__barProgress[data-percent="16"] .webpLoader__barCount:before{content:"16%"}.webpLoader__barProgress[data-percent="17"] .webpLoader__barCount:before{content:"17%"}.webpLoader__barProgress[data-percent="18"] .webpLoader__barCount:before{content:"18%"}.webpLoader__barProgress[data-percent="19"] .webpLoader__barCount:before{content:"19%"}.webpLoader__barProgress[data-percent="20"] .webpLoader__barCount:before{content:"20%"}.webpLoader__barProgress[data-percent="21"] .webpLoader__barCount:before{content:"21%"}.webpLoader__barProgress[data-percent="22"] .webpLoader__barCount:before{content:"22%"}.webpLoader__barProgress[data-percent="23"] .webpLoader__barCount:before{content:"23%"}.webpLoader__barProgress[data-percent="24"] .webpLoader__barCount:before{content:"24%"}.webpLoader__barProgress[data-percent="25"] .webpLoader__barCount:before{content:"25%"}.webpLoader__barProgress[data-percent="26"] .webpLoader__barCount:before{content:"26%"}.webpLoader__barProgress[data-percent="27"] .webpLoader__barCount:before{content:"27%"}.webpLoader__barProgress[data-percent="28"] .webpLoader__barCount:before{content:"28%"}.webpLoader__barProgress[data-percent="29"] .webpLoader__barCount:before{content:"29%"}.webpLoader__barProgress[data-percent="30"] .webpLoader__barCount:before{content:"30%"}.webpLoader__barProgress[data-percent="31"] .webpLoader__barCount:before{content:"31%"}.webpLoader__barProgress[data-percent="32"] .webpLoader__barCount:before{content:"32%"}.webpLoader__barProgress[data-percent="33"] .webpLoader__barCount:before{content:"33%"}.webpLoader__barProgress[data-percent="34"] .webpLoader__barCount:before{content:"34%"}.webpLoader__barProgress[data-percent="35"] .webpLoader__barCount:before{content:"35%"}.webpLoader__barProgress[data-percent="36"] .webpLoader__barCount:before{content:"36%"}.webpLoader__barProgress[data-percent="37"] .webpLoader__barCount:before{content:"37%"}.webpLoader__barProgress[data-percent="38"] .webpLoader__barCount:before{content:"38%"}.webpLoader__barProgress[data-percent="39"] .webpLoader__barCount:before{content:"39%"}.webpLoader__barProgress[data-percent="40"] .webpLoader__barCount:before{content:"40%"}.webpLoader__barProgress[data-percent="41"] .webpLoader__barCount:before{content:"41%"}.webpLoader__barProgress[data-percent="42"] .webpLoader__barCount:before{content:"42%"}.webpLoader__barProgress[data-percent="43"] .webpLoader__barCount:before{content:"43%"}.webpLoader__barProgress[data-percent="44"] .webpLoader__barCount:before{content:"44%"}.webpLoader__barProgress[data-percent="45"] .webpLoader__barCount:before{content:"45%"}.webpLoader__barProgress[data-percent="46"] .webpLoader__barCount:before{content:"46%"}.webpLoader__barProgress[data-percent="47"] .webpLoader__barCount:before{content:"47%"}.webpLoader__barProgress[data-percent="48"] .webpLoader__barCount:before{content:"48%"}.webpLoader__barProgress[data-percent="49"] .webpLoader__barCount:before{content:"49%"}.webpLoader__barProgress[data-percent="50"] .webpLoader__barCount:before{content:"50%"}.webpLoader__barProgress[data-percent="51"] .webpLoader__barCount:before{content:"51%"}.webpLoader__barProgress[data-percent="52"] .webpLoader__barCount:before{content:"52%"}.webpLoader__barProgress[data-percent="53"] .webpLoader__barCount:before{content:"53%"}.webpLoader__barProgress[data-percent="54"] .webpLoader__barCount:before{content:"54%"}.webpLoader__barProgress[data-percent="55"] .webpLoader__barCount:before{content:"55%"}.webpLoader__barProgress[data-percent="56"] .webpLoader__barCount:before{content:"56%"}.webpLoader__barProgress[data-percent="57"] .webpLoader__barCount:before{content:"57%"}.webpLoader__barProgress[data-percent="58"] .webpLoader__barCount:before{content:"58%"}.webpLoader__barProgress[data-percent="59"] .webpLoader__barCount:before{content:"59%"}.webpLoader__barProgress[data-percent="60"] .webpLoader__barCount:before{content:"60%"}.webpLoader__barProgress[data-percent="61"] .webpLoader__barCount:before{content:"61%"}.webpLoader__barProgress[data-percent="62"] .webpLoader__barCount:before{content:"62%"}.webpLoader__barProgress[data-percent="63"] .webpLoader__barCount:before{content:"63%"}.webpLoader__barProgress[data-percent="64"] .webpLoader__barCount:before{content:"64%"}.webpLoader__barProgress[data-percent="65"] .webpLoader__barCount:before{content:"65%"}.webpLoader__barProgress[data-percent="66"] .webpLoader__barCount:before{content:"66%"}.webpLoader__barProgress[data-percent="67"] .webpLoader__barCount:before{content:"67%"}.webpLoader__barProgress[data-percent="68"] .webpLoader__barCount:before{content:"68%"}.webpLoader__barProgress[data-percent="69"] .webpLoader__barCount:before{content:"69%"}.webpLoader__barProgress[data-percent="70"] .webpLoader__barCount:before{content:"70%"}.webpLoader__barProgress[data-percent="71"] .webpLoader__barCount:before{content:"71%"}.webpLoader__barProgress[data-percent="72"] .webpLoader__barCount:before{content:"72%"}.webpLoader__barProgress[data-percent="73"] .webpLoader__barCount:before{content:"73%"}.webpLoader__barProgress[data-percent="74"] .webpLoader__barCount:before{content:"74%"}.webpLoader__barProgress[data-percent="75"] .webpLoader__barCount:before{content:"75%"}.webpLoader__barProgress[data-percent="76"] .webpLoader__barCount:before{content:"76%"}.webpLoader__barProgress[data-percent="77"] .webpLoader__barCount:before{content:"77%"}.webpLoader__barProgress[data-percent="78"] .webpLoader__barCount:before{content:"78%"}.webpLoader__barProgress[data-percent="79"] .webpLoader__barCount:before{content:"79%"}.webpLoader__barProgress[data-percent="80"] .webpLoader__barCount:before{content:"80%"}.webpLoader__barProgress[data-percent="81"] .webpLoader__barCount:before{content:"81%"}.webpLoader__barProgress[data-percent="82"] .webpLoader__barCount:before{content:"82%"}.webpLoader__barProgress[data-percent="83"] .webpLoader__barCount:before{content:"83%"}.webpLoader__barProgress[data-percent="84"] .webpLoader__barCount:before{content:"84%"}.webpLoader__barProgress[data-percent="85"] .webpLoader__barCount:before{content:"85%"}.webpLoader__barProgress[data-percent="86"] .webpLoader__barCount:before{content:"86%"}.webpLoader__barProgress[data-percent="87"] .webpLoader__barCount:before{content:"87%"}.webpLoader__barProgress[data-percent="88"] .webpLoader__barCount:before{content:"88%"}.webpLoader__barProgress[data-percent="89"] .webpLoader__barCount:before{content:"89%"}.webpLoader__barProgress[data-percent="90"] .webpLoader__barCount:before{content:"90%"}.webpLoader__barProgress[data-percent="91"] .webpLoader__barCount:before{content:"91%"}.webpLoader__barProgress[data-percent="92"] .webpLoader__barCount:before{content:"92%"}.webpLoader__barProgress[data-percent="93"] .webpLoader__barCount:before{content:"93%"}.webpLoader__barProgress[data-percent="94"] .webpLoader__barCount:before{content:"94%"}.webpLoader__barProgress[data-percent="95"] .webpLoader__barCount:before{content:"95%"}.webpLoader__barProgress[data-percent="96"] .webpLoader__barCount:before{content:"96%"}.webpLoader__barProgress[data-percent="97"] .webpLoader__barCount:before{content:"97%"}.webpLoader__barProgress[data-percent="98"] .webpLoader__barCount:before{content:"98%"}.webpLoader__barProgress[data-percent="99"] .webpLoader__barCount:before{content:"99%"}.webpLoader__barProgress[data-percent="100"] .webpLoader__barCount:before{content:"100%"}.webpLoader__size{font-size:14px;line-height:1.5714285714;margin-bottom:-10px;padding:4px 0}.webpLoader__sizeProgress{font-weight:500}.webpLoader__success{margin-top:20px;padding:4px 0 4px 20px;position:relative}.webpLoader__success:before{background-color:#46b450;content:"";height:100%;left:0;position:absolute;top:0;width:2px}.webpLoader__successContent{color:#46b450;font-size:14px;font-weight:500;line-height:1.5714285714}.webpLoader__successContent a{color:inherit}.webpLoader__errors{border-left:2px solid #a0a5aa;margin-top:20px}.webpLoader__errorsTitle{background-color:#a0a5aa;color:#fff;display:inline-block;font-size:14px;line-height:1.5714285714;padding:4px 22px}.webpLoader__errorsContent{padding:10px 0 10px 20px}.webpLoader__errorsContent p{font-size:12px;line-height:1.75;margin:0;max-width:100%}.webpLoader__errorsContent p.webpLoader__errorsContentError{color:#dc3232;font-size:14px;font-weight:500;line-height:1.5714285714}.webpLoader__button--disabled{opacity:.25!important;pointer-events:none}.webpPopup{margin-top:20px}.webpPopup__inner{background-color:#fff;display:flex;flex-wrap:wrap}.webpPopup__image{background-image:url(../../img/author.jpg);background-position:50%;background-repeat:no-repeat;background-size:cover;width:152px}.webpPopup__content{border:1px solid #a0a5aa;border-left:0;flex:1;padding:10px 20px}.webpServerInfo{color:#222;text-align:center}.webpServerInfo pre{font-family:monospace;margin:0}.webpServerInfo h1,.webpServerInfo h2{display:none}.webpServerInfo p{max-width:100%}.webpServerInfo table{border:0;border-collapse:collapse;margin:10px auto;width:100%}.webpServerInfo td,.webpServerInfo th{border:1px solid #666;font-size:12px;line-height:1.75;padding:4px 5px;text-align:center;vertical-align:baseline}.webpServerInfo .p{text-align:left}.webpServerInfo .e{background-color:#ccf;font-weight:700;width:300px}.webpServerInfo .h{background-color:#99c;font-weight:700}.webpServerInfo .v{word-wrap:break-word;background-color:#ddd;max-width:300px;overflow-x:auto}.webpServerInfo .v i{color:#999}.webpServerInfo img{border:0;float:right}@media screen and (max-width:1024px){.webpPage__column--large{width:100%}.webpPage__column--small{margin-top:40px;width:100%}.webpPage__widget+.webpPage__widget{margin-top:40px}}@media screen and (max-width:782px){.webpModal__button{width:100%}.webpPage{padding-right:10px}.webpPopup__inner{border:1px solid #a0a5aa;display:block}.webpPopup__image{height:152px;margin:20px auto 0}.webpPopup__content{border:0}}@media screen and (max-width:768px){.webpPage__quality{display:block}.webpPage__qualityItem{border-left:0}.webpPage__qualityItem+.webpPage__qualityItem{border-top:1px solid #a0a5aa}}
assets/build/js/scripts.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e,t={70:function(){function e(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var t=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.setVars()&&this.setEvents()}var r,s,i;return r=t,(s=[{key:"setVars",value:function(){if(this.buttonOpen=document.querySelector('[data-slug="webp-converter-for-media"] a[href*="action=deactivate"]'),this.modal=document.querySelector(".webpModal"),this.buttonOpen&&this.modal)return this.outer=this.modal.querySelector(".webpModal__outer"),this.form=this.outer.querySelector(".webpModal__form"),this.formOptions=this.form.querySelectorAll('[name="webpc_reason"]'),this.formComment=this.form.querySelector('[name="webpc_comment"]'),this.buttonSubmit=this.form.querySelector('button[type="submit"]'),this.buttonCancel=this.form.querySelector('button[type="button"]'),this.events={openModal:this.openModal.bind(this)},this.atts={optionPlaceholder:"data-placeholder"},!0}},{key:"setEvents",value:function(){var e=this;this.buttonOpen.addEventListener("click",this.events.openModal),this.buttonSubmit.addEventListener("click",this.submitForm.bind(this)),this.buttonCancel.addEventListener("click",this.cancelForm.bind(this)),this.outer.addEventListener("click",this.closeModal.bind(this)),this.form.addEventListener("click",(function(e){e.stopPropagation()}));for(var t=this.formOptions.length,r=function(t){e.formOptions[t].addEventListener("change",(function(){e.setCurrentOption(t)}))},s=0;s<t;s++)r(s)}},{key:"openModal",value:function(e){e.preventDefault(),this.buttonOpen.removeEventListener("click",this.events.openModal),this.modal.removeAttribute("hidden")}},{key:"closeModal",value:function(){this.modal.setAttribute("hidden","hidden")}},{key:"submitForm",value:function(e){var t=this;e.preventDefault(),this.closeModal(),setTimeout((function(){var e=new FormData(t.form),r=t.form.getAttribute("action"),s=new XMLHttpRequest;s.open("POST",r,!0),s.send(e),t.buttonOpen.click()}),0)}},{key:"cancelForm",value:function(e){var t=this;e.preventDefault(),this.closeModal(),setTimeout((function(){t.buttonOpen.click()}),0)}},{key:"setCurrentOption",value:function(e){this.formComment.value="";var t=this.formOptions[e].getAttribute(this.atts.optionPlaceholder);this.formComment.setAttribute("placeholder",t)}}])&&e(r.prototype,s),i&&e(r,i),t}();function r(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.setVars()&&this.setEvents()}var t,s,i;return t=e,(s=[{key:"setVars",value:function(){if(this.notice=document.querySelector('.notice[data-notice="webp-converter-for-media"]'),this.notice)return this.settings={ajaxUrl:this.notice.getAttribute("data-url"),ajaxAction:"webpc_notice",buttonCloseClass:".notice-dismiss",buttonHideClass:"[data-permanently]"},this.events={clickOnClose:this.clickOnClose.bind(this)},!0}},{key:"setEvents",value:function(){this.notice.addEventListener("click",this.events.clickOnClose)}},{key:"clickOnClose",value:function(e){var t=this.settings,r=t.buttonCloseClass,s=t.buttonHideClass;this.notice.removeEventListener("click",this.events.clickOnClose),e.target.matches(r)?this.hideNotice(!1):e.target.matches(s)&&this.hideNotice(!0)}},{key:"hideNotice",value:function(e){var t=this.settings,r=t.ajaxUrl,s=t.ajaxAction,i=t.buttonCloseClass;jQuery.ajax(r,{type:"POST",data:{action:s,is_permanently:e?1:0}}),e&&this.notice.querySelector(i).click()}}])&&r(t.prototype,s),i&&r(t,i),e}();function i(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.setVars()&&this.setEvents()}var t,r,s;return t=e,(r=[{key:"setVars",value:function(){if(this.section=document.querySelector(".webpLoader"),this.section)return this.wrapper=this.section.querySelector(".webpLoader__status"),this.progress=this.wrapper.querySelector(".webpLoader__barProgress"),this.progressSize=this.section.querySelector(".webpLoader__sizeProgress"),this.errors=this.section.querySelector(".webpLoader__errors"),this.errorsInner=this.errors.querySelector(".webpLoader__errorsContentList"),this.errorsMessage=this.errors.querySelector(".webpLoader__errorsContentMessage"),this.success=this.section.querySelector(".webpLoader__success"),this.succesPopup=this.section.querySelector(".webpLoader__popup"),this.inputOptions=this.section.querySelectorAll('input[type="checkbox"]'),this.button=this.section.querySelector(".webpLoader__button"),this.data={count:0,max:0,items:[],size:{before:0,after:0},errors:[]},this.settings={isDisabled:!1,ajax:{urlPaths:this.section.getAttribute("data-api-paths"),urlRegenerate:this.section.getAttribute("data-api-regenerate"),errorMessage:this.section.getAttribute("data-api-error-message")},units:["kB","MB","GB"]},this.atts={progress:"data-percent"},this.classes={progressError:"webpLoader__barProgress--error",buttonDisabled:"webpLoader__button--disabled"},!0}},{key:"setEvents",value:function(){this.button.addEventListener("click",this.initRegenerate.bind(this))}},{key:"initRegenerate",value:function(e){if(e.preventDefault(),!this.settings.isDisabled){this.settings.isDisabled=!0,this.button.classList.add(this.classes.buttonDisabled);for(var t=this.inputOptions.length,r=0;r<t;r++)this.inputOptions[r].setAttribute("disabled",!0);this.wrapper.removeAttribute("hidden"),this.getImagesList()}}},{key:"getImagesList",value:function(){var e=this;jQuery.ajax(this.settings.ajax.urlPaths,{type:"POST",data:this.getDataForPathsRequest()}).done((function(t){e.data.items=t,e.data.max=t.length,e.regenerateNextImages()})).fail((function(){e.progress.classList.add(e.classes.progressError),e.errorsMessage.removeAttribute("hidden"),e.errors.removeAttribute("hidden")}))}},{key:"getDataForPathsRequest",value:function(){for(var e={},t=this.inputOptions.length,r=0;r<t;r++)e[this.inputOptions[r].getAttribute("name")]=this.inputOptions[r].checked?1:0;return e}},{key:"regenerateNextImages",value:function(){if(0===this.data.max&&this.updateProgress(),!(this.data.count>=this.data.max)){var e=this.data.items[this.data.count];this.data.count++,this.sendRequest(e)}}},{key:"sendRequest",value:function(e){var t=this;jQuery.ajax(this.settings.ajax.urlRegenerate,{type:"POST",data:{paths:e}}).done((function(e){t.updateErrors(e.errors),t.updateSize(e),t.updateProgress(),t.regenerateNextImages()})).fail((function(){var r=JSON.stringify(e),s=t.settings.ajax.errorMessage.replace("%s","<code>".concat(r,"</code>"));t.updateErrors([s]),t.regenerateNextImages()}))}},{key:"updateErrors",value:function(e){0!==e.length&&(this.data.errors=this.data.errors.concat(e),this.errorsInner.innerHTML=this.data.errors.join("<br>"),this.errors.removeAttribute("hidden"))}},{key:"updateSize",value:function(e){var t=this.data.size;t.before+=e.size.before,t.after+=e.size.after;var r=t.before-t.after;if(r<0&&(r=0),0!==r){var s=Math.round(100*(1-t.after/t.before));s<0&&(s=0);var i=-1;do{i++,r/=1024}while(r>1024);var n=r.toFixed(2),o=this.settings.units[i];this.progressSize.innerHTML="".concat(n," ").concat(o," (").concat(s,"%)")}}},{key:"updateProgress",value:function(){var e=this.data.max>0?Math.floor(this.data.count/this.data.max*100):100;e>100&&(e=100),100===e&&(this.success.removeAttribute("hidden"),this.succesPopup.removeAttribute("hidden")),this.progress.setAttribute(this.atts.progress,e)}}])&&i(t.prototype,r),s&&i(t,s),e}();new function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new t,new s,new n}},109:function(){}},r={};function s(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,s),n.exports}s.m=t,e=[],s.O=function(t,r,i,n){if(!r){var o=1/0;for(h=0;h<e.length;h++){r=e[h][0],i=e[h][1],n=e[h][2];for(var a=!0,u=0;u<r.length;u++)(!1&n||o>=n)&&Object.keys(s.O).every((function(e){return s.O[e](r[u])}))?r.splice(u--,1):(a=!1,n<o&&(o=n));if(a){e.splice(h--,1);var c=i();void 0!==c&&(t=c)}}return t}n=n||0;for(var h=e.length;h>0&&e[h-1][2]>n;h--)e[h]=e[h-1];e[h]=[r,i,n]},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={794:0,505:0};s.O.j=function(t){return 0===e[t]};var t=function(t,r){var i,n,o=r[0],a=r[1],u=r[2],c=0;if(o.some((function(t){return 0!==e[t]}))){for(i in a)s.o(a,i)&&(s.m[i]=a[i]);if(u)var h=u(s)}for(t&&t(r);c<o.length;c++)n=o[c],s.o(e,n)&&e[n]&&e[n][0](),e[o[c]]=0;return s.O(h)},r=self.webpackChunkwebp_converter_for_media=self.webpackChunkwebp_converter_for_media||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}(),s.O(void 0,[505],(function(){return s(70)}));var i=s.O(void 0,[505],(function(){return s(109)}));i=s.O(i)}();
1
+ !function(){var e,t={669:function(e,t,r){e.exports=r(609)},448:function(e,t,r){"use strict";var n=r(867),o=r(26),s=r(372),i=r(327),a=r(97),u=r(109),c=r(985),f=r(61);e.exports=function(e){return new Promise((function(t,r){var l=e.data,h=e.headers,d=e.responseType;n.isFormData(l)&&delete h["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",v=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";h.Authorization="Basic "+btoa(m+":"+v)}var g=a(e.baseURL,e.url);function b(){if(p){var n="getAllResponseHeaders"in p?u(p.getAllResponseHeaders()):null,s={data:d&&"text"!==d&&"json"!==d?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:n,config:e,request:p};o(t,r,s),p=null}}if(p.open(e.method.toUpperCase(),i(g,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,"onloadend"in p?p.onloadend=b:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(b)},p.onabort=function(){p&&(r(f("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(f("Network Error",e,null,p)),p=null},p.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(f(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var _=(e.withCredentials||c(g))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;_&&(h[e.xsrfHeaderName]=_)}"setRequestHeader"in p&&n.forEach(h,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete h[t]:p.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),d&&"json"!==d&&(p.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),r(e),p=null)})),l||(l=null),p.send(l)}))}},609:function(e,t,r){"use strict";var n=r(867),o=r(849),s=r(321),i=r(185);function a(e){var t=new s(e),r=o(s.prototype.request,t);return n.extend(r,s.prototype,t),n.extend(r,t),r}var u=a(r(655));u.Axios=s,u.create=function(e){return a(i(u.defaults,e))},u.Cancel=r(263),u.CancelToken=r(972),u.isCancel=r(502),u.all=function(e){return Promise.all(e)},u.spread=r(713),u.isAxiosError=r(268),e.exports=u,e.exports.default=u},263:function(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:function(e,t,r){"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:function(e){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:function(e,t,r){"use strict";var n=r(867),o=r(327),s=r(782),i=r(572),a=r(185),u=r(875),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new s,response:new s}}f.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var f=[i,void 0];for(Array.prototype.unshift.apply(f,r),f=f.concat(s),o=Promise.resolve(e);f.length;)o=o.then(f.shift(),f.shift());return o}for(var l=e;r.length;){var h=r.shift(),d=r.shift();try{l=h(l)}catch(e){d(e);break}}try{o=i(l)}catch(e){return Promise.reject(e)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=f},782:function(e,t,r){"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},97:function(e,t,r){"use strict";var n=r(793),o=r(303);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},61:function(e,t,r){"use strict";var n=r(481);e.exports=function(e,t,r,o,s){var i=new Error(e);return n(i,t,r,o,s)}},572:function(e,t,r){"use strict";var n=r(867),o=r(527),s=r(502),i=r(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function(t){return a(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return s(t)||(a(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:function(e){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],s=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function u(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function c(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=u(void 0,t[e]))})),n.forEach(s,c),n.forEach(i,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=u(e[n],t[n]):n in e&&(r[n]=u(void 0,e[n]))}));var f=o.concat(s).concat(i).concat(a),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===f.indexOf(e)}));return n.forEach(l,c),r}},26:function(e,t,r){"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:function(e,t,r){"use strict";var n=r(867),o=r(655);e.exports=function(e,t,r){var s=this||o;return n.forEach(r,(function(r){e=r.call(s,e,t)})),e}},655:function(e,t,r){"use strict";var n=r(155),o=r(867),s=r(16),i=r(481),a={"Content-Type":"application/x-www-form-urlencoded"};function u(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,f={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==n&&"[object process]"===Object.prototype.toString.call(n))&&(c=r(448)),c),transformRequest:[function(e,t){return s(t,"Accept"),s(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(u(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)||t&&"application/json"===t["Content-Type"]?(u(t,"application/json"),function(e,t,r){if(o.isString(e))try{return(t||JSON.parse)(e),o.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,s=!r&&"json"===this.responseType;if(s||n&&o.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};f.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],(function(e){f.headers[e]={}})),o.forEach(["post","put","patch"],(function(e){f.headers[e]=o.merge(a)})),e.exports=f},849:function(e){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},327:function(e,t,r){"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var s;if(r)s=r(t);else if(n.isURLSearchParams(t))s=t.toString();else{var i=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),i.push(o(t)+"="+o(e))})))})),s=i.join("&")}if(s){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}},303:function(e){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:function(e,t,r){"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(s)&&a.push("domain="+s),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:function(e){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},268:function(e){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},985:function(e,t,r){"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:function(e,t,r){"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,s,i={};return e?(n.forEach(e.split("\n"),(function(e){if(s=e.indexOf(":"),t=n.trim(e.substr(0,s)).toLowerCase(),r=n.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i}},713:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},875:function(e,t,r){"use strict";var n=r(593),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var s={},i=n.version.split(".");function a(e,t){for(var r=t?t.split("."):i,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}o.transitional=function(e,t,r){var o=t&&a(t);return function(i,a,u){if(!1===e)throw new Error(function(e,t){return"[Axios v"+n.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}(a," has been removed in "+t));return o&&!s[a]&&(s[a]=!0),!e||e(i,a,u)}},e.exports={isOlderVersion:a,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var s=n[o],i=t[s];if(i){var a=e[s],u=void 0===a||i(a,s,e);if(!0!==u)throw new TypeError("option "+s+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:o}},867:function(e,t,r){"use strict";var n=r(849),o=Object.prototype.toString;function s(e){return"[object Array]"===o.call(e)}function i(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:s,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!i(e)&&null!==e.constructor&&!i(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:i,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function r(r,n){u(t[n])&&u(r)?t[n]=e(t[n],r):u(r)?t[n]=e({},r):s(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)f(arguments[n],r);return t},extend:function(e,t,r){return f(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},70:function(e,t,r){"use strict";var n=r(669),o=r.n(n);function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.button_open=document.querySelector('[data-slug="webp-converter-for-media"] a[href*="action=deactivate"]'),this.modal=document.querySelector(".webpModal"),this.button_open&&this.modal)return this.outer=this.modal.querySelector(".webpModal__outer"),this.form=this.outer.querySelector(".webpModal__form"),this.form_options=this.form.querySelectorAll('[name="webpc_reason"]'),this.form_comment=this.form.querySelector('[name="webpc_comment"]'),this.button_submit=this.form.querySelector('button[type="submit"]'),this.button_cancel=this.form.querySelector('button[type="button"]'),this.events={open_modal:this.open_modal.bind(this)},this.atts={option_placeholder:"data-placeholder"},this.status={is_sent:!1},!0}},{key:"set_events",value:function(){var e=this;this.button_open.addEventListener("click",this.events.open_modal),this.button_submit.addEventListener("click",this.submit_form.bind(this)),this.button_cancel.addEventListener("click",this.cancel_form.bind(this)),this.outer.addEventListener("click",this.close_modal.bind(this)),this.form.addEventListener("click",(function(e){e.stopPropagation()}));for(var t=this.form_options.length,r=function(t){e.form_options[t].addEventListener("change",(function(){e.set_current_option(t)}))},n=0;n<t;n++)r(n)}},{key:"open_modal",value:function(e){e.preventDefault(),this.button_open.removeEventListener("click",this.events.open_modal),this.modal.removeAttribute("hidden")}},{key:"close_modal",value:function(){this.modal.setAttribute("hidden","hidden")}},{key:"submit_form",value:function(e){var t=this;e.preventDefault(),this.close_modal(),this.status.is_sent||(this.status.is_sent=!0,setTimeout((function(){t.send_request(),t.button_open.click()}),0))}},{key:"send_request",value:function(){var e=new FormData(this.form),t=this.form.getAttribute("action");o()({method:"POST",url:t,data:e})}},{key:"cancel_form",value:function(e){var t=this;e.preventDefault(),this.close_modal(),setTimeout((function(){t.button_open.click()}),0)}},{key:"set_current_option",value:function(e){this.form_comment.value="";var t=this.form_options[e].getAttribute(this.atts.option_placeholder);this.form_comment.setAttribute("placeholder",t)}}])&&s(t.prototype,r),n&&s(t,n),e}();function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.notice=document.querySelector('.notice[data-notice="webp-converter-for-media"]'),this.notice)return this.settings={ajax_url:this.notice.getAttribute("data-url"),ajax_action:"webpc_notice",button_close_class:".notice-dismiss",button_hide_class:"[data-permanently]"},this.events={click_on_close:this.click_on_close.bind(this)},!0}},{key:"set_events",value:function(){this.notice.addEventListener("click",this.events.click_on_close)}},{key:"click_on_close",value:function(e){var t=this.settings,r=t.button_close_class,n=t.button_hide_class;this.notice.removeEventListener("click",this.events.click_on_close),e.target.matches(r)?this.hide_notice(!1):e.target.matches(n)&&this.hide_notice(!0)}},{key:"hide_notice",value:function(e){var t=this.settings.button_close_class;this.send_request(e),e&&this.notice.querySelector(t).click()}},{key:"send_request",value:function(e){var t=this.settings.ajax_url;o()({method:"POST",url:t,data:this.get_data_for_request(e)})}},{key:"get_data_for_request",value:function(e){var t=this.settings.ajax_action,r=new FormData;return r.append("action",t),r.append("is_permanently",e?1:0),r}}])&&a(t.prototype,r),n&&a(t,n),e}();function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.section=document.querySelector(".webpLoader"),this.section)return this.wrapper=this.section.querySelector(".webpLoader__status"),this.progress=this.wrapper.querySelector(".webpLoader__barProgress"),this.progress_size=this.section.querySelector(".webpLoader__sizeProgress"),this.errors=this.section.querySelector(".webpLoader__errors"),this.errors_inner=this.errors.querySelector(".webpLoader__errorsContent"),this.success=this.section.querySelector(".webpLoader__success"),this.success_popup=this.section.querySelector(".webpLoader__popup"),this.option_force=this.section.querySelector('input[name="regenerate_force"]'),this.button=this.section.querySelector(".webpLoader__button"),this.data={count:0,max:0,items:[],size:{before:0,after:0},errors:[]},this.settings={is_disabled:!1,ajax:{url_paths:this.section.getAttribute("data-api-paths"),url_regenerate:this.section.getAttribute("data-api-regenerate"),error_message:this.section.getAttribute("data-api-error-message")},units:["kB","MB","GB"]},this.atts={progress:"data-percent"},this.classes={progress_error:"webpLoader__barProgress--error",button_disabled:"webpLoader__button--disabled",error_message:"webpLoader__errorsContentError"},!0}},{key:"set_events",value:function(){this.button.addEventListener("click",this.init_regeneration.bind(this))}},{key:"init_regeneration",value:function(e){e.preventDefault(),this.settings.is_disabled||(this.settings.is_disabled=!0,this.button.classList.add(this.classes.button_disabled),this.option_force.setAttribute("disabled","disabled"),this.wrapper.removeAttribute("hidden"),this.send_request_for_paths())}},{key:"send_request_for_paths",value:function(){var e=this,t=this.settings.ajax,r=t.url_paths,n=t.error_message;o()({method:"POST",url:r,data:this.get_data_for_paths_request()}).then((function(t){e.data.items=t.data,e.data.max=t.data.length,e.regenerate_next_images()})).catch((function(t){var r=t.response&&t.response.data.message||null;e.update_errors([r||n],!0)}))}},{key:"get_data_for_paths_request",value:function(){var e=new FormData;return e.append("regenerate_force",this.option_force.checked?1:0),e}},{key:"regenerate_next_images",value:function(){if(0===this.data.max&&this.update_progress(),!(this.data.count>=this.data.max)){var e=this.data.items[this.data.count];this.data.count++,this.send_request_for_regeneration(e)}}},{key:"send_request_for_regeneration",value:function(e){var t=this,r=this.settings.ajax,n=r.url_regenerate,s=r.error_message;o()({method:"POST",url:n,data:{paths:e}}).then((function(e){t.update_errors(e.data.errors),t.update_size(e.data.size.before,e.data.size.after),t.update_progress(),t.regenerate_next_images()})).catch((function(e){var r=e.response&&e.response.data.message||null;t.update_errors([r||s],!0)}))}},{key:"update_errors",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(0!==e.length){for(var r=0;r<e.length;r++)this.print_error_message(e[r],t);this.errors.removeAttribute("hidden"),t&&this.progress.classList.add(this.classes.progress_error)}}},{key:"print_error_message",value:function(e,t){var r=document.createElement("p");r.innerHTML=e,t&&r.classList.add(this.classes.error_message),this.errors_inner.appendChild(r)}},{key:"update_size",value:function(e,t){var r=this.data.size;r.before+=e,r.after+=t;var n=r.before-r.after;if(n<0&&(n=0),0!==n){var o=Math.round(100*(1-r.after/r.before));o<0&&(o=0);var s=-1;do{s++,n/=1024}while(n>1024);var i=n.toFixed(2),a=this.settings.units[s];this.progress_size.innerHTML="".concat(i," ").concat(a," (").concat(o,"%)")}}},{key:"update_progress",value:function(){var e=this.data.max>0?Math.floor(this.data.count/this.data.max*100):100;e>100&&(e=100),100===e&&(this.success.removeAttribute("hidden"),this.success_popup.removeAttribute("hidden")),this.progress.setAttribute(this.atts.progress,e.toString())}}])&&c(t.prototype,r),n&&c(t,n),e}();new function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new i,new u,new f}},694:function(){},155:function(e){var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,u=[],c=!1,f=-1;function l(){c&&a&&(c=!1,a.length?u=a.concat(u):f=-1,u.length&&h())}function h(){if(!c){var e=i(l);c=!0;for(var t=u.length;t;){for(a=u,u=[];++f<t;)a&&a[f].run();f=-1,t=u.length}a=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new d(e,t)),1!==u.length||c||i(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},593:function(e){"use strict";e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var s=r[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=function(t,r,o,s){if(!r){var i=1/0;for(f=0;f<e.length;f++){r=e[f][0],o=e[f][1],s=e[f][2];for(var a=!0,u=0;u<r.length;u++)(!1&s||i>=s)&&Object.keys(n.O).every((function(e){return n.O[e](r[u])}))?r.splice(u--,1):(a=!1,s<i&&(i=s));if(a){e.splice(f--,1);var c=o();void 0!==c&&(t=c)}}return t}s=s||0;for(var f=e.length;f>0&&e[f-1][2]>s;f--)e[f]=e[f-1];e[f]=[r,o,s]},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={794:0,505:0};n.O.j=function(t){return 0===e[t]};var t=function(t,r){var o,s,i=r[0],a=r[1],u=r[2],c=0;if(i.some((function(t){return 0!==e[t]}))){for(o in a)n.o(a,o)&&(n.m[o]=a[o]);if(u)var f=u(n)}for(t&&t(r);c<i.length;c++)s=i[c],n.o(e,s)&&e[s]&&e[s][0](),e[i[c]]=0;return n.O(f)},r=self.webpackChunkwebp_converter_for_media=self.webpackChunkwebp_converter_for_media||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}(),n.O(void 0,[505],(function(){return n(70)}));var o=n.O(void 0,[505],(function(){return n(694)}));o=n.O(o)}();
readme.txt CHANGED
@@ -231,6 +231,34 @@ add_filter( 'webpc_dir_name', function( $path, $directory ) {
231
 
232
  After setting the filters go to `Settings -> WebP Converter` in the admin panel and click the `Save Changes` button. `.htaccess` files with appropriate rules should be created in the directories `/uploads` and `/uploads-webpc`.
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  = How to run manually conversion? =
235
 
236
  By default, all images are converted when you click on the `Regenerate All` button. In addition, conversion is automatic when you add new files to your Media Library.
@@ -259,12 +287,6 @@ An alternative method is to manually start converting the selected attachment by
259
 
260
  `do_action( 'webpc_convert_attachment', $post_id );`
261
 
262
- In addition, you can edit the list of files that will be converted. For example, to add some to the exceptions. To do this, use the following filter, which by default returns a list of all paths:
263
-
264
- `add_filter( 'webpc_files_paths', function( $paths, $skip_exists ) {
265
- return $paths;
266
- }, 10, 2 );`
267
-
268
  Argument `$paths` is array of absolute server paths and `$skip_exists` means whether to skip converted images.
269
 
270
  You can also modify the list of image paths for an attachment, e.g. to exclude one image size. To do this, use the following filter:
@@ -436,6 +458,14 @@ This is all very important to us and allows us to do even better things for you!
436
 
437
  == Changelog ==
438
 
 
 
 
 
 
 
 
 
439
  = 3.1.1 (2021-09-08) =
440
  * `[Fixed]` Generating .htaccess files for multisite websites
441
  * `[Changed]` Fields on plugin settings page
231
 
232
  After setting the filters go to `Settings -> WebP Converter` in the admin panel and click the `Save Changes` button. `.htaccess` files with appropriate rules should be created in the directories `/uploads` and `/uploads-webpc`.
233
 
234
+ = How to exclude paths from converting? =
235
+
236
+ To exclude selected directories, use the following filter:
237
+
238
+ `add_filter( 'webpc_supported_source_directory', function( bool $status, string $directory_name, string $server_path ): bool {
239
+ $excluded_directories = [ 'my-directory' ];
240
+ if ( ! $status || in_array( $directory_name, $excluded_directories ) ) {
241
+ return false;
242
+ }
243
+
244
+ return $status;
245
+ }, 10, 3 );`
246
+
247
+ To exclude selected files use the following filter:
248
+
249
+ `add_filter( 'webpc_supported_source_file', function( bool $status, string $file_name, string $server_path ): bool {
250
+ $excluded_files = [ 'my-image.jpg' ];
251
+ if ( ! $status || in_array( $file_name, $excluded_files ) ) {
252
+ return false;
253
+ }
254
+
255
+ return $status;
256
+ }, 10, 3 );`
257
+
258
+ Argument `$server_path` is the absolute server path to a directory or file. Inside the filters, you can apply more complicated rules as needed.
259
+
260
+ Filters run before images are converted - they no longer support converted images. You have to delete them manually if they should not be converted.
261
+
262
  = How to run manually conversion? =
263
 
264
  By default, all images are converted when you click on the `Regenerate All` button. In addition, conversion is automatic when you add new files to your Media Library.
287
 
288
  `do_action( 'webpc_convert_attachment', $post_id );`
289
 
 
 
 
 
 
 
290
  Argument `$paths` is array of absolute server paths and `$skip_exists` means whether to skip converted images.
291
 
292
  You can also modify the list of image paths for an attachment, e.g. to exclude one image size. To do this, use the following filter:
458
 
459
  == Changelog ==
460
 
461
+ = 3.2.0 (2021-09-12) =
462
+ * `[Removed]` Filter `webpc_files_paths`
463
+ * `[Removed]` Filter `webpc_dir_excluded`
464
+ * `[Changed]` Error handling when converting images
465
+ * `[Added]` Filter `webpc_supported_source_file` to exclude paths to files from converting
466
+ * `[Added]` Filter `webpc_supported_source_directory` to exclude paths to directories from converting
467
+ * `[Added]` Modifications to appearance of plugin settings page
468
+
469
  = 3.1.1 (2021-09-08) =
470
  * `[Fixed]` Generating .htaccess files for multisite websites
471
  * `[Changed]` Fields on plugin settings page
src/Action/ConvertAttachment.php CHANGED
@@ -12,13 +12,10 @@ use WebpConverter\PluginData;
12
  class ConvertAttachment implements HookableInterface {
13
 
14
  /**
15
- * @var PluginData .
16
  */
17
  private $plugin_data;
18
 
19
- /**
20
- * @param PluginData $plugin_data .
21
- */
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
12
  class ConvertAttachment implements HookableInterface {
13
 
14
  /**
15
+ * @var PluginData
16
  */
17
  private $plugin_data;
18
 
 
 
 
19
  public function __construct( PluginData $plugin_data ) {
20
  $this->plugin_data = $plugin_data;
21
  }
src/Action/ConvertDir.php CHANGED
@@ -19,14 +19,14 @@ class ConvertDir implements HookableInterface {
19
  /**
20
  * Converts all images in directory to output formats.
21
  *
22
- * @param string $dir_path Server path of directory.
23
- * @param bool $skip_exists Skip converted images?
24
  *
25
  * @return void
26
  * @internal
27
  */
28
- public function convert_files_by_directory( string $dir_path, bool $skip_exists = true ) {
29
- $paths = apply_filters( 'webpc_dir_filess', [], $dir_path, $skip_exists );
30
  do_action( 'webpc_convert_paths', $paths );
31
  }
32
  }
19
  /**
20
  * Converts all images in directory to output formats.
21
  *
22
+ * @param string $dir_path Server path of directory.
23
+ * @param bool $skip_converted Skip converted images?
24
  *
25
  * @return void
26
  * @internal
27
  */
28
+ public function convert_files_by_directory( string $dir_path, bool $skip_converted = true ) {
29
+ $paths = apply_filters( 'webpc_dir_files', [], $dir_path, $skip_converted );
30
  do_action( 'webpc_convert_paths', $paths );
31
  }
32
  }
src/Action/ConvertPaths.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Action;
4
 
5
  use WebpConverter\Conversion\Method\MethodIntegrator;
 
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
8
 
@@ -11,14 +12,13 @@ use WebpConverter\PluginData;
11
  */
12
  class ConvertPaths implements HookableInterface {
13
 
 
 
14
  /**
15
- * @var PluginData .
16
  */
17
  private $plugin_data;
18
 
19
- /**
20
- * @param PluginData $plugin_data .
21
- */
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
@@ -40,28 +40,22 @@ class ConvertPaths implements HookableInterface {
40
  */
41
  public function convert_files_by_paths( array $paths ) {
42
  ( new MethodIntegrator( $this->plugin_data ) )
43
- ->init_conversion( $this->remove_paths_of_excluded_dirs( $paths ) );
44
  }
45
 
46
  /**
47
- * Removes paths of source images in excluded directories.
48
  *
49
- * @param string[] $paths Server paths of images.
50
  *
51
- * @return string[] Server paths of images.
52
  */
53
- private function remove_paths_of_excluded_dirs( array $paths ): array {
54
- $excluded_dirs = apply_filters( 'webpc_dir_excluded', [] );
55
- foreach ( $paths as $path_index => $path ) {
56
- foreach ( $excluded_dirs as $excluded_dir ) {
57
- $dir_pattern = str_replace( '.', '\.', $excluded_dir );
58
- if ( ! preg_match( '/(\\\\|\/)(' . $dir_pattern . ')(\\\\|\/)/', $path ) ) {
59
- continue;
60
- }
61
- unset( $paths[ $path_index ] );
62
- break;
63
  }
64
  }
65
- return $paths;
66
  }
67
  }
3
  namespace WebpConverter\Action;
4
 
5
  use WebpConverter\Conversion\Method\MethodIntegrator;
6
+ use WebpConverter\Conversion\PathsValidator;
7
  use WebpConverter\HookableInterface;
8
  use WebpConverter\PluginData;
9
 
12
  */
13
  class ConvertPaths implements HookableInterface {
14
 
15
+ use PathsValidator;
16
+
17
  /**
18
+ * @var PluginData
19
  */
20
  private $plugin_data;
21
 
 
 
 
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
40
  */
41
  public function convert_files_by_paths( array $paths ) {
42
  ( new MethodIntegrator( $this->plugin_data ) )
43
+ ->init_conversion( $this->remove_paths_from_excluded_paths( $paths ) );
44
  }
45
 
46
  /**
47
+ * Removes paths of source images from excluded paths.
48
  *
49
+ * @param string[] $source_paths Server paths of images.
50
  *
51
+ * @return string[]
52
  */
53
+ private function remove_paths_from_excluded_paths( array $source_paths ): array {
54
+ foreach ( $source_paths as $path_index => $path ) {
55
+ if ( ! $this->is_supported_source_file( $path ) ) {
56
+ unset( $source_paths[ $path_index ] );
 
 
 
 
 
 
57
  }
58
  }
59
+ return $source_paths;
60
  }
61
  }
src/Action/RegenerateAll.php CHANGED
@@ -12,13 +12,10 @@ use WebpConverter\PluginData;
12
  class RegenerateAll implements HookableInterface {
13
 
14
  /**
15
- * @var PluginData .
16
  */
17
  private $plugin_data;
18
 
19
- /**
20
- * @param PluginData $plugin_data .
21
- */
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
12
  class RegenerateAll implements HookableInterface {
13
 
14
  /**
15
+ * @var PluginData
16
  */
17
  private $plugin_data;
18
 
 
 
 
19
  public function __construct( PluginData $plugin_data ) {
20
  $this->plugin_data = $plugin_data;
21
  }
src/Conversion/Cron/Event.php CHANGED
@@ -4,6 +4,7 @@ namespace WebpConverter\Conversion\Cron;
4
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\PluginData;
 
7
 
8
  /**
9
  * Adds cron event that converts images.
@@ -11,13 +12,10 @@ use WebpConverter\PluginData;
11
  class Event implements HookableInterface {
12
 
13
  /**
14
- * @var PluginData .
15
  */
16
  private $plugin_data;
17
 
18
- /**
19
- * @param PluginData $plugin_data .
20
- */
21
  public function __construct( PluginData $plugin_data ) {
22
  $this->plugin_data = $plugin_data;
23
  }
@@ -40,7 +38,7 @@ class Event implements HookableInterface {
40
  public function add_cron_event() {
41
  if ( wp_next_scheduled( self::CRON_ACTION )
42
  || ! ( $settings = $this->plugin_data->get_plugin_settings() )
43
- || ! in_array( 'cron_enabled', $settings['features'] ) ) {
44
  return;
45
  }
46
 
4
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\PluginData;
7
+ use WebpConverter\Settings\Option\ExtraFeaturesOption;
8
 
9
  /**
10
  * Adds cron event that converts images.
12
  class Event implements HookableInterface {
13
 
14
  /**
15
+ * @var PluginData
16
  */
17
  private $plugin_data;
18
 
 
 
 
19
  public function __construct( PluginData $plugin_data ) {
20
  $this->plugin_data = $plugin_data;
21
  }
38
  public function add_cron_event() {
39
  if ( wp_next_scheduled( self::CRON_ACTION )
40
  || ! ( $settings = $this->plugin_data->get_plugin_settings() )
41
+ || ! in_array( ExtraFeaturesOption::OPTION_VALUE_CRON_ENABLED, $settings[ ExtraFeaturesOption::OPTION_NAME ] ) ) {
42
  return;
43
  }
44
 
src/Conversion/Directory/DirectoryIntegration.php CHANGED
@@ -10,8 +10,6 @@ use WebpConverter\HookableInterface;
10
  */
11
  class DirectoryIntegration implements HookableInterface {
12
 
13
- const DIRS_EXCLUDED = [ '.', '..', '.git', '.svn', 'node_modules' ];
14
-
15
  /**
16
  * Objects of supported directories.
17
  *
@@ -27,7 +25,6 @@ class DirectoryIntegration implements HookableInterface {
27
  add_filter( 'webpc_dir_path', [ $this, 'get_dir_as_path' ], 0, 2 );
28
  add_filter( 'webpc_dir_url', [ $this, 'get_dir_as_url' ], 0, 2 );
29
  add_filter( 'webpc_uploads_prefix', [ $this, 'get_prefix_path' ], 0 );
30
- add_filter( 'webpc_dir_excluded', [ $this, 'get_excluded_dirs' ], 0 );
31
  }
32
 
33
  /**
@@ -150,14 +147,4 @@ class DirectoryIntegration implements HookableInterface {
150
 
151
  return str_replace( '//', '/', $diff_path );
152
  }
153
-
154
- /**
155
- * Returns list of directories excluded from source file search.
156
- *
157
- * @return string[] Relative paths of excluded directories.
158
- * @internal
159
- */
160
- public function get_excluded_dirs(): array {
161
- return self::DIRS_EXCLUDED;
162
- }
163
  }
10
  */
11
  class DirectoryIntegration implements HookableInterface {
12
 
 
 
13
  /**
14
  * Objects of supported directories.
15
  *
25
  add_filter( 'webpc_dir_path', [ $this, 'get_dir_as_path' ], 0, 2 );
26
  add_filter( 'webpc_dir_url', [ $this, 'get_dir_as_url' ], 0, 2 );
27
  add_filter( 'webpc_uploads_prefix', [ $this, 'get_prefix_path' ], 0 );
 
28
  }
29
 
30
  /**
147
 
148
  return str_replace( '//', '/', $diff_path );
149
  }
 
 
 
 
 
 
 
 
 
 
150
  }
src/Conversion/DirectoryFiles.php CHANGED
@@ -4,20 +4,20 @@ namespace WebpConverter\Conversion;
4
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\PluginData;
 
7
 
8
  /**
9
  * Returns paths to files in given directory.
10
  */
11
  class DirectoryFiles implements HookableInterface {
12
 
 
 
13
  /**
14
- * @var PluginData .
15
  */
16
  private $plugin_data;
17
 
18
- /**
19
- * @param PluginData $plugin_data .
20
- */
21
  public function __construct( PluginData $plugin_data ) {
22
  $this->plugin_data = $plugin_data;
23
  }
@@ -32,35 +32,32 @@ class DirectoryFiles implements HookableInterface {
32
  /**
33
  * Returns list of source images for directory.
34
  *
35
- * @param string[] $value Server paths of source images.
36
- * @param string $dir_path Server path of source directory.
37
- * @param bool $skip_exists Skip images already converted?
38
  *
39
  * @return string[] Server paths of source images.
40
  * @internal
41
  */
42
- public function get_files_by_directory( array $value, string $dir_path, bool $skip_exists = false ): array {
43
  if ( ! file_exists( $dir_path ) ) {
44
  return $value;
45
  }
46
 
47
  $settings = $this->plugin_data->get_plugin_settings();
48
- $excluded = apply_filters( 'webpc_dir_excluded', [] );
49
-
50
- $paths = $this->find_files_in_directory( $dir_path, $settings['extensions'], $excluded );
51
- return apply_filters( 'webpc_files_paths', $paths, $skip_exists );
52
  }
53
 
54
  /**
55
  * Returns list of source images for directory.
56
  *
57
- * @param string $dir_path Server path of source directory.
58
- * @param string[] $allowed_exts File extensions to find.
59
- * @param string[] $excluded_dirs Directories to ignore search.
60
  *
61
  * @return string[] Server paths of source images.
62
  */
63
- private function find_files_in_directory( string $dir_path, array $allowed_exts, array $excluded_dirs ): array {
64
  $paths = scandir( $dir_path );
65
  $list = [];
66
  if ( ! is_array( $paths ) ) {
@@ -68,15 +65,15 @@ class DirectoryFiles implements HookableInterface {
68
  }
69
 
70
  foreach ( $paths as $path ) {
71
- if ( in_array( $path, $excluded_dirs ) ) {
72
- continue;
73
- }
74
-
75
  $current_path = $dir_path . '/' . urlencode( $path ); // phpcs:ignore
76
  if ( is_dir( $current_path ) ) {
77
- $list = array_merge( $list, $this->find_files_in_directory( $current_path, $allowed_exts, $excluded_dirs ) );
 
 
78
  } elseif ( in_array( strtolower( pathinfo( $current_path, PATHINFO_EXTENSION ) ), $allowed_exts ) ) {
79
- $list[] = $current_path;
 
 
80
  }
81
  }
82
  return $list;
4
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\PluginData;
7
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
8
 
9
  /**
10
  * Returns paths to files in given directory.
11
  */
12
  class DirectoryFiles implements HookableInterface {
13
 
14
+ use PathsValidator;
15
+
16
  /**
17
+ * @var PluginData
18
  */
19
  private $plugin_data;
20
 
 
 
 
21
  public function __construct( PluginData $plugin_data ) {
22
  $this->plugin_data = $plugin_data;
23
  }
32
  /**
33
  * Returns list of source images for directory.
34
  *
35
+ * @param string[] $value Server paths of source images.
36
+ * @param string $dir_path Server path of source directory.
37
+ * @param bool $skip_converted Skip images already converted?
38
  *
39
  * @return string[] Server paths of source images.
40
  * @internal
41
  */
42
+ public function get_files_by_directory( array $value, string $dir_path, bool $skip_converted = false ): array {
43
  if ( ! file_exists( $dir_path ) ) {
44
  return $value;
45
  }
46
 
47
  $settings = $this->plugin_data->get_plugin_settings();
48
+ return $this->find_files_in_directory( $dir_path, $settings[ SupportedExtensionsOption::OPTION_NAME ], $skip_converted );
 
 
 
49
  }
50
 
51
  /**
52
  * Returns list of source images for directory.
53
  *
54
+ * @param string $dir_path Server path of source directory.
55
+ * @param string[] $allowed_exts File extensions to find.
56
+ * @param bool $skip_converted Skip images already converted?
57
  *
58
  * @return string[] Server paths of source images.
59
  */
60
+ private function find_files_in_directory( string $dir_path, array $allowed_exts, bool $skip_converted ): array {
61
  $paths = scandir( $dir_path );
62
  $list = [];
63
  if ( ! is_array( $paths ) ) {
65
  }
66
 
67
  foreach ( $paths as $path ) {
 
 
 
 
68
  $current_path = $dir_path . '/' . urlencode( $path ); // phpcs:ignore
69
  if ( is_dir( $current_path ) ) {
70
+ if ( $this->is_supported_source_directory( $current_path ) ) {
71
+ $list = array_merge( $list, $this->find_files_in_directory( $current_path, $allowed_exts, $skip_converted ) );
72
+ }
73
  } elseif ( in_array( strtolower( pathinfo( $current_path, PATHINFO_EXTENSION ) ), $allowed_exts ) ) {
74
+ if ( $this->is_supported_source_file( $current_path, $skip_converted ) ) {
75
+ $list[] = $current_path;
76
+ }
77
  }
78
  }
79
  return $list;
src/Conversion/Endpoint/EndpointAbstract.php CHANGED
@@ -10,13 +10,10 @@ use WebpConverter\PluginData;
10
  abstract class EndpointAbstract implements EndpointInterface {
11
 
12
  /**
13
- * @var PluginData .
14
  */
15
  protected $plugin_data;
16
 
17
- /**
18
- * @param PluginData $plugin_data .
19
- */
20
  public function __construct( PluginData $plugin_data ) {
21
  $this->plugin_data = $plugin_data;
22
  }
10
  abstract class EndpointAbstract implements EndpointInterface {
11
 
12
  /**
13
+ * @var PluginData
14
  */
15
  protected $plugin_data;
16
 
 
 
 
17
  public function __construct( PluginData $plugin_data ) {
18
  $this->plugin_data = $plugin_data;
19
  }
src/Conversion/Endpoint/EndpointIntegration.php CHANGED
@@ -18,9 +18,6 @@ class EndpointIntegration implements HookableInterface {
18
  */
19
  private $endpoint_object;
20
 
21
- /**
22
- * @param EndpointInterface $endpoint_object .
23
- */
24
  public function __construct( EndpointInterface $endpoint_object ) {
25
  $this->endpoint_object = $endpoint_object;
26
  }
18
  */
19
  private $endpoint_object;
20
 
 
 
 
21
  public function __construct( EndpointInterface $endpoint_object ) {
22
  $this->endpoint_object = $endpoint_object;
23
  }
src/Conversion/Endpoint/PathsEndpoint.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
 
 
5
  /**
6
  * Supports endpoint to get list of image paths to be converted.
7
  */
@@ -41,10 +43,10 @@ class PathsEndpoint extends EndpointAbstract {
41
  * @internal
42
  */
43
  public function get_route_response( \WP_REST_Request $request ) {
44
- $params = $request->get_params();
45
- $skip_exists = isset( $params['regenerate_force'] ) && ! $params['regenerate_force'];
46
 
47
- $data = $this->get_paths( $skip_exists, self::PATHS_PER_REQUEST );
48
  return new \WP_REST_Response(
49
  $data,
50
  200
@@ -54,25 +56,25 @@ class PathsEndpoint extends EndpointAbstract {
54
  /**
55
  * Returns list of server paths of source images to be converted.
56
  *
57
- * @param bool $skip_exists Skip converted images?
58
- * @param int $chunk_size Number of files per one conversion request.
59
  *
60
  * @return array[] Server paths of source images.
61
  */
62
- public function get_paths( bool $skip_exists = false, int $chunk_size = 0 ): array {
63
  $settings = $this->plugin_data->get_plugin_settings();
64
  $dirs = array_filter(
65
  array_map(
66
  function ( $dir_name ) {
67
  return apply_filters( 'webpc_dir_path', '', $dir_name );
68
  },
69
- $settings['dirs']
70
  )
71
  );
72
 
73
  $list = [];
74
  foreach ( $dirs as $dir_path ) {
75
- $paths = apply_filters( 'webpc_dir_files', [], $dir_path, $skip_exists );
76
  $list = array_merge( $list, $paths );
77
  }
78
 
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
+ use WebpConverter\Settings\Option\SupportedDirectoriesOption;
6
+
7
  /**
8
  * Supports endpoint to get list of image paths to be converted.
9
  */
43
  * @internal
44
  */
45
  public function get_route_response( \WP_REST_Request $request ) {
46
+ $params = $request->get_params();
47
+ $skip_converted = ( $params['regenerate_force'] === true );
48
 
49
+ $data = $this->get_paths( $skip_converted, self::PATHS_PER_REQUEST );
50
  return new \WP_REST_Response(
51
  $data,
52
  200
56
  /**
57
  * Returns list of server paths of source images to be converted.
58
  *
59
+ * @param bool $skip_converted Skip converted images?
60
+ * @param int $chunk_size Number of files per one conversion request.
61
  *
62
  * @return array[] Server paths of source images.
63
  */
64
+ public function get_paths( bool $skip_converted = false, int $chunk_size = 0 ): array {
65
  $settings = $this->plugin_data->get_plugin_settings();
66
  $dirs = array_filter(
67
  array_map(
68
  function ( $dir_name ) {
69
  return apply_filters( 'webpc_dir_path', '', $dir_name );
70
  },
71
+ $settings[ SupportedDirectoriesOption::OPTION_NAME ]
72
  )
73
  );
74
 
75
  $list = [];
76
  foreach ( $dirs as $dir_path ) {
77
+ $paths = apply_filters( 'webpc_dir_files', [], $dir_path, $skip_converted );
78
  $list = array_merge( $list, $paths );
79
  }
80
 
src/Conversion/Endpoint/RegenerateEndpoint.php CHANGED
@@ -38,6 +38,7 @@ class RegenerateEndpoint extends EndpointAbstract {
38
  public function get_route_response( \WP_REST_Request $request ) {
39
  $params = $request->get_params();
40
  $data = $this->convert_images( $params['paths'] );
 
41
  if ( $data !== false ) {
42
  return new \WP_REST_Response(
43
  $data,
38
  public function get_route_response( \WP_REST_Request $request ) {
39
  $params = $request->get_params();
40
  $data = $this->convert_images( $params['paths'] );
41
+
42
  if ( $data !== false ) {
43
  return new \WP_REST_Response(
44
  $data,
src/Conversion/Format/FormatFactory.php CHANGED
@@ -46,12 +46,16 @@ class FormatFactory {
46
  /**
47
  * Returns list of available output formats.
48
  *
49
- * @param string $conversion_method Name of conversion method.
50
  *
51
  * @return string[] Extensions of output formats with labels.
52
  */
53
- public function get_available_formats( string $conversion_method ): array {
54
  $values = [];
 
 
 
 
55
  foreach ( $this->formats as $format ) {
56
  if ( ! $format->is_available( $conversion_method ) ) {
57
  continue;
46
  /**
47
  * Returns list of available output formats.
48
  *
49
+ * @param string|null $conversion_method Name of conversion method.
50
  *
51
  * @return string[] Extensions of output formats with labels.
52
  */
53
+ public function get_available_formats( string $conversion_method = null ): array {
54
  $values = [];
55
+ if ( $conversion_method === null ) {
56
+ return $values;
57
+ }
58
+
59
  foreach ( $this->formats as $format ) {
60
  if ( ! $format->is_available( $conversion_method ) ) {
61
  continue;
src/Conversion/Media/Attachment.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Conversion\Media;
4
 
5
  use WebpConverter\PluginData;
 
6
 
7
  /**
8
  * Returns all image paths for attachment.
@@ -10,7 +11,7 @@ use WebpConverter\PluginData;
10
  class Attachment {
11
 
12
  /**
13
- * @var PluginData .
14
  */
15
  private $plugin_data;
16
 
@@ -28,9 +29,6 @@ class Attachment {
28
  */
29
  private $image_sizes;
30
 
31
- /**
32
- * @param PluginData $plugin_data .
33
- */
34
  public function __construct( PluginData $plugin_data ) {
35
  $this->plugin_data = $plugin_data;
36
  $this->upload_dir = wp_upload_dir();
@@ -66,14 +64,12 @@ class Attachment {
66
 
67
  $extension = strtolower( pathinfo( $metadata['file'], PATHINFO_EXTENSION ) );
68
  if ( ! isset( $metadata['file'] )
69
- || ! in_array( $extension, $settings['extensions'] ) ) {
70
  return $list;
71
  }
72
 
73
  $paths = $this->get_paths_by_sizes( $post_id, $metadata['file'] );
74
- $paths = apply_filters( 'webpc_attachment_paths', $paths, $post_id );
75
- $paths = apply_filters( 'webpc_files_paths', $paths, false );
76
- return $paths;
77
  }
78
 
79
  /**
3
  namespace WebpConverter\Conversion\Media;
4
 
5
  use WebpConverter\PluginData;
6
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
7
 
8
  /**
9
  * Returns all image paths for attachment.
11
  class Attachment {
12
 
13
  /**
14
+ * @var PluginData
15
  */
16
  private $plugin_data;
17
 
29
  */
30
  private $image_sizes;
31
 
 
 
 
32
  public function __construct( PluginData $plugin_data ) {
33
  $this->plugin_data = $plugin_data;
34
  $this->upload_dir = wp_upload_dir();
64
 
65
  $extension = strtolower( pathinfo( $metadata['file'], PATHINFO_EXTENSION ) );
66
  if ( ! isset( $metadata['file'] )
67
+ || ! in_array( $extension, $settings[ SupportedExtensionsOption::OPTION_NAME ] ) ) {
68
  return $list;
69
  }
70
 
71
  $paths = $this->get_paths_by_sizes( $post_id, $metadata['file'] );
72
+ return apply_filters( 'webpc_attachment_paths', $paths, $post_id );
 
 
73
  }
74
 
75
  /**
src/Conversion/Media/Upload.php CHANGED
@@ -4,6 +4,7 @@ namespace WebpConverter\Conversion\Media;
4
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\PluginData;
 
7
 
8
  /**
9
  * Initializes image conversion when uploading images to media library.
@@ -11,7 +12,7 @@ use WebpConverter\PluginData;
11
  class Upload implements HookableInterface {
12
 
13
  /**
14
- * @var PluginData .
15
  */
16
  private $plugin_data;
17
 
@@ -22,9 +23,6 @@ class Upload implements HookableInterface {
22
  */
23
  private $converted_paths = [];
24
 
25
- /**
26
- * @param PluginData $plugin_data .
27
- */
28
  public function __construct( PluginData $plugin_data ) {
29
  $this->plugin_data = $plugin_data;
30
  }
@@ -52,7 +50,6 @@ class Upload implements HookableInterface {
52
 
53
  $paths = $this->get_sizes_paths( $data );
54
  $paths = apply_filters( 'webpc_attachment_paths', $paths, $attachment_id );
55
- $paths = apply_filters( 'webpc_files_paths', $paths, false );
56
 
57
  $paths = array_diff( $paths, $this->converted_paths );
58
  $this->converted_paths = array_merge( $this->converted_paths, $paths );
@@ -106,7 +103,7 @@ class Upload implements HookableInterface {
106
  private function init_conversion( array $paths ) {
107
  $settings = $this->plugin_data->get_plugin_settings();
108
 
109
- if ( in_array( 'cron_conversion', $settings['features'] ) ) {
110
  wp_schedule_single_event( ( time() + 1 ), 'webpc_convert_paths', [ $paths ] );
111
  } else {
112
  do_action( 'webpc_convert_paths', $paths );
4
 
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\PluginData;
7
+ use WebpConverter\Settings\Option\ExtraFeaturesOption;
8
 
9
  /**
10
  * Initializes image conversion when uploading images to media library.
12
  class Upload implements HookableInterface {
13
 
14
  /**
15
+ * @var PluginData
16
  */
17
  private $plugin_data;
18
 
23
  */
24
  private $converted_paths = [];
25
 
 
 
 
26
  public function __construct( PluginData $plugin_data ) {
27
  $this->plugin_data = $plugin_data;
28
  }
50
 
51
  $paths = $this->get_sizes_paths( $data );
52
  $paths = apply_filters( 'webpc_attachment_paths', $paths, $attachment_id );
 
53
 
54
  $paths = array_diff( $paths, $this->converted_paths );
55
  $this->converted_paths = array_merge( $this->converted_paths, $paths );
103
  private function init_conversion( array $paths ) {
104
  $settings = $this->plugin_data->get_plugin_settings();
105
 
106
+ if ( in_array( ExtraFeaturesOption::OPTION_VALUE_CRON_CONVERSION, $settings[ ExtraFeaturesOption::OPTION_NAME ] ) ) {
107
  wp_schedule_single_event( ( time() + 1 ), 'webpc_convert_paths', [ $paths ] );
108
  } else {
109
  do_action( 'webpc_convert_paths', $paths );
src/Conversion/Method/GdMethod.php CHANGED
@@ -5,11 +5,13 @@ namespace WebpConverter\Conversion\Method;
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Format\WebpFormat;
 
 
8
 
9
  /**
10
  * Supports image conversion method using GD library.
11
  */
12
- class GdMethod extends MethodAbstract {
13
 
14
  const METHOD_NAME = 'gd';
15
  const MAX_METHOD_QUALITY = 99.9;
@@ -83,7 +85,8 @@ class GdMethod extends MethodAbstract {
83
  );
84
 
85
  foreach ( $methods as $method => $extensions ) {
86
- if ( ! in_array( $extension, $plugin_settings['extensions'] ) || ! in_array( $extension, $extensions ) ) {
 
87
  continue;
88
  } elseif ( ! function_exists( $method ) ) {
89
  throw new Exception\FunctionUnavailableException( $method );
@@ -151,7 +154,7 @@ class GdMethod extends MethodAbstract {
151
  }
152
 
153
  $image = apply_filters( 'webpc_gd_before_saving', $image, $source_path );
154
- $output_quality = min( $plugin_settings['quality'], self::MAX_METHOD_QUALITY );
155
 
156
  if ( ! function_exists( $function ) ) {
157
  throw new Exception\FunctionUnavailableException( $function );
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Format\WebpFormat;
8
+ use WebpConverter\Settings\Option\ImagesQualityOption;
9
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
10
 
11
  /**
12
  * Supports image conversion method using GD library.
13
  */
14
+ class GdMethod extends LibraryMethodAbstract {
15
 
16
  const METHOD_NAME = 'gd';
17
  const MAX_METHOD_QUALITY = 99.9;
85
  );
86
 
87
  foreach ( $methods as $method => $extensions ) {
88
+ if ( ! in_array( $extension, $plugin_settings[ SupportedExtensionsOption::OPTION_NAME ] )
89
+ || ! in_array( $extension, $extensions ) ) {
90
  continue;
91
  } elseif ( ! function_exists( $method ) ) {
92
  throw new Exception\FunctionUnavailableException( $method );
154
  }
155
 
156
  $image = apply_filters( 'webpc_gd_before_saving', $image, $source_path );
157
+ $output_quality = min( $plugin_settings[ ImagesQualityOption::OPTION_NAME ], self::MAX_METHOD_QUALITY );
158
 
159
  if ( ! function_exists( $function ) ) {
160
  throw new Exception\FunctionUnavailableException( $function );
src/Conversion/Method/ImagickMethod.php CHANGED
@@ -5,11 +5,14 @@ namespace WebpConverter\Conversion\Method;
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Format\WebpFormat;
 
 
 
8
 
9
  /**
10
  * Supports image conversion method using Imagick library.
11
  */
12
- class ImagickMethod extends MethodAbstract {
13
 
14
  const METHOD_NAME = 'imagick';
15
  const MAX_METHOD_QUALITY = 99.9;
@@ -79,7 +82,7 @@ class ImagickMethod extends MethodAbstract {
79
 
80
  if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) ) {
81
  throw new Exception\ImagickUnavailableException();
82
- } elseif ( ! in_array( $extension, $plugin_settings['extensions'] ) ) {
83
  throw new Exception\ExtensionUnsupportedException( [ $extension, $source_path ] );
84
  }
85
 
@@ -99,14 +102,14 @@ class ImagickMethod extends MethodAbstract {
99
  public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings ) {
100
  $extension = self::get_format_extension( $format );
101
  $image = apply_filters( 'webpc_imagick_before_saving', $image, $source_path );
102
- $output_quality = min( $plugin_settings['quality'], self::MAX_METHOD_QUALITY );
103
 
104
  if ( ! in_array( $extension, $image->queryFormats() ) ) {
105
  throw new Exception\ImagickNotSupportWebpException();
106
  }
107
 
108
  $image->setImageFormat( $extension );
109
- if ( ! in_array( 'keep_metadata', $plugin_settings['features'] ) ) {
110
  $image->stripImage();
111
  }
112
  $image->setImageCompressionQuality( $output_quality );
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\Conversion\Format\AvifFormat;
7
  use WebpConverter\Conversion\Format\WebpFormat;
8
+ use WebpConverter\Settings\Option\ExtraFeaturesOption;
9
+ use WebpConverter\Settings\Option\ImagesQualityOption;
10
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
11
 
12
  /**
13
  * Supports image conversion method using Imagick library.
14
  */
15
+ class ImagickMethod extends LibraryMethodAbstract {
16
 
17
  const METHOD_NAME = 'imagick';
18
  const MAX_METHOD_QUALITY = 99.9;
82
 
83
  if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) ) {
84
  throw new Exception\ImagickUnavailableException();
85
+ } elseif ( ! in_array( $extension, $plugin_settings[ SupportedExtensionsOption::OPTION_NAME ] ) ) {
86
  throw new Exception\ExtensionUnsupportedException( [ $extension, $source_path ] );
87
  }
88
 
102
  public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings ) {
103
  $extension = self::get_format_extension( $format );
104
  $image = apply_filters( 'webpc_imagick_before_saving', $image, $source_path );
105
+ $output_quality = min( $plugin_settings[ ImagesQualityOption::OPTION_NAME ], self::MAX_METHOD_QUALITY );
106
 
107
  if ( ! in_array( $extension, $image->queryFormats() ) ) {
108
  throw new Exception\ImagickNotSupportWebpException();
109
  }
110
 
111
  $image->setImageFormat( $extension );
112
+ if ( ! in_array( ExtraFeaturesOption::OPTION_VALUE_KEEP_METADATA, $plugin_settings[ ExtraFeaturesOption::OPTION_NAME ] ) ) {
113
  $image->stripImage();
114
  }
115
  $image->setImageCompressionQuality( $output_quality );
src/Conversion/Method/LibraryMethodAbstract.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Conversion\Method;
4
+
5
+ use WebpConverter\Conversion\Exception;
6
+ use WebpConverter\Conversion\SkipLarger;
7
+ use WebpConverter\Settings\Option\OutputFormatsOption;
8
+
9
+ /**
10
+ * Abstract class for class that converts images using the PHP library.
11
+ */
12
+ abstract class LibraryMethodAbstract extends MethodAbstract implements LibraryMethodInterface {
13
+
14
+ /**
15
+ * {@inheritdoc}
16
+ */
17
+ public function convert_paths( array $paths, array $plugin_settings ) {
18
+ $output_formats = $plugin_settings[ OutputFormatsOption::OPTION_NAME ];
19
+ foreach ( $output_formats as $output_format ) {
20
+ foreach ( $paths as $path ) {
21
+ try {
22
+ $response = $this->convert_path( $path, $output_format, $plugin_settings );
23
+
24
+ $this->size_before += $response['data']['size_before'];
25
+ $this->size_after += $response['data']['size_after'];
26
+ } catch ( \Exception $e ) {
27
+ $this->errors[] = $e->getMessage();
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Converts source path to output formats.
35
+ *
36
+ * @param string $path Server path of source image.
37
+ * @param string $format Extension of output format.
38
+ * @param mixed[] $plugin_settings .
39
+ *
40
+ * @return mixed[] Results data of conversion.
41
+ *
42
+ * @throws Exception\OutputPathException
43
+ * @throws Exception\SourcePathException
44
+ */
45
+ private function convert_path( string $path, string $format, array $plugin_settings ): array {
46
+ $this->set_server_config();
47
+
48
+ try {
49
+ $source_path = $this->get_image_source_path( $path );
50
+ $image = $this->create_image_by_path( $source_path, $plugin_settings );
51
+ $output_path = $this->get_image_output_path( $source_path, $format );
52
+
53
+ if ( file_exists( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION ) ) {
54
+ unlink( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION );
55
+ }
56
+
57
+ $this->convert_image_to_output( $image, $source_path, $output_path, $format, $plugin_settings );
58
+ do_action( 'webpc_convert_after', $output_path, $source_path );
59
+
60
+ return [
61
+ 'success' => true,
62
+ 'message' => null,
63
+ 'data' => $this->get_conversion_stats( $source_path, $output_path ),
64
+ ];
65
+ } catch ( \Exception $e ) {
66
+ $this->save_conversion_error( $e->getMessage(), $plugin_settings );
67
+ throw $e;
68
+ }
69
+ }
70
+ }
src/Conversion/Method/LibraryMethodInterface.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Conversion\Method;
4
+
5
+ /**
6
+ * Interface for class that converts images using the PHP library.
7
+ */
8
+ interface LibraryMethodInterface {
9
+
10
+ /**
11
+ * Creates image object based on source path.
12
+ *
13
+ * @param string $source_path Server path of source image.
14
+ * @param mixed[] $plugin_settings .
15
+ *
16
+ * @return mixed Image object.
17
+ */
18
+ public function create_image_by_path( string $source_path, array $plugin_settings );
19
+
20
+ /**
21
+ * Converts image and saves to output location.
22
+ *
23
+ * @param mixed $image Image object.
24
+ * @param string $source_path Server path of source image.
25
+ * @param string $output_path Server path for output image.
26
+ * @param string $format Extension of output format.
27
+ * @param mixed[] $plugin_settings .
28
+ *
29
+ * @return void
30
+ */
31
+ public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings );
32
+ }
src/Conversion/Method/MethodAbstract.php CHANGED
@@ -4,10 +4,10 @@ namespace WebpConverter\Conversion\Method;
4
 
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\Conversion\OutputPath;
7
- use WebpConverter\Conversion\SkipLarger;
8
 
9
  /**
10
- * Abstract class for class that supports endpoint.
11
  */
12
  abstract class MethodAbstract implements MethodInterface {
13
 
@@ -16,21 +16,21 @@ abstract class MethodAbstract implements MethodInterface {
16
  *
17
  * @var string[]
18
  */
19
- private $errors = [];
20
 
21
  /**
22
  * Sum of size of source images before conversion.
23
  *
24
  * @var int
25
  */
26
- private $size_before = 0;
27
 
28
  /**
29
  * Sum of size of output images after conversion.
30
  *
31
  * @var int
32
  */
33
- private $size_after = 0;
34
 
35
  /**
36
  * {@inheritdoc}
@@ -54,69 +54,25 @@ abstract class MethodAbstract implements MethodInterface {
54
  }
55
 
56
  /**
57
- * {@inheritdoc}
58
- */
59
- public function convert_paths( array $paths, array $plugin_settings ) {
60
- $output_formats = $plugin_settings['output_formats'];
61
- foreach ( $output_formats as $output_format ) {
62
- foreach ( $paths as $path ) {
63
- try {
64
- $response = $this->convert_path( $path, $output_format, $plugin_settings );
65
-
66
- $this->size_before += $response['data']['size_before'];
67
- $this->size_after += $response['data']['size_after'];
68
- } catch ( \Exception $e ) {
69
- $this->errors[] = $e->getMessage();
70
- }
71
- }
72
- }
73
- }
74
-
75
- /**
76
- * {@inheritdoc}
77
- *
78
- * @throws Exception\OutputPathException
79
- * @throws Exception\SourcePathException
80
  */
81
- public function convert_path( string $path, string $format, array $plugin_settings ): array {
82
  ini_set( 'memory_limit', '1G' ); // phpcs:ignore
83
  if ( strpos( ini_get( 'disable_functions' ) ?: '', 'set_time_limit' ) === false ) {
84
  set_time_limit( 120 );
85
  }
86
-
87
- try {
88
- $source_path = $this->get_image_source_path( $path );
89
- $image = $this->create_image_by_path( $source_path, $plugin_settings );
90
- $output_path = $this->get_image_output_path( $source_path, $format );
91
-
92
- if ( file_exists( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION ) ) {
93
- unlink( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION );
94
- }
95
-
96
- $this->convert_image_to_output( $image, $source_path, $output_path, $format, $plugin_settings );
97
- do_action( 'webpc_convert_after', $output_path, $source_path );
98
-
99
- return [
100
- 'success' => true,
101
- 'message' => null,
102
- 'data' => $this->get_conversion_stats( $source_path, $output_path ),
103
- ];
104
- } catch ( \Exception $e ) {
105
- $features = $plugin_settings['features'] ?? [];
106
- if ( in_array( 'debug_enabled', $features ) ) {
107
- error_log( sprintf( 'WebP Converter for Media: %s', $e->getMessage() ) ); // phpcs:ignore
108
- }
109
-
110
- throw $e;
111
- }
112
  }
113
 
114
  /**
115
- * {@inheritdoc}
 
 
 
 
116
  *
117
  * @throws Exception\SourcePathException
118
  */
119
- public function get_image_source_path( string $source_path ): string {
120
  $path = urldecode( $source_path );
121
  if ( ! is_readable( $path ) ) {
122
  throw new Exception\SourcePathException( $path );
@@ -126,11 +82,16 @@ abstract class MethodAbstract implements MethodInterface {
126
  }
127
 
128
  /**
129
- * {@inheritdoc}
 
 
 
 
 
130
  *
131
  * @throws Exception\OutputPathException
132
  */
133
- public function get_image_output_path( string $source_path, string $format ): string {
134
  if ( ! $output_path = OutputPath::get_path( $source_path, true, $format ) ) {
135
  throw new Exception\OutputPathException( $source_path );
136
  }
@@ -139,9 +100,14 @@ abstract class MethodAbstract implements MethodInterface {
139
  }
140
 
141
  /**
142
- * {@inheritdoc}
 
 
 
 
 
143
  */
144
- public function get_conversion_stats( string $source_path, string $output_path ): array {
145
  $size_before = filesize( $source_path );
146
  $size_after = ( file_exists( $output_path ) ) ? filesize( $output_path ) : $size_before;
147
 
@@ -150,4 +116,17 @@ abstract class MethodAbstract implements MethodInterface {
150
  'size_after' => $size_after ?: 0,
151
  ];
152
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
4
 
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\Conversion\OutputPath;
7
+ use WebpConverter\Settings\Option\ExtraFeaturesOption;
8
 
9
  /**
10
+ * Abstract class for class that converts images.
11
  */
12
  abstract class MethodAbstract implements MethodInterface {
13
 
16
  *
17
  * @var string[]
18
  */
19
+ protected $errors = [];
20
 
21
  /**
22
  * Sum of size of source images before conversion.
23
  *
24
  * @var int
25
  */
26
+ protected $size_before = 0;
27
 
28
  /**
29
  * Sum of size of output images after conversion.
30
  *
31
  * @var int
32
  */
33
+ protected $size_after = 0;
34
 
35
  /**
36
  * {@inheritdoc}
54
  }
55
 
56
  /**
57
+ * @return void
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  */
59
+ protected function set_server_config() {
60
  ini_set( 'memory_limit', '1G' ); // phpcs:ignore
61
  if ( strpos( ini_get( 'disable_functions' ) ?: '', 'set_time_limit' ) === false ) {
62
  set_time_limit( 120 );
63
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
  /**
67
+ * Checks server path of source image.
68
+ *
69
+ * @param string $source_path Server path of source image.
70
+ *
71
+ * @return string Server path of source image.
72
  *
73
  * @throws Exception\SourcePathException
74
  */
75
+ protected function get_image_source_path( string $source_path ): string {
76
  $path = urldecode( $source_path );
77
  if ( ! is_readable( $path ) ) {
78
  throw new Exception\SourcePathException( $path );
82
  }
83
 
84
  /**
85
+ * Returns server path for output image.
86
+ *
87
+ * @param string $source_path Server path of source image.
88
+ * @param string $format Extension of output format.
89
+ *
90
+ * @return string Server path of output image.
91
  *
92
  * @throws Exception\OutputPathException
93
  */
94
+ protected function get_image_output_path( string $source_path, string $format ): string {
95
  if ( ! $output_path = OutputPath::get_path( $source_path, true, $format ) ) {
96
  throw new Exception\OutputPathException( $source_path );
97
  }
100
  }
101
 
102
  /**
103
+ * Returns results data of conversion.
104
+ *
105
+ * @param string $source_path Server path of source image.
106
+ * @param string $output_path Server path of output image.
107
+ *
108
+ * @return int[] Results data of conversion.
109
  */
110
+ protected function get_conversion_stats( string $source_path, string $output_path ): array {
111
  $size_before = filesize( $source_path );
112
  $size_after = ( file_exists( $output_path ) ) ? filesize( $output_path ) : $size_before;
113
 
116
  'size_after' => $size_after ?: 0,
117
  ];
118
  }
119
+
120
+ /**
121
+ * @param string $error_message .
122
+ * @param mixed[] $plugin_settings .
123
+ *
124
+ * @return void
125
+ */
126
+ protected function save_conversion_error( string $error_message, array $plugin_settings ) {
127
+ $features = $plugin_settings[ ExtraFeaturesOption::OPTION_NAME ];
128
+ if ( in_array( ExtraFeaturesOption::OPTION_VALUE_DEBUG_ENABLED, $features ) ) {
129
+ error_log( sprintf( 'WebP Converter for Media: %s', $error_message ) ); // phpcs:ignore
130
+ }
131
+ }
132
  }
src/Conversion/Method/MethodIntegrator.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Conversion\Method;
4
 
5
  use WebpConverter\PluginData;
 
6
 
7
  /**
8
  * Initializes image conversion using active image conversion method.
@@ -10,13 +11,10 @@ use WebpConverter\PluginData;
10
  class MethodIntegrator {
11
 
12
  /**
13
- * @var PluginData .
14
  */
15
  private $plugin_data;
16
 
17
- /**
18
- * @param PluginData $plugin_data .
19
- */
20
  public function __construct( PluginData $plugin_data ) {
21
  $this->plugin_data = $plugin_data;
22
  }
@@ -53,7 +51,7 @@ class MethodIntegrator {
53
  return null;
54
  }
55
 
56
- $method_key = $this->plugin_data->get_plugin_settings()['method'] ?? '';
57
  $methods = ( new MethodFactory() )->get_methods_objects();
58
  foreach ( $methods as $method_name => $method ) {
59
  if ( $method_key === $method_name ) {
3
  namespace WebpConverter\Conversion\Method;
4
 
5
  use WebpConverter\PluginData;
6
+ use WebpConverter\Settings\Option\ConversionMethodOption;
7
 
8
  /**
9
  * Initializes image conversion using active image conversion method.
11
  class MethodIntegrator {
12
 
13
  /**
14
+ * @var PluginData
15
  */
16
  private $plugin_data;
17
 
 
 
 
18
  public function __construct( PluginData $plugin_data ) {
19
  $this->plugin_data = $plugin_data;
20
  }
51
  return null;
52
  }
53
 
54
+ $method_key = $this->plugin_data->get_plugin_settings()[ ConversionMethodOption::OPTION_NAME ] ?? null;
55
  $methods = ( new MethodFactory() )->get_methods_objects();
56
  foreach ( $methods as $method_name => $method ) {
57
  if ( $method_key === $method_name ) {
src/Conversion/Method/MethodInterface.php CHANGED
@@ -3,28 +3,28 @@
3
  namespace WebpConverter\Conversion\Method;
4
 
5
  /**
6
- * Interface for class that supports image conversion method.
7
  */
8
  interface MethodInterface {
9
 
10
  /**
11
  * Returns name of conversion method.
12
  *
13
- * @return string Method name.
14
  */
15
  public function get_name(): string;
16
 
17
  /**
18
  * Returns label of conversion method.
19
  *
20
- * @return string Method label.
21
  */
22
  public function get_label(): string;
23
 
24
  /**
25
  * Returns status of whether method is installed.
26
  *
27
- * @return bool Is method installed?
28
  */
29
  public static function is_method_installed(): bool;
30
 
@@ -33,7 +33,7 @@ interface MethodInterface {
33
  *
34
  * @param string $format Extension of output format.
35
  *
36
- * @return bool Is method active?
37
  */
38
  public static function is_method_active( string $format ): bool;
39
 
@@ -47,14 +47,14 @@ interface MethodInterface {
47
  /**
48
  * Returns weight of source files before converting.
49
  *
50
- * @return int Source files weight.
51
  */
52
  public function get_size_before(): int;
53
 
54
  /**
55
  * Returns weight of output files after converting.
56
  *
57
- * @return int Output files weight.
58
  */
59
  public function get_size_after(): int;
60
 
@@ -62,72 +62,9 @@ interface MethodInterface {
62
  * Converts source paths to output formats.
63
  *
64
  * @param string[] $paths Server paths of source images.
65
- * @param mixed[] $plugin_settings Settings of plugin.
66
  *
67
  * @return void
68
  */
69
  public function convert_paths( array $paths, array $plugin_settings );
70
-
71
- /**
72
- * Converts source path to output formats.
73
- *
74
- * @param string $path Server path of source image.
75
- * @param string $format Extension of output format.
76
- * @param mixed[] $plugin_settings Settings of plugin.
77
- *
78
- * @return mixed[] Results data of conversion.
79
- */
80
- public function convert_path( string $path, string $format, array $plugin_settings ): array;
81
-
82
- /**
83
- * Checks server path of source image.
84
- *
85
- * @param string $source_path Server path of source image.
86
- *
87
- * @return string Server path of source image.
88
- */
89
- public function get_image_source_path( string $source_path ): string;
90
-
91
- /**
92
- * Creates image object based on source path.
93
- *
94
- * @param string $source_path Server path of source image.
95
- * @param mixed[] $plugin_settings Settings of plugin.
96
- *
97
- * @return mixed Image object.
98
- */
99
- public function create_image_by_path( string $source_path, array $plugin_settings );
100
-
101
- /**
102
- * Returns server path for output image.
103
- *
104
- * @param string $source_path Server path of source image.
105
- * @param string $format Extension of output format.
106
- *
107
- * @return string Server path of output image.
108
- */
109
- public function get_image_output_path( string $source_path, string $format ): string;
110
-
111
- /**
112
- * Converts image and saves to output location.
113
- *
114
- * @param mixed $image Image object.
115
- * @param string $source_path Server path of source image.
116
- * @param string $output_path Server path for output image.
117
- * @param string $format Extension of output format.
118
- * @param mixed[] $plugin_settings Settings of plugin.
119
- *
120
- * @return void
121
- */
122
- public function convert_image_to_output( $image, string $source_path, string $output_path, string $format, array $plugin_settings );
123
-
124
- /**
125
- * Returns results data of conversion.
126
- *
127
- * @param string $source_path Server path of source image.
128
- * @param string $output_path Server path of output image.
129
- *
130
- * @return int[] Results data of conversion.
131
- */
132
- public function get_conversion_stats( string $source_path, string $output_path ): array;
133
  }
3
  namespace WebpConverter\Conversion\Method;
4
 
5
  /**
6
+ * Interface for class that converts images.
7
  */
8
  interface MethodInterface {
9
 
10
  /**
11
  * Returns name of conversion method.
12
  *
13
+ * @return string
14
  */
15
  public function get_name(): string;
16
 
17
  /**
18
  * Returns label of conversion method.
19
  *
20
+ * @return string
21
  */
22
  public function get_label(): string;
23
 
24
  /**
25
  * Returns status of whether method is installed.
26
  *
27
+ * @return bool
28
  */
29
  public static function is_method_installed(): bool;
30
 
33
  *
34
  * @param string $format Extension of output format.
35
  *
36
+ * @return bool
37
  */
38
  public static function is_method_active( string $format ): bool;
39
 
47
  /**
48
  * Returns weight of source files before converting.
49
  *
50
+ * @return int
51
  */
52
  public function get_size_before(): int;
53
 
54
  /**
55
  * Returns weight of output files after converting.
56
  *
57
+ * @return int
58
  */
59
  public function get_size_after(): int;
60
 
62
  * Converts source paths to output formats.
63
  *
64
  * @param string[] $paths Server paths of source images.
65
+ * @param mixed[] $plugin_settings .
66
  *
67
  * @return void
68
  */
69
  public function convert_paths( array $paths, array $plugin_settings );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
src/Conversion/OutputPath.php CHANGED
@@ -35,7 +35,7 @@ class OutputPath {
35
  */
36
  public static function get_paths( string $path, bool $create_dir = false, array $file_extensions = [] ): array {
37
  $new_path = self::get_directory_path( $path );
38
- if ( $create_dir && ! self::make_directories( self::check_directories( $new_path ) ) ) {
39
  return [];
40
  }
41
 
@@ -55,13 +55,18 @@ class OutputPath {
55
  *
56
  * @param string $path Server path of source directory.
57
  *
58
- * @return string Server paths for output directory.
59
  */
60
- public static function get_directory_path( string $path ): string {
61
  $webp_root = apply_filters( 'webpc_dir_path', '', 'webp' );
62
  $uploads_root = dirname( $webp_root );
63
  $output_path = str_replace( realpath( $uploads_root ) ?: '', '', realpath( $path ) ?: '' );
64
  $output_path = trim( $output_path, '\/' );
 
 
 
 
 
65
  return sprintf( '%1$s/%2$s', $webp_root, $output_path );
66
  }
67
 
35
  */
36
  public static function get_paths( string $path, bool $create_dir = false, array $file_extensions = [] ): array {
37
  $new_path = self::get_directory_path( $path );
38
+ if ( $new_path && $create_dir && ! self::make_directories( self::check_directories( $new_path ) ) ) {
39
  return [];
40
  }
41
 
55
  *
56
  * @param string $path Server path of source directory.
57
  *
58
+ * @return string|null Server paths for output directory.
59
  */
60
+ public static function get_directory_path( string $path ) {
61
  $webp_root = apply_filters( 'webpc_dir_path', '', 'webp' );
62
  $uploads_root = dirname( $webp_root );
63
  $output_path = str_replace( realpath( $uploads_root ) ?: '', '', realpath( $path ) ?: '' );
64
  $output_path = trim( $output_path, '\/' );
65
+
66
+ if ( ! $output_path ) {
67
+ return null;
68
+ }
69
+
70
  return sprintf( '%1$s/%2$s', $webp_root, $output_path );
71
  }
72
 
src/Conversion/PathsValidator.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Conversion;
4
+
5
+ /**
6
+ * Handles checking if paths are supported for image conversion.
7
+ */
8
+ trait PathsValidator {
9
+
10
+ /**
11
+ * @param string $file_path .
12
+ * @param bool $skip_converted Skip images already converted?
13
+ */
14
+ public function is_supported_source_file( string $file_path, bool $skip_converted = false ): bool {
15
+ if ( ! $this->is_supported_source_directory( dirname( $file_path ) ) ) {
16
+ return false;
17
+ }
18
+
19
+ $server_path = $this->convert_server_path( $file_path );
20
+ return apply_filters( 'webpc_supported_source_file', true, basename( $server_path ), $server_path, $skip_converted );
21
+ }
22
+
23
+ public function is_supported_source_directory( string $directory_path ): bool {
24
+ $server_path = $this->convert_server_path( $directory_path );
25
+ return apply_filters( 'webpc_supported_source_directory', true, basename( $server_path ), $server_path );
26
+ }
27
+
28
+ private function convert_server_path( string $original_path ): string {
29
+ $server_path = urldecode( $original_path );
30
+ $server_path = preg_replace( '/[\\\\\/]+/', DIRECTORY_SEPARATOR, $server_path );
31
+ return trim( (string) $server_path, '\\/' );
32
+ }
33
+ }
src/Conversion/SkipConvertedPaths.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Conversion;
4
+
5
+ use WebpConverter\Conversion\Format\FormatFactory;
6
+ use WebpConverter\HookableInterface;
7
+ use WebpConverter\PluginData;
8
+ use WebpConverter\Settings\Option\ConversionMethodOption;
9
+
10
+ /**
11
+ * Removes from list of source file paths those that have already been converted.
12
+ */
13
+ class SkipConvertedPaths implements HookableInterface {
14
+
15
+ /**
16
+ * @var PluginData
17
+ */
18
+ private $plugin_data;
19
+
20
+ public function __construct( PluginData $plugin_data ) {
21
+ $this->plugin_data = $plugin_data;
22
+ }
23
+
24
+ /**
25
+ * {@inheritdoc}
26
+ */
27
+ public function init_hooks() {
28
+ add_filter( 'webpc_supported_source_file', [ $this, 'skip_converted_path' ], 0, 4 );
29
+ }
30
+
31
+ /**
32
+ * Returns the status if the given file path should be converted.
33
+ *
34
+ * @param bool $path_status .
35
+ * @param string $filename .
36
+ * @param string $server_path .
37
+ * @param bool $skip_converted Skip images already converted?
38
+ *
39
+ * @return bool Status if the given path has not been converted yet.
40
+ * @internal
41
+ */
42
+ public function skip_converted_path( bool $path_status, string $filename, string $server_path, bool $skip_converted ): bool {
43
+ if ( ! $skip_converted ) {
44
+ return $path_status;
45
+ }
46
+
47
+ $directory = new OutputPath();
48
+ $extensions = $this->get_output_extensions();
49
+ $output_paths = $directory->get_paths( urldecode( $server_path ), false, $extensions );
50
+
51
+ foreach ( $output_paths as $output_path ) {
52
+ if ( file_exists( $output_path ) || file_exists( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION ) ) {
53
+ return false;
54
+ }
55
+ }
56
+
57
+ return $path_status;
58
+ }
59
+
60
+ /**
61
+ * Returns list of file extensions in output directory.
62
+ *
63
+ * @return string[] Available output extensions.
64
+ */
65
+ private function get_output_extensions(): array {
66
+ $settings = $this->plugin_data->get_plugin_settings();
67
+ $extensions = ( new FormatFactory() )->get_available_formats( $settings[ ConversionMethodOption::OPTION_NAME ] ?? null );
68
+
69
+ $values = [];
70
+ foreach ( $extensions as $extension => $format_label ) {
71
+ $values[] = $extension;
72
+ }
73
+ return $values;
74
+ }
75
+ }
src/Conversion/SkipExcludedPaths.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Conversion;
4
+
5
+ use WebpConverter\HookableInterface;
6
+
7
+ /**
8
+ * Removes from list of source directory paths those that are excluded.
9
+ */
10
+ class SkipExcludedPaths implements HookableInterface {
11
+
12
+ const DIRS_EXCLUDED = [
13
+ '.',
14
+ '..',
15
+ '.git',
16
+ '.svn',
17
+ 'node_modules',
18
+ ];
19
+
20
+ /**
21
+ * {@inheritdoc}
22
+ */
23
+ public function init_hooks() {
24
+ add_filter( 'webpc_supported_source_directory', [ $this, 'skip_excluded_directory' ], 0, 3 );
25
+ }
26
+
27
+ /**
28
+ * Returns the status if the given directory path should be converted.
29
+ *
30
+ * @param bool $path_status .
31
+ * @param string $dirname .
32
+ * @param string $server_path .
33
+ *
34
+ * @return bool Status if the given path is not excluded.
35
+ * @internal
36
+ */
37
+ public function skip_excluded_directory( bool $path_status, string $dirname, string $server_path ): bool {
38
+ if ( in_array( $dirname, self::DIRS_EXCLUDED ) ) {
39
+ return false;
40
+ }
41
+
42
+ return $path_status;
43
+ }
44
+ }
src/Conversion/SkipExists.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
-
3
- namespace WebpConverter\Conversion;
4
-
5
- use WebpConverter\Conversion\Format\FormatFactory;
6
- use WebpConverter\HookableInterface;
7
- use WebpConverter\PluginData;
8
-
9
- /**
10
- * Removes from list of source file paths those that have already been converted.
11
- */
12
- class SkipExists implements HookableInterface {
13
-
14
- /**
15
- * @var PluginData .
16
- */
17
- private $plugin_data;
18
-
19
- /**
20
- * @param PluginData $plugin_data .
21
- */
22
- public function __construct( PluginData $plugin_data ) {
23
- $this->plugin_data = $plugin_data;
24
- }
25
-
26
- /**
27
- * {@inheritdoc}
28
- */
29
- public function init_hooks() {
30
- add_filter( 'webpc_files_paths', [ $this, 'skip_exists_images' ], 10, 2 );
31
- }
32
-
33
- /**
34
- * Removes from list of image paths those that have already been converted to output formats.
35
- *
36
- * @param string[] $paths Server paths of source images.
37
- * @param bool $skip_exists Delete images already converted?
38
- *
39
- * @return string[] Server paths of source images.
40
- * @internal
41
- */
42
- public function skip_exists_images( array $paths, bool $skip_exists = true ): array {
43
- if ( ! $skip_exists ) {
44
- return $paths;
45
- }
46
-
47
- $directory = new OutputPath();
48
- $extensions = $this->get_output_extensions();
49
- foreach ( $paths as $key => $path ) {
50
- $output_paths = $directory->get_paths( urldecode( $path ), false, $extensions );
51
- $is_exists = true;
52
- foreach ( $output_paths as $output_path ) {
53
- if ( ! file_exists( $output_path )
54
- && ! file_exists( $output_path . '.' . SkipLarger::DELETED_FILE_EXTENSION ) ) {
55
- $is_exists = false;
56
- }
57
- }
58
-
59
- if ( $is_exists ) {
60
- unset( $paths[ $key ] );
61
- }
62
- }
63
- return $paths;
64
- }
65
-
66
- /**
67
- * Returns list of file extensions in output directory.
68
- *
69
- * @return string[] Available output extensions.
70
- */
71
- private function get_output_extensions(): array {
72
- $settings = $this->plugin_data->get_plugin_settings();
73
- $extensions = ( new FormatFactory() )->get_available_formats( $settings['method'] );
74
-
75
- $values = [];
76
- foreach ( $extensions as $extension => $format_label ) {
77
- $values[] = $extension;
78
- }
79
- return $values;
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Conversion/SkipLarger.php CHANGED
@@ -5,6 +5,7 @@ namespace WebpConverter\Conversion;
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
 
8
 
9
  /**
10
  * Deletes output after conversion if it is larger than original.
@@ -14,13 +15,10 @@ class SkipLarger implements HookableInterface {
14
  const DELETED_FILE_EXTENSION = 'deleted';
15
 
16
  /**
17
- * @var PluginData .
18
  */
19
  private $plugin_data;
20
 
21
- /**
22
- * @param PluginData $plugin_data .
23
- */
24
  public function __construct( PluginData $plugin_data ) {
25
  $this->plugin_data = $plugin_data;
26
  }
@@ -44,7 +42,7 @@ class SkipLarger implements HookableInterface {
44
  */
45
  public function remove_image_if_is_larger( string $webp_path, string $original_path ) {
46
  if ( ( ! $settings = $this->plugin_data->get_plugin_settings() )
47
- || ! in_array( 'only_smaller', $settings['features'] )
48
  || ( ! file_exists( $webp_path ) || ! file_exists( $original_path ) )
49
  || ( filesize( $webp_path ) < filesize( $original_path ) ) ) {
50
  return;
5
  use WebpConverter\Conversion\Exception;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
8
+ use WebpConverter\Settings\Option\ExtraFeaturesOption;
9
 
10
  /**
11
  * Deletes output after conversion if it is larger than original.
15
  const DELETED_FILE_EXTENSION = 'deleted';
16
 
17
  /**
18
+ * @var PluginData
19
  */
20
  private $plugin_data;
21
 
 
 
 
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
42
  */
43
  public function remove_image_if_is_larger( string $webp_path, string $original_path ) {
44
  if ( ( ! $settings = $this->plugin_data->get_plugin_settings() )
45
+ || ! in_array( ExtraFeaturesOption::OPTION_VALUE_ONLY_SMALLER, $settings[ ExtraFeaturesOption::OPTION_NAME ] )
46
  || ( ! file_exists( $webp_path ) || ! file_exists( $original_path ) )
47
  || ( filesize( $webp_path ) < filesize( $original_path ) ) ) {
48
  return;
src/Error/Detector/LibsWithoutAvifSupportDetector.php CHANGED
@@ -7,6 +7,7 @@ use WebpConverter\Conversion\Method\GdMethod;
7
  use WebpConverter\Conversion\Method\ImagickMethod;
8
  use WebpConverter\Error\Notice\LibsWithoutAvifSupportNotice;
9
  use WebpConverter\PluginData;
 
10
 
11
  /**
12
  * Checks for configuration errors about image conversion methods that do not support AVIF output format.
@@ -14,13 +15,10 @@ use WebpConverter\PluginData;
14
  class LibsWithoutAvifSupportDetector implements ErrorDetector {
15
 
16
  /**
17
- * @var PluginData .
18
  */
19
  private $plugin_data;
20
 
21
- /**
22
- * @param PluginData $plugin_data .
23
- */
24
  public function __construct( PluginData $plugin_data ) {
25
  $this->plugin_data = $plugin_data;
26
  }
@@ -29,7 +27,7 @@ class LibsWithoutAvifSupportDetector implements ErrorDetector {
29
  * {@inheritdoc}
30
  */
31
  public function get_error() {
32
- $output_formats = $this->plugin_data->get_plugin_settings()['output_formats'] ?? [];
33
 
34
  if ( ! in_array( AvifFormat::FORMAT_EXTENSION, $output_formats )
35
  || GdMethod::is_method_active( AvifFormat::FORMAT_EXTENSION )
7
  use WebpConverter\Conversion\Method\ImagickMethod;
8
  use WebpConverter\Error\Notice\LibsWithoutAvifSupportNotice;
9
  use WebpConverter\PluginData;
10
+ use WebpConverter\Settings\Option\OutputFormatsOption;
11
 
12
  /**
13
  * Checks for configuration errors about image conversion methods that do not support AVIF output format.
15
  class LibsWithoutAvifSupportDetector implements ErrorDetector {
16
 
17
  /**
18
+ * @var PluginData
19
  */
20
  private $plugin_data;
21
 
 
 
 
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
27
  * {@inheritdoc}
28
  */
29
  public function get_error() {
30
+ $output_formats = $this->plugin_data->get_plugin_settings()[ OutputFormatsOption::OPTION_NAME ];
31
 
32
  if ( ! in_array( AvifFormat::FORMAT_EXTENSION, $output_formats )
33
  || GdMethod::is_method_active( AvifFormat::FORMAT_EXTENSION )
src/Error/Detector/PassthruExecutionDetector.php CHANGED
@@ -6,6 +6,7 @@ use WebpConverter\Error\Notice\PassthruExecutionNotice;
6
  use WebpConverter\Loader\LoaderAbstract;
7
  use WebpConverter\Loader\PassthruLoader;
8
  use WebpConverter\PluginData;
 
9
 
10
  /**
11
  * Checks for configuration errors about disabled file supports Pass Thru loader.
@@ -13,14 +14,17 @@ use WebpConverter\PluginData;
13
  class PassthruExecutionDetector implements ErrorDetector {
14
 
15
  /**
16
- * @var PluginData .
17
  */
18
- private $plugin_data;
19
 
20
  /**
21
- * @param PluginData $plugin_data .
22
  */
23
- public function __construct( PluginData $plugin_data ) {
 
 
 
24
  $this->plugin_data = $plugin_data;
25
  }
26
 
@@ -46,7 +50,7 @@ class PassthruExecutionDetector implements ErrorDetector {
46
  * @return bool Verification status.
47
  */
48
  private function if_passthru_execution_allowed(): bool {
49
- $loader = new PassthruLoader( $this->plugin_data );
50
  if ( $loader->is_active_loader() !== true ) {
51
  return true;
52
  }
6
  use WebpConverter\Loader\LoaderAbstract;
7
  use WebpConverter\Loader\PassthruLoader;
8
  use WebpConverter\PluginData;
9
+ use WebpConverter\PluginInfo;
10
 
11
  /**
12
  * Checks for configuration errors about disabled file supports Pass Thru loader.
14
  class PassthruExecutionDetector implements ErrorDetector {
15
 
16
  /**
17
+ * @var PluginInfo
18
  */
19
+ private $plugin_info;
20
 
21
  /**
22
+ * @var PluginData
23
  */
24
+ private $plugin_data;
25
+
26
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data ) {
27
+ $this->plugin_info = $plugin_info;
28
  $this->plugin_data = $plugin_data;
29
  }
30
 
50
  * @return bool Verification status.
51
  */
52
  private function if_passthru_execution_allowed(): bool {
53
+ $loader = new PassthruLoader( $this->plugin_info, $this->plugin_data );
54
  if ( $loader->is_active_loader() !== true ) {
55
  return true;
56
  }
src/Error/Detector/RewritesErrorsDetector.php CHANGED
@@ -11,6 +11,9 @@ use WebpConverter\Error\Notice\RewritesNotWorkingNotice;
11
  use WebpConverter\Helper\FileLoader;
12
  use WebpConverter\Loader\LoaderAbstract;
13
  use WebpConverter\PluginData;
 
 
 
14
 
15
  /**
16
  * Checks for configuration errors about non-working HTTP rewrites.
@@ -21,18 +24,27 @@ class RewritesErrorsDetector implements ErrorDetector {
21
  const PATH_SOURCE_FILE_WEBP = '/assets/img/icon-test.webp';
22
  const PATH_OUTPUT_FILE_PNG = '/webp-converter-for-media-test.png';
23
  const PATH_OUTPUT_FILE_PNG2 = '/webp-converter-for-media-test.png2';
24
- const URL_DEBUG_HTACCESS_FILE = WEBPC_URL . '/assets/img/debug-htaccess/icon-test.png';
25
 
26
  /**
27
- * @var PluginData .
 
 
 
 
 
28
  */
29
  private $plugin_data;
30
 
31
  /**
32
- * @param PluginData $plugin_data .
33
  */
34
- public function __construct( PluginData $plugin_data ) {
 
 
 
35
  $this->plugin_data = $plugin_data;
 
36
  }
37
 
38
  /**
@@ -40,7 +52,7 @@ class RewritesErrorsDetector implements ErrorDetector {
40
  */
41
  public function get_error() {
42
  $settings = $this->plugin_data->get_plugin_settings();
43
- if ( ! $settings['dirs'] || ! $settings['output_formats'] ) {
44
  return null;
45
  }
46
 
@@ -50,7 +62,7 @@ class RewritesErrorsDetector implements ErrorDetector {
50
 
51
  if ( $this->if_redirects_are_works() !== true ) {
52
  if ( $this->if_bypassing_apache_is_active() === true ) {
53
- $error = new BypassingApacheNotice();
54
  } elseif ( $this->if_htaccess_can_be_overwritten() !== true ) {
55
  $error = new RewritesNotExecutedNotice();
56
  } else {
@@ -79,17 +91,17 @@ class RewritesErrorsDetector implements ErrorDetector {
79
  }
80
 
81
  if ( ! file_exists( $path_file_png ) || ! file_exists( $path_file_png2 ) ) {
82
- copy( WEBPC_PATH . self::PATH_SOURCE_FILE_PNG, $path_file_png );
83
- copy( WEBPC_PATH . self::PATH_SOURCE_FILE_PNG, $path_file_png2 );
84
  }
85
 
86
  if ( ( $output_path = OutputPath::get_path( $path_file_png, true, WebpFormat::FORMAT_EXTENSION ) )
87
  && ! file_exists( $output_path ) ) {
88
- copy( WEBPC_PATH . self::PATH_SOURCE_FILE_WEBP, $output_path );
89
  }
90
  if ( ( $output_path = OutputPath::get_path( $path_file_png2, true, WebpFormat::FORMAT_EXTENSION ) )
91
  && ! file_exists( $output_path ) ) {
92
- copy( WEBPC_PATH . self::PATH_SOURCE_FILE_WEBP, $output_path );
93
  }
94
  }
95
 
@@ -103,12 +115,11 @@ class RewritesErrorsDetector implements ErrorDetector {
103
  $uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
104
  $ver_param = sprintf( 'ver=%s', time() );
105
 
106
- $file_size = FileLoader::get_file_size_by_path(
107
  $uploads_dir . self::PATH_OUTPUT_FILE_PNG
108
  );
109
- $file_webp = FileLoader::get_file_size_by_url(
110
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
111
- $this->plugin_data,
112
  true,
113
  $ver_param
114
  );
@@ -122,9 +133,8 @@ class RewritesErrorsDetector implements ErrorDetector {
122
  * @return bool Verification status.
123
  */
124
  private function if_htaccess_can_be_overwritten(): bool {
125
- $file_size = FileLoader::get_file_size_by_url(
126
- self::URL_DEBUG_HTACCESS_FILE,
127
- $this->plugin_data
128
  );
129
 
130
  return ( $file_size === 0 );
@@ -139,15 +149,13 @@ class RewritesErrorsDetector implements ErrorDetector {
139
  $uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
140
  $ver_param = sprintf( '&?ver=%s', time() );
141
 
142
- $file_png = FileLoader::get_file_size_by_url(
143
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
144
- $this->plugin_data,
145
  true,
146
  $ver_param
147
  );
148
- $file_png2 = FileLoader::get_file_size_by_url(
149
  $uploads_url . self::PATH_OUTPUT_FILE_PNG2,
150
- $this->plugin_data,
151
  true,
152
  $ver_param
153
  );
@@ -164,15 +172,13 @@ class RewritesErrorsDetector implements ErrorDetector {
164
  $uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
165
  $ver_param = sprintf( 'ver=%s', time() );
166
 
167
- $file_webp = FileLoader::get_file_size_by_url(
168
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
169
- $this->plugin_data,
170
  true,
171
  $ver_param
172
  );
173
- $file_original = FileLoader::get_file_size_by_url(
174
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
175
- $this->plugin_data,
176
  false,
177
  $ver_param
178
  );
11
  use WebpConverter\Helper\FileLoader;
12
  use WebpConverter\Loader\LoaderAbstract;
13
  use WebpConverter\PluginData;
14
+ use WebpConverter\PluginInfo;
15
+ use WebpConverter\Settings\Option\OutputFormatsOption;
16
+ use WebpConverter\Settings\Option\SupportedDirectoriesOption;
17
 
18
  /**
19
  * Checks for configuration errors about non-working HTTP rewrites.
24
  const PATH_SOURCE_FILE_WEBP = '/assets/img/icon-test.webp';
25
  const PATH_OUTPUT_FILE_PNG = '/webp-converter-for-media-test.png';
26
  const PATH_OUTPUT_FILE_PNG2 = '/webp-converter-for-media-test.png2';
27
+ const URL_DEBUG_HTACCESS_FILE = 'assets/img/debug-htaccess/icon-test.png';
28
 
29
  /**
30
+ * @var PluginInfo
31
+ */
32
+ private $plugin_info;
33
+
34
+ /**
35
+ * @var PluginData
36
  */
37
  private $plugin_data;
38
 
39
  /**
40
+ * @var FileLoader
41
  */
42
+ private $file_loader;
43
+
44
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data, FileLoader $file_loader = null ) {
45
+ $this->plugin_info = $plugin_info;
46
  $this->plugin_data = $plugin_data;
47
+ $this->file_loader = $file_loader ?: new FileLoader( $plugin_info, $plugin_data );
48
  }
49
 
50
  /**
52
  */
53
  public function get_error() {
54
  $settings = $this->plugin_data->get_plugin_settings();
55
+ if ( ! $settings[ SupportedDirectoriesOption::OPTION_NAME ] || ! $settings[ OutputFormatsOption::OPTION_NAME ] ) {
56
  return null;
57
  }
58
 
62
 
63
  if ( $this->if_redirects_are_works() !== true ) {
64
  if ( $this->if_bypassing_apache_is_active() === true ) {
65
+ $error = new BypassingApacheNotice( $this->plugin_info );
66
  } elseif ( $this->if_htaccess_can_be_overwritten() !== true ) {
67
  $error = new RewritesNotExecutedNotice();
68
  } else {
91
  }
92
 
93
  if ( ! file_exists( $path_file_png ) || ! file_exists( $path_file_png2 ) ) {
94
+ copy( $this->plugin_info->get_plugin_directory_path() . self::PATH_SOURCE_FILE_PNG, $path_file_png );
95
+ copy( $this->plugin_info->get_plugin_directory_path() . self::PATH_SOURCE_FILE_PNG, $path_file_png2 );
96
  }
97
 
98
  if ( ( $output_path = OutputPath::get_path( $path_file_png, true, WebpFormat::FORMAT_EXTENSION ) )
99
  && ! file_exists( $output_path ) ) {
100
+ copy( $this->plugin_info->get_plugin_directory_path() . self::PATH_SOURCE_FILE_WEBP, $output_path );
101
  }
102
  if ( ( $output_path = OutputPath::get_path( $path_file_png2, true, WebpFormat::FORMAT_EXTENSION ) )
103
  && ! file_exists( $output_path ) ) {
104
+ copy( $this->plugin_info->get_plugin_directory_path() . self::PATH_SOURCE_FILE_WEBP, $output_path );
105
  }
106
  }
107
 
115
  $uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
116
  $ver_param = sprintf( 'ver=%s', time() );
117
 
118
+ $file_size = $this->file_loader->get_file_size_by_path(
119
  $uploads_dir . self::PATH_OUTPUT_FILE_PNG
120
  );
121
+ $file_webp = $this->file_loader->get_file_size_by_url(
122
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
 
123
  true,
124
  $ver_param
125
  );
133
  * @return bool Verification status.
134
  */
135
  private function if_htaccess_can_be_overwritten(): bool {
136
+ $file_size = $this->file_loader->get_file_size_by_url(
137
+ $this->plugin_info->get_plugin_directory_url() . self::URL_DEBUG_HTACCESS_FILE
 
138
  );
139
 
140
  return ( $file_size === 0 );
149
  $uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
150
  $ver_param = sprintf( '&?ver=%s', time() );
151
 
152
+ $file_png = $this->file_loader->get_file_size_by_url(
153
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
 
154
  true,
155
  $ver_param
156
  );
157
+ $file_png2 = $this->file_loader->get_file_size_by_url(
158
  $uploads_url . self::PATH_OUTPUT_FILE_PNG2,
 
159
  true,
160
  $ver_param
161
  );
172
  $uploads_url = apply_filters( 'webpc_dir_url', '', 'uploads' );
173
  $ver_param = sprintf( 'ver=%s', time() );
174
 
175
+ $file_webp = $this->file_loader->get_file_size_by_url(
176
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
 
177
  true,
178
  $ver_param
179
  );
180
+ $file_original = $this->file_loader->get_file_size_by_url(
181
  $uploads_url . self::PATH_OUTPUT_FILE_PNG,
 
182
  false,
183
  $ver_param
184
  );
src/Error/Detector/SettingsIncorrectDetector.php CHANGED
@@ -4,6 +4,11 @@ namespace WebpConverter\Error\Detector;
4
 
5
  use WebpConverter\Error\Notice\SettingsIncorrectNotice;
6
  use WebpConverter\PluginData;
 
 
 
 
 
7
 
8
  /**
9
  * Checks for configuration errors about incorrectly saved plugin settings.
@@ -11,13 +16,10 @@ use WebpConverter\PluginData;
11
  class SettingsIncorrectDetector implements ErrorDetector {
12
 
13
  /**
14
- * @var PluginData .
15
  */
16
  private $plugin_data;
17
 
18
- /**
19
- * @param PluginData $plugin_data .
20
- */
21
  public function __construct( PluginData $plugin_data ) {
22
  $this->plugin_data = $plugin_data;
23
  }
@@ -28,11 +30,16 @@ class SettingsIncorrectDetector implements ErrorDetector {
28
  public function get_error() {
29
  $settings = $this->plugin_data->get_plugin_settings();
30
 
31
- if ( ( ! isset( $settings['extensions'] ) || ! $settings['extensions'] )
32
- || ( ! isset( $settings['dirs'] ) || ! $settings['dirs'] )
33
- || ( ! isset( $settings['method'] ) || ! $settings['method'] )
34
- || ( ! isset( $settings['output_formats'] ) || ! $settings['output_formats'] )
35
- || ( ! isset( $settings['quality'] ) || ! $settings['quality'] ) ) {
 
 
 
 
 
36
  return new SettingsIncorrectNotice();
37
  }
38
 
4
 
5
  use WebpConverter\Error\Notice\SettingsIncorrectNotice;
6
  use WebpConverter\PluginData;
7
+ use WebpConverter\Settings\Option\ConversionMethodOption;
8
+ use WebpConverter\Settings\Option\ImagesQualityOption;
9
+ use WebpConverter\Settings\Option\OutputFormatsOption;
10
+ use WebpConverter\Settings\Option\SupportedDirectoriesOption;
11
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
12
 
13
  /**
14
  * Checks for configuration errors about incorrectly saved plugin settings.
16
  class SettingsIncorrectDetector implements ErrorDetector {
17
 
18
  /**
19
+ * @var PluginData
20
  */
21
  private $plugin_data;
22
 
 
 
 
23
  public function __construct( PluginData $plugin_data ) {
24
  $this->plugin_data = $plugin_data;
25
  }
30
  public function get_error() {
31
  $settings = $this->plugin_data->get_plugin_settings();
32
 
33
+ if ( ( ! isset( $settings[ SupportedExtensionsOption::OPTION_NAME ] )
34
+ || ! $settings[ SupportedExtensionsOption::OPTION_NAME ] )
35
+ || ( ! isset( $settings[ SupportedDirectoriesOption::OPTION_NAME ] )
36
+ || ! $settings[ SupportedDirectoriesOption::OPTION_NAME ] )
37
+ || ( ! isset( $settings[ ConversionMethodOption::OPTION_NAME ] )
38
+ || ! $settings[ ConversionMethodOption::OPTION_NAME ] )
39
+ || ( ! isset( $settings[ OutputFormatsOption::OPTION_NAME ] )
40
+ || ! $settings[ OutputFormatsOption::OPTION_NAME ] )
41
+ || ( ! isset( $settings[ ImagesQualityOption::OPTION_NAME ] )
42
+ || ! $settings[ ImagesQualityOption::OPTION_NAME ] ) ) {
43
  return new SettingsIncorrectNotice();
44
  }
45
 
src/Error/ErrorDetectorAggregator.php CHANGED
@@ -15,6 +15,7 @@ use WebpConverter\Error\Notice\RewritesCachedNotice;
15
  use WebpConverter\Helper\OptionsAccess;
16
  use WebpConverter\HookableInterface;
17
  use WebpConverter\PluginData;
 
18
 
19
  /**
20
  * Supports generating list of server configuration errors.
@@ -24,7 +25,12 @@ class ErrorDetectorAggregator implements HookableInterface {
24
  const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
25
 
26
  /**
27
- * @var PluginData .
 
 
 
 
 
28
  */
29
  private $plugin_data;
30
 
@@ -40,10 +46,8 @@ class ErrorDetectorAggregator implements HookableInterface {
40
  */
41
  private $cached_errors = null;
42
 
43
- /**
44
- * @param PluginData $plugin_data .
45
- */
46
- public function __construct( PluginData $plugin_data ) {
47
  $this->plugin_data = $plugin_data;
48
  }
49
 
@@ -152,9 +156,9 @@ class ErrorDetectorAggregator implements HookableInterface {
152
  $this->cached_errors[] = $new_error;
153
  }
154
 
155
- if ( $new_error = ( new PassthruExecutionDetector( $this->plugin_data ) )->get_error() ) {
156
  $this->cached_errors[] = $new_error;
157
- } elseif ( $new_error = ( new RewritesErrorsDetector( $this->plugin_data ) )->get_error() ) {
158
  $this->cached_errors[] = $new_error;
159
  }
160
 
15
  use WebpConverter\Helper\OptionsAccess;
16
  use WebpConverter\HookableInterface;
17
  use WebpConverter\PluginData;
18
+ use WebpConverter\PluginInfo;
19
 
20
  /**
21
  * Supports generating list of server configuration errors.
25
  const ERRORS_CACHE_OPTION = 'webpc_errors_cache';
26
 
27
  /**
28
+ * @var PluginInfo
29
+ */
30
+ private $plugin_info;
31
+
32
+ /**
33
+ * @var PluginData
34
  */
35
  private $plugin_data;
36
 
46
  */
47
  private $cached_errors = null;
48
 
49
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data ) {
50
+ $this->plugin_info = $plugin_info;
 
 
51
  $this->plugin_data = $plugin_data;
52
  }
53
 
156
  $this->cached_errors[] = $new_error;
157
  }
158
 
159
+ if ( $new_error = ( new PassthruExecutionDetector( $this->plugin_info, $this->plugin_data ) )->get_error() ) {
160
  $this->cached_errors[] = $new_error;
161
+ } elseif ( $new_error = ( new RewritesErrorsDetector( $this->plugin_info, $this->plugin_data ) )->get_error() ) {
162
  $this->cached_errors[] = $new_error;
163
  }
164
 
src/Error/Notice/BypassingApacheNotice.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  namespace WebpConverter\Error\Notice;
4
 
 
 
5
  /**
6
  * {@inheritdoc}
7
  */
@@ -9,6 +11,15 @@ class BypassingApacheNotice implements ErrorNotice {
9
 
10
  const ERROR_KEY = 'bypassing_apache';
11
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * {@inheritdoc}
14
  */
@@ -24,9 +35,9 @@ class BypassingApacheNotice implements ErrorNotice {
24
  sprintf(
25
  /* translators: %1$s: open anchor tag, %2$s: close anchor tag, %3$s: open anchor tag, %4$s: close anchor tag */
26
  __( 'Requests to images are processed by your server bypassing Apache. When loading images, rules from the .htaccess file are not executed. Occasionally, this only applies to known file extensions: .jpg, .png, etc. and when e.g. .png2 extension is loaded, then the redirections from the .htaccess file work, because the server does not understand this format and does not treat it as image files. Check the redirects for %1$s.png file%2$s (for which the redirection does not work) and for %3$s.png2 file%4$s (for which the redirection works correctly). Change the server settings to stop ignoring the rules from the .htaccess file.', 'webp-converter-for-media' ),
27
- '<a href="' . WEBPC_URL . 'assets/img/debug/icon-before.png" target="_blank">',
28
  '</a>',
29
- '<a href="' . WEBPC_URL . 'assets/img/debug/icon-before.png2" target="_blank">',
30
  '</a>'
31
  ),
32
  __( 'In this case, please contact your server administrator.', 'webp-converter-for-media' ),
2
 
3
  namespace WebpConverter\Error\Notice;
4
 
5
+ use WebpConverter\PluginInfo;
6
+
7
  /**
8
  * {@inheritdoc}
9
  */
11
 
12
  const ERROR_KEY = 'bypassing_apache';
13
 
14
+ /**
15
+ * @var PluginInfo
16
+ */
17
+ private $plugin_info;
18
+
19
+ public function __construct( PluginInfo $plugin_info ) {
20
+ $this->plugin_info = $plugin_info;
21
+ }
22
+
23
  /**
24
  * {@inheritdoc}
25
  */
35
  sprintf(
36
  /* translators: %1$s: open anchor tag, %2$s: close anchor tag, %3$s: open anchor tag, %4$s: close anchor tag */
37
  __( 'Requests to images are processed by your server bypassing Apache. When loading images, rules from the .htaccess file are not executed. Occasionally, this only applies to known file extensions: .jpg, .png, etc. and when e.g. .png2 extension is loaded, then the redirections from the .htaccess file work, because the server does not understand this format and does not treat it as image files. Check the redirects for %1$s.png file%2$s (for which the redirection does not work) and for %3$s.png2 file%4$s (for which the redirection works correctly). Change the server settings to stop ignoring the rules from the .htaccess file.', 'webp-converter-for-media' ),
38
+ '<a href="' . $this->plugin_info->get_plugin_directory_url() . 'assets/img/debug/icon-before.png" target="_blank">',
39
  '</a>',
40
+ '<a href="' . $this->plugin_info->get_plugin_directory_url() . 'assets/img/debug/icon-before.png2" target="_blank">',
41
  '</a>'
42
  ),
43
  __( 'In this case, please contact your server administrator.', 'webp-converter-for-media' ),
src/Helper/FileLoader.php CHANGED
@@ -4,29 +4,44 @@ namespace WebpConverter\Helper;
4
 
5
  use WebpConverter\Loader\PassthruLoader;
6
  use WebpConverter\PluginData;
 
7
 
8
  /**
9
  * Returns size of image downloaded based on server path or URL.
10
  */
11
  class FileLoader {
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  /**
14
  * Checks size of file by sending request using active image loader.
15
  *
16
- * @param string $url URL of image.
17
- * @param PluginData $plugin_data .
18
- * @param bool $set_headers Whether to send headers to confirm that browser supports WebP?
19
- * @param string $extra_param Additional GET param.
20
  *
21
  * @return int Size of retrieved file.
22
  */
23
- public static function get_file_size_by_url( string $url, PluginData $plugin_data, bool $set_headers = true, string $extra_param = '' ): int {
24
  $headers = [
25
  'Accept: image/webp',
26
- 'Referer: ' . WEBPC_URL,
27
  ];
28
 
29
- $image_url = ( new PassthruLoader( $plugin_data ) )->update_image_urls( $url, true );
30
  if ( $extra_param ) {
31
  $image_url .= ( ( strpos( $image_url, '?' ) !== false ) ? '&' : '?' ) . $extra_param;
32
  }
@@ -41,7 +56,7 @@ class FileLoader {
41
  *
42
  * @return int Size of file.
43
  */
44
- public static function get_file_size_by_path( string $path ): int {
45
  return ( file_exists( $path ) ) ? ( filesize( $path ) ?: 0 ) : 0;
46
  }
47
 
@@ -53,7 +68,7 @@ class FileLoader {
53
  *
54
  * @return int Size of retrieved file.
55
  */
56
- private static function get_file_size_for_loaded_file( string $url, array $headers ): int {
57
  foreach ( wp_get_nocache_headers() as $header_key => $header_value ) {
58
  $headers[] = sprintf( '%s: %s', $header_key, $header_value );
59
  }
4
 
5
  use WebpConverter\Loader\PassthruLoader;
6
  use WebpConverter\PluginData;
7
+ use WebpConverter\PluginInfo;
8
 
9
  /**
10
  * Returns size of image downloaded based on server path or URL.
11
  */
12
  class FileLoader {
13
 
14
+ /**
15
+ * @var PluginInfo
16
+ */
17
+ private $plugin_info;
18
+
19
+ /**
20
+ * @var PluginData
21
+ */
22
+ private $plugin_data;
23
+
24
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data ) {
25
+ $this->plugin_info = $plugin_info;
26
+ $this->plugin_data = $plugin_data;
27
+ }
28
+
29
  /**
30
  * Checks size of file by sending request using active image loader.
31
  *
32
+ * @param string $url URL of image.
33
+ * @param bool $set_headers Whether to send headers to confirm that browser supports WebP?
34
+ * @param string $extra_param Additional GET param.
 
35
  *
36
  * @return int Size of retrieved file.
37
  */
38
+ public function get_file_size_by_url( string $url, bool $set_headers = true, string $extra_param = '' ): int {
39
  $headers = [
40
  'Accept: image/webp',
41
+ 'Referer: ' . $this->plugin_info->get_plugin_directory_url(),
42
  ];
43
 
44
+ $image_url = ( new PassthruLoader( $this->plugin_info, $this->plugin_data ) )->update_image_urls( $url, true );
45
  if ( $extra_param ) {
46
  $image_url .= ( ( strpos( $image_url, '?' ) !== false ) ? '&' : '?' ) . $extra_param;
47
  }
56
  *
57
  * @return int Size of file.
58
  */
59
+ public function get_file_size_by_path( string $path ): int {
60
  return ( file_exists( $path ) ) ? ( filesize( $path ) ?: 0 ) : 0;
61
  }
62
 
68
  *
69
  * @return int Size of retrieved file.
70
  */
71
+ private function get_file_size_for_loaded_file( string $url, array $headers ): int {
72
  foreach ( wp_get_nocache_headers() as $header_key => $header_value ) {
73
  $headers[] = sprintf( '%s: %s', $header_key, $header_value );
74
  }
src/Helper/ViewLoader.php CHANGED
@@ -2,12 +2,21 @@
2
 
3
  namespace WebpConverter\Helper;
4
 
 
 
5
  /**
6
  * Supports loading views from /templates directory.
7
  */
8
  class ViewLoader {
9
 
10
- const ROOT_DIRECTORY = WEBPC_PATH;
 
 
 
 
 
 
 
11
 
12
  /**
13
  * Loads view with given variables.
@@ -17,9 +26,9 @@ class ViewLoader {
17
  *
18
  * @return void
19
  */
20
- public static function load_view( string $path, array $params = [] ) {
21
  extract( $params ); // phpcs:ignore
22
- $view_path = sprintf( '%1$s/templates/%2$s', self::ROOT_DIRECTORY, $path );
23
  if ( file_exists( $view_path ) ) {
24
  /** @noinspection PhpIncludeInspection */ // phpcs:ignore
25
  require_once $view_path;
2
 
3
  namespace WebpConverter\Helper;
4
 
5
+ use WebpConverter\PluginInfo;
6
+
7
  /**
8
  * Supports loading views from /templates directory.
9
  */
10
  class ViewLoader {
11
 
12
+ /**
13
+ * @var PluginInfo
14
+ */
15
+ private $plugin_info;
16
+
17
+ public function __construct( PluginInfo $plugin_info ) {
18
+ $this->plugin_info = $plugin_info;
19
+ }
20
 
21
  /**
22
  * Loads view with given variables.
26
  *
27
  * @return void
28
  */
29
+ public function load_view( string $path, array $params = [] ) {
30
  extract( $params ); // phpcs:ignore
31
+ $view_path = sprintf( '%1$s/templates/%2$s', $this->plugin_info->get_plugin_directory_path(), $path );
32
  if ( file_exists( $view_path ) ) {
33
  /** @noinspection PhpIncludeInspection */ // phpcs:ignore
34
  require_once $view_path;
src/Loader/HtaccessLoader.php CHANGED
@@ -2,6 +2,10 @@
2
 
3
  namespace WebpConverter\Loader;
4
 
 
 
 
 
5
  /**
6
  * Supports method of loading images using rewrites from .htaccess file.
7
  */
@@ -14,7 +18,7 @@ class HtaccessLoader extends LoaderAbstract {
14
  */
15
  public function is_active_loader(): bool {
16
  $settings = $this->plugin_data->get_plugin_settings();
17
- return ( ! isset( $settings['loader_type'] ) || ( $settings['loader_type'] === self::LOADER_TYPE ) );
18
  }
19
 
20
  /**
@@ -136,7 +140,7 @@ class HtaccessLoader extends LoaderAbstract {
136
  */
137
  private function get_mod_rewrite_rules( array $settings, $output_path = null ): string {
138
  $content = '';
139
- if ( ! $settings['extensions'] ) {
140
  return $content;
141
  }
142
 
@@ -150,10 +154,10 @@ class HtaccessLoader extends LoaderAbstract {
150
  foreach ( $this->get_mime_types() as $format => $mime_type ) {
151
  $content .= '<IfModule mod_rewrite.c>' . PHP_EOL;
152
  $content .= ' RewriteEngine On' . PHP_EOL;
153
- foreach ( $settings['extensions'] as $ext ) {
154
  $content .= " RewriteCond %{HTTP_ACCEPT} ${mime_type}" . PHP_EOL;
155
  $content .= " RewriteCond %{DOCUMENT_ROOT}${prefix_path}${path}/$1.${ext}.${format} -f" . PHP_EOL;
156
- if ( ! in_array( 'referer_disabled', $settings['features'] ) ) {
157
  $content .= " RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} ^([^@]*)@@https?://\\1/.*" . PHP_EOL;
158
  }
159
  $content .= " RewriteRule (.+)\.${ext}$ ${prefix_rule}${path}/$1.${ext}.${format} [NC,T=${mime_type},L]" . PHP_EOL;
@@ -190,7 +194,7 @@ class HtaccessLoader extends LoaderAbstract {
190
  */
191
  private function get_mod_expires_rules( array $settings ): string {
192
  $content = '';
193
- if ( ! in_array( 'mod_expires', $settings['features'] ) ) {
194
  return $content;
195
  }
196
 
@@ -211,7 +215,7 @@ class HtaccessLoader extends LoaderAbstract {
211
  */
212
  private function get_mod_mime_rules( array $settings ): string {
213
  $content = '';
214
- if ( ! $settings['extensions'] ) {
215
  return $content;
216
  }
217
 
2
 
3
  namespace WebpConverter\Loader;
4
 
5
+ use WebpConverter\Settings\Option\ExtraFeaturesOption;
6
+ use WebpConverter\Settings\Option\LoaderTypeOption;
7
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
8
+
9
  /**
10
  * Supports method of loading images using rewrites from .htaccess file.
11
  */
18
  */
19
  public function is_active_loader(): bool {
20
  $settings = $this->plugin_data->get_plugin_settings();
21
+ return ( ( $settings[ LoaderTypeOption::OPTION_NAME ] ?? '' ) === self::LOADER_TYPE );
22
  }
23
 
24
  /**
140
  */
141
  private function get_mod_rewrite_rules( array $settings, $output_path = null ): string {
142
  $content = '';
143
+ if ( ! $settings[ SupportedExtensionsOption::OPTION_NAME ] ) {
144
  return $content;
145
  }
146
 
154
  foreach ( $this->get_mime_types() as $format => $mime_type ) {
155
  $content .= '<IfModule mod_rewrite.c>' . PHP_EOL;
156
  $content .= ' RewriteEngine On' . PHP_EOL;
157
+ foreach ( $settings[ SupportedExtensionsOption::OPTION_NAME ] as $ext ) {
158
  $content .= " RewriteCond %{HTTP_ACCEPT} ${mime_type}" . PHP_EOL;
159
  $content .= " RewriteCond %{DOCUMENT_ROOT}${prefix_path}${path}/$1.${ext}.${format} -f" . PHP_EOL;
160
+ if ( ! in_array( ExtraFeaturesOption::OPTION_VALUE_REFERER_DISABLED, $settings[ ExtraFeaturesOption::OPTION_NAME ] ) ) {
161
  $content .= " RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} ^([^@]*)@@https?://\\1/.*" . PHP_EOL;
162
  }
163
  $content .= " RewriteRule (.+)\.${ext}$ ${prefix_rule}${path}/$1.${ext}.${format} [NC,T=${mime_type},L]" . PHP_EOL;
194
  */
195
  private function get_mod_expires_rules( array $settings ): string {
196
  $content = '';
197
+ if ( ! in_array( ExtraFeaturesOption::OPTION_VALUE_MOD_EXPIRES, $settings[ ExtraFeaturesOption::OPTION_NAME ] ) ) {
198
  return $content;
199
  }
200
 
215
  */
216
  private function get_mod_mime_rules( array $settings ): string {
217
  $content = '';
218
+ if ( ! $settings[ SupportedExtensionsOption::OPTION_NAME ] ) {
219
  return $content;
220
  }
221
 
src/Loader/LoaderAbstract.php CHANGED
@@ -4,6 +4,8 @@ namespace WebpConverter\Loader;
4
 
5
  use WebpConverter\Conversion\Format\FormatFactory;
6
  use WebpConverter\PluginData;
 
 
7
 
8
  /**
9
  * Abstract class for class that supports method of loading images.
@@ -13,14 +15,17 @@ abstract class LoaderAbstract implements LoaderInterface {
13
  const ACTION_NAME = 'webpc_refresh_loader';
14
 
15
  /**
16
- * @var PluginData .
17
  */
18
- protected $plugin_data;
19
 
20
  /**
21
- * @param PluginData $plugin_data .
22
  */
23
- public function __construct( PluginData $plugin_data ) {
 
 
 
24
  $this->plugin_data = $plugin_data;
25
  }
26
 
@@ -35,6 +40,6 @@ abstract class LoaderAbstract implements LoaderInterface {
35
  */
36
  public function get_mime_types(): array {
37
  $settings = $this->plugin_data->get_plugin_settings();
38
- return ( new FormatFactory() )->get_mime_types( $settings['output_formats'] );
39
  }
40
  }
4
 
5
  use WebpConverter\Conversion\Format\FormatFactory;
6
  use WebpConverter\PluginData;
7
+ use WebpConverter\PluginInfo;
8
+ use WebpConverter\Settings\Option\OutputFormatsOption;
9
 
10
  /**
11
  * Abstract class for class that supports method of loading images.
15
  const ACTION_NAME = 'webpc_refresh_loader';
16
 
17
  /**
18
+ * @var PluginInfo
19
  */
20
+ protected $plugin_info;
21
 
22
  /**
23
+ * @var PluginData
24
  */
25
+ protected $plugin_data;
26
+
27
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data ) {
28
+ $this->plugin_info = $plugin_info;
29
  $this->plugin_data = $plugin_data;
30
  }
31
 
40
  */
41
  public function get_mime_types(): array {
42
  $settings = $this->plugin_data->get_plugin_settings();
43
+ return ( new FormatFactory() )->get_mime_types( $settings[ OutputFormatsOption::OPTION_NAME ] );
44
  }
45
  }
src/Loader/LoaderIntegration.php CHANGED
@@ -16,9 +16,6 @@ class LoaderIntegration implements HookableInterface {
16
  */
17
  private $loader;
18
 
19
- /**
20
- * @param LoaderInterface $loader .
21
- */
22
  public function __construct( LoaderInterface $loader ) {
23
  $this->loader = $loader;
24
  }
16
  */
17
  private $loader;
18
 
 
 
 
19
  public function __construct( LoaderInterface $loader ) {
20
  $this->loader = $loader;
21
  }
src/Loader/PassthruLoader.php CHANGED
@@ -2,6 +2,10 @@
2
 
3
  namespace WebpConverter\Loader;
4
 
 
 
 
 
5
  /**
6
  * Supports method of loading images using .php file as Pass Thru.
7
  */
@@ -23,14 +27,14 @@ class PassthruLoader extends LoaderAbstract {
23
  */
24
  public function is_active_loader(): bool {
25
  $settings = $this->plugin_data->get_plugin_settings();
26
- return ( isset( $settings['loader_type'] ) && ( $settings['loader_type'] === self::LOADER_TYPE ) );
27
  }
28
 
29
  /**
30
  * {@inheritdoc}
31
  */
32
  public function activate_loader( bool $is_debug = false ) {
33
- $path_source = WEBPC_PATH . self::LOADER_SOURCE;
34
  $source_code = ( is_readable( $path_source ) ) ? file_get_contents( $path_source ) ?: '' : '';
35
  if ( ! $source_code ) {
36
  return;
@@ -101,7 +105,7 @@ class PassthruLoader extends LoaderAbstract {
101
  }
102
 
103
  $settings = ( ! $is_debug ) ? $this->plugin_data->get_plugin_settings() : $this->plugin_data->get_debug_settings();
104
- $extensions = implode( '|', $settings['extensions'] ?? [] );
105
  if ( ! $extensions || ( ! $source_dir = self::get_loader_url() )
106
  || ( ! $allowed_dirs = $this->get_allowed_dirs( $settings ) ) ) {
107
  return $buffer;
@@ -138,7 +142,7 @@ class PassthruLoader extends LoaderAbstract {
138
  */
139
  private function get_allowed_dirs( array $settings ): array {
140
  $dirs = [];
141
- foreach ( $settings['dirs'] as $dir ) {
142
  $dirs[] = apply_filters( 'webpc_dir_name', '', $dir );
143
  }
144
  return array_filter( $dirs );
2
 
3
  namespace WebpConverter\Loader;
4
 
5
+ use WebpConverter\Settings\Option\LoaderTypeOption;
6
+ use WebpConverter\Settings\Option\SupportedDirectoriesOption;
7
+ use WebpConverter\Settings\Option\SupportedExtensionsOption;
8
+
9
  /**
10
  * Supports method of loading images using .php file as Pass Thru.
11
  */
27
  */
28
  public function is_active_loader(): bool {
29
  $settings = $this->plugin_data->get_plugin_settings();
30
+ return ( ( $settings[ LoaderTypeOption::OPTION_NAME ] ?? '' ) === self::LOADER_TYPE );
31
  }
32
 
33
  /**
34
  * {@inheritdoc}
35
  */
36
  public function activate_loader( bool $is_debug = false ) {
37
+ $path_source = $this->plugin_info->get_plugin_directory_path() . self::LOADER_SOURCE;
38
  $source_code = ( is_readable( $path_source ) ) ? file_get_contents( $path_source ) ?: '' : '';
39
  if ( ! $source_code ) {
40
  return;
105
  }
106
 
107
  $settings = ( ! $is_debug ) ? $this->plugin_data->get_plugin_settings() : $this->plugin_data->get_debug_settings();
108
+ $extensions = implode( '|', $settings[ SupportedExtensionsOption::OPTION_NAME ] );
109
  if ( ! $extensions || ( ! $source_dir = self::get_loader_url() )
110
  || ( ! $allowed_dirs = $this->get_allowed_dirs( $settings ) ) ) {
111
  return $buffer;
142
  */
143
  private function get_allowed_dirs( array $settings ): array {
144
  $dirs = [];
145
+ foreach ( $settings[ SupportedDirectoriesOption::OPTION_NAME ] as $dir ) {
146
  $dirs[] = apply_filters( 'webpc_dir_name', '', $dir );
147
  }
148
  return array_filter( $dirs );
src/Notice/NoticeFactory.php CHANGED
@@ -3,12 +3,22 @@
3
  namespace WebpConverter\Notice;
4
 
5
  use WebpConverter\HookableInterface;
 
6
 
7
  /**
8
  * Adds integration for list of notices.
9
  */
10
  class NoticeFactory implements HookableInterface {
11
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * {@inheritdoc}
14
  */
@@ -25,6 +35,6 @@ class NoticeFactory implements HookableInterface {
25
  * @return void
26
  */
27
  private function set_integration( NoticeInterface $notice ) {
28
- ( new NoticeIntegration( $notice ) )->init_hooks();
29
  }
30
  }
3
  namespace WebpConverter\Notice;
4
 
5
  use WebpConverter\HookableInterface;
6
+ use WebpConverter\PluginInfo;
7
 
8
  /**
9
  * Adds integration for list of notices.
10
  */
11
  class NoticeFactory implements HookableInterface {
12
 
13
+ /**
14
+ * @var PluginInfo
15
+ */
16
+ private $plugin_info;
17
+
18
+ public function __construct( PluginInfo $plugin_info ) {
19
+ $this->plugin_info = $plugin_info;
20
+ }
21
+
22
  /**
23
  * {@inheritdoc}
24
  */
35
  * @return void
36
  */
37
  private function set_integration( NoticeInterface $notice ) {
38
+ ( new NoticeIntegration( $this->plugin_info, $notice ) )->init_hooks();
39
  }
40
  }
src/Notice/NoticeIntegration.php CHANGED
@@ -5,6 +5,7 @@ namespace WebpConverter\Notice;
5
  use WebpConverter\Helper\OptionsAccess;
6
  use WebpConverter\Helper\ViewLoader;
7
  use WebpConverter\HookableInterface;
 
8
  use WebpConverter\Settings\AdminAssets;
9
 
10
  /**
@@ -13,17 +14,18 @@ use WebpConverter\Settings\AdminAssets;
13
  class NoticeIntegration implements HookableInterface {
14
 
15
  /**
16
- * Object of notice.
17
- *
18
- * @var NoticeInterface
19
  */
20
- private $notice;
21
 
22
  /**
23
- * @param NoticeInterface $notice .
24
  */
25
- public function __construct( NoticeInterface $notice ) {
26
- $this->notice = $notice;
 
 
 
27
  }
28
 
29
  /**
@@ -48,7 +50,7 @@ class NoticeIntegration implements HookableInterface {
48
  return;
49
  }
50
 
51
- ( new AdminAssets() )->init_hooks();
52
  if ( ! is_multisite() ) {
53
  add_action( 'admin_notices', [ $this, 'load_notice' ] );
54
  } else {
@@ -63,7 +65,7 @@ class NoticeIntegration implements HookableInterface {
63
  * @internal
64
  */
65
  public function load_notice() {
66
- ViewLoader::load_view(
67
  $this->notice->get_output_path(),
68
  $this->notice->get_vars_for_view()
69
  );
5
  use WebpConverter\Helper\OptionsAccess;
6
  use WebpConverter\Helper\ViewLoader;
7
  use WebpConverter\HookableInterface;
8
+ use WebpConverter\PluginInfo;
9
  use WebpConverter\Settings\AdminAssets;
10
 
11
  /**
14
  class NoticeIntegration implements HookableInterface {
15
 
16
  /**
17
+ * @var PluginInfo
 
 
18
  */
19
+ private $plugin_info;
20
 
21
  /**
22
+ * @var NoticeInterface
23
  */
24
+ private $notice;
25
+
26
+ public function __construct( PluginInfo $plugin_info, NoticeInterface $notice ) {
27
+ $this->plugin_info = $plugin_info;
28
+ $this->notice = $notice;
29
  }
30
 
31
  /**
50
  return;
51
  }
52
 
53
+ ( new AdminAssets( $this->plugin_info ) )->init_hooks();
54
  if ( ! is_multisite() ) {
55
  add_action( 'admin_notices', [ $this, 'load_notice' ] );
56
  } else {
65
  * @internal
66
  */
67
  public function load_notice() {
68
+ ( new ViewLoader( $this->plugin_info ) )->load_view(
69
  $this->notice->get_output_path(),
70
  $this->notice->get_vars_for_view()
71
  );
src/Plugin/Activation.php CHANGED
@@ -6,17 +6,27 @@ use WebpConverter\HookableInterface;
6
  use WebpConverter\Plugin\Activation\DefaultSettings;
7
  use WebpConverter\Plugin\Activation\RefreshLoader;
8
  use WebpConverter\Plugin\Activation\WebpDirectory;
 
9
 
10
  /**
11
  * Runs actions after plugin activation.
12
  */
13
  class Activation implements HookableInterface {
14
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * {@inheritdoc}
17
  */
18
  public function init_hooks() {
19
- register_activation_hook( WEBPC_FILE, [ $this, 'load_activation_actions' ] );
20
  }
21
 
22
  /**
@@ -27,7 +37,7 @@ class Activation implements HookableInterface {
27
  */
28
  public function load_activation_actions() {
29
  ( new WebpDirectory() )->create_directory_for_uploads_webp();
30
- ( new DefaultSettings() )->add_default_options();
31
  ( new RefreshLoader() )->refresh_image_loader();
32
  }
33
  }
6
  use WebpConverter\Plugin\Activation\DefaultSettings;
7
  use WebpConverter\Plugin\Activation\RefreshLoader;
8
  use WebpConverter\Plugin\Activation\WebpDirectory;
9
+ use WebpConverter\PluginInfo;
10
 
11
  /**
12
  * Runs actions after plugin activation.
13
  */
14
  class Activation implements HookableInterface {
15
 
16
+ /**
17
+ * @var PluginInfo
18
+ */
19
+ private $plugin_info;
20
+
21
+ public function __construct( PluginInfo $plugin_info ) {
22
+ $this->plugin_info = $plugin_info;
23
+ }
24
+
25
  /**
26
  * {@inheritdoc}
27
  */
28
  public function init_hooks() {
29
+ register_activation_hook( $this->plugin_info->get_plugin_file(), [ $this, 'load_activation_actions' ] );
30
  }
31
 
32
  /**
37
  */
38
  public function load_activation_actions() {
39
  ( new WebpDirectory() )->create_directory_for_uploads_webp();
40
+ ( new DefaultSettings( $this->plugin_info ) )->add_default_options();
41
  ( new RefreshLoader() )->refresh_image_loader();
42
  }
43
  }
src/Plugin/Activation/DefaultSettings.php CHANGED
@@ -5,19 +5,29 @@ namespace WebpConverter\Plugin\Activation;
5
  use WebpConverter\Notice\NoticeIntegration;
6
  use WebpConverter\Notice\ThanksNotice;
7
  use WebpConverter\Notice\WelcomeNotice;
 
8
 
9
  /**
10
  * Adds default options for plugin settings.
11
  */
12
  class DefaultSettings {
13
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * Sets default value for admin notices.
16
  *
17
  * @return void
18
  */
19
  public function add_default_options() {
20
- ( new NoticeIntegration( new ThanksNotice() ) )->set_default_value();
21
- ( new NoticeIntegration( new WelcomeNotice() ) )->set_default_value();
22
  }
23
  }
5
  use WebpConverter\Notice\NoticeIntegration;
6
  use WebpConverter\Notice\ThanksNotice;
7
  use WebpConverter\Notice\WelcomeNotice;
8
+ use WebpConverter\PluginInfo;
9
 
10
  /**
11
  * Adds default options for plugin settings.
12
  */
13
  class DefaultSettings {
14
 
15
+ /**
16
+ * @var PluginInfo
17
+ */
18
+ private $plugin_info;
19
+
20
+ public function __construct( PluginInfo $plugin_info ) {
21
+ $this->plugin_info = $plugin_info;
22
+ }
23
+
24
  /**
25
  * Sets default value for admin notices.
26
  *
27
  * @return void
28
  */
29
  public function add_default_options() {
30
+ ( new NoticeIntegration( $this->plugin_info, new ThanksNotice() ) )->set_default_value();
31
+ ( new NoticeIntegration( $this->plugin_info, new WelcomeNotice() ) )->set_default_value();
32
  }
33
  }
src/Plugin/Deactivation.php CHANGED
@@ -5,17 +5,27 @@ namespace WebpConverter\Plugin;
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Plugin\Deactivation\CronReset;
7
  use WebpConverter\Plugin\Deactivation\RefreshLoader;
 
8
 
9
  /**
10
  * Runs actions after plugin deactivation.
11
  */
12
  class Deactivation implements HookableInterface {
13
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * {@inheritdoc}
16
  */
17
  public function init_hooks() {
18
- register_deactivation_hook( WEBPC_FILE, [ $this, 'load_deactivation_actions' ] );
19
  }
20
 
21
  /**
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Plugin\Deactivation\CronReset;
7
  use WebpConverter\Plugin\Deactivation\RefreshLoader;
8
+ use WebpConverter\PluginInfo;
9
 
10
  /**
11
  * Runs actions after plugin deactivation.
12
  */
13
  class Deactivation implements HookableInterface {
14
 
15
+ /**
16
+ * @var PluginInfo
17
+ */
18
+ private $plugin_info;
19
+
20
+ public function __construct( PluginInfo $plugin_info ) {
21
+ $this->plugin_info = $plugin_info;
22
+ }
23
+
24
  /**
25
  * {@inheritdoc}
26
  */
27
  public function init_hooks() {
28
+ register_deactivation_hook( $this->plugin_info->get_plugin_file(), [ $this, 'load_deactivation_actions' ] );
29
  }
30
 
31
  /**
src/Plugin/Deactivation/Modal.php CHANGED
@@ -5,6 +5,7 @@ namespace WebpConverter\Plugin\Deactivation;
5
  use WebpConverter\Helper\ViewLoader;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
 
8
  use WebpConverter\Settings\AdminAssets;
9
 
10
  /**
@@ -15,14 +16,17 @@ class Modal implements HookableInterface {
15
  const FEEDBACK_API_URL = 'https://feedback.gbiorczyk.pl/';
16
 
17
  /**
18
- * @var PluginData .
19
  */
20
- private $plugin_data;
21
 
22
  /**
23
- * @param PluginData $plugin_data .
24
  */
25
- public function __construct( PluginData $plugin_data ) {
 
 
 
26
  $this->plugin_data = $plugin_data;
27
  }
28
 
@@ -34,7 +38,7 @@ class Modal implements HookableInterface {
34
  return;
35
  }
36
 
37
- ( new AdminAssets() )->init_hooks();
38
  add_action( 'admin_footer', [ $this, 'load_deactivation_modal' ] );
39
  }
40
 
@@ -44,13 +48,14 @@ class Modal implements HookableInterface {
44
  * @return void
45
  */
46
  public function load_deactivation_modal() {
47
- ViewLoader::load_view(
48
  'views/deactivation-modal.php',
49
  [
50
- 'errors' => apply_filters( 'webpc_server_errors', [] ),
51
- 'reasons' => $this->get_reasons(),
52
- 'settings' => $this->plugin_data->get_plugin_settings(),
53
- 'api_url' => self::FEEDBACK_API_URL,
 
54
  ]
55
  );
56
  }
5
  use WebpConverter\Helper\ViewLoader;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\PluginData;
8
+ use WebpConverter\PluginInfo;
9
  use WebpConverter\Settings\AdminAssets;
10
 
11
  /**
16
  const FEEDBACK_API_URL = 'https://feedback.gbiorczyk.pl/';
17
 
18
  /**
19
+ * @var PluginInfo
20
  */
21
+ private $plugin_info;
22
 
23
  /**
24
+ * @var PluginData
25
  */
26
+ private $plugin_data;
27
+
28
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data ) {
29
+ $this->plugin_info = $plugin_info;
30
  $this->plugin_data = $plugin_data;
31
  }
32
 
38
  return;
39
  }
40
 
41
+ ( new AdminAssets( $this->plugin_info ) )->init_hooks();
42
  add_action( 'admin_footer', [ $this, 'load_deactivation_modal' ] );
43
  }
44
 
48
  * @return void
49
  */
50
  public function load_deactivation_modal() {
51
+ ( new ViewLoader( $this->plugin_info ) )->load_view(
52
  'views/deactivation-modal.php',
53
  [
54
+ 'errors' => apply_filters( 'webpc_server_errors', [] ),
55
+ 'reasons' => $this->get_reasons(),
56
+ 'settings' => $this->plugin_data->get_plugin_settings(),
57
+ 'api_url' => self::FEEDBACK_API_URL,
58
+ 'plugin_version' => $this->plugin_info->get_plugin_version(),
59
  ]
60
  );
61
  }
src/Plugin/Links.php CHANGED
@@ -3,6 +3,7 @@
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\HookableInterface;
 
6
  use WebpConverter\Settings\Page\PageIntegration;
7
 
8
  /**
@@ -12,12 +13,21 @@ class Links implements HookableInterface {
12
 
13
  const DONATION_URL = 'https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=plugin-links';
14
 
 
 
 
 
 
 
 
 
 
15
  /**
16
  * {@inheritdoc}
17
  */
18
  public function init_hooks() {
19
- add_filter( 'plugin_action_links_' . WEBPC_NAME, [ $this, 'add_plugin_links_for_admin' ] );
20
- add_filter( 'network_admin_plugin_action_links_' . WEBPC_NAME, [ $this, 'add_plugin_links_for_network' ] );
21
  }
22
 
23
  /**
3
  namespace WebpConverter\Plugin;
4
 
5
  use WebpConverter\HookableInterface;
6
+ use WebpConverter\PluginInfo;
7
  use WebpConverter\Settings\Page\PageIntegration;
8
 
9
  /**
13
 
14
  const DONATION_URL = 'https://ko-fi.com/gbiorczyk/?utm_source=webp-converter-for-media&utm_medium=plugin-links';
15
 
16
+ /**
17
+ * @var PluginInfo
18
+ */
19
+ private $plugin_info;
20
+
21
+ public function __construct( PluginInfo $plugin_info ) {
22
+ $this->plugin_info = $plugin_info;
23
+ }
24
+
25
  /**
26
  * {@inheritdoc}
27
  */
28
  public function init_hooks() {
29
+ add_filter( 'plugin_action_links_' . $this->plugin_info->get_plugin_basename(), [ $this, 'add_plugin_links_for_admin' ] );
30
+ add_filter( 'network_admin_plugin_action_links_' . $this->plugin_info->get_plugin_basename(), [ $this, 'add_plugin_links_for_network' ] );
31
  }
32
 
33
  /**
src/Plugin/Uninstall.php CHANGED
@@ -7,17 +7,27 @@ use WebpConverter\Plugin\Uninstall\DebugFiles;
7
  use WebpConverter\Plugin\Uninstall\HtaccessFile;
8
  use WebpConverter\Plugin\Uninstall\PluginSettings;
9
  use WebpConverter\Plugin\Uninstall\WebpFiles;
 
10
 
11
  /**
12
  * Runs actions before plugin uninstallation.
13
  */
14
  class Uninstall implements HookableInterface {
15
 
 
 
 
 
 
 
 
 
 
16
  /**
17
  * {@inheritdoc}
18
  */
19
  public function init_hooks() {
20
- register_uninstall_hook( WEBPC_FILE, [ 'WebpConverter\Plugin\Uninstall', 'load_uninstall_actions' ] );
21
  }
22
 
23
  /**
7
  use WebpConverter\Plugin\Uninstall\HtaccessFile;
8
  use WebpConverter\Plugin\Uninstall\PluginSettings;
9
  use WebpConverter\Plugin\Uninstall\WebpFiles;
10
+ use WebpConverter\PluginInfo;
11
 
12
  /**
13
  * Runs actions before plugin uninstallation.
14
  */
15
  class Uninstall implements HookableInterface {
16
 
17
+ /**
18
+ * @var PluginInfo
19
+ */
20
+ private $plugin_info;
21
+
22
+ public function __construct( PluginInfo $plugin_info ) {
23
+ $this->plugin_info = $plugin_info;
24
+ }
25
+
26
  /**
27
  * {@inheritdoc}
28
  */
29
  public function init_hooks() {
30
+ register_uninstall_hook( $this->plugin_info->get_plugin_file(), [ 'WebpConverter\Plugin\Uninstall', 'load_uninstall_actions' ] );
31
  }
32
 
33
  /**
src/Plugin/Update.php CHANGED
@@ -6,6 +6,7 @@ use WebpConverter\Helper\OptionsAccess;
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\Loader\LoaderAbstract;
8
  use WebpConverter\Plugin\Activation\DefaultSettings;
 
9
 
10
  /**
11
  * Runs actions after plugin update to new version.
@@ -14,6 +15,15 @@ class Update implements HookableInterface {
14
 
15
  const VERSION_OPTION = 'webpc_latest_version';
16
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * {@inheritdoc}
19
  */
@@ -29,13 +39,13 @@ class Update implements HookableInterface {
29
  */
30
  public function run_actions_after_update() {
31
  $version = OptionsAccess::get_option( self::VERSION_OPTION );
32
- if ( $version === WEBPC_VERSION ) {
33
  return;
34
  }
35
 
36
- ( new DefaultSettings() )->add_default_options();
37
  do_action( LoaderAbstract::ACTION_NAME, true );
38
 
39
- OptionsAccess::update_option( self::VERSION_OPTION, WEBPC_VERSION );
40
  }
41
  }
6
  use WebpConverter\HookableInterface;
7
  use WebpConverter\Loader\LoaderAbstract;
8
  use WebpConverter\Plugin\Activation\DefaultSettings;
9
+ use WebpConverter\PluginInfo;
10
 
11
  /**
12
  * Runs actions after plugin update to new version.
15
 
16
  const VERSION_OPTION = 'webpc_latest_version';
17
 
18
+ /**
19
+ * @var PluginInfo
20
+ */
21
+ private $plugin_info;
22
+
23
+ public function __construct( PluginInfo $plugin_info ) {
24
+ $this->plugin_info = $plugin_info;
25
+ }
26
+
27
  /**
28
  * {@inheritdoc}
29
  */
39
  */
40
  public function run_actions_after_update() {
41
  $version = OptionsAccess::get_option( self::VERSION_OPTION );
42
+ if ( $version === $this->plugin_info->get_plugin_version() ) {
43
  return;
44
  }
45
 
46
+ ( new DefaultSettings( $this->plugin_info ) )->add_default_options();
47
  do_action( LoaderAbstract::ACTION_NAME, true );
48
 
49
+ OptionsAccess::update_option( self::VERSION_OPTION, $this->plugin_info->get_plugin_version() );
50
  }
51
  }
src/PluginData.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace WebpConverter;
4
 
5
- use WebpConverter\Settings\Option\OptionFactory;
6
 
7
  /**
8
  * Manages plugin values.
@@ -12,7 +12,7 @@ class PluginData {
12
  /**
13
  * Handler of class with plugin settings.
14
  *
15
- * @var OptionFactory
16
  */
17
  private $settings_object;
18
 
@@ -31,7 +31,7 @@ class PluginData {
31
  private $debug_settings = null;
32
 
33
  public function __construct() {
34
- $this->settings_object = new OptionFactory();
35
  }
36
 
37
  /**
2
 
3
  namespace WebpConverter;
4
 
5
+ use WebpConverter\Settings\PluginOptions;
6
 
7
  /**
8
  * Manages plugin values.
12
  /**
13
  * Handler of class with plugin settings.
14
  *
15
+ * @var PluginOptions
16
  */
17
  private $settings_object;
18
 
31
  private $debug_settings = null;
32
 
33
  public function __construct() {
34
+ $this->settings_object = new PluginOptions();
35
  }
36
 
37
  /**
src/PluginInfo.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter;
4
+
5
+ /**
6
+ * Stores information about the plugin.
7
+ */
8
+ class PluginInfo {
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $plugin_file;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $plugin_version;
19
+
20
+ /**
21
+ * @var string
22
+ */
23
+ private $plugin_basename;
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ private $plugin_directory_path;
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ private $plugin_directory_url;
34
+
35
+ /**
36
+ * @param string $plugin_file Path to the main plugin file.
37
+ * @param string $plugin_version .
38
+ */
39
+ public function __construct( string $plugin_file, string $plugin_version ) {
40
+ $this->plugin_file = $plugin_file;
41
+ $this->plugin_version = $plugin_version;
42
+ $this->plugin_basename = plugin_basename( $plugin_file );
43
+ $this->plugin_directory_path = plugin_dir_path( $plugin_file );
44
+ $this->plugin_directory_url = plugin_dir_url( $plugin_file );
45
+ }
46
+
47
+ public function get_plugin_file(): string {
48
+ return $this->plugin_file;
49
+ }
50
+
51
+ public function get_plugin_version(): string {
52
+ return $this->plugin_version;
53
+ }
54
+
55
+ public function get_plugin_basename(): string {
56
+ return $this->plugin_basename;
57
+ }
58
+
59
+ public function get_plugin_directory_path(): string {
60
+ return $this->plugin_directory_path;
61
+ }
62
+
63
+ public function get_plugin_directory_url(): string {
64
+ return $this->plugin_directory_url;
65
+ }
66
+ }
src/Settings/AdminAssets.php CHANGED
@@ -3,25 +3,24 @@
3
  namespace WebpConverter\Settings;
4
 
5
  use WebpConverter\HookableInterface;
 
6
 
7
  /**
8
  * Initializes loading of assets in admin panel.
9
  */
10
  class AdminAssets implements HookableInterface {
11
 
12
- /**
13
- * URL of CSS file.
14
- *
15
- * @var string
16
- */
17
- private $path_css = WEBPC_URL . 'assets/build/css/styles.css';
18
 
19
  /**
20
- * URL of JS file.
21
- *
22
- * @var string
23
  */
24
- private $path_js = WEBPC_URL . 'assets/build/js/scripts.js';
 
 
 
 
25
 
26
  /**
27
  * {@inheritdoc}
@@ -38,7 +37,12 @@ class AdminAssets implements HookableInterface {
38
  * @internal
39
  */
40
  public function load_styles() {
41
- wp_register_style( 'webp-converter', $this->path_css, [], WEBPC_VERSION );
 
 
 
 
 
42
  wp_enqueue_style( 'webp-converter' );
43
  }
44
 
@@ -49,7 +53,13 @@ class AdminAssets implements HookableInterface {
49
  * @internal
50
  */
51
  public function load_scripts() {
52
- wp_register_script( 'webp-converter', $this->path_js, [ 'jquery' ], WEBPC_VERSION, true );
 
 
 
 
 
 
53
  wp_enqueue_script( 'webp-converter' );
54
  }
55
  }
3
  namespace WebpConverter\Settings;
4
 
5
  use WebpConverter\HookableInterface;
6
+ use WebpConverter\PluginInfo;
7
 
8
  /**
9
  * Initializes loading of assets in admin panel.
10
  */
11
  class AdminAssets implements HookableInterface {
12
 
13
+ const CSS_FILE_PATH = 'assets/build/css/styles.css';
14
+ const JS_FILE_PATH = 'assets/build/js/scripts.js';
 
 
 
 
15
 
16
  /**
17
+ * @var PluginInfo
 
 
18
  */
19
+ private $plugin_info;
20
+
21
+ public function __construct( PluginInfo $plugin_info ) {
22
+ $this->plugin_info = $plugin_info;
23
+ }
24
 
25
  /**
26
  * {@inheritdoc}
37
  * @internal
38
  */
39
  public function load_styles() {
40
+ wp_register_style(
41
+ 'webp-converter',
42
+ $this->plugin_info->get_plugin_directory_url() . self::CSS_FILE_PATH,
43
+ [],
44
+ $this->plugin_info->get_plugin_version()
45
+ );
46
  wp_enqueue_style( 'webp-converter' );
47
  }
48
 
53
  * @internal
54
  */
55
  public function load_scripts() {
56
+ wp_register_script(
57
+ 'webp-converter',
58
+ $this->plugin_info->get_plugin_directory_url() . self::JS_FILE_PATH,
59
+ [],
60
+ $this->plugin_info->get_plugin_version(),
61
+ true
62
+ );
63
  wp_enqueue_script( 'webp-converter' );
64
  }
65
  }
src/Settings/Option/ConversionMethodOption.php CHANGED
@@ -5,11 +5,11 @@ namespace WebpConverter\Settings\Option;
5
  use WebpConverter\Conversion\Method\MethodFactory;
6
 
7
  /**
8
- * Handles data about "Conversion method" field in plugin settings.
9
  */
10
  class ConversionMethodOption extends OptionAbstract {
11
 
12
- const LOADER_TYPE = 'method';
13
 
14
  /**
15
  * Object of integration class supports all output formats.
@@ -18,16 +18,22 @@ class ConversionMethodOption extends OptionAbstract {
18
  */
19
  private $methods_integration;
20
 
21
-
22
  public function __construct() {
23
  $this->methods_integration = new MethodFactory();
24
  }
25
 
 
 
 
 
 
 
 
26
  /**
27
  * {@inheritdoc}
28
  */
29
  public function get_name(): string {
30
- return self::LOADER_TYPE;
31
  }
32
 
33
  /**
@@ -53,6 +59,8 @@ class ConversionMethodOption extends OptionAbstract {
53
 
54
  /**
55
  * {@inheritdoc}
 
 
56
  */
57
  public function get_values( array $settings ): array {
58
  return $this->methods_integration->get_methods();
@@ -60,6 +68,8 @@ class ConversionMethodOption extends OptionAbstract {
60
 
61
  /**
62
  * {@inheritdoc}
 
 
63
  */
64
  public function get_disabled_values( array $settings ): array {
65
  $methods = $this->methods_integration->get_methods();
5
  use WebpConverter\Conversion\Method\MethodFactory;
6
 
7
  /**
8
+ * {@inheritdoc}
9
  */
10
  class ConversionMethodOption extends OptionAbstract {
11
 
12
+ const OPTION_NAME = 'method';
13
 
14
  /**
15
  * Object of integration class supports all output formats.
18
  */
19
  private $methods_integration;
20
 
 
21
  public function __construct() {
22
  $this->methods_integration = new MethodFactory();
23
  }
24
 
25
+ /**
26
+ * {@inheritdoc}
27
+ */
28
+ public function get_priority(): int {
29
+ return 40;
30
+ }
31
+
32
  /**
33
  * {@inheritdoc}
34
  */
35
  public function get_name(): string {
36
+ return self::OPTION_NAME;
37
  }
38
 
39
  /**
59
 
60
  /**
61
  * {@inheritdoc}
62
+ *
63
+ * @return string[]
64
  */
65
  public function get_values( array $settings ): array {
66
  return $this->methods_integration->get_methods();
68
 
69
  /**
70
  * {@inheritdoc}
71
+ *
72
+ * @return string[]
73
  */
74
  public function get_disabled_values( array $settings ): array {
75
  $methods = $this->methods_integration->get_methods();
src/Settings/Option/ExtraFeaturesOption.php CHANGED
@@ -2,21 +2,35 @@
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
- use WebpConverter\Conversion\Method\ImagickMethod;
6
  use WebpConverter\Loader\HtaccessLoader;
7
 
8
  /**
9
- * Handles data about "Extra features" field in plugin settings.
10
  */
11
  class ExtraFeaturesOption extends OptionAbstract {
12
 
13
- const LOADER_TYPE = 'features';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  /**
16
  * {@inheritdoc}
17
  */
18
  public function get_name(): string {
19
- return self::LOADER_TYPE;
20
  }
21
 
22
  /**
@@ -42,34 +56,36 @@ class ExtraFeaturesOption extends OptionAbstract {
42
 
43
  /**
44
  * {@inheritdoc}
 
 
45
  */
46
  public function get_values( array $settings ): array {
47
  return [
48
- 'only_smaller' => __(
49
  'Automatic removal of WebP files larger than original',
50
  'webp-converter-for-media'
51
  ),
52
- 'mod_expires' => __(
53
  'Browser Caching for WebP files (saving images in browser cache memory)',
54
  'webp-converter-for-media'
55
  ),
56
- 'keep_metadata' => __(
57
- 'Keep images metadata stored in EXIF or XMP formats (only available for Imagick conversion method)',
58
  'webp-converter-for-media'
59
  ),
60
- 'cron_enabled' => __(
61
  'Enable cron to automatically convert images from outside Media Library (images from Media Library are converted immediately after upload)',
62
  'webp-converter-for-media'
63
  ),
64
- 'cron_conversion' => __(
65
  'Enable cron to convert images uploaded to Media Library to speed up process of adding images (deactivate this option if images added to Media Library are not automatically converted)',
66
  'webp-converter-for-media'
67
  ),
68
- 'referer_disabled' => __(
69
  'Force redirections to WebP for all domains (by default, images in WebP are loaded only in domain of your website - when image is displayed via URL on another domain that original file is loaded)',
70
  'webp-converter-for-media'
71
  ),
72
- 'debug_enabled' => __(
73
  'Log errors while converting to debug.log file (when debugging in WordPress is active)',
74
  'webp-converter-for-media'
75
  ),
@@ -78,13 +94,15 @@ class ExtraFeaturesOption extends OptionAbstract {
78
 
79
  /**
80
  * {@inheritdoc}
 
 
81
  */
82
  public function get_disabled_values( array $settings ): array {
83
  $values = [];
84
- if ( ( $settings[ ConversionMethodOption::LOADER_TYPE ] ?? '' ) !== ImagickMethod::METHOD_NAME ) {
85
  $values[] = 'keep_metadata';
86
  }
87
- if ( ( $settings[ LoaderTypeOption::LOADER_TYPE ] ?? '' ) !== HtaccessLoader::LOADER_TYPE ) {
88
  $values[] = 'referer_disabled';
89
  }
90
  return $values;
2
 
3
  namespace WebpConverter\Settings\Option;
4
 
5
+ use WebpConverter\Conversion\Method\GdMethod;
6
  use WebpConverter\Loader\HtaccessLoader;
7
 
8
  /**
9
+ * {@inheritdoc}
10
  */
11
  class ExtraFeaturesOption extends OptionAbstract {
12
 
13
+ const OPTION_NAME = 'features';
14
+ const OPTION_VALUE_ONLY_SMALLER = 'only_smaller';
15
+ const OPTION_VALUE_MOD_EXPIRES = 'mod_expires';
16
+ const OPTION_VALUE_KEEP_METADATA = 'keep_metadata';
17
+ const OPTION_VALUE_CRON_ENABLED = 'cron_enabled';
18
+ const OPTION_VALUE_CRON_CONVERSION = 'cron_conversion';
19
+ const OPTION_VALUE_REFERER_DISABLED = 'referer_disabled';
20
+ const OPTION_VALUE_DEBUG_ENABLED = 'debug_enabled';
21
+
22
+ /**
23
+ * {@inheritdoc}
24
+ */
25
+ public function get_priority(): int {
26
+ return 70;
27
+ }
28
 
29
  /**
30
  * {@inheritdoc}
31
  */
32
  public function get_name(): string {
33
+ return self::OPTION_NAME;
34
  }
35
 
36
  /**
56
 
57
  /**
58
  * {@inheritdoc}
59
+ *
60
+ * @return string[]
61
  */
62
  public function get_values( array $settings ): array {
63
  return [
64
+ self::OPTION_VALUE_ONLY_SMALLER => __(
65
  'Automatic removal of WebP files larger than original',
66
  'webp-converter-for-media'
67
  ),
68
+ self::OPTION_VALUE_MOD_EXPIRES => __(
69
  'Browser Caching for WebP files (saving images in browser cache memory)',
70
  'webp-converter-for-media'
71
  ),
72
+ self::OPTION_VALUE_KEEP_METADATA => __(
73
+ 'Keep images metadata stored in EXIF or XMP formats (unavailable for GD conversion method)',
74
  'webp-converter-for-media'
75
  ),
76
+ self::OPTION_VALUE_CRON_ENABLED => __(
77
  'Enable cron to automatically convert images from outside Media Library (images from Media Library are converted immediately after upload)',
78
  'webp-converter-for-media'
79
  ),
80
+ self::OPTION_VALUE_CRON_CONVERSION => __(
81
  'Enable cron to convert images uploaded to Media Library to speed up process of adding images (deactivate this option if images added to Media Library are not automatically converted)',
82
  'webp-converter-for-media'
83
  ),
84
+ self::OPTION_VALUE_REFERER_DISABLED => __(
85
  'Force redirections to WebP for all domains (by default, images in WebP are loaded only in domain of your website - when image is displayed via URL on another domain that original file is loaded)',
86
  'webp-converter-for-media'
87
  ),
88
+ self::OPTION_VALUE_DEBUG_ENABLED => __(
89
  'Log errors while converting to debug.log file (when debugging in WordPress is active)',
90
  'webp-converter-for-media'
91
  ),
94
 
95
  /**
96
  * {@inheritdoc}
97
+ *
98
+ * @return string[]
99
  */
100
  public function get_disabled_values( array $settings ): array {
101
  $values = [];
102
+ if ( ( $settings[ ConversionMethodOption::OPTION_NAME ] ?? '' ) === GdMethod::METHOD_NAME ) {
103
  $values[] = 'keep_metadata';
104
  }
105
+ if ( ( $settings[ LoaderTypeOption::OPTION_NAME ] ?? '' ) !== HtaccessLoader::LOADER_TYPE ) {
106
  $values[] = 'referer_disabled';
107
  }
108
  return $values;
src/Settings/Option/ImagesQualityOption.php CHANGED
@@ -3,17 +3,24 @@
3
  namespace WebpConverter\Settings\Option;
4
 
5
  /**
6
- * Handles data about "Images quality" field in plugin settings.
7
  */
8
  class ImagesQualityOption extends OptionAbstract {
9
 
10
- const LOADER_TYPE = 'quality';
 
 
 
 
 
 
 
11
 
12
  /**
13
  * {@inheritdoc}
14
  */
15
  public function get_name(): string {
16
- return self::LOADER_TYPE;
17
  }
18
 
19
  /**
@@ -39,6 +46,8 @@ class ImagesQualityOption extends OptionAbstract {
39
 
40
  /**
41
  * {@inheritdoc}
 
 
42
  */
43
  public function get_values( array $settings ): array {
44
  return [
3
  namespace WebpConverter\Settings\Option;
4
 
5
  /**
6
+ * {@inheritdoc}
7
  */
8
  class ImagesQualityOption extends OptionAbstract {
9
 
10
+ const OPTION_NAME = 'quality';
11
+
12
+ /**
13
+ * {@inheritdoc}
14
+ */
15
+ public function get_priority(): int {
16
+ return 60;
17
+ }
18
 
19
  /**
20
  * {@inheritdoc}
21
  */
22
  public function get_name(): string {
23
+ return self::OPTION_NAME;
24
  }
25
 
26
  /**
46
 
47
  /**
48
  * {@inheritdoc}
49
+ *
50
+ * @return string[]
51
  */
52
  public function get_values( array $settings ): array {
53
  return [
src/Settings/Option/LoaderTypeOption.php CHANGED
@@ -6,17 +6,24 @@ use WebpConverter\Loader\HtaccessLoader;
6
  use WebpConverter\Loader\PassthruLoader;
7
 
8
  /**
9
- * Handles data about "Image loading mode" field in plugin settings.
10
  */
11
  class LoaderTypeOption extends OptionAbstract {
12
 
13
- const LOADER_TYPE = 'loader_type';
 
 
 
 
 
 
 
14
 
15
  /**
16
  * {@inheritdoc}
17
  */
18
  public function get_name(): string {
19
- return self::LOADER_TYPE;
20
  }
21
 
22
  /**
@@ -42,6 +49,8 @@ class LoaderTypeOption extends OptionAbstract {
42
 
43
  /**
44
  * {@inheritdoc}
 
 
45
  */
46
  public function get_values( array $settings ): array {
47
  return [
6
  use WebpConverter\Loader\PassthruLoader;
7
 
8
  /**
9
+ * {@inheritdoc}
10
  */
11
  class LoaderTypeOption extends OptionAbstract {
12
 
13
+ const OPTION_NAME = 'loader_type';
14
+
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ public function get_priority(): int {
19
+ return 10;
20
+ }
21
 
22
  /**
23
  * {@inheritdoc}
24
  */
25
  public function get_name(): string {
26
+ return self::OPTION_NAME;
27
  }
28
 
29
  /**
49
 
50
  /**
51
  * {@inheritdoc}
52
+ *
53
+ * @return string[]
54
  */
55
  public function get_values( array $settings ): array {
56
  return [
src/Settings/Option/OptionAbstract.php CHANGED
@@ -10,19 +10,20 @@ abstract class OptionAbstract implements OptionInterface {
10
  const OPTION_TYPE_CHECKBOX = 'checkbox';
11
  const OPTION_TYPE_RADIO = 'radio';
12
  const OPTION_TYPE_QUALITY = 'quality';
 
13
 
14
  /**
15
  * {@inheritdoc}
16
  */
17
- public function get_info(): string {
18
- return '';
19
  }
20
 
21
  /**
22
  * {@inheritdoc}
23
  */
24
- public function get_disabled_values( array $settings ): array {
25
- return [];
26
  }
27
 
28
  /**
10
  const OPTION_TYPE_CHECKBOX = 'checkbox';
11
  const OPTION_TYPE_RADIO = 'radio';
12
  const OPTION_TYPE_QUALITY = 'quality';
13
+ const OPTION_TYPE_INPUT = 'input';
14
 
15
  /**
16
  * {@inheritdoc}
17
  */
18
+ public function get_info() {
19
+ return null;
20
  }
21
 
22
  /**
23
  * {@inheritdoc}
24
  */
25
+ public function get_disabled_values( array $settings ) {
26
+ return null;
27
  }
28
 
29
  /**
src/Settings/Option/OptionIntegration.php CHANGED
@@ -50,31 +50,43 @@ class OptionIntegration {
50
  'label' => $this->option->get_label(),
51
  'info' => $this->option->get_info(),
52
  'values' => $values,
53
- 'disabled' => $disabled_values,
54
- 'value' => $value,
55
  ];
56
  }
57
 
58
  /**
59
  * Returns value of option based on plugin settings.
60
  *
61
- * @param mixed $current_value Value from plugin settings.
62
- * @param string $option_type Key of option.
63
- * @param string[] $values Values of option.
64
- * @param string[] $disabled_values Disabled values of option.
65
  *
66
- * @return string[]|string Value of option.
67
  */
68
- private function get_option_value( $current_value, string $option_type, array $values, array $disabled_values ) {
69
- $valid_values = [];
70
- foreach ( (array) $current_value as $option_value ) {
71
- if ( array_key_exists( $option_value, $values ) && ! in_array( $option_value, $disabled_values ) ) {
72
- $valid_values[] = $option_value;
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
- return ( in_array( $option_type, [ OptionAbstract::OPTION_TYPE_RADIO, OptionAbstract::OPTION_TYPE_QUALITY ] ) )
77
- ? ( $valid_values[0] ?? '' )
78
- : $valid_values;
79
  }
80
  }
50
  'label' => $this->option->get_label(),
51
  'info' => $this->option->get_info(),
52
  'values' => $values,
53
+ 'disabled' => $disabled_values ?: [],
54
+ 'value' => ( $value !== null ) ? $value : $this->option->get_default_value( $settings ),
55
  ];
56
  }
57
 
58
  /**
59
  * Returns value of option based on plugin settings.
60
  *
61
+ * @param mixed $current_value Value from plugin settings.
62
+ * @param string $option_type Key of option.
63
+ * @param string[]|null $values Values of option.
64
+ * @param string[]|null $disabled_values Disabled values of option.
65
  *
66
+ * @return string[]|string|null Value of option.
67
  */
68
+ private function get_option_value( $current_value, string $option_type, array $values = null, array $disabled_values = null ) {
69
+ switch ( $option_type ) {
70
+ case OptionAbstract::OPTION_TYPE_CHECKBOX:
71
+ $valid_values = [];
72
+ foreach ( (array) $current_value as $option_value ) {
73
+ if ( array_key_exists( $option_value, $values ?: [] )
74
+ && ! in_array( $option_value, $disabled_values ?: [] ) ) {
75
+ $valid_values[] = $option_value;
76
+ }
77
+ }
78
+ return $valid_values;
79
+ case OptionAbstract::OPTION_TYPE_RADIO:
80
+ case OptionAbstract::OPTION_TYPE_QUALITY:
81
+ if ( array_key_exists( $current_value, $values ?: [] )
82
+ && ! in_array( $current_value, $disabled_values ?: [] ) ) {
83
+ return $current_value;
84
+ }
85
+ return null;
86
+ case OptionAbstract::OPTION_TYPE_INPUT:
87
+ return sanitize_text_field( $current_value );
88
  }
89
 
90
+ return null;
 
 
91
  }
92
  }
src/Settings/Option/OptionInterface.php CHANGED
@@ -7,67 +7,74 @@ namespace WebpConverter\Settings\Option;
7
  */
8
  interface OptionInterface {
9
 
 
 
 
 
 
 
 
10
  /**
11
  * Returns name of option.
12
  *
13
- * @return string Option name.
14
  */
15
  public function get_name(): string;
16
 
17
  /**
18
  * Returns type of field.
19
  *
20
- * @return string Field type.
21
  */
22
  public function get_type(): string;
23
 
24
  /**
25
  * Returns label of option.
26
  *
27
- * @return string Option label.
28
  */
29
  public function get_label(): string;
30
 
31
  /**
32
  * Returns additional information of field.
33
  *
34
- * @return string Additional information.
35
  */
36
- public function get_info(): string;
37
 
38
  /**
39
  * Returns available values for field.
40
  *
41
  * @param mixed[] $settings Plugin settings.
42
  *
43
- * @return string[] Values for field.
44
  */
45
- public function get_values( array $settings ): array;
46
 
47
  /**
48
- * Returns unavailable values for field.
49
  *
50
- * @param mixed[] $settings Plugin settings.
51
  *
52
- * @return string[] Disabled values for field.
53
  */
54
- public function get_disabled_values( array $settings ): array;
55
 
56
  /**
57
- * Returns default value of field.
58
  *
59
- * @param mixed[]|null $settings Plugin settings.
60
  *
61
- * @return string|string[] Default value of field.
62
  */
63
- public function get_default_value( array $settings = null );
64
 
65
  /**
66
  * Returns default value of field when debugging.
67
  *
68
  * @param mixed[] $settings Plugin settings.
69
  *
70
- * @return string|string[] Default value of field for debug.
71
  */
72
  public function get_value_for_debug( array $settings );
73
  }
7
  */
8
  interface OptionInterface {
9
 
10
+ /**
11
+ * Returns order priority (ascending).
12
+ *
13
+ * @return int
14
+ */
15
+ public function get_priority(): int;
16
+
17
  /**
18
  * Returns name of option.
19
  *
20
+ * @return string
21
  */
22
  public function get_name(): string;
23
 
24
  /**
25
  * Returns type of field.
26
  *
27
+ * @return string
28
  */
29
  public function get_type(): string;
30
 
31
  /**
32
  * Returns label of option.
33
  *
34
+ * @return string
35
  */
36
  public function get_label(): string;
37
 
38
  /**
39
  * Returns additional information of field.
40
  *
41
+ * @return string|null
42
  */
43
+ public function get_info();
44
 
45
  /**
46
  * Returns available values for field.
47
  *
48
  * @param mixed[] $settings Plugin settings.
49
  *
50
+ * @return string[]|null
51
  */
52
+ public function get_values( array $settings );
53
 
54
  /**
55
+ * Returns default value of field.
56
  *
57
+ * @param mixed[]|null $settings Plugin settings.
58
  *
59
+ * @return string|string[]
60
  */
61
+ public function get_default_value( array $settings = null );
62
 
63
  /**
64
+ * Returns unavailable values for field.
65
  *
66
+ * @param mixed[] $settings Plugin settings.
67
  *
68
+ * @return string[]|null
69
  */
70
+ public function get_disabled_values( array $settings );
71
 
72
  /**
73
  * Returns default value of field when debugging.
74
  *
75
  * @param mixed[] $settings Plugin settings.
76
  *
77
+ * @return string|string[]
78
  */
79
  public function get_value_for_debug( array $settings );
80
  }
src/Settings/Option/OptionsAggregator.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Settings\Option;
4
+
5
+ /**
6
+ * .
7
+ */
8
+ class OptionsAggregator {
9
+
10
+ /**
11
+ * Objects of supported options.
12
+ *
13
+ * @var OptionInterface[]
14
+ */
15
+ private $options = [];
16
+
17
+ public function __construct() {
18
+ $this->set_option( new LoaderTypeOption() );
19
+ $this->set_option( new SupportedExtensionsOption() );
20
+ $this->set_option( new SupportedDirectoriesOption() );
21
+ $this->set_option( new ConversionMethodOption() );
22
+ $this->set_option( new OutputFormatsOption() );
23
+ $this->set_option( new ImagesQualityOption() );
24
+ $this->set_option( new ExtraFeaturesOption() );
25
+ }
26
+
27
+ /**
28
+ * @return OptionInterface[]
29
+ */
30
+ public function get_options(): array {
31
+ $options = apply_filters( 'webpc_settings_options', $this->options );
32
+
33
+ usort(
34
+ $options,
35
+ function ( OptionInterface $option_a, OptionInterface $option_b ) {
36
+ return $option_a->get_priority() <=> $option_b->get_priority();
37
+ }
38
+ );
39
+ return $options;
40
+ }
41
+
42
+ /**
43
+ * @param OptionInterface $new_option .
44
+ *
45
+ * @return void
46
+ */
47
+ private function set_option( OptionInterface $new_option ) {
48
+ foreach ( $this->options as $option_index => $option ) {
49
+ if ( $option->get_name() === $new_option->get_name() ) {
50
+ $this->options[ $option_index ] = $new_option;
51
+ return;
52
+ }
53
+ }
54
+
55
+ $this->options[] = $new_option;
56
+ }
57
+ }
src/Settings/Option/OutputFormatsOption.php CHANGED
@@ -6,11 +6,11 @@ use WebpConverter\Conversion\Format\FormatFactory;
6
  use WebpConverter\Conversion\Format\WebpFormat;
7
 
8
  /**
9
- * Handles data about "Supported output formats" field in plugin settings.
10
  */
11
  class OutputFormatsOption extends OptionAbstract {
12
 
13
- const LOADER_TYPE = 'output_formats';
14
 
15
  /**
16
  * Object of integration class supports all conversion methods.
@@ -23,11 +23,18 @@ class OutputFormatsOption extends OptionAbstract {
23
  $this->formats_integration = new FormatFactory();
24
  }
25
 
 
 
 
 
 
 
 
26
  /**
27
  * {@inheritdoc}
28
  */
29
  public function get_name(): string {
30
- return self::LOADER_TYPE;
31
  }
32
 
33
  /**
@@ -46,6 +53,8 @@ class OutputFormatsOption extends OptionAbstract {
46
 
47
  /**
48
  * {@inheritdoc}
 
 
49
  */
50
  public function get_values( array $settings ): array {
51
  return $this->formats_integration->get_formats();
@@ -59,7 +68,7 @@ class OutputFormatsOption extends OptionAbstract {
59
  * @return string[] Default value of field.
60
  */
61
  public function get_default_value( array $settings = null ): array {
62
- $method = $settings['method'] ?? ( new ConversionMethodOption() )->get_default_value();
63
  $formats = array_keys( $this->formats_integration->get_available_formats( $method ) );
64
 
65
  return ( in_array( WebpFormat::FORMAT_EXTENSION, $formats ) ) ? [ WebpFormat::FORMAT_EXTENSION ] : [];
@@ -67,9 +76,11 @@ class OutputFormatsOption extends OptionAbstract {
67
 
68
  /**
69
  * {@inheritdoc}
 
 
70
  */
71
  public function get_disabled_values( array $settings ): array {
72
- $method = $settings['method'] ?? ( new ConversionMethodOption() )->get_default_value();
73
  $formats = $this->formats_integration->get_formats();
74
  $formats_available = $this->formats_integration->get_available_formats( $method );
75
  return array_keys( array_diff( $formats, $formats_available ) );
6
  use WebpConverter\Conversion\Format\WebpFormat;
7
 
8
  /**
9
+ * {@inheritdoc}
10
  */
11
  class OutputFormatsOption extends OptionAbstract {
12
 
13
+ const OPTION_NAME = 'output_formats';
14
 
15
  /**
16
  * Object of integration class supports all conversion methods.
23
  $this->formats_integration = new FormatFactory();
24
  }
25
 
26
+ /**
27
+ * {@inheritdoc}
28
+ */
29
+ public function get_priority(): int {
30
+ return 50;
31
+ }
32
+
33
  /**
34
  * {@inheritdoc}
35
  */
36
  public function get_name(): string {
37
+ return self::OPTION_NAME;
38
  }
39
 
40
  /**
53
 
54
  /**
55
  * {@inheritdoc}
56
+ *
57
+ * @return string[]
58
  */
59
  public function get_values( array $settings ): array {
60
  return $this->formats_integration->get_formats();
68
  * @return string[] Default value of field.
69
  */
70
  public function get_default_value( array $settings = null ): array {
71
+ $method = $settings[ ConversionMethodOption::OPTION_NAME ] ?? ( new ConversionMethodOption() )->get_default_value();
72
  $formats = array_keys( $this->formats_integration->get_available_formats( $method ) );
73
 
74
  return ( in_array( WebpFormat::FORMAT_EXTENSION, $formats ) ) ? [ WebpFormat::FORMAT_EXTENSION ] : [];
76
 
77
  /**
78
  * {@inheritdoc}
79
+ *
80
+ * @return string[]
81
  */
82
  public function get_disabled_values( array $settings ): array {
83
+ $method = $settings[ ConversionMethodOption::OPTION_NAME ] ?? ( new ConversionMethodOption() )->get_default_value();
84
  $formats = $this->formats_integration->get_formats();
85
  $formats_available = $this->formats_integration->get_available_formats( $method );
86
  return array_keys( array_diff( $formats, $formats_available ) );
src/Settings/Option/SupportedDirectoriesOption.php CHANGED
@@ -5,17 +5,24 @@ namespace WebpConverter\Settings\Option;
5
  use WebpConverter\Conversion\Directory\DirectoryFactory;
6
 
7
  /**
8
- * Handles data about "Supported directories" field in plugin settings.
9
  */
10
  class SupportedDirectoriesOption extends OptionAbstract {
11
 
12
- const LOADER_TYPE = 'dirs';
 
 
 
 
 
 
 
13
 
14
  /**
15
  * {@inheritdoc}
16
  */
17
  public function get_name(): string {
18
- return self::LOADER_TYPE;
19
  }
20
 
21
  /**
@@ -41,6 +48,8 @@ class SupportedDirectoriesOption extends OptionAbstract {
41
 
42
  /**
43
  * {@inheritdoc}
 
 
44
  */
45
  public function get_values( array $settings ): array {
46
  return ( new DirectoryFactory() )->get_directories();
5
  use WebpConverter\Conversion\Directory\DirectoryFactory;
6
 
7
  /**
8
+ * {@inheritdoc}
9
  */
10
  class SupportedDirectoriesOption extends OptionAbstract {
11
 
12
+ const OPTION_NAME = 'dirs';
13
+
14
+ /**
15
+ * {@inheritdoc}
16
+ */
17
+ public function get_priority(): int {
18
+ return 30;
19
+ }
20
 
21
  /**
22
  * {@inheritdoc}
23
  */
24
  public function get_name(): string {
25
+ return self::OPTION_NAME;
26
  }
27
 
28
  /**
48
 
49
  /**
50
  * {@inheritdoc}
51
+ *
52
+ * @return string[]
53
  */
54
  public function get_values( array $settings ): array {
55
  return ( new DirectoryFactory() )->get_directories();
src/Settings/Option/SupportedExtensionsOption.php CHANGED
@@ -3,17 +3,24 @@
3
  namespace WebpConverter\Settings\Option;
4
 
5
  /**
6
- * Handles data about "Supported files extensions" field in plugin settings.
7
  */
8
  class SupportedExtensionsOption extends OptionAbstract {
9
 
10
- const LOADER_TYPE = 'extensions';
 
 
 
 
 
 
 
11
 
12
  /**
13
  * {@inheritdoc}
14
  */
15
  public function get_name(): string {
16
- return self::LOADER_TYPE;
17
  }
18
 
19
  /**
@@ -32,6 +39,8 @@ class SupportedExtensionsOption extends OptionAbstract {
32
 
33
  /**
34
  * {@inheritdoc}
 
 
35
  */
36
  public function get_values( array $settings ): array {
37
  return [
3
  namespace WebpConverter\Settings\Option;
4
 
5
  /**
6
+ * {@inheritdoc}
7
  */
8
  class SupportedExtensionsOption extends OptionAbstract {
9
 
10
+ const OPTION_NAME = 'extensions';
11
+
12
+ /**
13
+ * {@inheritdoc}
14
+ */
15
+ public function get_priority(): int {
16
+ return 20;
17
+ }
18
 
19
  /**
20
  * {@inheritdoc}
21
  */
22
  public function get_name(): string {
23
+ return self::OPTION_NAME;
24
  }
25
 
26
  /**
39
 
40
  /**
41
  * {@inheritdoc}
42
+ *
43
+ * @return string[]
44
  */
45
  public function get_values( array $settings ): array {
46
  return [
src/Settings/Page/DebugPage.php CHANGED
@@ -7,6 +7,8 @@ use WebpConverter\Error\Detector\RewritesErrorsDetector;
7
  use WebpConverter\Helper\FileLoader;
8
  use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Loader\LoaderAbstract;
 
 
10
  use WebpConverter\Settings\SettingsSave;
11
 
12
  /**
@@ -16,6 +18,21 @@ class DebugPage extends PageAbstract {
16
 
17
  const PAGE_VIEW_PATH = 'views/settings-debug.php';
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  /**
20
  * {@inheritdoc}
21
  */
@@ -33,7 +50,7 @@ class DebugPage extends PageAbstract {
33
 
34
  do_action( LoaderAbstract::ACTION_NAME, true, true );
35
 
36
- ViewLoader::load_view(
37
  self::PAGE_VIEW_PATH,
38
  [
39
  'settings_url' => sprintf(
@@ -46,33 +63,29 @@ class DebugPage extends PageAbstract {
46
  '%s&action=server',
47
  PageIntegration::get_settings_page_url()
48
  ),
49
- 'size_png_path' => FileLoader::get_file_size_by_path(
50
  $uploads_path . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG
51
  ),
52
- 'size_png2_path' => FileLoader::get_file_size_by_path(
53
  $uploads_path . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG2
54
  ),
55
- 'size_png_url' => FileLoader::get_file_size_by_url(
56
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG,
57
- $this->plugin_data,
58
  false,
59
  $ver_param
60
  ),
61
- 'size_png2_url' => FileLoader::get_file_size_by_url(
62
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG2,
63
- $this->plugin_data,
64
  false,
65
  $ver_param
66
  ),
67
- 'size_png_as_webp_url' => FileLoader::get_file_size_by_url(
68
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG,
69
- $this->plugin_data,
70
  true,
71
  $ver_param
72
  ),
73
- 'size_png2_as_webp_url' => FileLoader::get_file_size_by_url(
74
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG2,
75
- $this->plugin_data,
76
  true,
77
  $ver_param
78
  ),
7
  use WebpConverter\Helper\FileLoader;
8
  use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Loader\LoaderAbstract;
10
+ use WebpConverter\PluginData;
11
+ use WebpConverter\PluginInfo;
12
  use WebpConverter\Settings\SettingsSave;
13
 
14
  /**
18
 
19
  const PAGE_VIEW_PATH = 'views/settings-debug.php';
20
 
21
+ /**
22
+ * @var PluginInfo
23
+ */
24
+ private $plugin_info;
25
+
26
+ /**
27
+ * @var FileLoader
28
+ */
29
+ private $file_loader;
30
+
31
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data, FileLoader $file_loader = null ) {
32
+ $this->plugin_info = $plugin_info;
33
+ $this->file_loader = $file_loader ?: new FileLoader( $plugin_info, $plugin_data );
34
+ }
35
+
36
  /**
37
  * {@inheritdoc}
38
  */
50
 
51
  do_action( LoaderAbstract::ACTION_NAME, true, true );
52
 
53
+ ( new ViewLoader( $this->plugin_info ) )->load_view(
54
  self::PAGE_VIEW_PATH,
55
  [
56
  'settings_url' => sprintf(
63
  '%s&action=server',
64
  PageIntegration::get_settings_page_url()
65
  ),
66
+ 'size_png_path' => $this->file_loader->get_file_size_by_path(
67
  $uploads_path . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG
68
  ),
69
+ 'size_png2_path' => $this->file_loader->get_file_size_by_path(
70
  $uploads_path . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG2
71
  ),
72
+ 'size_png_url' => $this->file_loader->get_file_size_by_url(
73
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG,
 
74
  false,
75
  $ver_param
76
  ),
77
+ 'size_png2_url' => $this->file_loader->get_file_size_by_url(
78
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG2,
 
79
  false,
80
  $ver_param
81
  ),
82
+ 'size_png_as_webp_url' => $this->file_loader->get_file_size_by_url(
83
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG,
 
84
  true,
85
  $ver_param
86
  ),
87
+ 'size_png2_as_webp_url' => $this->file_loader->get_file_size_by_url(
88
  $uploads_url . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG2,
 
89
  true,
90
  $ver_param
91
  ),
src/Settings/Page/PageAbstract.php CHANGED
@@ -2,25 +2,11 @@
2
 
3
  namespace WebpConverter\Settings\Page;
4
 
5
- use WebpConverter\PluginData;
6
-
7
  /**
8
  * Abstract class for class that supports tab in plugin settings page.
9
  */
10
  abstract class PageAbstract implements PageInterface {
11
 
12
- /**
13
- * @var PluginData .
14
- */
15
- protected $plugin_data;
16
-
17
- /**
18
- * @param PluginData $plugin_data .
19
- */
20
- public function __construct( PluginData $plugin_data ) {
21
- $this->plugin_data = $plugin_data;
22
- }
23
-
24
  /**
25
  * Returns status if view is active.
26
  *
2
 
3
  namespace WebpConverter\Settings\Page;
4
 
 
 
5
  /**
6
  * Abstract class for class that supports tab in plugin settings page.
7
  */
8
  abstract class PageAbstract implements PageInterface {
9
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  /**
11
  * Returns status if view is active.
12
  *
src/Settings/Page/PageIntegration.php CHANGED
@@ -5,6 +5,7 @@ namespace WebpConverter\Settings\Page;
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Notice\NoticeIntegration;
7
  use WebpConverter\Notice\WelcomeNotice;
 
8
  use WebpConverter\Settings\AdminAssets;
9
 
10
  /**
@@ -14,6 +15,15 @@ class PageIntegration implements HookableInterface {
14
 
15
  const ADMIN_MENU_PAGE = 'webpc_admin_page';
16
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Objects of supported plugin settings pages.
19
  *
@@ -131,7 +141,7 @@ class PageIntegration implements HookableInterface {
131
  * @internal
132
  */
133
  public function load_scripts_for_page() {
134
- ( new NoticeIntegration( new WelcomeNotice() ) )->set_disable_value();
135
- ( new AdminAssets() )->init_hooks();
136
  }
137
  }
5
  use WebpConverter\HookableInterface;
6
  use WebpConverter\Notice\NoticeIntegration;
7
  use WebpConverter\Notice\WelcomeNotice;
8
+ use WebpConverter\PluginInfo;
9
  use WebpConverter\Settings\AdminAssets;
10
 
11
  /**
15
 
16
  const ADMIN_MENU_PAGE = 'webpc_admin_page';
17
 
18
+ /**
19
+ * @var PluginInfo
20
+ */
21
+ private $plugin_info;
22
+
23
+ public function __construct( PluginInfo $plugin_info ) {
24
+ $this->plugin_info = $plugin_info;
25
+ }
26
+
27
  /**
28
  * Objects of supported plugin settings pages.
29
  *
141
  * @internal
142
  */
143
  public function load_scripts_for_page() {
144
+ ( new NoticeIntegration( $this->plugin_info, new WelcomeNotice() ) )->set_disable_value();
145
+ ( new AdminAssets( $this->plugin_info ) )->init_hooks();
146
  }
147
  }
src/Settings/Page/SettingsPage.php CHANGED
@@ -7,7 +7,9 @@ use WebpConverter\Conversion\Endpoint\PathsEndpoint;
7
  use WebpConverter\Conversion\Endpoint\RegenerateEndpoint;
8
  use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Loader\LoaderAbstract;
10
- use WebpConverter\Settings\Option\OptionFactory;
 
 
11
  use WebpConverter\Settings\SettingsSave;
12
 
13
  /**
@@ -17,6 +19,21 @@ class SettingsPage extends PageAbstract {
17
 
18
  const PAGE_VIEW_PATH = 'views/settings.php';
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * {@inheritdoc}
22
  */
@@ -30,12 +47,12 @@ class SettingsPage extends PageAbstract {
30
  public function show_page_view() {
31
  ( new SettingsSave( $this->plugin_data ) )->save_settings();
32
 
33
- ViewLoader::load_view(
34
  self::PAGE_VIEW_PATH,
35
  [
36
  'errors_messages' => apply_filters( 'webpc_server_errors_messages', [] ),
37
  'errors_codes' => apply_filters( 'webpc_server_errors', [] ),
38
- 'options' => ( new OptionFactory() )->get_options(),
39
  'submit_value' => SettingsSave::SUBMIT_VALUE,
40
  'settings_url' => sprintf(
41
  '%1$s&%2$s=%3$s',
7
  use WebpConverter\Conversion\Endpoint\RegenerateEndpoint;
8
  use WebpConverter\Helper\ViewLoader;
9
  use WebpConverter\Loader\LoaderAbstract;
10
+ use WebpConverter\PluginData;
11
+ use WebpConverter\PluginInfo;
12
+ use WebpConverter\Settings\PluginOptions;
13
  use WebpConverter\Settings\SettingsSave;
14
 
15
  /**
19
 
20
  const PAGE_VIEW_PATH = 'views/settings.php';
21
 
22
+ /**
23
+ * @var PluginInfo
24
+ */
25
+ private $plugin_info;
26
+
27
+ /**
28
+ * @var PluginData
29
+ */
30
+ private $plugin_data;
31
+
32
+ public function __construct( PluginInfo $plugin_info, PluginData $plugin_data ) {
33
+ $this->plugin_info = $plugin_info;
34
+ $this->plugin_data = $plugin_data;
35
+ }
36
+
37
  /**
38
  * {@inheritdoc}
39
  */
47
  public function show_page_view() {
48
  ( new SettingsSave( $this->plugin_data ) )->save_settings();
49
 
50
+ ( new ViewLoader( $this->plugin_info ) )->load_view(
51
  self::PAGE_VIEW_PATH,
52
  [
53
  'errors_messages' => apply_filters( 'webpc_server_errors_messages', [] ),
54
  'errors_codes' => apply_filters( 'webpc_server_errors', [] ),
55
+ 'options' => ( new PluginOptions() )->get_options(),
56
  'submit_value' => SettingsSave::SUBMIT_VALUE,
57
  'settings_url' => sprintf(
58
  '%1$s&%2$s=%3$s',
src/Settings/{Option/OptionFactory.php → PluginOptions.php} RENAMED
@@ -1,41 +1,23 @@
1
  <?php
2
 
3
- namespace WebpConverter\Settings\Option;
4
 
5
  use WebpConverter\Helper\OptionsAccess;
6
- use WebpConverter\Settings\SettingsSave;
 
7
 
8
  /**
9
  * Allows to integration with plugin settings by providing list of settings fields and saved values.
10
  */
11
- class OptionFactory {
12
 
13
  /**
14
- * Objects of supported options.
15
- *
16
- * @var OptionInterface[]
17
  */
18
- private $options = [];
19
 
20
  public function __construct() {
21
- $this->set_integration( new LoaderTypeOption() );
22
- $this->set_integration( new SupportedExtensionsOption() );
23
- $this->set_integration( new SupportedDirectoriesOption() );
24
- $this->set_integration( new ConversionMethodOption() );
25
- $this->set_integration( new OutputFormatsOption() );
26
- $this->set_integration( new ImagesQualityOption() );
27
- $this->set_integration( new ExtraFeaturesOption() );
28
- }
29
-
30
- /**
31
- * Sets integration for option.
32
- *
33
- * @param OptionInterface $option .
34
- *
35
- * @return void
36
- */
37
- private function set_integration( OptionInterface $option ) {
38
- $this->options[] = $option;
39
  }
40
 
41
  /**
@@ -51,7 +33,7 @@ class OptionFactory {
51
  $settings = ( $is_save ) ? $posted_settings : OptionsAccess::get_option( SettingsSave::SETTINGS_OPTION, [] );
52
 
53
  $options = [];
54
- foreach ( $this->options as $option_object ) {
55
  $options[] = ( new OptionIntegration( $option_object ) )->get_option_data( $settings, $is_debug, $is_save );
56
  }
57
  return $options;
1
  <?php
2
 
3
+ namespace WebpConverter\Settings;
4
 
5
  use WebpConverter\Helper\OptionsAccess;
6
+ use WebpConverter\Settings\Option\OptionIntegration;
7
+ use WebpConverter\Settings\Option\OptionsAggregator;
8
 
9
  /**
10
  * Allows to integration with plugin settings by providing list of settings fields and saved values.
11
  */
12
+ class PluginOptions {
13
 
14
  /**
15
+ * @var OptionsAggregator
 
 
16
  */
17
+ private $options_aggregator;
18
 
19
  public function __construct() {
20
+ $this->options_aggregator = new OptionsAggregator();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  /**
33
  $settings = ( $is_save ) ? $posted_settings : OptionsAccess::get_option( SettingsSave::SETTINGS_OPTION, [] );
34
 
35
  $options = [];
36
+ foreach ( $this->options_aggregator->get_options() as $option_object ) {
37
  $options[] = ( new OptionIntegration( $option_object ) )->get_option_data( $settings, $is_debug, $is_save );
38
  }
39
  return $options;
src/Settings/SettingsSave.php CHANGED
@@ -7,7 +7,7 @@ use WebpConverter\Conversion\Directory\DirectoryFactory;
7
  use WebpConverter\Helper\OptionsAccess;
8
  use WebpConverter\Loader\LoaderAbstract;
9
  use WebpConverter\PluginData;
10
- use WebpConverter\Settings\Option\OptionFactory;
11
 
12
  /**
13
  * Supports saving plugin settings on plugin settings page.
@@ -15,13 +15,10 @@ use WebpConverter\Settings\Option\OptionFactory;
15
  class SettingsSave {
16
 
17
  /**
18
- * @var PluginData .
19
  */
20
  private $plugin_data;
21
 
22
- /**
23
- * @param PluginData $plugin_data .
24
- */
25
  public function __construct( PluginData $plugin_data ) {
26
  $this->plugin_data = $plugin_data;
27
  }
@@ -43,7 +40,7 @@ class SettingsSave {
43
  return;
44
  }
45
 
46
- OptionsAccess::update_option( self::SETTINGS_OPTION, ( new OptionFactory() )->get_values( false, $_POST ) );
47
  $this->plugin_data->invalidate_plugin_settings();
48
  $this->init_actions_after_save();
49
  }
@@ -58,6 +55,6 @@ class SettingsSave {
58
  wp_clear_scheduled_hook( Event::CRON_ACTION );
59
 
60
  $settings = $this->plugin_data->get_plugin_settings();
61
- ( new DirectoryFactory() )->remove_unused_output_directories( $settings['dirs'] );
62
  }
63
  }
7
  use WebpConverter\Helper\OptionsAccess;
8
  use WebpConverter\Loader\LoaderAbstract;
9
  use WebpConverter\PluginData;
10
+ use WebpConverter\Settings\Option\SupportedDirectoriesOption;
11
 
12
  /**
13
  * Supports saving plugin settings on plugin settings page.
15
  class SettingsSave {
16
 
17
  /**
18
+ * @var PluginData
19
  */
20
  private $plugin_data;
21
 
 
 
 
22
  public function __construct( PluginData $plugin_data ) {
23
  $this->plugin_data = $plugin_data;
24
  }
40
  return;
41
  }
42
 
43
+ OptionsAccess::update_option( self::SETTINGS_OPTION, ( new PluginOptions() )->get_values( false, $_POST ) );
44
  $this->plugin_data->invalidate_plugin_settings();
45
  $this->init_actions_after_save();
46
  }
55
  wp_clear_scheduled_hook( Event::CRON_ACTION );
56
 
57
  $settings = $this->plugin_data->get_plugin_settings();
58
+ ( new DirectoryFactory() )->remove_unused_output_directories( $settings[ SupportedDirectoriesOption::OPTION_NAME ] );
59
  }
60
  }
src/WebpConverter.php CHANGED
@@ -17,7 +17,7 @@ use WebpConverter\Settings\Page;
17
  */
18
  class WebpConverter {
19
 
20
- public function __construct() {
21
  $plugin_data = new PluginData();
22
 
23
  ( new Action\ConvertAttachment( $plugin_data ) )->init_hooks();
@@ -29,25 +29,26 @@ class WebpConverter {
29
  ( new Conversion\DirectoryFiles( $plugin_data ) )->init_hooks();
30
  ( new Endpoint\EndpointIntegration( new Endpoint\PathsEndpoint( $plugin_data ) ) )->init_hooks();
31
  ( new Endpoint\EndpointIntegration( new Endpoint\RegenerateEndpoint( $plugin_data ) ) )->init_hooks();
32
- ( new Conversion\SkipExists( $plugin_data ) )->init_hooks();
 
33
  ( new Conversion\SkipLarger( $plugin_data ) )->init_hooks();
34
  ( new Cron\Event( $plugin_data ) )->init_hooks();
35
  ( new Cron\Schedules() )->init_hooks();
36
- ( new ErrorDetectorAggregator( $plugin_data ) )->init_hooks();
37
- ( new Notice\NoticeFactory() )->init_hooks();
38
- ( new Loader\LoaderIntegration( new Loader\HtaccessLoader( $plugin_data ) ) )->init_hooks();
39
- ( new Loader\LoaderIntegration( new Loader\PassthruLoader( $plugin_data ) ) )->init_hooks();
40
  ( new Media\Delete() )->init_hooks();
41
  ( new Media\Upload( $plugin_data ) )->init_hooks();
42
- ( new Plugin\Activation() )->init_hooks();
43
- ( new Plugin\Deactivation() )->init_hooks();
44
- ( new Plugin\Deactivation\Modal( $plugin_data ) )->init_hooks();
45
- ( new Plugin\Links() )->init_hooks();
46
- ( new Plugin\Uninstall() )->init_hooks();
47
- ( new Plugin\Update() )->init_hooks();
48
- ( new Page\PageIntegration() )
49
- ->set_page_integration( new Page\SettingsPage( $plugin_data ) )
50
- ->set_page_integration( new Page\DebugPage( $plugin_data ) )
51
  ->init_hooks();
52
  }
53
  }
17
  */
18
  class WebpConverter {
19
 
20
+ public function __construct( PluginInfo $plugin_info ) {
21
  $plugin_data = new PluginData();
22
 
23
  ( new Action\ConvertAttachment( $plugin_data ) )->init_hooks();
29
  ( new Conversion\DirectoryFiles( $plugin_data ) )->init_hooks();
30
  ( new Endpoint\EndpointIntegration( new Endpoint\PathsEndpoint( $plugin_data ) ) )->init_hooks();
31
  ( new Endpoint\EndpointIntegration( new Endpoint\RegenerateEndpoint( $plugin_data ) ) )->init_hooks();
32
+ ( new Conversion\SkipConvertedPaths( $plugin_data ) )->init_hooks();
33
+ ( new Conversion\SkipExcludedPaths() )->init_hooks();
34
  ( new Conversion\SkipLarger( $plugin_data ) )->init_hooks();
35
  ( new Cron\Event( $plugin_data ) )->init_hooks();
36
  ( new Cron\Schedules() )->init_hooks();
37
+ ( new ErrorDetectorAggregator( $plugin_info, $plugin_data ) )->init_hooks();
38
+ ( new Notice\NoticeFactory( $plugin_info ) )->init_hooks();
39
+ ( new Loader\LoaderIntegration( new Loader\HtaccessLoader( $plugin_info, $plugin_data ) ) )->init_hooks();
40
+ ( new Loader\LoaderIntegration( new Loader\PassthruLoader( $plugin_info, $plugin_data ) ) )->init_hooks();
41
  ( new Media\Delete() )->init_hooks();
42
  ( new Media\Upload( $plugin_data ) )->init_hooks();
43
+ ( new Plugin\Activation( $plugin_info ) )->init_hooks();
44
+ ( new Plugin\Deactivation( $plugin_info ) )->init_hooks();
45
+ ( new Plugin\Deactivation\Modal( $plugin_info, $plugin_data ) )->init_hooks();
46
+ ( new Plugin\Links( $plugin_info ) )->init_hooks();
47
+ ( new Plugin\Uninstall( $plugin_info ) )->init_hooks();
48
+ ( new Plugin\Update( $plugin_info ) )->init_hooks();
49
+ ( new Page\PageIntegration( $plugin_info ) )
50
+ ->set_page_integration( new Page\SettingsPage( $plugin_info, $plugin_data ) )
51
+ ->set_page_integration( new Page\DebugPage( $plugin_info, $plugin_data ) )
52
  ->init_hooks();
53
  }
54
  }
templates/components/fields/checkbox.php CHANGED
@@ -21,9 +21,7 @@
21
  <?php echo ( in_array( $value, $option['disabled'] ) ) ? 'disabled' : ''; ?>
22
  <?php echo ( in_array( $value, $option['value'] ) ) ? 'checked' : ''; ?>
23
  >
24
- <label for="<?php echo esc_attr( $option['name'] . '-' . $value ); ?>"
25
- class="webpField__label">
26
- <?php echo wp_kses_post( $label ); ?>
27
- </label>
28
  </div>
29
  <?php endforeach; ?>
21
  <?php echo ( in_array( $value, $option['disabled'] ) ) ? 'disabled' : ''; ?>
22
  <?php echo ( in_array( $value, $option['value'] ) ) ? 'checked' : ''; ?>
23
  >
24
+ <label for="<?php echo esc_attr( $option['name'] . '-' . $value ); ?>"></label>
25
+ <span class="webpField__label"><?php echo wp_kses_post( $label ); ?></span>
 
 
26
  </div>
27
  <?php endforeach; ?>
templates/components/fields/input.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Text field displayed in plugin settings form.
4
+ *
5
+ * @var mixed[] $option Data of field.
6
+ * @var string $index Index of field.
7
+ * @package WebP Converter for Media
8
+ */
9
+
10
+ ?>
11
+ <?php if ( $option['info'] ) : ?>
12
+ <p><?php echo wp_kses_post( $option['info'] ); ?></p>
13
+ <?php endif; ?>
14
+ <div class="webpInput">
15
+ <input type="text"
16
+ name="<?php echo esc_attr( $option['name'] ); ?>"
17
+ value="<?php echo esc_attr( $option['value'] ); ?>"
18
+ id="<?php echo esc_attr( $option['name'] ); ?>"
19
+ class="webpInput__field"
20
+ >
21
+ </div>
templates/components/fields/radio.php CHANGED
@@ -21,9 +21,7 @@
21
  <?php echo ( in_array( $value, $option['disabled'] ) ) ? 'disabled' : ''; ?>
22
  <?php echo ( $value == $option['value'] ) ? 'checked' : ''; // phpcs:ignore ?>
23
  >
24
- <label for="<?php echo esc_attr( $option['name'] . '-' . $value ); ?>"
25
- class="webpField__label">
26
- <?php echo wp_kses_post( $label ); ?>
27
- </label>
28
  </div>
29
  <?php endforeach; ?>
21
  <?php echo ( in_array( $value, $option['disabled'] ) ) ? 'disabled' : ''; ?>
22
  <?php echo ( $value == $option['value'] ) ? 'checked' : ''; // phpcs:ignore ?>
23
  >
24
+ <label for="<?php echo esc_attr( $option['name'] . '-' . $value ); ?>"></label>
25
+ <span class="webpField__label"><?php echo wp_kses_post( $label ); ?></span>
 
 
26
  </div>
27
  <?php endforeach; ?>
templates/components/server/filters.php CHANGED
@@ -51,12 +51,5 @@
51
  <?php echo esc_html( apply_filters( 'webpc_uploads_prefix', '/' ) ); ?>
52
  </td>
53
  </tr>
54
- <tr>
55
- <tr>
56
- <td class="e">webpc_dir_excluded</td>
57
- <td class="v">
58
- <?php echo esc_html( implode( ' | ', apply_filters( 'webpc_dir_excluded', [] ) ) ); ?>
59
- </td>
60
- </tr>
61
  </tbody>
62
  </table>
51
  <?php echo esc_html( apply_filters( 'webpc_uploads_prefix', '/' ) ); ?>
52
  </td>
53
  </tr>
 
 
 
 
 
 
 
54
  </tbody>
55
  </table>
templates/components/widgets/regenerate.php CHANGED
@@ -7,9 +7,6 @@
7
  * @package WebP Converter for Media
8
  */
9
 
10
- /* translators: %s error message */
11
- $error_message = __( 'An unknown error occurred while converting the images: %s', 'webp-converter-for-media' );
12
-
13
  ?>
14
  <div class="webpPage__widget">
15
  <h3 class="webpPage__widgetTitle">
@@ -18,7 +15,7 @@ $error_message = __( 'An unknown error occurred while converting the images: %s'
18
  <div class="webpLoader webpContent"
19
  data-api-paths="<?php echo esc_url( $api_paths_url ); ?>"
20
  data-api-regenerate="<?php echo esc_url( $api_regenerate_url ); ?>"
21
- data-api-error-message="<?php echo esc_attr( $error_message ); ?>"
22
  >
23
  <div class="webpPage__widgetRow">
24
  <p>
@@ -89,12 +86,7 @@ $error_message = __( 'An unknown error occurred while converting the images: %s'
89
  <div class="webpLoader__errorsTitle">
90
  <?php echo esc_html( __( 'Additional informations about process:', 'webp-converter-for-media' ) ); ?>
91
  </div>
92
- <div class="webpLoader__errorsContent">
93
- <div class="webpLoader__errorsContentList"></div>
94
- <div class="webpLoader__errorsContentMessage" hidden>
95
- <?php echo wp_kses_post( __( 'An error occurred while connecting to REST API. Please try again.', 'webp-converter-for-media' ) ); ?>
96
- </div>
97
- </div>
98
  </div>
99
  </div>
100
  </div>
@@ -105,10 +97,10 @@ $error_message = __( 'An unknown error occurred while converting the images: %s'
105
  value="1"
106
  id="webpc-regenerate-force"
107
  class="webpField__input webpField__input--toggle">
108
- <label for="webpc-regenerate-force"
109
- class="webpField__label">
110
  <?php echo esc_html( __( 'Force convert all images again', 'webp-converter-for-media' ) ); ?>
111
- </label>
112
  </div>
113
  <button type="button"
114
  class="webpLoader__button webpButton webpButton--green"
7
  * @package WebP Converter for Media
8
  */
9
 
 
 
 
10
  ?>
11
  <div class="webpPage__widget">
12
  <h3 class="webpPage__widgetTitle">
15
  <div class="webpLoader webpContent"
16
  data-api-paths="<?php echo esc_url( $api_paths_url ); ?>"
17
  data-api-regenerate="<?php echo esc_url( $api_regenerate_url ); ?>"
18
+ data-api-error-message="<?php echo wp_kses_post( __( 'An error occurred while connecting to REST API. Please try again.', 'webp-converter-for-media' ) ); ?>"
19
  >
20
  <div class="webpPage__widgetRow">
21
  <p>
86
  <div class="webpLoader__errorsTitle">
87
  <?php echo esc_html( __( 'Additional informations about process:', 'webp-converter-for-media' ) ); ?>
88
  </div>
89
+ <div class="webpLoader__errorsContent"></div>
 
 
 
 
 
90
  </div>
91
  </div>
92
  </div>
97
  value="1"
98
  id="webpc-regenerate-force"
99
  class="webpField__input webpField__input--toggle">
100
+ <label for="webpc-regenerate-force"></label>
101
+ <span class="webpField__label">
102
  <?php echo esc_html( __( 'Force convert all images again', 'webp-converter-for-media' ) ); ?>
103
+ </span>
104
  </div>
105
  <button type="button"
106
  class="webpLoader__button webpButton webpButton--green"
templates/views/deactivation-modal.php CHANGED
@@ -2,10 +2,11 @@
2
  /**
3
  * Modal with poll displayed in list of plugins.
4
  *
5
- * @var string[] $errors List of errors detected by plugin.
6
- * @var mixed[] $reasons Reasons for plugin deactivation.
7
- * @var mixed[] $settings Plugin settings.
8
- * @var string $api_url URL of API for feedback request.
 
9
  * @package WebP Converter for Media
10
  */
11
 
@@ -29,10 +30,8 @@
29
  class="webpField__input webpField__input--radio"
30
  data-placeholder="<?php echo esc_attr( $reason['placeholder'] ); ?>"
31
  >
32
- <label for="webpc-option-<?php echo esc_attr( $index ); ?>"
33
- class="webpField__label">
34
- <?php echo esc_html( $reason['label'] ); ?>
35
- </label>
36
  </div>
37
  <?php endforeach; ?>
38
  </div>
@@ -56,7 +55,7 @@
56
  value='<?php echo json_encode( $settings ); ?>'
57
  >
58
  <input type="hidden" name="webpc_plugin_version"
59
- value="<?php echo esc_attr( WEBPC_VERSION ); ?>"
60
  >
61
  </form>
62
  </div>
2
  /**
3
  * Modal with poll displayed in list of plugins.
4
  *
5
+ * @var string[] $errors List of errors detected by plugin.
6
+ * @var mixed[] $reasons Reasons for plugin deactivation.
7
+ * @var mixed[] $settings Plugin settings.
8
+ * @var string $api_url URL of API for feedback request.
9
+ * @var string $plugin_version .
10
  * @package WebP Converter for Media
11
  */
12
 
30
  class="webpField__input webpField__input--radio"
31
  data-placeholder="<?php echo esc_attr( $reason['placeholder'] ); ?>"
32
  >
33
+ <label for="webpc-option-<?php echo esc_attr( $index ); ?>"></label>
34
+ <span class="webpField__label"><?php echo esc_html( $reason['label'] ); ?></span>
 
 
35
  </div>
36
  <?php endforeach; ?>
37
  </div>
55
  value='<?php echo json_encode( $settings ); ?>'
56
  >
57
  <input type="hidden" name="webpc_plugin_version"
58
+ value="<?php echo esc_attr( $plugin_version ); ?>"
59
  >
60
  </form>
61
  </div>
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit86c856d7af1950143b554dace890ec99::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit2030f27ad23da16097b04d49bce16e0c::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -52,12 +52,16 @@ return array(
52
  'WebpConverter\\Conversion\\Media\\Upload' => $baseDir . '/src/Conversion/Media/Upload.php',
53
  'WebpConverter\\Conversion\\Method\\GdMethod' => $baseDir . '/src/Conversion/Method/GdMethod.php',
54
  'WebpConverter\\Conversion\\Method\\ImagickMethod' => $baseDir . '/src/Conversion/Method/ImagickMethod.php',
 
 
55
  'WebpConverter\\Conversion\\Method\\MethodAbstract' => $baseDir . '/src/Conversion/Method/MethodAbstract.php',
56
  'WebpConverter\\Conversion\\Method\\MethodFactory' => $baseDir . '/src/Conversion/Method/MethodFactory.php',
57
  'WebpConverter\\Conversion\\Method\\MethodIntegrator' => $baseDir . '/src/Conversion/Method/MethodIntegrator.php',
58
  'WebpConverter\\Conversion\\Method\\MethodInterface' => $baseDir . '/src/Conversion/Method/MethodInterface.php',
59
  'WebpConverter\\Conversion\\OutputPath' => $baseDir . '/src/Conversion/OutputPath.php',
60
- 'WebpConverter\\Conversion\\SkipExists' => $baseDir . '/src/Conversion/SkipExists.php',
 
 
61
  'WebpConverter\\Conversion\\SkipLarger' => $baseDir . '/src/Conversion/SkipLarger.php',
62
  'WebpConverter\\Error\\Detector\\ErrorDetector' => $baseDir . '/src/Error/Detector/ErrorDetector.php',
63
  'WebpConverter\\Error\\Detector\\LibsNotInstalledDetector' => $baseDir . '/src/Error/Detector/LibsNotInstalledDetector.php',
@@ -100,6 +104,7 @@ return array(
100
  'WebpConverter\\Notice\\ThanksNotice' => $baseDir . '/src/Notice/ThanksNotice.php',
101
  'WebpConverter\\Notice\\WelcomeNotice' => $baseDir . '/src/Notice/WelcomeNotice.php',
102
  'WebpConverter\\PluginData' => $baseDir . '/src/PluginData.php',
 
103
  'WebpConverter\\Plugin\\Activation' => $baseDir . '/src/Plugin/Activation.php',
104
  'WebpConverter\\Plugin\\Activation\\DefaultSettings' => $baseDir . '/src/Plugin/Activation/DefaultSettings.php',
105
  'WebpConverter\\Plugin\\Activation\\RefreshLoader' => $baseDir . '/src/Plugin/Activation/RefreshLoader.php',
@@ -121,9 +126,9 @@ return array(
121
  'WebpConverter\\Settings\\Option\\ImagesQualityOption' => $baseDir . '/src/Settings/Option/ImagesQualityOption.php',
122
  'WebpConverter\\Settings\\Option\\LoaderTypeOption' => $baseDir . '/src/Settings/Option/LoaderTypeOption.php',
123
  'WebpConverter\\Settings\\Option\\OptionAbstract' => $baseDir . '/src/Settings/Option/OptionAbstract.php',
124
- 'WebpConverter\\Settings\\Option\\OptionFactory' => $baseDir . '/src/Settings/Option/OptionFactory.php',
125
  'WebpConverter\\Settings\\Option\\OptionIntegration' => $baseDir . '/src/Settings/Option/OptionIntegration.php',
126
  'WebpConverter\\Settings\\Option\\OptionInterface' => $baseDir . '/src/Settings/Option/OptionInterface.php',
 
127
  'WebpConverter\\Settings\\Option\\OutputFormatsOption' => $baseDir . '/src/Settings/Option/OutputFormatsOption.php',
128
  'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => $baseDir . '/src/Settings/Option/SupportedDirectoriesOption.php',
129
  'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => $baseDir . '/src/Settings/Option/SupportedExtensionsOption.php',
@@ -132,6 +137,7 @@ return array(
132
  'WebpConverter\\Settings\\Page\\PageIntegration' => $baseDir . '/src/Settings/Page/PageIntegration.php',
133
  'WebpConverter\\Settings\\Page\\PageInterface' => $baseDir . '/src/Settings/Page/PageInterface.php',
134
  'WebpConverter\\Settings\\Page\\SettingsPage' => $baseDir . '/src/Settings/Page/SettingsPage.php',
 
135
  'WebpConverter\\Settings\\SettingsSave' => $baseDir . '/src/Settings/SettingsSave.php',
136
  'WebpConverter\\WebpConverter' => $baseDir . '/src/WebpConverter.php',
137
  );
52
  'WebpConverter\\Conversion\\Media\\Upload' => $baseDir . '/src/Conversion/Media/Upload.php',
53
  'WebpConverter\\Conversion\\Method\\GdMethod' => $baseDir . '/src/Conversion/Method/GdMethod.php',
54
  'WebpConverter\\Conversion\\Method\\ImagickMethod' => $baseDir . '/src/Conversion/Method/ImagickMethod.php',
55
+ 'WebpConverter\\Conversion\\Method\\LibraryMethodAbstract' => $baseDir . '/src/Conversion/Method/LibraryMethodAbstract.php',
56
+ 'WebpConverter\\Conversion\\Method\\LibraryMethodInterface' => $baseDir . '/src/Conversion/Method/LibraryMethodInterface.php',
57
  'WebpConverter\\Conversion\\Method\\MethodAbstract' => $baseDir . '/src/Conversion/Method/MethodAbstract.php',
58
  'WebpConverter\\Conversion\\Method\\MethodFactory' => $baseDir . '/src/Conversion/Method/MethodFactory.php',
59
  'WebpConverter\\Conversion\\Method\\MethodIntegrator' => $baseDir . '/src/Conversion/Method/MethodIntegrator.php',
60
  'WebpConverter\\Conversion\\Method\\MethodInterface' => $baseDir . '/src/Conversion/Method/MethodInterface.php',
61
  'WebpConverter\\Conversion\\OutputPath' => $baseDir . '/src/Conversion/OutputPath.php',
62
+ 'WebpConverter\\Conversion\\PathsValidator' => $baseDir . '/src/Conversion/PathsValidator.php',
63
+ 'WebpConverter\\Conversion\\SkipConvertedPaths' => $baseDir . '/src/Conversion/SkipConvertedPaths.php',
64
+ 'WebpConverter\\Conversion\\SkipExcludedPaths' => $baseDir . '/src/Conversion/SkipExcludedPaths.php',
65
  'WebpConverter\\Conversion\\SkipLarger' => $baseDir . '/src/Conversion/SkipLarger.php',
66
  'WebpConverter\\Error\\Detector\\ErrorDetector' => $baseDir . '/src/Error/Detector/ErrorDetector.php',
67
  'WebpConverter\\Error\\Detector\\LibsNotInstalledDetector' => $baseDir . '/src/Error/Detector/LibsNotInstalledDetector.php',
104
  'WebpConverter\\Notice\\ThanksNotice' => $baseDir . '/src/Notice/ThanksNotice.php',
105
  'WebpConverter\\Notice\\WelcomeNotice' => $baseDir . '/src/Notice/WelcomeNotice.php',
106
  'WebpConverter\\PluginData' => $baseDir . '/src/PluginData.php',
107
+ 'WebpConverter\\PluginInfo' => $baseDir . '/src/PluginInfo.php',
108
  'WebpConverter\\Plugin\\Activation' => $baseDir . '/src/Plugin/Activation.php',
109
  'WebpConverter\\Plugin\\Activation\\DefaultSettings' => $baseDir . '/src/Plugin/Activation/DefaultSettings.php',
110
  'WebpConverter\\Plugin\\Activation\\RefreshLoader' => $baseDir . '/src/Plugin/Activation/RefreshLoader.php',
126
  'WebpConverter\\Settings\\Option\\ImagesQualityOption' => $baseDir . '/src/Settings/Option/ImagesQualityOption.php',
127
  'WebpConverter\\Settings\\Option\\LoaderTypeOption' => $baseDir . '/src/Settings/Option/LoaderTypeOption.php',
128
  'WebpConverter\\Settings\\Option\\OptionAbstract' => $baseDir . '/src/Settings/Option/OptionAbstract.php',
 
129
  'WebpConverter\\Settings\\Option\\OptionIntegration' => $baseDir . '/src/Settings/Option/OptionIntegration.php',
130
  'WebpConverter\\Settings\\Option\\OptionInterface' => $baseDir . '/src/Settings/Option/OptionInterface.php',
131
+ 'WebpConverter\\Settings\\Option\\OptionsAggregator' => $baseDir . '/src/Settings/Option/OptionsAggregator.php',
132
  'WebpConverter\\Settings\\Option\\OutputFormatsOption' => $baseDir . '/src/Settings/Option/OutputFormatsOption.php',
133
  'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => $baseDir . '/src/Settings/Option/SupportedDirectoriesOption.php',
134
  'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => $baseDir . '/src/Settings/Option/SupportedExtensionsOption.php',
137
  'WebpConverter\\Settings\\Page\\PageIntegration' => $baseDir . '/src/Settings/Page/PageIntegration.php',
138
  'WebpConverter\\Settings\\Page\\PageInterface' => $baseDir . '/src/Settings/Page/PageInterface.php',
139
  'WebpConverter\\Settings\\Page\\SettingsPage' => $baseDir . '/src/Settings/Page/SettingsPage.php',
140
+ 'WebpConverter\\Settings\\PluginOptions' => $baseDir . '/src/Settings/PluginOptions.php',
141
  'WebpConverter\\Settings\\SettingsSave' => $baseDir . '/src/Settings/SettingsSave.php',
142
  'WebpConverter\\WebpConverter' => $baseDir . '/src/WebpConverter.php',
143
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit86c856d7af1950143b554dace890ec99
6
  {
7
  private static $loader;
8
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit86c856d7af1950143b554dace890ec99
22
  return self::$loader;
23
  }
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit86c856d7af1950143b554dace890ec99', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit86c856d7af1950143b554dace890ec99', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require __DIR__ . '/autoload_static.php';
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInit86c856d7af1950143b554dace890ec99::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit2030f27ad23da16097b04d49bce16e0c
6
  {
7
  private static $loader;
8
 
22
  return self::$loader;
23
  }
24
 
25
+ spl_autoload_register(array('ComposerAutoloaderInit2030f27ad23da16097b04d49bce16e0c', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit2030f27ad23da16097b04d49bce16e0c', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require __DIR__ . '/autoload_static.php';
32
 
33
+ call_user_func(\Composer\Autoload\ComposerStaticInit2030f27ad23da16097b04d49bce16e0c::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit86c856d7af1950143b554dace890ec99
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
@@ -67,12 +67,16 @@ class ComposerStaticInit86c856d7af1950143b554dace890ec99
67
  'WebpConverter\\Conversion\\Media\\Upload' => __DIR__ . '/../..' . '/src/Conversion/Media/Upload.php',
68
  'WebpConverter\\Conversion\\Method\\GdMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/GdMethod.php',
69
  'WebpConverter\\Conversion\\Method\\ImagickMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/ImagickMethod.php',
 
 
70
  'WebpConverter\\Conversion\\Method\\MethodAbstract' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodAbstract.php',
71
  'WebpConverter\\Conversion\\Method\\MethodFactory' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodFactory.php',
72
  'WebpConverter\\Conversion\\Method\\MethodIntegrator' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodIntegrator.php',
73
  'WebpConverter\\Conversion\\Method\\MethodInterface' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodInterface.php',
74
  'WebpConverter\\Conversion\\OutputPath' => __DIR__ . '/../..' . '/src/Conversion/OutputPath.php',
75
- 'WebpConverter\\Conversion\\SkipExists' => __DIR__ . '/../..' . '/src/Conversion/SkipExists.php',
 
 
76
  'WebpConverter\\Conversion\\SkipLarger' => __DIR__ . '/../..' . '/src/Conversion/SkipLarger.php',
77
  'WebpConverter\\Error\\Detector\\ErrorDetector' => __DIR__ . '/../..' . '/src/Error/Detector/ErrorDetector.php',
78
  'WebpConverter\\Error\\Detector\\LibsNotInstalledDetector' => __DIR__ . '/../..' . '/src/Error/Detector/LibsNotInstalledDetector.php',
@@ -115,6 +119,7 @@ class ComposerStaticInit86c856d7af1950143b554dace890ec99
115
  'WebpConverter\\Notice\\ThanksNotice' => __DIR__ . '/../..' . '/src/Notice/ThanksNotice.php',
116
  'WebpConverter\\Notice\\WelcomeNotice' => __DIR__ . '/../..' . '/src/Notice/WelcomeNotice.php',
117
  'WebpConverter\\PluginData' => __DIR__ . '/../..' . '/src/PluginData.php',
 
118
  'WebpConverter\\Plugin\\Activation' => __DIR__ . '/../..' . '/src/Plugin/Activation.php',
119
  'WebpConverter\\Plugin\\Activation\\DefaultSettings' => __DIR__ . '/../..' . '/src/Plugin/Activation/DefaultSettings.php',
120
  'WebpConverter\\Plugin\\Activation\\RefreshLoader' => __DIR__ . '/../..' . '/src/Plugin/Activation/RefreshLoader.php',
@@ -136,9 +141,9 @@ class ComposerStaticInit86c856d7af1950143b554dace890ec99
136
  'WebpConverter\\Settings\\Option\\ImagesQualityOption' => __DIR__ . '/../..' . '/src/Settings/Option/ImagesQualityOption.php',
137
  'WebpConverter\\Settings\\Option\\LoaderTypeOption' => __DIR__ . '/../..' . '/src/Settings/Option/LoaderTypeOption.php',
138
  'WebpConverter\\Settings\\Option\\OptionAbstract' => __DIR__ . '/../..' . '/src/Settings/Option/OptionAbstract.php',
139
- 'WebpConverter\\Settings\\Option\\OptionFactory' => __DIR__ . '/../..' . '/src/Settings/Option/OptionFactory.php',
140
  'WebpConverter\\Settings\\Option\\OptionIntegration' => __DIR__ . '/../..' . '/src/Settings/Option/OptionIntegration.php',
141
  'WebpConverter\\Settings\\Option\\OptionInterface' => __DIR__ . '/../..' . '/src/Settings/Option/OptionInterface.php',
 
142
  'WebpConverter\\Settings\\Option\\OutputFormatsOption' => __DIR__ . '/../..' . '/src/Settings/Option/OutputFormatsOption.php',
143
  'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedDirectoriesOption.php',
144
  'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedExtensionsOption.php',
@@ -147,6 +152,7 @@ class ComposerStaticInit86c856d7af1950143b554dace890ec99
147
  'WebpConverter\\Settings\\Page\\PageIntegration' => __DIR__ . '/../..' . '/src/Settings/Page/PageIntegration.php',
148
  'WebpConverter\\Settings\\Page\\PageInterface' => __DIR__ . '/../..' . '/src/Settings/Page/PageInterface.php',
149
  'WebpConverter\\Settings\\Page\\SettingsPage' => __DIR__ . '/../..' . '/src/Settings/Page/SettingsPage.php',
 
150
  'WebpConverter\\Settings\\SettingsSave' => __DIR__ . '/../..' . '/src/Settings/SettingsSave.php',
151
  'WebpConverter\\WebpConverter' => __DIR__ . '/../..' . '/src/WebpConverter.php',
152
  );
@@ -154,9 +160,9 @@ class ComposerStaticInit86c856d7af1950143b554dace890ec99
154
  public static function getInitializer(ClassLoader $loader)
155
  {
156
  return \Closure::bind(function () use ($loader) {
157
- $loader->prefixLengthsPsr4 = ComposerStaticInit86c856d7af1950143b554dace890ec99::$prefixLengthsPsr4;
158
- $loader->prefixDirsPsr4 = ComposerStaticInit86c856d7af1950143b554dace890ec99::$prefixDirsPsr4;
159
- $loader->classMap = ComposerStaticInit86c856d7af1950143b554dace890ec99::$classMap;
160
 
161
  }, null, ClassLoader::class);
162
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit2030f27ad23da16097b04d49bce16e0c
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'W' =>
67
  'WebpConverter\\Conversion\\Media\\Upload' => __DIR__ . '/../..' . '/src/Conversion/Media/Upload.php',
68
  'WebpConverter\\Conversion\\Method\\GdMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/GdMethod.php',
69
  'WebpConverter\\Conversion\\Method\\ImagickMethod' => __DIR__ . '/../..' . '/src/Conversion/Method/ImagickMethod.php',
70
+ 'WebpConverter\\Conversion\\Method\\LibraryMethodAbstract' => __DIR__ . '/../..' . '/src/Conversion/Method/LibraryMethodAbstract.php',
71
+ 'WebpConverter\\Conversion\\Method\\LibraryMethodInterface' => __DIR__ . '/../..' . '/src/Conversion/Method/LibraryMethodInterface.php',
72
  'WebpConverter\\Conversion\\Method\\MethodAbstract' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodAbstract.php',
73
  'WebpConverter\\Conversion\\Method\\MethodFactory' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodFactory.php',
74
  'WebpConverter\\Conversion\\Method\\MethodIntegrator' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodIntegrator.php',
75
  'WebpConverter\\Conversion\\Method\\MethodInterface' => __DIR__ . '/../..' . '/src/Conversion/Method/MethodInterface.php',
76
  'WebpConverter\\Conversion\\OutputPath' => __DIR__ . '/../..' . '/src/Conversion/OutputPath.php',
77
+ 'WebpConverter\\Conversion\\PathsValidator' => __DIR__ . '/../..' . '/src/Conversion/PathsValidator.php',
78
+ 'WebpConverter\\Conversion\\SkipConvertedPaths' => __DIR__ . '/../..' . '/src/Conversion/SkipConvertedPaths.php',
79
+ 'WebpConverter\\Conversion\\SkipExcludedPaths' => __DIR__ . '/../..' . '/src/Conversion/SkipExcludedPaths.php',
80
  'WebpConverter\\Conversion\\SkipLarger' => __DIR__ . '/../..' . '/src/Conversion/SkipLarger.php',
81
  'WebpConverter\\Error\\Detector\\ErrorDetector' => __DIR__ . '/../..' . '/src/Error/Detector/ErrorDetector.php',
82
  'WebpConverter\\Error\\Detector\\LibsNotInstalledDetector' => __DIR__ . '/../..' . '/src/Error/Detector/LibsNotInstalledDetector.php',
119
  'WebpConverter\\Notice\\ThanksNotice' => __DIR__ . '/../..' . '/src/Notice/ThanksNotice.php',
120
  'WebpConverter\\Notice\\WelcomeNotice' => __DIR__ . '/../..' . '/src/Notice/WelcomeNotice.php',
121
  'WebpConverter\\PluginData' => __DIR__ . '/../..' . '/src/PluginData.php',
122
+ 'WebpConverter\\PluginInfo' => __DIR__ . '/../..' . '/src/PluginInfo.php',
123
  'WebpConverter\\Plugin\\Activation' => __DIR__ . '/../..' . '/src/Plugin/Activation.php',
124
  'WebpConverter\\Plugin\\Activation\\DefaultSettings' => __DIR__ . '/../..' . '/src/Plugin/Activation/DefaultSettings.php',
125
  'WebpConverter\\Plugin\\Activation\\RefreshLoader' => __DIR__ . '/../..' . '/src/Plugin/Activation/RefreshLoader.php',
141
  'WebpConverter\\Settings\\Option\\ImagesQualityOption' => __DIR__ . '/../..' . '/src/Settings/Option/ImagesQualityOption.php',
142
  'WebpConverter\\Settings\\Option\\LoaderTypeOption' => __DIR__ . '/../..' . '/src/Settings/Option/LoaderTypeOption.php',
143
  'WebpConverter\\Settings\\Option\\OptionAbstract' => __DIR__ . '/../..' . '/src/Settings/Option/OptionAbstract.php',
 
144
  'WebpConverter\\Settings\\Option\\OptionIntegration' => __DIR__ . '/../..' . '/src/Settings/Option/OptionIntegration.php',
145
  'WebpConverter\\Settings\\Option\\OptionInterface' => __DIR__ . '/../..' . '/src/Settings/Option/OptionInterface.php',
146
+ 'WebpConverter\\Settings\\Option\\OptionsAggregator' => __DIR__ . '/../..' . '/src/Settings/Option/OptionsAggregator.php',
147
  'WebpConverter\\Settings\\Option\\OutputFormatsOption' => __DIR__ . '/../..' . '/src/Settings/Option/OutputFormatsOption.php',
148
  'WebpConverter\\Settings\\Option\\SupportedDirectoriesOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedDirectoriesOption.php',
149
  'WebpConverter\\Settings\\Option\\SupportedExtensionsOption' => __DIR__ . '/../..' . '/src/Settings/Option/SupportedExtensionsOption.php',
152
  'WebpConverter\\Settings\\Page\\PageIntegration' => __DIR__ . '/../..' . '/src/Settings/Page/PageIntegration.php',
153
  'WebpConverter\\Settings\\Page\\PageInterface' => __DIR__ . '/../..' . '/src/Settings/Page/PageInterface.php',
154
  'WebpConverter\\Settings\\Page\\SettingsPage' => __DIR__ . '/../..' . '/src/Settings/Page/SettingsPage.php',
155
+ 'WebpConverter\\Settings\\PluginOptions' => __DIR__ . '/../..' . '/src/Settings/PluginOptions.php',
156
  'WebpConverter\\Settings\\SettingsSave' => __DIR__ . '/../..' . '/src/Settings/SettingsSave.php',
157
  'WebpConverter\\WebpConverter' => __DIR__ . '/../..' . '/src/WebpConverter.php',
158
  );
160
  public static function getInitializer(ClassLoader $loader)
161
  {
162
  return \Closure::bind(function () use ($loader) {
163
+ $loader->prefixLengthsPsr4 = ComposerStaticInit2030f27ad23da16097b04d49bce16e0c::$prefixLengthsPsr4;
164
+ $loader->prefixDirsPsr4 = ComposerStaticInit2030f27ad23da16097b04d49bce16e0c::$prefixDirsPsr4;
165
+ $loader->classMap = ComposerStaticInit2030f27ad23da16097b04d49bce16e0c::$classMap;
166
 
167
  }, null, ClassLoader::class);
168
  }
vendor/composer/installed.php CHANGED
@@ -5,7 +5,7 @@
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => '225ac8c9ec65c9637b8bd91cda5eed293122804a',
9
  'name' => 'gbiorczyk/webp-converter-for-media',
10
  'dev' => false,
11
  ),
@@ -16,7 +16,7 @@
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
- 'reference' => '225ac8c9ec65c9637b8bd91cda5eed293122804a',
20
  'dev_requirement' => false,
21
  ),
22
  ),
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => '51d36d536f535bf80f12ec225a64c87b948b39a2',
9
  'name' => 'gbiorczyk/webp-converter-for-media',
10
  'dev' => false,
11
  ),
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
+ 'reference' => '51d36d536f535bf80f12ec225a64c87b948b39a2',
20
  'dev_requirement' => false,
21
  ),
22
  ),
webp-converter-for-media.php CHANGED
@@ -3,18 +3,15 @@
3
  /**
4
  * Plugin Name: WebP Converter for Media
5
  * Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
- * Version: 3.1.1
7
  * Author: Mateusz Gbiorczyk
8
  * Author URI: https://gbiorczyk.pl/
9
  * Text Domain: webp-converter-for-media
10
  * Network: true
11
  */
12
 
13
- define( 'WEBPC_VERSION', '3.1.1' );
14
- define( 'WEBPC_FILE', __FILE__ );
15
- define( 'WEBPC_NAME', plugin_basename( __FILE__ ) );
16
- define( 'WEBPC_PATH', plugin_dir_path( __FILE__ ) );
17
- define( 'WEBPC_URL', plugin_dir_url( __FILE__ ) );
18
-
19
  require_once __DIR__ . '/vendor/autoload.php';
20
- new WebpConverter\WebpConverter();
 
 
 
3
  /**
4
  * Plugin Name: WebP Converter for Media
5
  * Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
+ * Version: 3.2.0
7
  * Author: Mateusz Gbiorczyk
8
  * Author URI: https://gbiorczyk.pl/
9
  * Text Domain: webp-converter-for-media
10
  * Network: true
11
  */
12
 
 
 
 
 
 
 
13
  require_once __DIR__ . '/vendor/autoload.php';
14
+
15
+ new WebpConverter\WebpConverter(
16
+ new WebpConverter\PluginInfo( __FILE__, '3.2.0' )
17
+ );