Version Description
Download this release
Release Info
Developer | ryanhellyer |
Plugin | Unique Headers |
Version | 1.4.2 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.4.2
- inc/class-dotorg-plugin-review.php +184 -0
- index.php +22 -14
- readme.txt +11 -10
inc/class-dotorg-plugin-review.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Plugin review class.
|
5 |
+
* Prompts users to give a review of the plugin on WordPress.org after a period of usage.
|
6 |
+
*
|
7 |
+
* Heavily based on code by Rhys Wynne
|
8 |
+
* https://winwar.co.uk/2014/10/ask-wordpress-plugin-reviews-week/
|
9 |
+
*
|
10 |
+
* @copyright Copyright (c), Ryan Hellyer
|
11 |
+
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
12 |
+
*/
|
13 |
+
if ( ! class_exists( 'DotOrg_Plugin_Review' ) ) :
|
14 |
+
class DotOrg_Plugin_Review {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Private variables.
|
18 |
+
*
|
19 |
+
* These should be customised for each project.
|
20 |
+
*/
|
21 |
+
private $slug; // The plugin slug
|
22 |
+
private $name; // The plugin name
|
23 |
+
private $time_limit; // The time limit at which notice is shown
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Variables.
|
27 |
+
*/
|
28 |
+
public $nobug_option;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Fire the constructor up :)
|
32 |
+
*/
|
33 |
+
public function __construct( $args ) {
|
34 |
+
|
35 |
+
$this->slug = $args['slug'];
|
36 |
+
$this->name = $args['name'];
|
37 |
+
if ( isset( $args['time_limit'] ) ) {
|
38 |
+
$this->time_limit = $args['time_limit'];
|
39 |
+
} else {
|
40 |
+
$this->time_limit = WEEK_IN_SECONDS;
|
41 |
+
}
|
42 |
+
|
43 |
+
$this->nobug_option = $this->slug . '-no-bug';
|
44 |
+
|
45 |
+
// Loading main functionality
|
46 |
+
add_action( 'admin_init', array( $this, 'check_installation_date' ) );
|
47 |
+
add_action( 'admin_init', array( $this, 'set_no_bug' ), 5 );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Seconds to words.
|
52 |
+
*/
|
53 |
+
public function seconds_to_words( $seconds ) {
|
54 |
+
|
55 |
+
// Get the years
|
56 |
+
$years = ( intval( $seconds ) / MONTH_IN_SECONDS ) % 4;
|
57 |
+
if ( $years > 1 ) {
|
58 |
+
return sprintf( __( '%s years', $this->slug ), $years );
|
59 |
+
} elseif ( $years > 0) {
|
60 |
+
return __( 'a year', $this->slug );
|
61 |
+
}
|
62 |
+
|
63 |
+
// Get the months
|
64 |
+
$months = ( intval( $seconds ) / MONTH_IN_SECONDS ) % 4;
|
65 |
+
if ( $months > 1 ) {
|
66 |
+
return sprintf( __( '%s months', $this->slug ), $months );
|
67 |
+
} elseif ( $months > 0) {
|
68 |
+
return __( 'a month', $this->slug );
|
69 |
+
}
|
70 |
+
|
71 |
+
// Get the weeks
|
72 |
+
$weeks = ( intval( $seconds ) / WEEK_IN_SECONDS ) % 4;
|
73 |
+
if ( $weeks > 1 ) {
|
74 |
+
return sprintf( __( '%s weeks', $this->slug ), $weeks );
|
75 |
+
} elseif ( $weeks > 0) {
|
76 |
+
return __( 'a week', $this->slug );
|
77 |
+
}
|
78 |
+
|
79 |
+
// Get the days
|
80 |
+
$days = ( intval( $seconds ) / DAY_IN_SECONDS ) % 7;
|
81 |
+
if ( $days > 1 ) {
|
82 |
+
return sprintf( __( '%s days', $this->slug ), $days );
|
83 |
+
} elseif ( $days > 0) {
|
84 |
+
return __( 'a day', $this->slug );
|
85 |
+
}
|
86 |
+
|
87 |
+
// Get the hours
|
88 |
+
$hours = ( intval( $seconds ) / HOUR_IN_SECONDS ) % 24;
|
89 |
+
if ( $hours > 1 ) {
|
90 |
+
return sprintf( __( '%s hours', $this->slug ), $hours );
|
91 |
+
} elseif ( $hours > 0) {
|
92 |
+
return __( 'an hour', $this->slug );
|
93 |
+
}
|
94 |
+
|
95 |
+
// Get the minutes
|
96 |
+
$minutes = ( intval( $seconds ) / MINUTE_IN_SECONDS ) % 60;
|
97 |
+
if ( $minutes > 1 ) {
|
98 |
+
return sprintf( __( '%s minutes', $this->slug ), $minutes );
|
99 |
+
} elseif ( $minutes > 0) {
|
100 |
+
return __( 'a minute', $this->slug );
|
101 |
+
}
|
102 |
+
|
103 |
+
// Get the seconds
|
104 |
+
$seconds = intval( $seconds ) % 60;
|
105 |
+
if ( $seconds > 1 ) {
|
106 |
+
return sprintf( __( '%s seconds', $this->slug ), $seconds );
|
107 |
+
} elseif ( $seconds > 0) {
|
108 |
+
return __( 'a second', $this->slug );
|
109 |
+
}
|
110 |
+
|
111 |
+
return;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Check date on admin initiation and add to admin notice if it was more than the time limit.
|
116 |
+
*/
|
117 |
+
public function check_installation_date() {
|
118 |
+
|
119 |
+
if ( true != get_site_option( $this->nobug_option ) ) {
|
120 |
+
|
121 |
+
// If not installation date set, then add it
|
122 |
+
$install_date = get_site_option( $this->slug . '-activation-date' );
|
123 |
+
if ( '' == $install_date ) {
|
124 |
+
add_site_option( $this->slug . '-activation-date', time() );
|
125 |
+
}
|
126 |
+
|
127 |
+
// If difference between install date and now is greater than time limit, then display notice
|
128 |
+
if ( ( time() - $install_date ) > $this->time_limit ) {
|
129 |
+
add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
|
130 |
+
}
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Display Admin Notice, asking for a review.
|
138 |
+
*/
|
139 |
+
public function display_admin_notice() {
|
140 |
+
|
141 |
+
$no_bug_url = wp_nonce_url( admin_url( '?' . $this->nobug_option . '=true' ), 'review-nonce' );
|
142 |
+
|
143 |
+
$time = $this->seconds_to_words( time() - get_site_option( $this->slug . '-activation-date' ) );
|
144 |
+
|
145 |
+
echo '
|
146 |
+
<div class="updated">
|
147 |
+
<p>' . sprintf( __( 'You have been using the %s plugin for %s now, do you like it? If so, please leave us a review with your feedback!', 'spam-destroyer' ), $this->name, $time ) . '
|
148 |
+
<br /><br />
|
149 |
+
<a onclick="location.href=\'' . esc_url( $no_bug_url ) . '\';" class="button button-primary" href="' . esc_url( 'https://wordpress.org/support/view/plugin-reviews/' . $this->slug . '#postform' ) . '" target="_blank">' . __( 'Leave A Review', 'spam-destroyer' ) . '</a>
|
150 |
+
|
151 |
+
<a href="' . esc_url( $no_bug_url ) . '">' . __( 'No thanks.', 'spam-destroyer' ) . '</a>
|
152 |
+
</p>
|
153 |
+
</div>';
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Set the plugin to no longer bug users if user asks not to be.
|
159 |
+
*/
|
160 |
+
public function set_no_bug() {
|
161 |
+
|
162 |
+
// Bail out if not on correct page
|
163 |
+
if (
|
164 |
+
! isset( $_GET['_wpnonce'] )
|
165 |
+
||
|
166 |
+
(
|
167 |
+
! wp_verify_nonce( $_GET['_wpnonce'], 'review-nonce' )
|
168 |
+
||
|
169 |
+
! is_admin()
|
170 |
+
||
|
171 |
+
! isset( $_GET[$this->nobug_option] )
|
172 |
+
||
|
173 |
+
! current_user_can( 'manage_options' )
|
174 |
+
)
|
175 |
+
) {
|
176 |
+
return;
|
177 |
+
}
|
178 |
+
|
179 |
+
add_site_option( $this->nobug_option, true );
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
}
|
184 |
+
endif;
|
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.4.
|
7 |
Author: Ryan Hellyer
|
8 |
Author URI: https://geek.hellyer.kiwi/
|
9 |
Text Domain: unique-headers
|
@@ -41,18 +41,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
41 |
}
|
42 |
|
43 |
|
44 |
-
/**
|
45 |
-
* Load classes
|
46 |
-
*
|
47 |
-
* @since 1.0
|
48 |
-
* @author Ryan Hellyer <ryanhellyer@gmail.com>
|
49 |
-
*/
|
50 |
-
require( 'inc/class-unique-headers-taxonomy-header-images.php' );
|
51 |
-
require( 'inc/class-unique-headers-display.php' );
|
52 |
-
require( 'inc/class-custom-image-meta-box.php' );
|
53 |
-
require( 'inc/legacy.php' );
|
54 |
-
|
55 |
-
|
56 |
/**
|
57 |
* Add a custom image meta box
|
58 |
*
|
@@ -70,8 +58,28 @@ class Unique_Headers_Instantiate {
|
|
70 |
* @since 1.3.10
|
71 |
*/
|
72 |
public function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
add_action( 'plugins_loaded', array( $this, 'localization' ), 5 );
|
74 |
-
add_action( '
|
75 |
}
|
76 |
|
77 |
|
3 |
Plugin Name: Unique Headers
|
4 |
Plugin URI: https://geek.hellyer.kiwi/plugins/unique-headers/
|
5 |
Description: Unique Headers
|
6 |
+
Version: 1.4.2
|
7 |
Author: Ryan Hellyer
|
8 |
Author URI: https://geek.hellyer.kiwi/
|
9 |
Text Domain: unique-headers
|
41 |
}
|
42 |
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
/**
|
45 |
* Add a custom image meta box
|
46 |
*
|
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' => MINUTE_IN_SECONDS, // The time limit at which notice is shown
|
76 |
+
)
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
// Add hooks
|
81 |
add_action( 'plugins_loaded', array( $this, 'localization' ), 5 );
|
82 |
+
add_action( 'init', array( $this, 'instantiate_classes' ) );
|
83 |
}
|
84 |
|
85 |
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
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.
|
6 |
Tested up to: 4.5
|
7 |
-
Stable tag: 1.4.
|
8 |
|
9 |
|
10 |
|
@@ -18,7 +18,7 @@ The <a href="https://geek.hellyer.kiwi/products/unique-headers/">Unique Headers
|
|
18 |
This functionality also works with categories and tags.
|
19 |
|
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:
|
@@ -45,7 +45,7 @@ Visit the <a href="https://geek.hellyer.kiwi/products/unique-headers/">Unique He
|
|
45 |
== Frequently Asked Questions ==
|
46 |
|
47 |
= Do I need to install an extra plugin for categories/tags support? =
|
48 |
-
|
49 |
|
50 |
= Your plugin doesn't work =
|
51 |
Actually, it does work ;) The problem is likely with your theme. Some themes have "custom headers", but don't use the built-in WordPress custom header system and will not work with the Unique Headers plugin because of this. It is not possible to predict how other custom header systems work, and so those can not be supported by this plugin. To test if this is the problem, simply switch to one of the default themes which come with WordPress and see if the plugin works with those, if it does, then your theme is at fault.
|
@@ -126,11 +126,12 @@ No, I'm too busy. Having said that, if you are willing to pay me a small fortune
|
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
-
Version 1.4.
|
130 |
-
Version 1.4:
|
131 |
-
Version 1.
|
132 |
-
Version 1.3.
|
133 |
-
Version 1.3.
|
|
|
134 |
Version 1.3.9: Fixing error which caused header images to disappear on upgrading (data was still available just not accessed correctly).<br />
|
135 |
Version 1.3.8: Modification translation system to work with changes on WordPress.org.<br />
|
136 |
Version 1.3.7: Addition of Spanish translation<br />
|
@@ -153,5 +154,5 @@ Thanks to the following for help with the development of this plugin:<br />
|
|
153 |
* <a href="http://www.graphicana.de/">Tobias Klotz</a> - Deutsch (German) language translation.
|
154 |
* <a href="http://nakri.co.uk/">Nadia Tokerud</a> - Proof-reading of Norsk Bokmål (Norwegian) translation (coming soon)<br />
|
155 |
* <a href="http://bjornjohansen.no/">Bjørn Johansen</a> - Proof-reading of Norwegian Bokmål translation (coming soon)<br />
|
156 |
-
* <a href="https://www.facebook.com/kaljam/">Karl Olofsson</a> - Proof-reading of Swedish translation<br />
|
157 |
* <a href="http://www.jennybeaumont.com/">Jenny Beaumont</a> - French translation (coming soon)<br />
|
2 |
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.5
|
7 |
+
Stable tag: 1.4.2
|
8 |
|
9 |
|
10 |
|
18 |
This functionality also works with categories and tags.
|
19 |
|
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:
|
45 |
== Frequently Asked Questions ==
|
46 |
|
47 |
= Do I need to install an extra plugin for categories/tags support? =
|
48 |
+
No. This functionality previously required the <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a>, but as of WordPress 4.4, that plugin is no longer required as terms meta was added to WordPress core. Your old categories and tags header images will be retained, but you should make sure that the taxonomy metadata plugin has upgraded your data before deactivating it.
|
49 |
|
50 |
= Your plugin doesn't work =
|
51 |
Actually, it does work ;) The problem is likely with your theme. Some themes have "custom headers", but don't use the built-in WordPress custom header system and will not work with the Unique Headers plugin because of this. It is not possible to predict how other custom header systems work, and so those can not be supported by this plugin. To test if this is the problem, simply switch to one of the default themes which come with WordPress and see if the plugin works with those, if it does, then your theme is at fault.
|
126 |
|
127 |
== Changelog ==
|
128 |
|
129 |
+
Version 1.4.2: Adding a plugin review class.
|
130 |
+
Version 1.4.1: Instantiating the plugin later (allows for adding additional post-types in themes).
|
131 |
+
Version 1.4: Adding backwards compatibility to maintain header images provided by the Taxonomy metadata plugin.
|
132 |
+
Version 1.3.12: Added French language translation.
|
133 |
+
Version 1.3.11: Moved instantiation and localization code into a class.
|
134 |
+
Version 1.3.10: Added Deutsch (German) language translation.
|
135 |
Version 1.3.9: Fixing error which caused header images to disappear on upgrading (data was still available just not accessed correctly).<br />
|
136 |
Version 1.3.8: Modification translation system to work with changes on WordPress.org.<br />
|
137 |
Version 1.3.7: Addition of Spanish translation<br />
|
154 |
* <a href="http://www.graphicana.de/">Tobias Klotz</a> - Deutsch (German) language translation.
|
155 |
* <a href="http://nakri.co.uk/">Nadia Tokerud</a> - Proof-reading of Norsk Bokmål (Norwegian) translation (coming soon)<br />
|
156 |
* <a href="http://bjornjohansen.no/">Bjørn Johansen</a> - Proof-reading of Norwegian Bokmål translation (coming soon)<br />
|
157 |
+
* <a href="https://www.facebook.com/kaljam/">Karl Olofsson</a> - Proof-reading of Swedish translation (coming soon)<br />
|
158 |
* <a href="http://www.jennybeaumont.com/">Jenny Beaumont</a> - French translation (coming soon)<br />
|