├── .editorconfig
├── .gitignore
├── .travis.yml
├── codesniffer.ruleset.xml
├── composer.json
├── composer.lock
├── licence.txt
├── media
└── samurai.jpg
├── phpunit.xml.dist
├── readme-1.md
├── readme.md
├── src
├── Edge.php
├── Filters
│ ├── Page.php
│ └── Post.php
├── Helpers
│ ├── Config.php
│ └── Formatter.php
└── Start.php
└── tests
└── Katana
└── Helpers
├── ConfigTest.php
└── FormatterTest.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | root=true
2 |
3 | [*]
4 | charset=utf-8
5 | end_of_line=lf
6 | insert_final_newline=true
7 | trim_trailing_whitespace=true
8 |
9 | [*.php]
10 | indent_style=tab
11 | indent_size=4
12 |
13 | [*.yml]
14 | indent_style=space
15 | indent_size=2
16 |
17 | [*.md]
18 | trim_trailing_whitespace = false
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor/
2 | /node_modules
3 | .DS_Store
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | sudo: false
3 |
4 | php:
5 | - 5.5
6 | - 5.6
7 |
8 | before_script:
9 | - composer self-update -q
10 | - composer install
11 | - composer update -n
12 |
13 | cache:
14 | directories:
15 | - vendor
16 |
17 | script:
18 | - composer test && composer ci
19 |
--------------------------------------------------------------------------------
/codesniffer.ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Use "WordPress" as the sniffer context, with some exclusions.
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mitogh/katana",
3 | "description": "Filters to control where the size of images are generated.",
4 | "keywords": ["wordpress", "filter", "images"],
5 | "homepage": "https://github.com/mitogh/Katana",
6 | "type": "library",
7 | "licence": "MIT",
8 | "authors": [
9 | {
10 | "name": "Crisoforo Gaspar Hernandez",
11 | "email": "hello@crisoforo.com"
12 | }
13 | ],
14 | "require": {
15 | "php": ">=5.3.0"
16 | },
17 | "require-dev": {
18 | "squizlabs/php_codesniffer": "2.*",
19 | "wp-coding-standards/wpcs": "^0.9.0",
20 | "phpunit/phpunit": "~4.5"
21 | },
22 | "autoload": {
23 | "psr-4": {
24 | "Katana\\": "src/"
25 | }
26 | },
27 | "autoload-dev": {
28 | "psr-4": {
29 | "Katana\\": "src/"
30 | },
31 | "files": ["src/Start.php"]
32 | },
33 | "scripts": {
34 | "setup-ci": [
35 | "./vendor/bin/phpcs --config-set installed_paths vendor/wp-coding-standards/wpcs/",
36 | "./vendor/bin/phpcs --config-set default_standard ./codesniffer.ruleset.xml",
37 | "./vendor/bin/phpcs --config-set show_progress 0",
38 | "./vendor/bin/phpcs --config-set colors 1"
39 | ],
40 | "post-install-cmd": [ "@setup-ci"],
41 | "post-update-cmd": [ "@setup-ci"],
42 | "ci": [ "phpcs ./src/*.php ./src/*/*.php" ],
43 | "test": [ "phpunit" ]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "hash": "9c5c7ad779dd586cdfb09c79ad297716",
8 | "content-hash": "2643f5c63916f0fbcf4688da18d3e603",
9 | "packages": [],
10 | "packages-dev": [
11 | {
12 | "name": "doctrine/instantiator",
13 | "version": "1.0.5",
14 | "source": {
15 | "type": "git",
16 | "url": "https://github.com/doctrine/instantiator.git",
17 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
18 | },
19 | "dist": {
20 | "type": "zip",
21 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
22 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
23 | "shasum": ""
24 | },
25 | "require": {
26 | "php": ">=5.3,<8.0-DEV"
27 | },
28 | "require-dev": {
29 | "athletic/athletic": "~0.1.8",
30 | "ext-pdo": "*",
31 | "ext-phar": "*",
32 | "phpunit/phpunit": "~4.0",
33 | "squizlabs/php_codesniffer": "~2.0"
34 | },
35 | "type": "library",
36 | "extra": {
37 | "branch-alias": {
38 | "dev-master": "1.0.x-dev"
39 | }
40 | },
41 | "autoload": {
42 | "psr-4": {
43 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
44 | }
45 | },
46 | "notification-url": "https://packagist.org/downloads/",
47 | "license": [
48 | "MIT"
49 | ],
50 | "authors": [
51 | {
52 | "name": "Marco Pivetta",
53 | "email": "ocramius@gmail.com",
54 | "homepage": "http://ocramius.github.com/"
55 | }
56 | ],
57 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
58 | "homepage": "https://github.com/doctrine/instantiator",
59 | "keywords": [
60 | "constructor",
61 | "instantiate"
62 | ],
63 | "time": "2015-06-14 21:17:01"
64 | },
65 | {
66 | "name": "phpdocumentor/reflection-docblock",
67 | "version": "2.0.4",
68 | "source": {
69 | "type": "git",
70 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
71 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
72 | },
73 | "dist": {
74 | "type": "zip",
75 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
76 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
77 | "shasum": ""
78 | },
79 | "require": {
80 | "php": ">=5.3.3"
81 | },
82 | "require-dev": {
83 | "phpunit/phpunit": "~4.0"
84 | },
85 | "suggest": {
86 | "dflydev/markdown": "~1.0",
87 | "erusev/parsedown": "~1.0"
88 | },
89 | "type": "library",
90 | "extra": {
91 | "branch-alias": {
92 | "dev-master": "2.0.x-dev"
93 | }
94 | },
95 | "autoload": {
96 | "psr-0": {
97 | "phpDocumentor": [
98 | "src/"
99 | ]
100 | }
101 | },
102 | "notification-url": "https://packagist.org/downloads/",
103 | "license": [
104 | "MIT"
105 | ],
106 | "authors": [
107 | {
108 | "name": "Mike van Riel",
109 | "email": "mike.vanriel@naenius.com"
110 | }
111 | ],
112 | "time": "2015-02-03 12:10:50"
113 | },
114 | {
115 | "name": "phpspec/prophecy",
116 | "version": "v1.6.0",
117 | "source": {
118 | "type": "git",
119 | "url": "https://github.com/phpspec/prophecy.git",
120 | "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972"
121 | },
122 | "dist": {
123 | "type": "zip",
124 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972",
125 | "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972",
126 | "shasum": ""
127 | },
128 | "require": {
129 | "doctrine/instantiator": "^1.0.2",
130 | "php": "^5.3|^7.0",
131 | "phpdocumentor/reflection-docblock": "~2.0",
132 | "sebastian/comparator": "~1.1",
133 | "sebastian/recursion-context": "~1.0"
134 | },
135 | "require-dev": {
136 | "phpspec/phpspec": "~2.0"
137 | },
138 | "type": "library",
139 | "extra": {
140 | "branch-alias": {
141 | "dev-master": "1.5.x-dev"
142 | }
143 | },
144 | "autoload": {
145 | "psr-0": {
146 | "Prophecy\\": "src/"
147 | }
148 | },
149 | "notification-url": "https://packagist.org/downloads/",
150 | "license": [
151 | "MIT"
152 | ],
153 | "authors": [
154 | {
155 | "name": "Konstantin Kudryashov",
156 | "email": "ever.zet@gmail.com",
157 | "homepage": "http://everzet.com"
158 | },
159 | {
160 | "name": "Marcello Duarte",
161 | "email": "marcello.duarte@gmail.com"
162 | }
163 | ],
164 | "description": "Highly opinionated mocking framework for PHP 5.3+",
165 | "homepage": "https://github.com/phpspec/prophecy",
166 | "keywords": [
167 | "Double",
168 | "Dummy",
169 | "fake",
170 | "mock",
171 | "spy",
172 | "stub"
173 | ],
174 | "time": "2016-02-15 07:46:21"
175 | },
176 | {
177 | "name": "phpunit/php-code-coverage",
178 | "version": "2.2.4",
179 | "source": {
180 | "type": "git",
181 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
182 | "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
183 | },
184 | "dist": {
185 | "type": "zip",
186 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
187 | "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
188 | "shasum": ""
189 | },
190 | "require": {
191 | "php": ">=5.3.3",
192 | "phpunit/php-file-iterator": "~1.3",
193 | "phpunit/php-text-template": "~1.2",
194 | "phpunit/php-token-stream": "~1.3",
195 | "sebastian/environment": "^1.3.2",
196 | "sebastian/version": "~1.0"
197 | },
198 | "require-dev": {
199 | "ext-xdebug": ">=2.1.4",
200 | "phpunit/phpunit": "~4"
201 | },
202 | "suggest": {
203 | "ext-dom": "*",
204 | "ext-xdebug": ">=2.2.1",
205 | "ext-xmlwriter": "*"
206 | },
207 | "type": "library",
208 | "extra": {
209 | "branch-alias": {
210 | "dev-master": "2.2.x-dev"
211 | }
212 | },
213 | "autoload": {
214 | "classmap": [
215 | "src/"
216 | ]
217 | },
218 | "notification-url": "https://packagist.org/downloads/",
219 | "license": [
220 | "BSD-3-Clause"
221 | ],
222 | "authors": [
223 | {
224 | "name": "Sebastian Bergmann",
225 | "email": "sb@sebastian-bergmann.de",
226 | "role": "lead"
227 | }
228 | ],
229 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
230 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
231 | "keywords": [
232 | "coverage",
233 | "testing",
234 | "xunit"
235 | ],
236 | "time": "2015-10-06 15:47:00"
237 | },
238 | {
239 | "name": "phpunit/php-file-iterator",
240 | "version": "1.4.1",
241 | "source": {
242 | "type": "git",
243 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
244 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0"
245 | },
246 | "dist": {
247 | "type": "zip",
248 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
249 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
250 | "shasum": ""
251 | },
252 | "require": {
253 | "php": ">=5.3.3"
254 | },
255 | "type": "library",
256 | "extra": {
257 | "branch-alias": {
258 | "dev-master": "1.4.x-dev"
259 | }
260 | },
261 | "autoload": {
262 | "classmap": [
263 | "src/"
264 | ]
265 | },
266 | "notification-url": "https://packagist.org/downloads/",
267 | "license": [
268 | "BSD-3-Clause"
269 | ],
270 | "authors": [
271 | {
272 | "name": "Sebastian Bergmann",
273 | "email": "sb@sebastian-bergmann.de",
274 | "role": "lead"
275 | }
276 | ],
277 | "description": "FilterIterator implementation that filters files based on a list of suffixes.",
278 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
279 | "keywords": [
280 | "filesystem",
281 | "iterator"
282 | ],
283 | "time": "2015-06-21 13:08:43"
284 | },
285 | {
286 | "name": "phpunit/php-text-template",
287 | "version": "1.2.1",
288 | "source": {
289 | "type": "git",
290 | "url": "https://github.com/sebastianbergmann/php-text-template.git",
291 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
292 | },
293 | "dist": {
294 | "type": "zip",
295 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
296 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
297 | "shasum": ""
298 | },
299 | "require": {
300 | "php": ">=5.3.3"
301 | },
302 | "type": "library",
303 | "autoload": {
304 | "classmap": [
305 | "src/"
306 | ]
307 | },
308 | "notification-url": "https://packagist.org/downloads/",
309 | "license": [
310 | "BSD-3-Clause"
311 | ],
312 | "authors": [
313 | {
314 | "name": "Sebastian Bergmann",
315 | "email": "sebastian@phpunit.de",
316 | "role": "lead"
317 | }
318 | ],
319 | "description": "Simple template engine.",
320 | "homepage": "https://github.com/sebastianbergmann/php-text-template/",
321 | "keywords": [
322 | "template"
323 | ],
324 | "time": "2015-06-21 13:50:34"
325 | },
326 | {
327 | "name": "phpunit/php-timer",
328 | "version": "1.0.7",
329 | "source": {
330 | "type": "git",
331 | "url": "https://github.com/sebastianbergmann/php-timer.git",
332 | "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b"
333 | },
334 | "dist": {
335 | "type": "zip",
336 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
337 | "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
338 | "shasum": ""
339 | },
340 | "require": {
341 | "php": ">=5.3.3"
342 | },
343 | "type": "library",
344 | "autoload": {
345 | "classmap": [
346 | "src/"
347 | ]
348 | },
349 | "notification-url": "https://packagist.org/downloads/",
350 | "license": [
351 | "BSD-3-Clause"
352 | ],
353 | "authors": [
354 | {
355 | "name": "Sebastian Bergmann",
356 | "email": "sb@sebastian-bergmann.de",
357 | "role": "lead"
358 | }
359 | ],
360 | "description": "Utility class for timing",
361 | "homepage": "https://github.com/sebastianbergmann/php-timer/",
362 | "keywords": [
363 | "timer"
364 | ],
365 | "time": "2015-06-21 08:01:12"
366 | },
367 | {
368 | "name": "phpunit/php-token-stream",
369 | "version": "1.4.8",
370 | "source": {
371 | "type": "git",
372 | "url": "https://github.com/sebastianbergmann/php-token-stream.git",
373 | "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
374 | },
375 | "dist": {
376 | "type": "zip",
377 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
378 | "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
379 | "shasum": ""
380 | },
381 | "require": {
382 | "ext-tokenizer": "*",
383 | "php": ">=5.3.3"
384 | },
385 | "require-dev": {
386 | "phpunit/phpunit": "~4.2"
387 | },
388 | "type": "library",
389 | "extra": {
390 | "branch-alias": {
391 | "dev-master": "1.4-dev"
392 | }
393 | },
394 | "autoload": {
395 | "classmap": [
396 | "src/"
397 | ]
398 | },
399 | "notification-url": "https://packagist.org/downloads/",
400 | "license": [
401 | "BSD-3-Clause"
402 | ],
403 | "authors": [
404 | {
405 | "name": "Sebastian Bergmann",
406 | "email": "sebastian@phpunit.de"
407 | }
408 | ],
409 | "description": "Wrapper around PHP's tokenizer extension.",
410 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
411 | "keywords": [
412 | "tokenizer"
413 | ],
414 | "time": "2015-09-15 10:49:45"
415 | },
416 | {
417 | "name": "phpunit/phpunit",
418 | "version": "4.8.24",
419 | "source": {
420 | "type": "git",
421 | "url": "https://github.com/sebastianbergmann/phpunit.git",
422 | "reference": "a1066c562c52900a142a0e2bbf0582994671385e"
423 | },
424 | "dist": {
425 | "type": "zip",
426 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e",
427 | "reference": "a1066c562c52900a142a0e2bbf0582994671385e",
428 | "shasum": ""
429 | },
430 | "require": {
431 | "ext-dom": "*",
432 | "ext-json": "*",
433 | "ext-pcre": "*",
434 | "ext-reflection": "*",
435 | "ext-spl": "*",
436 | "php": ">=5.3.3",
437 | "phpspec/prophecy": "^1.3.1",
438 | "phpunit/php-code-coverage": "~2.1",
439 | "phpunit/php-file-iterator": "~1.4",
440 | "phpunit/php-text-template": "~1.2",
441 | "phpunit/php-timer": ">=1.0.6",
442 | "phpunit/phpunit-mock-objects": "~2.3",
443 | "sebastian/comparator": "~1.1",
444 | "sebastian/diff": "~1.2",
445 | "sebastian/environment": "~1.3",
446 | "sebastian/exporter": "~1.2",
447 | "sebastian/global-state": "~1.0",
448 | "sebastian/version": "~1.0",
449 | "symfony/yaml": "~2.1|~3.0"
450 | },
451 | "suggest": {
452 | "phpunit/php-invoker": "~1.1"
453 | },
454 | "bin": [
455 | "phpunit"
456 | ],
457 | "type": "library",
458 | "extra": {
459 | "branch-alias": {
460 | "dev-master": "4.8.x-dev"
461 | }
462 | },
463 | "autoload": {
464 | "classmap": [
465 | "src/"
466 | ]
467 | },
468 | "notification-url": "https://packagist.org/downloads/",
469 | "license": [
470 | "BSD-3-Clause"
471 | ],
472 | "authors": [
473 | {
474 | "name": "Sebastian Bergmann",
475 | "email": "sebastian@phpunit.de",
476 | "role": "lead"
477 | }
478 | ],
479 | "description": "The PHP Unit Testing framework.",
480 | "homepage": "https://phpunit.de/",
481 | "keywords": [
482 | "phpunit",
483 | "testing",
484 | "xunit"
485 | ],
486 | "time": "2016-03-14 06:16:08"
487 | },
488 | {
489 | "name": "phpunit/phpunit-mock-objects",
490 | "version": "2.3.8",
491 | "source": {
492 | "type": "git",
493 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
494 | "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
495 | },
496 | "dist": {
497 | "type": "zip",
498 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
499 | "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
500 | "shasum": ""
501 | },
502 | "require": {
503 | "doctrine/instantiator": "^1.0.2",
504 | "php": ">=5.3.3",
505 | "phpunit/php-text-template": "~1.2",
506 | "sebastian/exporter": "~1.2"
507 | },
508 | "require-dev": {
509 | "phpunit/phpunit": "~4.4"
510 | },
511 | "suggest": {
512 | "ext-soap": "*"
513 | },
514 | "type": "library",
515 | "extra": {
516 | "branch-alias": {
517 | "dev-master": "2.3.x-dev"
518 | }
519 | },
520 | "autoload": {
521 | "classmap": [
522 | "src/"
523 | ]
524 | },
525 | "notification-url": "https://packagist.org/downloads/",
526 | "license": [
527 | "BSD-3-Clause"
528 | ],
529 | "authors": [
530 | {
531 | "name": "Sebastian Bergmann",
532 | "email": "sb@sebastian-bergmann.de",
533 | "role": "lead"
534 | }
535 | ],
536 | "description": "Mock Object library for PHPUnit",
537 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
538 | "keywords": [
539 | "mock",
540 | "xunit"
541 | ],
542 | "time": "2015-10-02 06:51:40"
543 | },
544 | {
545 | "name": "sebastian/comparator",
546 | "version": "1.2.0",
547 | "source": {
548 | "type": "git",
549 | "url": "https://github.com/sebastianbergmann/comparator.git",
550 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22"
551 | },
552 | "dist": {
553 | "type": "zip",
554 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22",
555 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22",
556 | "shasum": ""
557 | },
558 | "require": {
559 | "php": ">=5.3.3",
560 | "sebastian/diff": "~1.2",
561 | "sebastian/exporter": "~1.2"
562 | },
563 | "require-dev": {
564 | "phpunit/phpunit": "~4.4"
565 | },
566 | "type": "library",
567 | "extra": {
568 | "branch-alias": {
569 | "dev-master": "1.2.x-dev"
570 | }
571 | },
572 | "autoload": {
573 | "classmap": [
574 | "src/"
575 | ]
576 | },
577 | "notification-url": "https://packagist.org/downloads/",
578 | "license": [
579 | "BSD-3-Clause"
580 | ],
581 | "authors": [
582 | {
583 | "name": "Jeff Welch",
584 | "email": "whatthejeff@gmail.com"
585 | },
586 | {
587 | "name": "Volker Dusch",
588 | "email": "github@wallbash.com"
589 | },
590 | {
591 | "name": "Bernhard Schussek",
592 | "email": "bschussek@2bepublished.at"
593 | },
594 | {
595 | "name": "Sebastian Bergmann",
596 | "email": "sebastian@phpunit.de"
597 | }
598 | ],
599 | "description": "Provides the functionality to compare PHP values for equality",
600 | "homepage": "http://www.github.com/sebastianbergmann/comparator",
601 | "keywords": [
602 | "comparator",
603 | "compare",
604 | "equality"
605 | ],
606 | "time": "2015-07-26 15:48:44"
607 | },
608 | {
609 | "name": "sebastian/diff",
610 | "version": "1.4.1",
611 | "source": {
612 | "type": "git",
613 | "url": "https://github.com/sebastianbergmann/diff.git",
614 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e"
615 | },
616 | "dist": {
617 | "type": "zip",
618 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e",
619 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e",
620 | "shasum": ""
621 | },
622 | "require": {
623 | "php": ">=5.3.3"
624 | },
625 | "require-dev": {
626 | "phpunit/phpunit": "~4.8"
627 | },
628 | "type": "library",
629 | "extra": {
630 | "branch-alias": {
631 | "dev-master": "1.4-dev"
632 | }
633 | },
634 | "autoload": {
635 | "classmap": [
636 | "src/"
637 | ]
638 | },
639 | "notification-url": "https://packagist.org/downloads/",
640 | "license": [
641 | "BSD-3-Clause"
642 | ],
643 | "authors": [
644 | {
645 | "name": "Kore Nordmann",
646 | "email": "mail@kore-nordmann.de"
647 | },
648 | {
649 | "name": "Sebastian Bergmann",
650 | "email": "sebastian@phpunit.de"
651 | }
652 | ],
653 | "description": "Diff implementation",
654 | "homepage": "https://github.com/sebastianbergmann/diff",
655 | "keywords": [
656 | "diff"
657 | ],
658 | "time": "2015-12-08 07:14:41"
659 | },
660 | {
661 | "name": "sebastian/environment",
662 | "version": "1.3.5",
663 | "source": {
664 | "type": "git",
665 | "url": "https://github.com/sebastianbergmann/environment.git",
666 | "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf"
667 | },
668 | "dist": {
669 | "type": "zip",
670 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
671 | "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
672 | "shasum": ""
673 | },
674 | "require": {
675 | "php": ">=5.3.3"
676 | },
677 | "require-dev": {
678 | "phpunit/phpunit": "~4.4"
679 | },
680 | "type": "library",
681 | "extra": {
682 | "branch-alias": {
683 | "dev-master": "1.3.x-dev"
684 | }
685 | },
686 | "autoload": {
687 | "classmap": [
688 | "src/"
689 | ]
690 | },
691 | "notification-url": "https://packagist.org/downloads/",
692 | "license": [
693 | "BSD-3-Clause"
694 | ],
695 | "authors": [
696 | {
697 | "name": "Sebastian Bergmann",
698 | "email": "sebastian@phpunit.de"
699 | }
700 | ],
701 | "description": "Provides functionality to handle HHVM/PHP environments",
702 | "homepage": "http://www.github.com/sebastianbergmann/environment",
703 | "keywords": [
704 | "Xdebug",
705 | "environment",
706 | "hhvm"
707 | ],
708 | "time": "2016-02-26 18:40:46"
709 | },
710 | {
711 | "name": "sebastian/exporter",
712 | "version": "1.2.1",
713 | "source": {
714 | "type": "git",
715 | "url": "https://github.com/sebastianbergmann/exporter.git",
716 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e"
717 | },
718 | "dist": {
719 | "type": "zip",
720 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e",
721 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e",
722 | "shasum": ""
723 | },
724 | "require": {
725 | "php": ">=5.3.3",
726 | "sebastian/recursion-context": "~1.0"
727 | },
728 | "require-dev": {
729 | "phpunit/phpunit": "~4.4"
730 | },
731 | "type": "library",
732 | "extra": {
733 | "branch-alias": {
734 | "dev-master": "1.2.x-dev"
735 | }
736 | },
737 | "autoload": {
738 | "classmap": [
739 | "src/"
740 | ]
741 | },
742 | "notification-url": "https://packagist.org/downloads/",
743 | "license": [
744 | "BSD-3-Clause"
745 | ],
746 | "authors": [
747 | {
748 | "name": "Jeff Welch",
749 | "email": "whatthejeff@gmail.com"
750 | },
751 | {
752 | "name": "Volker Dusch",
753 | "email": "github@wallbash.com"
754 | },
755 | {
756 | "name": "Bernhard Schussek",
757 | "email": "bschussek@2bepublished.at"
758 | },
759 | {
760 | "name": "Sebastian Bergmann",
761 | "email": "sebastian@phpunit.de"
762 | },
763 | {
764 | "name": "Adam Harvey",
765 | "email": "aharvey@php.net"
766 | }
767 | ],
768 | "description": "Provides the functionality to export PHP variables for visualization",
769 | "homepage": "http://www.github.com/sebastianbergmann/exporter",
770 | "keywords": [
771 | "export",
772 | "exporter"
773 | ],
774 | "time": "2015-06-21 07:55:53"
775 | },
776 | {
777 | "name": "sebastian/global-state",
778 | "version": "1.1.1",
779 | "source": {
780 | "type": "git",
781 | "url": "https://github.com/sebastianbergmann/global-state.git",
782 | "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4"
783 | },
784 | "dist": {
785 | "type": "zip",
786 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4",
787 | "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4",
788 | "shasum": ""
789 | },
790 | "require": {
791 | "php": ">=5.3.3"
792 | },
793 | "require-dev": {
794 | "phpunit/phpunit": "~4.2"
795 | },
796 | "suggest": {
797 | "ext-uopz": "*"
798 | },
799 | "type": "library",
800 | "extra": {
801 | "branch-alias": {
802 | "dev-master": "1.0-dev"
803 | }
804 | },
805 | "autoload": {
806 | "classmap": [
807 | "src/"
808 | ]
809 | },
810 | "notification-url": "https://packagist.org/downloads/",
811 | "license": [
812 | "BSD-3-Clause"
813 | ],
814 | "authors": [
815 | {
816 | "name": "Sebastian Bergmann",
817 | "email": "sebastian@phpunit.de"
818 | }
819 | ],
820 | "description": "Snapshotting of global state",
821 | "homepage": "http://www.github.com/sebastianbergmann/global-state",
822 | "keywords": [
823 | "global state"
824 | ],
825 | "time": "2015-10-12 03:26:01"
826 | },
827 | {
828 | "name": "sebastian/recursion-context",
829 | "version": "1.0.2",
830 | "source": {
831 | "type": "git",
832 | "url": "https://github.com/sebastianbergmann/recursion-context.git",
833 | "reference": "913401df809e99e4f47b27cdd781f4a258d58791"
834 | },
835 | "dist": {
836 | "type": "zip",
837 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791",
838 | "reference": "913401df809e99e4f47b27cdd781f4a258d58791",
839 | "shasum": ""
840 | },
841 | "require": {
842 | "php": ">=5.3.3"
843 | },
844 | "require-dev": {
845 | "phpunit/phpunit": "~4.4"
846 | },
847 | "type": "library",
848 | "extra": {
849 | "branch-alias": {
850 | "dev-master": "1.0.x-dev"
851 | }
852 | },
853 | "autoload": {
854 | "classmap": [
855 | "src/"
856 | ]
857 | },
858 | "notification-url": "https://packagist.org/downloads/",
859 | "license": [
860 | "BSD-3-Clause"
861 | ],
862 | "authors": [
863 | {
864 | "name": "Jeff Welch",
865 | "email": "whatthejeff@gmail.com"
866 | },
867 | {
868 | "name": "Sebastian Bergmann",
869 | "email": "sebastian@phpunit.de"
870 | },
871 | {
872 | "name": "Adam Harvey",
873 | "email": "aharvey@php.net"
874 | }
875 | ],
876 | "description": "Provides functionality to recursively process PHP variables",
877 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
878 | "time": "2015-11-11 19:50:13"
879 | },
880 | {
881 | "name": "sebastian/version",
882 | "version": "1.0.6",
883 | "source": {
884 | "type": "git",
885 | "url": "https://github.com/sebastianbergmann/version.git",
886 | "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
887 | },
888 | "dist": {
889 | "type": "zip",
890 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
891 | "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
892 | "shasum": ""
893 | },
894 | "type": "library",
895 | "autoload": {
896 | "classmap": [
897 | "src/"
898 | ]
899 | },
900 | "notification-url": "https://packagist.org/downloads/",
901 | "license": [
902 | "BSD-3-Clause"
903 | ],
904 | "authors": [
905 | {
906 | "name": "Sebastian Bergmann",
907 | "email": "sebastian@phpunit.de",
908 | "role": "lead"
909 | }
910 | ],
911 | "description": "Library that helps with managing the version number of Git-hosted PHP projects",
912 | "homepage": "https://github.com/sebastianbergmann/version",
913 | "time": "2015-06-21 13:59:46"
914 | },
915 | {
916 | "name": "squizlabs/php_codesniffer",
917 | "version": "2.5.1",
918 | "source": {
919 | "type": "git",
920 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
921 | "reference": "6731851d6aaf1d0d6c58feff1065227b7fda3ba8"
922 | },
923 | "dist": {
924 | "type": "zip",
925 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6731851d6aaf1d0d6c58feff1065227b7fda3ba8",
926 | "reference": "6731851d6aaf1d0d6c58feff1065227b7fda3ba8",
927 | "shasum": ""
928 | },
929 | "require": {
930 | "ext-tokenizer": "*",
931 | "ext-xmlwriter": "*",
932 | "php": ">=5.1.2"
933 | },
934 | "require-dev": {
935 | "phpunit/phpunit": "~4.0"
936 | },
937 | "bin": [
938 | "scripts/phpcs",
939 | "scripts/phpcbf"
940 | ],
941 | "type": "library",
942 | "extra": {
943 | "branch-alias": {
944 | "dev-master": "2.x-dev"
945 | }
946 | },
947 | "autoload": {
948 | "classmap": [
949 | "CodeSniffer.php",
950 | "CodeSniffer/CLI.php",
951 | "CodeSniffer/Exception.php",
952 | "CodeSniffer/File.php",
953 | "CodeSniffer/Fixer.php",
954 | "CodeSniffer/Report.php",
955 | "CodeSniffer/Reporting.php",
956 | "CodeSniffer/Sniff.php",
957 | "CodeSniffer/Tokens.php",
958 | "CodeSniffer/Reports/",
959 | "CodeSniffer/Tokenizers/",
960 | "CodeSniffer/DocGenerators/",
961 | "CodeSniffer/Standards/AbstractPatternSniff.php",
962 | "CodeSniffer/Standards/AbstractScopeSniff.php",
963 | "CodeSniffer/Standards/AbstractVariableSniff.php",
964 | "CodeSniffer/Standards/IncorrectPatternException.php",
965 | "CodeSniffer/Standards/Generic/Sniffs/",
966 | "CodeSniffer/Standards/MySource/Sniffs/",
967 | "CodeSniffer/Standards/PEAR/Sniffs/",
968 | "CodeSniffer/Standards/PSR1/Sniffs/",
969 | "CodeSniffer/Standards/PSR2/Sniffs/",
970 | "CodeSniffer/Standards/Squiz/Sniffs/",
971 | "CodeSniffer/Standards/Zend/Sniffs/"
972 | ]
973 | },
974 | "notification-url": "https://packagist.org/downloads/",
975 | "license": [
976 | "BSD-3-Clause"
977 | ],
978 | "authors": [
979 | {
980 | "name": "Greg Sherwood",
981 | "role": "lead"
982 | }
983 | ],
984 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
985 | "homepage": "http://www.squizlabs.com/php-codesniffer",
986 | "keywords": [
987 | "phpcs",
988 | "standards"
989 | ],
990 | "time": "2016-01-19 23:39:10"
991 | },
992 | {
993 | "name": "symfony/yaml",
994 | "version": "v3.0.3",
995 | "source": {
996 | "type": "git",
997 | "url": "https://github.com/symfony/yaml.git",
998 | "reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c"
999 | },
1000 | "dist": {
1001 | "type": "zip",
1002 | "url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c",
1003 | "reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c",
1004 | "shasum": ""
1005 | },
1006 | "require": {
1007 | "php": ">=5.5.9"
1008 | },
1009 | "type": "library",
1010 | "extra": {
1011 | "branch-alias": {
1012 | "dev-master": "3.0-dev"
1013 | }
1014 | },
1015 | "autoload": {
1016 | "psr-4": {
1017 | "Symfony\\Component\\Yaml\\": ""
1018 | },
1019 | "exclude-from-classmap": [
1020 | "/Tests/"
1021 | ]
1022 | },
1023 | "notification-url": "https://packagist.org/downloads/",
1024 | "license": [
1025 | "MIT"
1026 | ],
1027 | "authors": [
1028 | {
1029 | "name": "Fabien Potencier",
1030 | "email": "fabien@symfony.com"
1031 | },
1032 | {
1033 | "name": "Symfony Community",
1034 | "homepage": "https://symfony.com/contributors"
1035 | }
1036 | ],
1037 | "description": "Symfony Yaml Component",
1038 | "homepage": "https://symfony.com",
1039 | "time": "2016-02-23 15:16:06"
1040 | },
1041 | {
1042 | "name": "wp-coding-standards/wpcs",
1043 | "version": "0.9.0",
1044 | "source": {
1045 | "type": "git",
1046 | "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
1047 | "reference": "b415094aa5fd24da6eba2295323bcff840902dd3"
1048 | },
1049 | "dist": {
1050 | "type": "zip",
1051 | "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/b415094aa5fd24da6eba2295323bcff840902dd3",
1052 | "reference": "b415094aa5fd24da6eba2295323bcff840902dd3",
1053 | "shasum": ""
1054 | },
1055 | "require": {
1056 | "squizlabs/php_codesniffer": "~2.2"
1057 | },
1058 | "type": "library",
1059 | "notification-url": "https://packagist.org/downloads/",
1060 | "license": [
1061 | "MIT"
1062 | ],
1063 | "authors": [
1064 | {
1065 | "name": "Contributors",
1066 | "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
1067 | }
1068 | ],
1069 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
1070 | "keywords": [
1071 | "phpcs",
1072 | "standards",
1073 | "wordpress"
1074 | ],
1075 | "time": "2016-02-01 16:14:59"
1076 | }
1077 | ],
1078 | "aliases": [],
1079 | "minimum-stability": "stable",
1080 | "stability-flags": [],
1081 | "prefer-stable": false,
1082 | "prefer-lowest": false,
1083 | "platform": {
1084 | "php": ">=5.3.0"
1085 | },
1086 | "platform-dev": []
1087 | }
1088 |
--------------------------------------------------------------------------------
/licence.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Crisoforo Gaspar Hernández
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/media/samurai.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mitogh/Katana/9eb7267f061fbe555dbe9c12461650bb4153915f/media/samurai.jpg
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | tests/Katana/
7 |
8 |
9 |
10 |
11 |
12 | src/Katana/
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/readme-1.md:
--------------------------------------------------------------------------------
1 | # Katana [](https://travis-ci.org/mitogh/Katana)
2 |
3 | > Save disk space and creates custom images sizes only where is
4 | required.
5 |
6 | Custom filters to allow easy update of images sizes for [Wordpress](https://wordpress.org/).
7 |
8 | 
9 | ***Picture from [WikiImages](https://pixabay.com/samurai-guerrero-caza-de-samurai-67662/)***
10 |
11 | # Version 1.1.3 and below only
12 |
13 | ## Installation
14 |
15 | **This is not a plugin**, you can just download the `class-katana.php`
16 | or use composer to add it as a dependency in your website or plugin.
17 | After you download the file make sure to include the file using `include` function.
18 |
19 | In order to have access to the filters you need to create a new instance
20 | of the Kata object.
21 |
22 | ```php
23 | $katana = new Katana();
24 | ```
25 |
26 | Also makes sure to inclode the file `class-katana.php` into your
27 | `functions.php` file or in your plugin directory. After that you
28 | can add all your custom filters that you may require.
29 |
30 | ## Usage
31 |
32 | This library comes with custom filters that allows edit what sizes are
33 | generated under some custom post types or under a specific `post_id`.
34 |
35 | **Note:** The default size of the image is always generated no matter
36 | if you remove all sizes.
37 |
38 | ## Filters
39 |
40 | Each filter allow to return what sizes of images are needed for that
41 | particular filter, the returned sizes represents the allowed images
42 | sizes, each size is the name that was registered when you created an
43 | image size using `add_image_size`.
44 |
45 | ### katana_refine_{post_type}
46 |
47 | `{post_type}`, can be any post type declared on the site, post page or
48 | even a custom one, like movies.
49 |
50 | This filter allows to refine the sizes of images for a certain post
51 | type.
52 |
53 | **Example**
54 |
55 | This example remove all the sizes from all of the pages, so any time you
56 | add an image on a page it wont create any new size of image.
57 |
58 | ```php
59 | add_filter('katana_refine_page', 'remove_all_sizes_from_pages');
60 |
61 | function remove_all_sizes_from_pages( $sizes ){
62 | // Clear all the sizes of images
63 | $sizes = array();
64 | return $sizes;
65 | }
66 | ```
67 |
68 | ### katana_refine_{post_id}
69 |
70 | `{post_id}`, is the id of the post, page or custom post type all new
71 | entries has a `post_id`
72 |
73 | This filter allow you to change the required sizes on a particular
74 | post_id all posts, pages or custom post types has a post_id than can be
75 | used for this.
76 |
77 | **Example**
78 |
79 | Imagine we have previously declared an `author_profile_image` size of
80 | image, like:
81 |
82 | ```php
83 | add_image_size( 'author_profile_image', 350, 350, true );
84 | ```
85 |
86 | We need to creates images of the `author_profile_image` size only in the
87 | entry with the id: `105`.
88 |
89 | ```php
90 | add_filter('katana_refine_105', 'allow_only_author_profile_image');
91 |
92 | function allow_only_author_profile_image( $sizes ){
93 | $sizes = array( 'author_profile_image' );
94 | return $sizes;
95 | }
96 | ```
97 |
98 | ### katana_refine_{template_slug}
99 |
100 | `{template_slug}`, is the slug of the template, the slug is where is
101 | located the template, replacing `-` and `/` by `_` and witout the `.php`
102 | extension.
103 |
104 | **Examples**
105 |
106 | | Location | Filter name |
107 | |-----------------------------|-----------------------------|
108 | | page-templates/full.php | page_templates_full |
109 | | page-templates/shop.php | page_templates_shop |
110 | | portfolio.php | portfolio |
111 |
112 | **Example**
113 |
114 | This filter just allow to create two sizes of images in the
115 | `page-template/full.php`:
116 |
117 | - poster
118 | - landscape
119 |
120 | ```php
121 | add_filter('katana_refine_page_templates_full', 'image_sizes_for_full_page_template');
122 |
123 | function image_sizes_for_full_page_template( $sizes ){
124 | $sizes = array( 'poster', 'landscape' );
125 | return $sizes;
126 | }
127 | ```
128 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Katana [](https://travis-ci.org/mitogh/Katana)
2 |
3 | > Save disk space and creates custom images sizes only where is
4 | required.
5 |
6 | Custom filters to make sure the image sizes are generated only on pages or posts that requires the sizes on [WordPress](https://wordpress.org/), this will help to save some disk space of images that are not used at all on your WordPress installation.
7 |
8 | 
9 | Picture from [WikiImages](https://pixabay.com/samurai-guerrero-caza-de-samurai-67662/)
10 |
11 | ## Previous version.
12 |
13 | If you are using a version below 2, please make sure you take a look at
14 | [the previous docs](readme-1.md) and if you are going to upgrade make
15 | sure you follow the installation guide.
16 |
17 | ## Installation
18 |
19 | **This is not a plugin**, rather is a library that can be used with your
20 | own plugin or your theme.
21 |
22 | 1. You need to download the library using [composer](https://getcomposer.org/). In order to do this you can run the following command:
23 |
24 | ```bash
25 | composer require mitogh/katana
26 | ```
27 |
28 | This will add the latest version of the library on your installation and
29 | will create a vendor directory where the files are going to be located.
30 |
31 | 2. If you are using a plugin or `functions.php` from a theme you only
32 | need to include the following file:
33 |
34 | ```php
35 | include dirname( __FILE__ ) . '/vendor/autoload.php';
36 | ```
37 |
38 | That will allow you to use any filter from the class from `Katana` or
39 | any other package installed via composer.
40 |
41 | That's practically all the process you need to follow in order to
42 | install the library, since the library automatically creates the object
43 | that is used for create the post and page filters.
44 |
45 | ## Usage
46 |
47 | This library comes with some filters that allows you edit what sizes of
48 | images are generated under certain post types, page templates, post ID
49 | or any other custom conditional.
50 |
51 | ## Default size
52 |
53 | As a note or reminder take into account that the default image size is
54 | always generated even if you remove all image sizes with the filters.
55 |
56 | ## Filters
57 |
58 | Each filter allow to return what sizes of images are needed for that
59 | particular filter, the returned sizes represents the allowed images
60 | sizes, each size is the name that was registered when you created an
61 | image size using `add_image_size`.
62 |
63 | By default Katana applies 3 filters in the following order:
64 |
65 | 1. Filter by post_id - priority 10
66 | 2. Filter by post type - priority 20
67 | 3. Filter by template page - priority 30
68 |
69 | About filter priorities:
70 |
71 | > Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the filter.
72 |
73 | So if you are creating your own filter make sure to take priorities into account.
74 |
75 | ### katana_refine
76 |
77 | This is the filter triggered by Katana and is the one that you can use
78 | to create custom conditionals or to create new filter names.
79 |
80 | The filter sends two parameters, so you need to explicity specify the
81 | number of arguments that are send to the filter:
82 |
83 | - `$sizes` An array with the sizes of the images availables on the site.
84 | - `$id` The id of the post that triggers the filter.
85 |
86 | For example you want to remove all the image sizes from a page that has
87 | the title `tomacco`
88 |
89 | ```php
90 | add_filer( 'katana_refine', function($sizes, $id) {
91 | $title = strtolower( get_the_title( $id ) );
92 | if ( $title === 'tomacco' ) {
93 | return [];
94 | } else {
95 | return $sizes;
96 | }
97 | }, 10, 2);
98 | ```
99 |
100 | ### katana_refine_{post_type}
101 |
102 | `{post_type}`, can be any post type declared on the site, post page or
103 | even a custom one, like movies.
104 |
105 | This filter allows to refine the sizes of images for a certain post
106 | type.
107 |
108 | **Example**
109 |
110 | This example remove all the sizes from all of the pages, so any time you
111 | add an image on a page it won't create a new size of image.
112 |
113 | ```php
114 | add_filter('katana_refine_page', '__return_empty_array');
115 | ```
116 |
117 | The default two filters are:
118 |
119 | - `katana_refine_post`: Will allow you to update all the images
120 | generated in all posts.
121 | - `katana_refine_page`: Allow you to change the default sizes generated
122 | on all the pages.
123 |
124 | Every time you create a new post type, you can use a new filter with the
125 | slug of the new post type.
126 |
127 | ### katana_refine_{post_id}
128 |
129 | `{post_id}`, is the id of the post, page or custom post type. (all new
130 | entries has a `post_id`)
131 |
132 | This filter allows you to change the sizes on a particular `post_id`. (All posts, pages or custom post types has a post_id, than can be used with this filter).
133 |
134 | **Example**
135 |
136 | Imagine we have previously declared an `author_profile_image` size of an
137 | image, as follows:
138 |
139 | ```php
140 | add_image_size( 'author_profile_image', 350, 350, true );
141 | ```
142 |
143 | We need to creates images of the `author_profile_image` size only in the
144 | entry with the id: `105`.
145 |
146 | ```php
147 | add_filter('katana_refine_105', 'allow_only_author_profile_image');
148 |
149 | function allow_only_author_profile_image( $sizes ){
150 | return array( 'author_profile_image' );
151 | }
152 | ```
153 |
154 | ### katana_refine_{template_slug}
155 |
156 | `{template_slug}`, is the slug of the template, the slug is where is
157 | located the template, the template name is generated only with the last
158 | name of the template and removing the `.php` extension of that template
159 | file, some examples below:
160 |
161 | **Examples**
162 |
163 | | Location | Filter name |
164 | |-----------------------------|-----------------------------|
165 | | page-templates/full.php | katana_refine_full |
166 | | page-templates/shop-page.php| katana_refine_shop_page |
167 | | portfolio.php | katana_refine_portfolio |
168 |
169 | **Example**
170 |
171 | This filter just allow to create two sizes of images in the
172 | `page-template/full.php`:
173 |
174 | - poster
175 | - landscape
176 |
177 | ```php
178 | add_filter('katana_refine_full', 'image_sizes_for_full_page_template');
179 |
180 | function image_sizes_for_full_page_template( $sizes ){
181 | return array( 'poster', 'landscape' );
182 | }
183 | ```
184 |
--------------------------------------------------------------------------------
/src/Edge.php:
--------------------------------------------------------------------------------
1 | request_id() );
38 | return $sizes;
39 | }
40 |
41 | /**
42 | * Allow access to the current post_id using the $_REQUEST variable
43 | *
44 | * @since 1.0.0
45 | *
46 | * @return int An int from 0 to n, that represents the current post id
47 | */
48 | public function request_id() {
49 | return isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/Filters/Page.php:
--------------------------------------------------------------------------------
1 | contact-page
54 | *
55 | * To have shorter filter names.
56 | *
57 | * @param string $template_path The path to the template.
58 | * @return string See example above.
59 | */
60 | public static function get_template_name( $template_path ) {
61 | $tmp = trim( strtolower( $template_path ), ' _-' );
62 | return basename( $tmp, '.php' );
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/Start.php:
--------------------------------------------------------------------------------
1 | assertEquals( 'intermediate_image_sizes', Config::WP_FILTER );
10 | $this->assertEquals( 'katana_refine', Config::KATANA_FILTER );
11 | $this->assertEquals( 'katana', Config::KATANA );
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/tests/Katana/Helpers/FormatterTest.php:
--------------------------------------------------------------------------------
1 | assertEquals( $expected, Formatter::to_filter_format( $name ) );
10 | }
11 |
12 | public function namesPack(){
13 | return [
14 | [ '', '' ],
15 | [ ' _page-template_ ', 'page_template' ],
16 | [ 'page-templates/default', 'default' ],
17 | [ 'page-templates/contact-page', 'contact_page' ],
18 | [ 'contact-page', 'contact_page' ],
19 | [ 'contact-PAGE.PHP', 'contact_page' ],
20 | ];
21 | }
22 |
23 | /**
24 | * @dataProvider templatesNames
25 | */
26 | public function testGetTemplateName( $template_name, $expected ){
27 | $this->assertEquals( $expected, Formatter::get_template_name( $template_name ) );
28 | }
29 |
30 | public function templatesNames() {
31 | return [
32 | ['', ''],
33 | ['page-templates/template-name', 'template-name'],
34 | [' page-templates/template-name ', 'template-name'],
35 | ['customPathToaTemplateName/contact-page', 'contact-page'],
36 | ['customPathToaTemplateName/contact-page.php', 'contact-page'],
37 | ['contact-page.php', 'contact-page'],
38 | ];
39 | }
40 |
41 | /**
42 | * @dataProvider filterParams
43 | */
44 | public function testKatanaFilter( $param, $expected ){
45 | $this->assertEquals( $expected, Formatter::katana_filter( $param ) );
46 | }
47 |
48 | public function filterParams(){
49 | return [
50 | [ '', Config::KATANA_FILTER ],
51 | [ '12', Config::KATANA_FILTER . '_12' ],
52 | [ 'contact_page', Config::KATANA_FILTER . '_contact_page' ],
53 | [ '_extra_slaslh_before_after_', Config::KATANA_FILTER . '_extra_slaslh_before_after' ],
54 | [ ' _extra_slaslh_before_after_ ', Config::KATANA_FILTER . '_extra_slaslh_before_after' ],
55 | ];
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------