Version Description
- Bug fix for srcset with taxonomies
- Changed to class autoloader
- Moved instantiation class to it's own file
- Added extendible core class
Download this release
Release Info
Developer | ryanhellyer |
Plugin | Unique Headers |
Version | 1.7.3 |
Comparing to | |
See all releases |
Code changes from version 1.7.2 to 1.7.3
- inc/class-custom-image-meta-box.php +21 -0
- inc/class-unique-headers-core.php +44 -0
- inc/class-unique-headers-display.php +38 -26
- inc/class-unique-headers-instantiate.php +96 -0
- inc/class-unique-headers-taxonomy-header-images.php +48 -3
- index.php +19 -89
- readme.txt +8 -2
inc/class-custom-image-meta-box.php
CHANGED
@@ -144,6 +144,27 @@ class Custom_Image_Meta_Box {
|
|
144 |
return $url;
|
145 |
}
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
/**
|
148 |
* Registers the JavaScript for handling the media uploader.
|
149 |
*
|
144 |
return $url;
|
145 |
}
|
146 |
|
147 |
+
/*
|
148 |
+
* Get the attachment URL from the attachment ID
|
149 |
+
*
|
150 |
+
* @since 1.3
|
151 |
+
* @access static This method is static so that front-end scripts can access the attachments SRC
|
152 |
+
* @param int $attachment_id The attachment ID
|
153 |
+
* @return int
|
154 |
+
*/
|
155 |
+
static function get_attachment_dimensions( $attachment_id, $dimension = 'width' ) {
|
156 |
+
|
157 |
+
// Grab URL from WordPress
|
158 |
+
$data = wp_get_attachment_image_src( $attachment_id, 'full' );
|
159 |
+
|
160 |
+
if ( 'width' == $dimension ) {
|
161 |
+
return $data[1];
|
162 |
+
} else if ( 'height' == $dimension ) {
|
163 |
+
return $data[2];
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
/**
|
169 |
* Registers the JavaScript for handling the media uploader.
|
170 |
*
|
inc/class-unique-headers-core.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Core class which is extended by other classes.
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c), Ryan Hellyer
|
7 |
+
* @license http://www.gnu.org/licenses/gpl.html GPL
|
8 |
+
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
9 |
+
* @since 1.7.3
|
10 |
+
*/
|
11 |
+
class Unique_Headers_Core {
|
12 |
+
|
13 |
+
/*
|
14 |
+
* Filter for modifying the srcset values.
|
15 |
+
* This is required for when the srcset attribute is used within the header.
|
16 |
+
*
|
17 |
+
* @since 1.7
|
18 |
+
*
|
19 |
+
* @param string $srcset The new array of URLs
|
20 |
+
* @param array $size_array Array of width and height values in pixels (in that order).
|
21 |
+
* @param string $image_src The 'src' of the image.
|
22 |
+
* @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
|
23 |
+
* @param int $attachment_id Optional. The image attachment ID to pass to the filter. Default 0.
|
24 |
+
*
|
25 |
+
* @return string $srcset The new array of URLs
|
26 |
+
*/
|
27 |
+
public function header_srcset_filter( $srcset, $size_array, $image_src, $image_meta, $attachment_id = 0 ) {
|
28 |
+
|
29 |
+
// Bail out if not on header ID
|
30 |
+
if ( $attachment_id != get_custom_header()->attachment_id ) {
|
31 |
+
return $srcset;
|
32 |
+
}
|
33 |
+
|
34 |
+
// Changing each URL within the set
|
35 |
+
if ( is_array( $srcset ) ) {
|
36 |
+
foreach( $srcset as $size => $set ) {
|
37 |
+
$srcset[ $size ]['url'] = $this->header_image_filter( $srcset[ $size ]['url'] );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
return $srcset;
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
inc/class-unique-headers-display.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
9 |
* @since 1.3
|
10 |
*/
|
11 |
-
class Unique_Headers_Display {
|
12 |
|
13 |
/**
|
14 |
* The name of the image meta
|
@@ -36,11 +36,13 @@ class Unique_Headers_Display {
|
|
36 |
* @since 1.3
|
37 |
*/
|
38 |
public function __construct( $args ) {
|
|
|
39 |
$this->name_underscores = str_replace( '-', '_', $args['name'] );
|
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',
|
43 |
-
add_filter( 'wp_calculate_image_srcset',
|
|
|
44 |
|
45 |
}
|
46 |
|
@@ -76,36 +78,46 @@ class Unique_Headers_Display {
|
|
76 |
return $url;
|
77 |
}
|
78 |
|
79 |
-
|
80 |
-
*
|
81 |
-
*
|
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 |
-
* @
|
|
|
92 |
*/
|
93 |
-
public function
|
94 |
-
// return $srcset;
|
95 |
|
96 |
-
// Bail out if not
|
97 |
-
if (
|
98 |
-
return $
|
99 |
}
|
100 |
|
101 |
-
//
|
102 |
-
if (
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
}
|
107 |
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
}
|
8 |
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
9 |
* @since 1.3
|
10 |
*/
|
11 |
+
class Unique_Headers_Display extends Unique_Headers_Core {
|
12 |
|
13 |
/**
|
14 |
* The name of the image meta
|
36 |
* @since 1.3
|
37 |
*/
|
38 |
public function __construct( $args ) {
|
39 |
+
|
40 |
$this->name_underscores = str_replace( '-', '_', $args['name'] );
|
41 |
|
42 |
// Add filter for post header image (uses increased priority to ensure that single post thumbnails aren't overridden by category images)
|
43 |
+
add_filter( 'theme_mod_header_image', array( $this, 'header_image_filter' ), 20 );
|
44 |
+
add_filter( 'wp_calculate_image_srcset', array( $this, 'header_srcset_filter' ), 20, 5 );
|
45 |
+
add_filter( 'theme_mod_header_image_data', array( $this, 'modify_header_image_data' ) );
|
46 |
|
47 |
}
|
48 |
|
78 |
return $url;
|
79 |
}
|
80 |
|
81 |
+
/**
|
82 |
+
* Modify the header image data.
|
83 |
+
* Required to make TwentySixteen work.
|
84 |
+
* This is a replica of the method in Unique_Headers_Taxonomy_Header_Images().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
*
|
86 |
+
* @param array $data The data
|
87 |
+
* @return array The modified data with new attachment ID
|
88 |
*/
|
89 |
+
public function modify_header_image_data( $data ) {
|
|
|
90 |
|
91 |
+
// Bail out now if not in post (is_single or is_page) or blog (is_home)
|
92 |
+
if ( ! is_single() && ! is_page() && ! is_home() ) {
|
93 |
+
return $data;
|
94 |
}
|
95 |
|
96 |
+
// Get current post ID (if on blog, then checks current posts page for it's ID)
|
97 |
+
if ( is_home() ) {
|
98 |
+
$post_id = get_option( 'page_for_posts' );
|
99 |
+
} else {
|
100 |
+
$post_id = get_the_ID();
|
101 |
}
|
102 |
|
103 |
+
// Get attachment ID
|
104 |
+
$attachment_id = Custom_Image_Meta_Box::get_attachment_id( $post_id, $this->name_underscores );
|
105 |
+
|
106 |
+
// Set new data based on new header image attachment ID
|
107 |
+
if ( is_numeric( $attachment_id ) ) {
|
108 |
+
|
109 |
+
// Create object
|
110 |
+
if ( null == $data ) {
|
111 |
+
$data = (object) null;
|
112 |
+
}
|
113 |
+
|
114 |
+
$data->attachment_id = $attachment_id;
|
115 |
+
$data->width = Custom_Image_Meta_Box::get_attachment_dimensions( $attachment_id, 'width' );
|
116 |
+
$data->height = Custom_Image_Meta_Box::get_attachment_dimensions( $attachment_id, 'height' );
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
return $data;
|
121 |
}
|
122 |
|
123 |
}
|
inc/class-unique-headers-instantiate.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Add a custom image meta box
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c), Ryan Hellyer
|
7 |
+
* @license http://www.gnu.org/licenses/gpl.html GPL
|
8 |
+
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
9 |
+
* @since 1.3
|
10 |
+
*/
|
11 |
+
class Unique_Headers_Instantiate {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class constructor
|
15 |
+
* Adds methods to appropriate hooks
|
16 |
+
*
|
17 |
+
* @since 1.3.10
|
18 |
+
*/
|
19 |
+
public function __construct() {
|
20 |
+
|
21 |
+
// Load classes
|
22 |
+
require( 'class-custom-image-meta-box.php' );
|
23 |
+
require( 'legacy.php' );
|
24 |
+
|
25 |
+
// Loading dotorg plugin review code
|
26 |
+
if ( is_admin() ) {
|
27 |
+
require( 'class-dotorg-plugin-review.php' );
|
28 |
+
new DotOrg_Plugin_Review(
|
29 |
+
array(
|
30 |
+
'slug' => 'unique-headers', // The plugin slug
|
31 |
+
'name' => 'Unique Headers', // The plugin name
|
32 |
+
'time_limit' => WEEK_IN_SECONDS, // The time limit at which notice is shown
|
33 |
+
)
|
34 |
+
);
|
35 |
+
}
|
36 |
+
|
37 |
+
// Add hooks
|
38 |
+
add_action( 'plugins_loaded', array( $this, 'localization' ), 5 );
|
39 |
+
add_action( 'init', array( $this, 'instantiate_classes' ), 20 );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Instantiate classes
|
44 |
+
*
|
45 |
+
* @since 1.3
|
46 |
+
*/
|
47 |
+
public function instantiate_classes() {
|
48 |
+
|
49 |
+
$name = 'custom-header-image'; // This says "custom-header" instead of "unique-header" to ensure compatibilty with Justin Tadlock's Custom Header Extended plugin which originally used a different post meta key value than the Unique Headers plugin
|
50 |
+
$args = array(
|
51 |
+
'name' => $name,
|
52 |
+
'dir_uri' => plugin_dir_url( dirname( __FILE__ ) ) . 'assets',
|
53 |
+
'title' => __( 'Custom header', 'unique-headers' ),
|
54 |
+
'set_custom_image' => __( 'Set Custom Header Image', 'unique-headers' ),
|
55 |
+
'remove_custom_image' => __( 'Remove Custom Header Image', 'unique-headers' ),
|
56 |
+
'post_types' => get_post_types( array( 'public' => true ) ),
|
57 |
+
);
|
58 |
+
|
59 |
+
// Add support for post-types
|
60 |
+
if ( is_admin() ) {
|
61 |
+
new Custom_Image_Meta_Box( $args );
|
62 |
+
} else {
|
63 |
+
new Unique_Headers_Display( array( 'name' => $name ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
// Add support for taxonomies (this conditional can be removed after the release of WordPress 4.4 - plus the taxonmies argument above can be moved into the main array then)
|
67 |
+
if ( function_exists( 'get_term_meta' ) ) {
|
68 |
+
|
69 |
+
// Add support for publicly available taxonomies - this can be moved into the main arguments array above after the release of WordPress 4.4
|
70 |
+
$args['taxonomies'] = get_taxonomies( array( 'public'=>true ) );
|
71 |
+
|
72 |
+
// Add upload text
|
73 |
+
$args['upload_header_image'] = __( 'Upload header image', 'unique-headers' );
|
74 |
+
|
75 |
+
// new Unique_Headers_Taxonomy_Header_Images( $args );
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
/*
|
81 |
+
* Setup localization for translations
|
82 |
+
*
|
83 |
+
* @since 1.3
|
84 |
+
*/
|
85 |
+
public function localization() {
|
86 |
+
|
87 |
+
// Localization
|
88 |
+
load_plugin_textdomain(
|
89 |
+
'unique-headers', // Unique identifier
|
90 |
+
false, // Deprecated abs path
|
91 |
+
dirname( plugin_basename( __FILE__ ) ) . '/languages/' // Languages folder
|
92 |
+
);
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
inc/class-unique-headers-taxonomy-header-images.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
9 |
* @since 1.0
|
10 |
*/
|
11 |
-
class
|
12 |
|
13 |
/**
|
14 |
* The name of the image meta
|
@@ -92,8 +92,11 @@ class Unique_Header_Taxonomy_Header_Images {
|
|
92 |
$this->taxonomies = $args['taxonomies'];
|
93 |
$this->upload_header_image = $args['upload_header_image'];
|
94 |
|
95 |
-
add_action( 'admin_init',
|
96 |
-
add_filter( 'theme_mod_header_image',
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -336,4 +339,46 @@ class Unique_Header_Taxonomy_Header_Images {
|
|
336 |
|
337 |
}
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
}
|
8 |
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
9 |
* @since 1.0
|
10 |
*/
|
11 |
+
class Unique_Headers_Taxonomy_Header_Images extends Unique_Headers_Core {
|
12 |
|
13 |
/**
|
14 |
* The name of the image meta
|
92 |
$this->taxonomies = $args['taxonomies'];
|
93 |
$this->upload_header_image = $args['upload_header_image'];
|
94 |
|
95 |
+
add_action( 'admin_init', array( $this, 'add_fields' ) );
|
96 |
+
add_filter( 'theme_mod_header_image', array( $this, 'header_image_filter' ), 5 );
|
97 |
+
add_filter( 'wp_calculate_image_srcset', array( $this, 'header_srcset_filter' ), 20, 5 );
|
98 |
+
add_filter( 'theme_mod_header_image_data', array( $this, 'modify_header_image_data' ) );
|
99 |
+
|
100 |
}
|
101 |
|
102 |
/**
|
339 |
|
340 |
}
|
341 |
|
342 |
+
/**
|
343 |
+
* Modify the header image data.
|
344 |
+
* Required to make TwentySixteen work.
|
345 |
+
* This is a replica of the method in Unique_Headers_Display().
|
346 |
+
*
|
347 |
+
* @param array $data The data
|
348 |
+
* @return array The modified data with new attachment ID
|
349 |
+
*/
|
350 |
+
public function modify_header_image_data( $data ) {
|
351 |
+
|
352 |
+
// Bail out now if not in post (is_single or is_page) or blog (is_home)
|
353 |
+
if ( ! is_single() && ! is_page() && ! is_home() ) {
|
354 |
+
return $data;
|
355 |
+
}
|
356 |
+
|
357 |
+
// Get current post ID (if on blog, then checks current posts page for it's ID)
|
358 |
+
if ( is_home() ) {
|
359 |
+
$post_id = get_option( 'page_for_posts' );
|
360 |
+
} else {
|
361 |
+
$post_id = get_the_ID();
|
362 |
+
}
|
363 |
+
|
364 |
+
// Get attachment ID
|
365 |
+
$attachment_id = Custom_Image_Meta_Box::get_attachment_id( $post_id, $this->name_underscores );
|
366 |
+
|
367 |
+
// Set new data based on new header image attachment ID
|
368 |
+
if ( is_numeric( $attachment_id ) ) {
|
369 |
+
|
370 |
+
// Create object
|
371 |
+
if ( null == $data ) {
|
372 |
+
$data = (object) null;
|
373 |
+
}
|
374 |
+
|
375 |
+
$data->attachment_id = $attachment_id;
|
376 |
+
$data->width = Custom_Image_Meta_Box::get_attachment_dimensions( $attachment_id, 'width' );
|
377 |
+
$data->height = Custom_Image_Meta_Box::get_attachment_dimensions( $attachment_id, 'height' );
|
378 |
+
|
379 |
+
}
|
380 |
+
|
381 |
+
return $data;
|
382 |
+
}
|
383 |
+
|
384 |
}
|
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.7.
|
7 |
Author: Ryan Hellyer
|
8 |
Author URI: https://geek.hellyer.kiwi/
|
9 |
Text Domain: unique-headers
|
@@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
29 |
*/
|
30 |
|
31 |
|
32 |
-
|
33 |
/**
|
34 |
* Do not continue processing since file was called directly
|
35 |
*
|
@@ -42,99 +41,30 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
42 |
|
43 |
|
44 |
/**
|
45 |
-
*
|
|
|
46 |
*
|
47 |
-
* @
|
48 |
-
* @license http://www.gnu.org/licenses/gpl.html GPL
|
49 |
-
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
50 |
-
* @since 1.3
|
51 |
*/
|
52 |
-
class
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Class constructor
|
56 |
-
* Adds methods to appropriate hooks
|
57 |
-
*
|
58 |
-
* @since 1.3.10
|
59 |
-
*/
|
60 |
-
public function __construct() {
|
61 |
-
|
62 |
-
// Load classes
|
63 |
-
require( 'inc/class-unique-headers-taxonomy-header-images.php' );
|
64 |
-
require( 'inc/class-unique-headers-display.php' );
|
65 |
-
require( 'inc/class-custom-image-meta-box.php' );
|
66 |
-
require( 'inc/legacy.php' );
|
67 |
-
|
68 |
-
// Loading dotorg plugin review code
|
69 |
-
if ( is_admin() ) {
|
70 |
-
require( 'inc/class-dotorg-plugin-review.php' );
|
71 |
-
new DotOrg_Plugin_Review(
|
72 |
-
array(
|
73 |
-
'slug' => 'unique-headers', // The plugin slug
|
74 |
-
'name' => 'Unique Headers', // The plugin name
|
75 |
-
'time_limit' => WEEK_IN_SECONDS, // The time limit at which notice is shown
|
76 |
-
)
|
77 |
-
);
|
78 |
-
}
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
}
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
*/
|
90 |
-
public function instantiate_classes() {
|
91 |
-
|
92 |
-
$name = 'custom-header-image'; // This says "custom-header" instead of "unique-header" to ensure compatibilty with Justin Tadlock's Custom Header Extended plugin which originally used a different post meta key value than the Unique Headers plugin
|
93 |
-
$args = array(
|
94 |
-
'name' => $name,
|
95 |
-
'dir_uri' => plugin_dir_url( __FILE__ ) . 'assets',
|
96 |
-
'title' => __( 'Custom header', 'unique-headers' ),
|
97 |
-
'set_custom_image' => __( 'Set Custom Header Image', 'unique-headers' ),
|
98 |
-
'remove_custom_image' => __( 'Remove Custom Header Image', 'unique-headers' ),
|
99 |
-
'post_types' => get_post_types( array( 'public' => true ) ),
|
100 |
-
);
|
101 |
-
|
102 |
-
// Add support for post-types
|
103 |
-
if ( is_admin() ) {
|
104 |
-
new Custom_Image_Meta_Box( $args );
|
105 |
-
} else {
|
106 |
-
new Unique_Headers_Display( array( 'name' => $name ) );
|
107 |
-
}
|
108 |
-
|
109 |
-
// Add support for taxonomies (this conditional can be removed after the release of WordPress 4.4 - plus the taxonmies argument above can be moved into the main array then)
|
110 |
-
if ( function_exists( 'get_term_meta' ) ) {
|
111 |
-
|
112 |
-
// Add support for publicly available taxonomies - this can be moved into the main arguments array above after the release of WordPress 4.4
|
113 |
-
$args['taxonomies'] = get_taxonomies( array( 'public'=>true ) );
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
new Unique_Header_Taxonomy_Header_Images( $args );
|
119 |
-
}
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
/*
|
124 |
-
* Setup localization for translations
|
125 |
-
*
|
126 |
-
* @since 1.3
|
127 |
-
*/
|
128 |
-
public function localization() {
|
129 |
-
|
130 |
-
// Localization
|
131 |
-
load_plugin_textdomain(
|
132 |
-
'unique-headers', // Unique identifier
|
133 |
-
false, // Deprecated abs path
|
134 |
-
dirname( plugin_basename( __FILE__ ) ) . '/languages/' // Languages folder
|
135 |
-
);
|
136 |
-
|
137 |
-
}
|
138 |
|
|
|
|
|
139 |
}
|
|
|
|
|
140 |
new Unique_Headers_Instantiate;
|
3 |
Plugin Name: Unique Headers
|
4 |
Plugin URI: https://geek.hellyer.kiwi/plugins/unique-headers/
|
5 |
Description: Unique Headers
|
6 |
+
Version: 1.7.3
|
7 |
Author: Ryan Hellyer
|
8 |
Author URI: https://geek.hellyer.kiwi/
|
9 |
Text Domain: unique-headers
|
29 |
*/
|
30 |
|
31 |
|
|
|
32 |
/**
|
33 |
* Do not continue processing since file was called directly
|
34 |
*
|
41 |
|
42 |
|
43 |
/**
|
44 |
+
* Autoload the classes.
|
45 |
+
* Includes the classes, and automatically instantiates them via spl_autoload_register().
|
46 |
*
|
47 |
+
* @param string $class The class being instantiated
|
|
|
|
|
|
|
48 |
*/
|
49 |
+
function autoload_unique_headers( $class ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
// Bail out if not loading a Media Manager class
|
52 |
+
if ( 'Unique_Headers_' != substr( $class, 0, 15 ) ) {
|
53 |
+
return;
|
54 |
}
|
55 |
|
56 |
+
// Convert from the class name, to the classes file name
|
57 |
+
$file_data = strtolower( $class );
|
58 |
+
$file_data = str_replace( '_', '-', $file_data );
|
59 |
+
$file_name = 'class-' . $file_data . '.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
// Get the classes file path
|
62 |
+
$dir = dirname( __FILE__ );
|
63 |
+
$path = $dir . '/inc/' . $file_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
+
// Include the class (spl_autoload_register will automatically instantiate it for us)
|
66 |
+
require( $path );
|
67 |
}
|
68 |
+
spl_autoload_register( 'autoload_unique_headers' );
|
69 |
+
|
70 |
new Unique_Headers_Instantiate;
|
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.
|
7 |
-
Stable tag: 1.7.
|
8 |
|
9 |
|
10 |
|
@@ -92,6 +92,12 @@ Yes. Just send me a message via <a href="https://ryan.hellyer.kiwi/contact/">my
|
|
92 |
|
93 |
== Changelog ==
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
= 1.7.2 =
|
96 |
* Bug fix for custom taxonomies
|
97 |
|
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.8
|
7 |
+
Stable tag: 1.7.3
|
8 |
|
9 |
|
10 |
|
92 |
|
93 |
== Changelog ==
|
94 |
|
95 |
+
= 1.7.3 =
|
96 |
+
* Bug fix for srcset with taxonomies
|
97 |
+
* Changed to class autoloader
|
98 |
+
* Moved instantiation class to it's own file
|
99 |
+
* Added extendible core class
|
100 |
+
|
101 |
= 1.7.2 =
|
102 |
* Bug fix for custom taxonomies
|
103 |
|