| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Unique Headers |
| 4 |
Plugin URI: https://geek.hellyer.kiwi/plugins/unique-headers/ |
| 5 |
Description: Unique Headers |
| 6 |
Version: 1.4.3 |
| 7 |
Author: Ryan Hellyer |
| 8 |
Author URI: https://geek.hellyer.kiwi/ |
| 9 |
Text Domain: unique-headers |
| 10 |
License: GPL2 |
| 11 |
|
| 12 |
------------------------------------------------------------------------ |
| 13 |
Copyright Ryan Hellyer |
| 14 |
|
| 15 |
This program is free software; you can redistribute it and/or modify |
| 16 |
it under the terms of the GNU General Public License as published by |
| 17 |
the Free Software Foundation; either version 2 of the License, or |
| 18 |
(at your option) any later version. |
| 19 |
|
| 20 |
This program is distributed in the hope that it will be useful, |
| 21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
GNU General Public License for more details. |
| 24 |
|
| 25 |
You should have received a copy of the GNU General Public License |
| 26 |
along with this program; if not, write to the Free Software |
| 27 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 28 |
|
| 29 |
*/ |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
/** |
| 34 |
* Do not continue processing since file was called directly |
| 35 |
* |
| 36 |
* @since 1.0 |
| 37 |
* @author Ryan Hellyer <ryanhellyer@gmail.com> |
| 38 |
*/ |
| 39 |
if ( ! defined( 'ABSPATH' ) ) { |
| 40 |
die( 'Eh! What you doin in here?' ); |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
/** |
| 45 |
* Add a custom image meta box |
| 46 |
* |
| 47 |
* @copyright Copyright (c), Ryan Hellyer |
| 48 |
* @license http://www.gnu.org/licenses/gpl.html GPL |
| 49 |
* @author Ryan Hellyer <ryanhellyer@gmail.com> |
| 50 |
* @since 1.3 |
| 51 |
*/ |
| 52 |
class Unique_Headers_Instantiate { |
| 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 |
Temporary removal due to: |
| 69 |
"Warning: Division by zero in /wp-content/plugins/unique-headers/inc/class-dotorg-plugin-review.php on line 56" |
| 70 |
"Warning: Division by zero in /wp-content/plugins/unique-headers/inc/class-dotorg-plugin-review.php on line 64" |
| 71 |
// Loading dotorg plugin review code |
| 72 |
if ( is_admin() ) { |
| 73 |
require( 'inc/class-dotorg-plugin-review.php' ); |
| 74 |
new DotOrg_Plugin_Review( |
| 75 |
array( |
| 76 |
'slug' => 'unique-headers', // The plugin slug |
| 77 |
'name' => 'Unique Headers', // The plugin name |
| 78 |
'time_limit' => MINUTE_IN_SECONDS, // The time limit at which notice is shown |
| 79 |
) |
| 80 |
); |
| 81 |
} |
| 82 |
*/ |
| 83 |
// Add hooks |
| 84 |
add_action( 'plugins_loaded', array( $this, 'localization' ), 5 ); |
| 85 |
add_action( 'init', array( $this, 'instantiate_classes' ) ); |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
/** |
| 90 |
* Instantiate classes |
| 91 |
* |
| 92 |
* @since 1.3 |
| 93 |
*/ |
| 94 |
public function instantiate_classes() { |
| 95 |
|
| 96 |
$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 |
| 97 |
$args = array( |
| 98 |
'name' => $name, |
| 99 |
'dir_uri' => plugin_dir_url( __FILE__ ) . 'assets', |
| 100 |
'title' => __( 'Custom header', 'unique-headers' ), |
| 101 |
'set_custom_image' => __( 'Set Custom Header Image', 'unique-headers' ), |
| 102 |
'remove_custom_image' => __( 'Remove Custom Header Image', 'unique-headers' ), |
| 103 |
'post_types' => apply_filters( 'unique_headers_post_types', array( 'post', 'page' ) ), |
| 104 |
); |
| 105 |
|
| 106 |
// Add support for post-types |
| 107 |
if ( is_admin() ) { |
| 108 |
new Custom_Image_Meta_Box( $args ); |
| 109 |
} else { |
| 110 |
new Unique_Headers_Display( array( 'name' => $name ) ); |
| 111 |
} |
| 112 |
|
| 113 |
// Add support for taxonomies |
| 114 |
if ( function_exists( 'get_term_meta' ) ) { |
| 115 |
$args['taxonomies'] = apply_filters( 'unique_headers_taxonomies', array( 'category', 'post_tag' ) ); |
| 116 |
$args['upload_header_image'] = __( 'Upload header image', 'unique-headers' ); |
| 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; |
| 141 |
|