Unique Headers - Version 1.7.1

Version Description

  • Bug fix to make srcset work correctly on regular header images
Download this release

Release Info

Developer ryanhellyer
Plugin Icon wp plugin Unique Headers
Version 1.7.1
Comparing to
See all releases

Code changes from version 1.6.1 to 1.7.1

Files changed (3) hide show
  1. inc/class-unique-headers-display.php +33 -0
  2. index.php +1 -1
  3. readme.txt +14 -11
inc/class-unique-headers-display.php CHANGED
@@ -40,6 +40,7 @@ class Unique_Headers_Display {
40
 
41
  // Add filter for post header image (uses increased priority to ensure that single post thumbnails aren't overridden by category images)
42
  add_filter( 'theme_mod_header_image', array( $this, 'header_image_filter' ), 20 );
 
43
 
44
  }
45
 
@@ -75,4 +76,36 @@ class Unique_Headers_Display {
75
  return $url;
76
  }
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
40
 
41
  // Add filter for post header image (uses increased priority to ensure that single post thumbnails aren't overridden by category images)
42
  add_filter( 'theme_mod_header_image', array( $this, 'header_image_filter' ), 20 );
43
+ add_filter( 'wp_calculate_image_srcset', array( $this, 'header_srcset_filter' ), 20, 5 );
44
 
45
  }
46
 
76
  return $url;
77
  }
78
 
79
+ /*
80
+ * Filter for modifying the srcset values.
81
+ * This is required for when the srcset attribute is used within the header.
82
+ *
83
+ * @since 1.7
84
+ *
85
+ * @param string $srcset The new array of URLs
86
+ * @param array $size_array Array of width and height values in pixels (in that order).
87
+ * @param string $image_src The 'src' of the image.
88
+ * @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
89
+ * @param int $attachment_id Optional. The image attachment ID to pass to the filter. Default 0.
90
+ *
91
+ * @return string $srcset The new array of URLs
92
+ */
93
+ public function header_srcset_filter( $srcset, $size_array, $image_src, $image_meta, $attachment_id = 0 ) {
94
+ // return $srcset;
95
+
96
+ // Bail out if not on header ID
97
+ if ( $attachment_id != get_custom_header()->attachment_id ) {
98
+ return $srcset;
99
+ }
100
+
101
+ // Changing each URL within the set
102
+ if ( is_array( $srcset ) ) {
103
+ foreach( $srcset as $size => $set ) {
104
+ $srcset[ $size ]['url'] = $this->header_image_filter( $srcset[ $size ]['url'] );
105
+ }
106
+ }
107
+
108
+ return $srcset;
109
+ }
110
+
111
  }
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Unique Headers
4
  Plugin URI: https://geek.hellyer.kiwi/plugins/unique-headers/
5
  Description: Unique Headers
6
- Version: 1.6.1
7
  Author: Ryan Hellyer
8
  Author URI: https://geek.hellyer.kiwi/
9
  Text Domain: unique-headers
3
  Plugin Name: Unique Headers
4
  Plugin URI: https://geek.hellyer.kiwi/plugins/unique-headers/
5
  Description: Unique Headers
6
+ Version: 1.7.1
7
  Author: Ryan Hellyer
8
  Author URI: https://geek.hellyer.kiwi/
9
  Text Domain: unique-headers
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: ryanhellyer
3
  Tags: custom-header, header, headers, images, page, post, plugin, image, images, categories, gallery, media, header-image, header-images, taxonomy, tag, category, posts, pages, taxonomies, post, page, unique, custom
4
  Donate link: https://geek.hellyer.kiwi/donate/
5
  Requires at least: 4.3
6
- Tested up to: 4.6
7
- Stable tag: 1.6.1
8
 
9
 
10
 
@@ -20,13 +20,8 @@ This functionality also works with categories and tags.
20
  = Requirements =
21
  You must use a theme which utilizes the built-in custom header functionality of WordPress. If your theme implement it's own header functionality, then this plugin will not work with it.
22
 
23
- = Language support =
24
- The plugin includes translations for the following languages:
25
-
26
- 1. Spanish - provided by <a href="http://westoresolutions.com/">Mariano J. Ponce</a>
27
- 2. German - provided by <a href="http://www.graphicana.de/">Tobias Klotz</a>
28
- 3. French - provided by <a href="http://www.jennybeaumont.com/">Jenny Beaumont</a>
29
- 4. Swedish - provided by <a href="https:r//twitter.com/CyanAlice">Alice Carlsson</a>
30
 
31
 
32
  == Installation ==
@@ -84,7 +79,7 @@ Mostly, but I only actively support the latest version of WordPress. Support for
84
 
85
  = I need custom functionality. Can we pay you to build it for us? =
86
 
87
- No, I'm too busy. Having said that, if you are willing to pay me a small fortune then I could <a href="https://ryan.hellyer.kiwi/contact/">probably be persuaded</a>. I'm also open to suggestions for improvements, so feel free to send me ideas and if you are lucky, it may be added for free :)
88
 
89
 
90
 
@@ -97,6 +92,13 @@ No, I'm too busy. Having said that, if you are willing to pay me a small fortune
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
 
 
100
  = 1.6.1 =
101
  * Added checks in file to see if WordPress is loaded.
102
  * Hooking class instantiation in later, due to taxonomies sometimes not being loaded in time.
@@ -163,7 +165,7 @@ No, I'm too busy. Having said that, if you are willing to pay me a small fortune
163
 
164
  = 1.3.7 =
165
  * Addition of Spanish translation.
166
-
167
  = 1.3.1 =
168
  * Adjustment to match post meta key to other plugins, for compatibilty reasons.
169
 
@@ -195,6 +197,7 @@ No, I'm too busy. Having said that, if you are willing to pay me a small fortune
195
  = Credits =
196
 
197
  Thanks to the following for help with the development of this plugin:<br />
 
198
  * <a href="http://onmytodd.org">Todd</a> - Assistance with implementing support for tags.
199
  * <a href="http://westoresolutions.com/">Mariano J. Ponce</a> - Spanish translation.
200
  * <a href="http://www.graphicana.de/">Tobias Klotz</a> - Deutsch (German) language translation.
3
  Tags: custom-header, header, headers, images, page, post, plugin, image, images, categories, gallery, media, header-image, header-images, taxonomy, tag, category, posts, pages, taxonomies, post, page, unique, custom
4
  Donate link: https://geek.hellyer.kiwi/donate/
5
  Requires at least: 4.3
6
+ Tested up to: 4.7
7
+ Stable tag: 1.7.1
8
 
9
 
10
 
20
  = Requirements =
21
  You must use a theme which utilizes the built-in custom header functionality of WordPress. If your theme implement it's own header functionality, then this plugin will not work with it.
22
 
23
+ = Paid WordPress development =
24
+ If you would like to pay for assistance, additional features to be added to the plugin or are just looking for general WordPress development services, please contact me via <a href="https://ryan.hellyer.kiwi/contact/">my contact form</a>.
 
 
 
 
 
25
 
26
 
27
  == Installation ==
79
 
80
  = I need custom functionality. Can we pay you to build it for us? =
81
 
82
+ Yes. Just send me a message via <a href="https://ryan.hellyer.kiwi/contact/">my contact form</a> with precise information about what you require.
83
 
84
 
85
 
92
 
93
  == Changelog ==
94
 
95
+ = 1.7.1 =
96
+ * Bug fix to make srcset work correctly on regular header images
97
+
98
+ = 1.7 =
99
+ * Added support for srcset.
100
+ * Confirmed support for TwentySixteen theme.
101
+
102
  = 1.6.1 =
103
  * Added checks in file to see if WordPress is loaded.
104
  * Hooking class instantiation in later, due to taxonomies sometimes not being loaded in time.
165
 
166
  = 1.3.7 =
167
  * Addition of Spanish translation.
168
+
169
  = 1.3.1 =
170
  * Adjustment to match post meta key to other plugins, for compatibilty reasons.
171
 
197
  = Credits =
198
 
199
  Thanks to the following for help with the development of this plugin:<br />
200
+ * <a href="http://www.datamind.co.uk/">crabsallover - Assitance with debugging
201
  * <a href="http://onmytodd.org">Todd</a> - Assistance with implementing support for tags.
202
  * <a href="http://westoresolutions.com/">Mariano J. Ponce</a> - Spanish translation.
203
  * <a href="http://www.graphicana.de/">Tobias Klotz</a> - Deutsch (German) language translation.