Index: trunk/tools/wp-photocommons/inc/class-photocommons.php |
— | — | @@ -1,76 +1,76 @@ |
2 | 2 | <?php |
3 | 3 | class PhotoCommons { |
4 | | - const PLUGIN_PATH = '/wp-photocommons/'; |
5 | | - const FILEPATH_PATTERN = 'http://commons.wikimedia.org/w/index.php?title=Special:FilePath&file=%s&width=%s'; |
6 | | - const FILEPAGE_PATTERN = 'http://commons.wikimedia.org/w/index.php?title=File:%s'; |
| 4 | + const PLUGIN_PATH = '/wp-photocommons/'; |
| 5 | + const FILEPATH_PATTERN = 'http://commons.wikimedia.org/w/index.php?title=Special:FilePath&file=%s&width=%s'; |
| 6 | + const FILEPAGE_PATTERN = 'http://commons.wikimedia.org/w/index.php?title=File:%s'; |
7 | 7 | |
8 | | - function __construct() { |
9 | | - if ( is_admin() ) { |
10 | | - $this->initAdmin(); |
11 | | - } else { |
12 | | - $this->initFrontend(); |
13 | | - } |
14 | | - } |
| 8 | + function __construct() { |
| 9 | + if ( is_admin() ) { |
| 10 | + $this->initAdmin(); |
| 11 | + } else { |
| 12 | + $this->initFrontend(); |
| 13 | + } |
| 14 | + } |
15 | 15 | |
16 | | - public function addShortcode($args) { |
17 | | - $filename = $args['file']; |
18 | | - $width = $args['width']; |
19 | | - $align = empty($args['align']) ? 'alignright' : 'align' . $args['align']; |
20 | | - $thumb = $this->getThumbUrl($filename, $width); |
21 | | - $filepage = $this->getPageUrl($filename, $width); |
| 16 | + public function addShortcode($args) { |
| 17 | + $filename = $args['file']; |
| 18 | + $width = $args['width']; |
| 19 | + $align = empty($args['align']) ? 'alignright' : 'align' . $args['align']; |
| 20 | + $thumb = $this->getThumbUrl($filename, $width); |
| 21 | + $filepage = $this->getPageUrl($filename, $width); |
22 | 22 | |
23 | | - return sprintf( |
24 | | - '<a href="%s" title="%s" class="wp-photocommons-thumb">' . |
25 | | - '<img src="%s" title="%s via Wikimedia Commons" alt="%s" class="%s" width="%s" />' . |
26 | | - '</a>', |
27 | | - $filepage, $filename, |
28 | | - $thumb, $filename, $filename, $align, $width |
29 | | - ); |
30 | | - } |
| 23 | + return sprintf( |
| 24 | + '<a href="%s" title="%s" class="wp-photocommons-thumb">' . |
| 25 | + '<img src="%s" title="%s via Wikimedia Commons" alt="%s" class="%s" width="%s" />' . |
| 26 | + '</a>', |
| 27 | + $filepage, $filename, |
| 28 | + $thumb, $filename, $filename, $align, $width |
| 29 | + ); |
| 30 | + } |
31 | 31 | |
32 | | - private function getThumbUrl($file, $width) { |
33 | | - return sprintf(self::FILEPATH_PATTERN, rawurlencode($file), rawurlencode($width)); |
34 | | - } |
| 32 | + private function getThumbUrl($file, $width) { |
| 33 | + return sprintf(self::FILEPATH_PATTERN, rawurlencode($file), rawurlencode($width)); |
| 34 | + } |
35 | 35 | |
36 | | - private function getPageUrl($file, $width) { |
37 | | - return sprintf(self::FILEPAGE_PATTERN, rawurlencode($file)); |
38 | | - } |
| 36 | + private function getPageUrl($file, $width) { |
| 37 | + return sprintf(self::FILEPAGE_PATTERN, rawurlencode($file)); |
| 38 | + } |
39 | 39 | |
40 | | - private function initAdmin() { |
41 | | - $this->enqueueScripts(); |
42 | | - $this->enqueueStyles(); |
43 | | - } |
| 40 | + private function initAdmin() { |
| 41 | + $this->enqueueScripts(); |
| 42 | + $this->enqueueStyles(); |
| 43 | + } |
44 | 44 | |
45 | | - private function enqueueScripts() { |
46 | | - // Register some of our own scripts |
47 | | - wp_register_script('admin', plugins_url() . self::PLUGIN_PATH . 'js/admin.js'); |
48 | | - wp_register_script('search', plugins_url() . self::PLUGIN_PATH . 'js/search.js'); |
49 | | - wp_register_script('suggestions', plugins_url() . self::PLUGIN_PATH . 'js/jquery.suggestions.js'); |
| 45 | + private function enqueueScripts() { |
| 46 | + // Register some of our own scripts |
| 47 | + wp_register_script('admin', plugins_url() . self::PLUGIN_PATH . 'js/admin.js'); |
| 48 | + wp_register_script('search', plugins_url() . self::PLUGIN_PATH . 'js/search.js'); |
| 49 | + wp_register_script('suggestions', plugins_url() . self::PLUGIN_PATH . 'js/jquery.suggestions.js'); |
50 | 50 | |
51 | | - // Enqueue external libraries |
52 | | - wp_enqueue_script('jquery'); |
53 | | - wp_enqueue_script('jquery-ui-core'); |
54 | | - wp_enqueue_script('jquery-ui-dialog'); |
| 51 | + // Enqueue external libraries |
| 52 | + wp_enqueue_script('jquery'); |
| 53 | + wp_enqueue_script('jquery-ui-core'); |
| 54 | + wp_enqueue_script('jquery-ui-dialog'); |
55 | 55 | |
56 | | - // Enqueue our own scripts |
57 | | - wp_enqueue_script('admin'); |
58 | | - wp_enqueue_script('search'); |
59 | | - wp_enqueue_script('suggestions'); |
60 | | - } |
| 56 | + // Enqueue our own scripts |
| 57 | + wp_enqueue_script('admin'); |
| 58 | + wp_enqueue_script('search'); |
| 59 | + wp_enqueue_script('suggestions'); |
| 60 | + } |
61 | 61 | |
62 | | - private function enqueueStyles() { |
63 | | - // Register our own styles and enqueue |
64 | | - wp_register_style('jquid_jquery_blog_stylesheet', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/redmond/jquery-ui.css'); |
65 | | - wp_register_style('suggestions', plugins_url() . self::PLUGIN_PATH . 'css/jquery.suggestions.css'); |
66 | | - wp_register_style('search', plugins_url() . self::PLUGIN_PATH . 'css/search.css'); |
| 62 | + private function enqueueStyles() { |
| 63 | + // Register our own styles and enqueue |
| 64 | + wp_register_style('jquid_jquery_blog_stylesheet', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/redmond/jquery-ui.css'); |
| 65 | + wp_register_style('suggestions', plugins_url() . self::PLUGIN_PATH . 'css/jquery.suggestions.css'); |
| 66 | + wp_register_style('search', plugins_url() . self::PLUGIN_PATH . 'css/search.css'); |
67 | 67 | |
68 | 68 | wp_enqueue_style('jquid_jquery_blog_stylesheet'); |
69 | 69 | wp_enqueue_style('suggestions'); |
70 | 70 | wp_enqueue_style('search'); |
71 | 71 | |
72 | | - } |
| 72 | + } |
73 | 73 | |
74 | | - private function initFrontend() { |
75 | | - add_shortcode('photocommons', array($this, 'addShortcode')); |
76 | | - } |
| 74 | + private function initFrontend() { |
| 75 | + add_shortcode('photocommons', array($this, 'addShortcode')); |
| 76 | + } |
77 | 77 | } |
\ No newline at end of file |