Version Description
Download this release
Release Info
| Developer | ryanhellyer |
| Plugin | |
| Version | 1.0 |
| Comparing to | |
| See all releases | |
Version 1.0
- inc/class-category-header-images.php +174 -0
- inc/class-multi-post-thumbnails.php +343 -0
- inc/class-post-header-images.php +62 -0
- index.php +79 -0
- readme.txt +72 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- scripts/multi-post-thumbnails-admin.js +48 -0
- scripts/my-uploads.js +15 -0
inc/class-category-header-images.php
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Add category specific header images
|
| 5 |
+
*
|
| 6 |
+
* @copyright Copyright (c), Ryan Hellyer
|
| 7 |
+
* @license http://www.gnu.org/licenses/gpl.html GPL
|
| 8 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 9 |
+
* @since 1.0
|
| 10 |
+
*/
|
| 11 |
+
class Category_Header_Images {
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Class constructor
|
| 15 |
+
*
|
| 16 |
+
* Adds methods to appropriate hooks
|
| 17 |
+
*
|
| 18 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 19 |
+
* @since 1.0
|
| 20 |
+
*/
|
| 21 |
+
public function __construct() {
|
| 22 |
+
add_action( 'init', array( $this, 'init' ) );
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Print styles to admin page
|
| 28 |
+
*
|
| 29 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 30 |
+
* @since 1.0
|
| 31 |
+
*/
|
| 32 |
+
public function init() {
|
| 33 |
+
|
| 34 |
+
// Bail out now if taxonomy meta data plugin not installed
|
| 35 |
+
if ( !class_exists( 'Taxonomy_Metadata' ) )
|
| 36 |
+
return;
|
| 37 |
+
|
| 38 |
+
// Add actions
|
| 39 |
+
add_action( 'admin_print_scripts', array( $this, 'print_styles' ) );
|
| 40 |
+
add_action( 'admin_print_scripts', array( $this, 'external_scripts' ) );
|
| 41 |
+
add_action( 'admin_head', array( $this, 'inline_scripts' ) );
|
| 42 |
+
$taxonomy = 'category';
|
| 43 |
+
add_action( $taxonomy . '_edit_form_fields', array( $this, 'extra_fields'), 1 );
|
| 44 |
+
add_action( 'edit_category', array( $this, 'storing_taxonomy_data' ) );
|
| 45 |
+
|
| 46 |
+
// Add filters
|
| 47 |
+
add_filter( 'theme_mod_header_image', array( $this, 'header_image_filter' ) );
|
| 48 |
+
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Print styles to admin page
|
| 53 |
+
*
|
| 54 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 55 |
+
* @since 1.0
|
| 56 |
+
*/
|
| 57 |
+
public function print_styles() {
|
| 58 |
+
|
| 59 |
+
// If on category page, then bail out
|
| 60 |
+
if ( !isset( $_GET['taxonomy'] ) )
|
| 61 |
+
return;
|
| 62 |
+
|
| 63 |
+
wp_enqueue_style( 'thickbox' );
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Print external scripts to admin page
|
| 68 |
+
*
|
| 69 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 70 |
+
* @since 1.0
|
| 71 |
+
*/
|
| 72 |
+
public function external_scripts() {
|
| 73 |
+
|
| 74 |
+
// If on category page, then bail out
|
| 75 |
+
if ( !isset( $_GET['taxonomy'] ) )
|
| 76 |
+
return;
|
| 77 |
+
|
| 78 |
+
wp_enqueue_script( 'media-upload' );
|
| 79 |
+
wp_enqueue_script( 'thickbox' );
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* Print inline scripts to admin page
|
| 84 |
+
*
|
| 85 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 86 |
+
* @since 1.0
|
| 87 |
+
*/
|
| 88 |
+
public function inline_scripts() {
|
| 89 |
+
|
| 90 |
+
// If on category page, then bail out
|
| 91 |
+
if ( !isset( $_GET['taxonomy'] ) )
|
| 92 |
+
return;
|
| 93 |
+
|
| 94 |
+
echo "
|
| 95 |
+
<script>
|
| 96 |
+
jQuery(document).ready(function() {
|
| 97 |
+
jQuery('#upload_image_button').click(function() {
|
| 98 |
+
formfield = jQuery('#upload_image').attr('name');
|
| 99 |
+
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
|
| 100 |
+
return false;
|
| 101 |
+
});
|
| 102 |
+
window.send_to_editor = function(html) {
|
| 103 |
+
imgurl = jQuery('img',html).attr('src');
|
| 104 |
+
jQuery('#upload_image').val(imgurl);
|
| 105 |
+
tb_remove();
|
| 106 |
+
}
|
| 107 |
+
});
|
| 108 |
+
</script>";
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/*
|
| 112 |
+
* Filter for modifying the output of get_header()
|
| 113 |
+
*
|
| 114 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 115 |
+
* @since 1.0
|
| 116 |
+
*/
|
| 117 |
+
function header_image_filter( $url ) {
|
| 118 |
+
|
| 119 |
+
// Bail out now if not in category
|
| 120 |
+
if ( ! is_category() )
|
| 121 |
+
return $url;
|
| 122 |
+
|
| 123 |
+
// Grab current category ID
|
| 124 |
+
$tag_ID = get_query_var( 'cat' );
|
| 125 |
+
|
| 126 |
+
// Grab stored taxonomy header
|
| 127 |
+
$url = get_term_meta( $tag_ID, 'taxonomy-header-image', true );
|
| 128 |
+
|
| 129 |
+
return $url;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* Storing the taxonomy header image selection
|
| 134 |
+
*
|
| 135 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 136 |
+
* @since 1.0
|
| 137 |
+
*/
|
| 138 |
+
public function storing_taxonomy_data() {
|
| 139 |
+
|
| 140 |
+
// Sanitize inputs
|
| 141 |
+
$tag_ID = (int) $_POST['tag_ID'];
|
| 142 |
+
$url = $_POST['taxonomy-header-image'];
|
| 143 |
+
$url = esc_url( $url );
|
| 144 |
+
|
| 145 |
+
update_term_meta( $tag_ID, 'taxonomy-header-image', $url );
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Extra fields
|
| 150 |
+
*
|
| 151 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 152 |
+
* @since 1.0
|
| 153 |
+
*/
|
| 154 |
+
public function extra_fields() {
|
| 155 |
+
$tag_ID = $_GET['tag_ID'];
|
| 156 |
+
$url = get_term_meta( $tag_ID, 'taxonomy-header-image', true );
|
| 157 |
+
|
| 158 |
+
echo '
|
| 159 |
+
<tr valign="top">
|
| 160 |
+
<th scope="row">' . __( 'Upload header image', 'hyper_headers' ) . '</th>
|
| 161 |
+
<td>
|
| 162 |
+
<label for="upload_image">
|
| 163 |
+
<input id="upload_image" type="text" size="36" name="taxonomy-header-image" value="' . $url . '" />
|
| 164 |
+
<input id="upload_image_button" type="button" value="Upload Image" />
|
| 165 |
+
<br />' . __( 'Enter an URL or upload an image for the banner.', 'hyper_headers' ) . '
|
| 166 |
+
<br />
|
| 167 |
+
<img style="width:500px;height:auto;" src="' . $url . '" alt="" />
|
| 168 |
+
</label>
|
| 169 |
+
</td>
|
| 170 |
+
</tr>';
|
| 171 |
+
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
}
|
inc/class-multi-post-thumbnails.php
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/*
|
| 3 |
+
Code abstracted from the Multiple Post Thumbnails plugin by Chris Scott (http://vocecommuncations.com/)
|
| 4 |
+
http://wordpress.org/extend/plugins/multiple-post-thumbnails/
|
| 5 |
+
|
| 6 |
+
Copyright 2010 Chris Scott (cscott@voceconnect.com)
|
| 7 |
+
|
| 8 |
+
This program is free software; you can redistribute it and/or modify
|
| 9 |
+
it under the terms of the GNU General Public License, version 2, as
|
| 10 |
+
published by the Free Software Foundation.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program; if not, write to the Free Software
|
| 19 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if ( !class_exists( 'MultiPostThumbnails' ) ) :
|
| 24 |
+
class MultiPostThumbnails {
|
| 25 |
+
|
| 26 |
+
public function __construct($args = array()) {
|
| 27 |
+
$this->register($args);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* Register a new post thumbnail.
|
| 32 |
+
*
|
| 33 |
+
* Required $args contents:
|
| 34 |
+
*
|
| 35 |
+
* label - The name of the post thumbnail to display in the admin metabox
|
| 36 |
+
*
|
| 37 |
+
* id - Used to build the CSS class for the admin meta box. Needs to be unique and valid in a CSS class selector.
|
| 38 |
+
*
|
| 39 |
+
* Optional $args contents:
|
| 40 |
+
*
|
| 41 |
+
* post_type - The post type to register this thumbnail for. Defaults to post.
|
| 42 |
+
*
|
| 43 |
+
* priority - The admin metabox priority. Defaults to low to show after normal post thumbnail meta box.
|
| 44 |
+
*
|
| 45 |
+
* @param array|string $args See above description.
|
| 46 |
+
* @return void
|
| 47 |
+
*/
|
| 48 |
+
public function register($args = array()) {
|
| 49 |
+
$defaults = array(
|
| 50 |
+
'label' => null,
|
| 51 |
+
'id' => null,
|
| 52 |
+
'post_type' => 'post',
|
| 53 |
+
'priority' => 'low',
|
| 54 |
+
);
|
| 55 |
+
|
| 56 |
+
$args = wp_parse_args($args, $defaults);
|
| 57 |
+
|
| 58 |
+
// Create and set properties
|
| 59 |
+
foreach($args as $k => $v) {
|
| 60 |
+
$this->$k = $v;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// Need these args to be set at a minimum
|
| 64 |
+
if (null === $this->label || null === $this->id) {
|
| 65 |
+
if (WP_DEBUG) {
|
| 66 |
+
trigger_error(sprintf("The 'label' and 'id' values of the 'args' parameter of '%s::%s()' are required", __CLASS__, __FUNCTION__));
|
| 67 |
+
}
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// add theme support if not already added
|
| 72 |
+
if (!current_theme_supports('post-thumbnails')) {
|
| 73 |
+
add_theme_support( 'post-thumbnails' );
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
add_action('add_meta_boxes', array($this, 'add_metabox'));
|
| 77 |
+
add_filter('attachment_fields_to_edit', array($this, 'add_attachment_field'), 20, 2);
|
| 78 |
+
add_action('admin_init', array($this, 'enqueue_admin_scripts'));
|
| 79 |
+
add_action("wp_ajax_set-{$this->post_type}-{$this->id}-thumbnail", array($this, 'set_thumbnail'));
|
| 80 |
+
add_action('delete_attachment', array($this, 'action_delete_attachment'));
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Add admin metabox for thumbnail chooser
|
| 85 |
+
*
|
| 86 |
+
* @return void
|
| 87 |
+
*/
|
| 88 |
+
public function add_metabox() {
|
| 89 |
+
add_meta_box("{$this->post_type}-{$this->id}", __($this->label), array($this, 'thumbnail_meta_box'), $this->post_type, 'side', $this->priority);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Output the thumbnail meta box
|
| 94 |
+
*
|
| 95 |
+
* @return string HTML output
|
| 96 |
+
*/
|
| 97 |
+
public function thumbnail_meta_box() {
|
| 98 |
+
global $post;
|
| 99 |
+
$thumbnail_id = get_post_meta($post->ID, "{$this->post_type}_{$this->id}_thumbnail_id", true);
|
| 100 |
+
echo $this->post_thumbnail_html($thumbnail_id);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* Throw this in the media attachment fields
|
| 105 |
+
*
|
| 106 |
+
* @param string $form_fields
|
| 107 |
+
* @param string $post
|
| 108 |
+
* @return void
|
| 109 |
+
*/
|
| 110 |
+
public function add_attachment_field($form_fields, $post) {
|
| 111 |
+
$calling_post_id = 0;
|
| 112 |
+
if (isset($_GET['post_id']))
|
| 113 |
+
$calling_post_id = absint($_GET['post_id']);
|
| 114 |
+
elseif (isset($_POST) && count($_POST)) // Like for async-upload where $_GET['post_id'] isn't set
|
| 115 |
+
$calling_post_id = $post->post_parent;
|
| 116 |
+
|
| 117 |
+
// check the post type to see if link needs to be added
|
| 118 |
+
$calling_post = get_post($calling_post_id);
|
| 119 |
+
if (is_null($calling_post) || $calling_post->post_type != $this->post_type) {
|
| 120 |
+
return $form_fields;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
$ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$calling_post_id}");
|
| 124 |
+
$link = sprintf('<a id="%4$s-%1$s-thumbnail-%2$s" class="%1$s-thumbnail" href="#" onclick="MultiPostThumbnailsSetAsThumbnail(\'%2$s\', \'%1$s\', \'%4$s\', \'%5$s\');return false;">Set as %3$s</a>', $this->id, $post->ID, $this->label, $this->post_type, $ajax_nonce);
|
| 125 |
+
$form_fields["{$this->post_type}-{$this->id}-thumbnail"] = array(
|
| 126 |
+
'label' => $this->label,
|
| 127 |
+
'input' => 'html',
|
| 128 |
+
'html' => $link);
|
| 129 |
+
return $form_fields;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
/**
|
| 133 |
+
* Enqueue admin JavaScripts
|
| 134 |
+
*
|
| 135 |
+
* @return void
|
| 136 |
+
*/
|
| 137 |
+
public function enqueue_admin_scripts() {
|
| 138 |
+
|
| 139 |
+
// Bail out now if not on edit post/page page
|
| 140 |
+
if ( empty( $_GET['post'] ) )
|
| 141 |
+
return;
|
| 142 |
+
|
| 143 |
+
// Enqueue the script
|
| 144 |
+
wp_enqueue_script(
|
| 145 |
+
'featured-image-custom',
|
| 146 |
+
UNIQUEHEADERS_URL . '/scripts/multi-post-thumbnails-admin.js',
|
| 147 |
+
array(
|
| 148 |
+
'jquery'
|
| 149 |
+
)
|
| 150 |
+
);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Deletes the post meta data for posts when an attachment used as a
|
| 155 |
+
* multiple post thumbnail is deleted from the Media Libray
|
| 156 |
+
*
|
| 157 |
+
* @global object $wpdb
|
| 158 |
+
* @param int $post_id
|
| 159 |
+
*/
|
| 160 |
+
public function action_delete_attachment($post_id) {
|
| 161 |
+
global $wpdb;
|
| 162 |
+
$meta_key = "{$this->post_type}_{$this->id}_thumbnail_id";
|
| 163 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '%s' AND meta_value = %d", $meta_key, $post_id ));
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
private function plugins_url($relative_path, $plugin_path) {
|
| 167 |
+
$template_dir = get_template_directory();
|
| 168 |
+
|
| 169 |
+
foreach ( array('template_dir', 'plugin_path') as $var ) {
|
| 170 |
+
$$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs
|
| 171 |
+
$$var = preg_replace('|/+|', '/', $$var);
|
| 172 |
+
}
|
| 173 |
+
if(0 === strpos($plugin_path, $template_dir)) {
|
| 174 |
+
$url = get_template_directory_uri();
|
| 175 |
+
$folder = str_replace($template_dir, '', dirname($plugin_path));
|
| 176 |
+
if ( '.' != $folder ) {
|
| 177 |
+
$url .= '/' . ltrim($folder, '/');
|
| 178 |
+
}
|
| 179 |
+
if ( !empty($relative_path) && is_string($relative_path) && strpos($relative_path, '..') === false ) {
|
| 180 |
+
$url .= '/' . ltrim($relative_path, '/');
|
| 181 |
+
}
|
| 182 |
+
return $url;
|
| 183 |
+
} else {
|
| 184 |
+
return plugins_url($relative_path, $plugin_path);
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/**
|
| 189 |
+
* Check if post has an image attached.
|
| 190 |
+
*
|
| 191 |
+
* @param string $post_type The post type.
|
| 192 |
+
* @param string $id The id used to register the thumbnail.
|
| 193 |
+
* @param string $post_id Optional. Post ID.
|
| 194 |
+
* @return bool Whether post has an image attached.
|
| 195 |
+
*/
|
| 196 |
+
public static function has_post_thumbnail($post_type, $id, $post_id = null) {
|
| 197 |
+
if (null === $post_id) {
|
| 198 |
+
$post_id = get_the_ID();
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
if (!$post_id) {
|
| 202 |
+
return false;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
return get_post_meta($post_id, "{$post_type}_{$id}_thumbnail_id", true);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* Display Post Thumbnail.
|
| 210 |
+
*
|
| 211 |
+
* @param string $post_type The post type.
|
| 212 |
+
* @param string $thumb_id The id used to register the thumbnail.
|
| 213 |
+
* @param string $post_id Optional. Post ID.
|
| 214 |
+
* @param int $size Optional. Image size. Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );.
|
| 215 |
+
* @param string|array $attr Optional. Query string or array of attributes.
|
| 216 |
+
* @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
|
| 217 |
+
*/
|
| 218 |
+
public static function the_post_thumbnail($post_type, $thumb_id, $post_id = null, $size = 'post-thumbnail', $attr = '', $link_to_original = false) {
|
| 219 |
+
echo self::get_the_post_thumbnail($post_type, $thumb_id, $post_id, $size, $attr, $link_to_original);
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
/**
|
| 223 |
+
* Retrieve Post Thumbnail.
|
| 224 |
+
*
|
| 225 |
+
* @param string $post_type The post type.
|
| 226 |
+
* @param string $thumb_id The id used to register the thumbnail.
|
| 227 |
+
* @param int $post_id Optional. Post ID.
|
| 228 |
+
* @param string $size Optional. Image size. Defaults to 'thumbnail'.
|
| 229 |
+
* @param bool $link_to_original Optional. Wrap link to original image around thumbnail?
|
| 230 |
+
* @param string|array $attr Optional. Query string or array of attributes.
|
| 231 |
+
*/
|
| 232 |
+
public static function get_the_post_thumbnail($post_type, $thumb_id, $post_id = NULL, $size = 'post-thumbnail', $attr = '' , $link_to_original = false) {
|
| 233 |
+
global $id;
|
| 234 |
+
$post_id = (NULL === $post_id) ? get_the_ID() : $post_id;
|
| 235 |
+
$post_thumbnail_id = self::get_post_thumbnail_id($post_type, $thumb_id, $post_id);
|
| 236 |
+
$size = apply_filters("{$post_type}_{$post_id}_thumbnail_size", $size);
|
| 237 |
+
if ($post_thumbnail_id) {
|
| 238 |
+
do_action("begin_fetch_multi_{$post_type}_thumbnail_html", $post_id, $post_thumbnail_id, $size); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
|
| 239 |
+
$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
|
| 240 |
+
do_action("end_fetch_multi_{$post_type}_thumbnail_html", $post_id, $post_thumbnail_id, $size);
|
| 241 |
+
} else {
|
| 242 |
+
$html = '';
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
if ($link_to_original && $html) {
|
| 246 |
+
$html = sprintf('<a href="%s">%s</a>', wp_get_attachment_url($post_thumbnail_id), $html);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
return apply_filters("{$post_type}_{$thumb_id}_thumbnail_html", $html, $post_id, $post_thumbnail_id, $size, $attr);
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* Retrieve Post Thumbnail ID.
|
| 254 |
+
*
|
| 255 |
+
* @param string $post_type The post type.
|
| 256 |
+
* @param string $id The id used to register the thumbnail.
|
| 257 |
+
* @param int $post_id Post ID.
|
| 258 |
+
* @return int
|
| 259 |
+
*/
|
| 260 |
+
public static function get_post_thumbnail_id($post_type, $id, $post_id) {
|
| 261 |
+
return get_post_meta($post_id, "{$post_type}_{$id}_thumbnail_id", true);
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
/**
|
| 265 |
+
*
|
| 266 |
+
* @param string $post_type The post type.
|
| 267 |
+
* @param string $id The id used to register the thumbnail.
|
| 268 |
+
* @param int $post_id Optional. The post ID. If not set, will attempt to get it.
|
| 269 |
+
* @return mixed Thumbnail url or false if the post doesn't have a thumbnail for the given post type, and id.
|
| 270 |
+
*/
|
| 271 |
+
public static function get_post_thumbnail_url($post_type, $id, $post_id = 0) {
|
| 272 |
+
if (!$post_id) {
|
| 273 |
+
$post_id = get_the_ID();
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
$post_thumbnail_id = self::get_post_thumbnail_id($post_type, $id, $post_id);
|
| 277 |
+
|
| 278 |
+
return wp_get_attachment_url($post_thumbnail_id);
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* Output the post thumbnail HTML for the metabox and AJAX callbacks
|
| 283 |
+
*
|
| 284 |
+
* @param string $thumbnail_id The thumbnail's post ID.
|
| 285 |
+
* @return string HTML
|
| 286 |
+
*/
|
| 287 |
+
private function post_thumbnail_html($thumbnail_id = null) {
|
| 288 |
+
global $content_width, $_wp_additional_image_sizes, $post_ID;
|
| 289 |
+
|
| 290 |
+
$set_thumbnail_link = sprintf('<p class="hide-if-no-js"><a title="%1$s" href="%2$s" id="set-%3$s-%4$s-thumbnail" class="thickbox">%%s</a></p>', esc_attr__( "Set {$this->label}" ), get_upload_iframe_src('image'), $this->post_type, $this->id);
|
| 291 |
+
$content = sprintf($set_thumbnail_link, esc_html__( "Set {$this->label}" ));
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
if ($thumbnail_id && get_post($thumbnail_id)) {
|
| 295 |
+
$old_content_width = $content_width;
|
| 296 |
+
$content_width = 266;
|
| 297 |
+
if ( !isset($_wp_additional_image_sizes["{$this->post_type}-{$this->id}-thumbnail"]))
|
| 298 |
+
$thumbnail_html = wp_get_attachment_image($thumbnail_id, array($content_width, $content_width));
|
| 299 |
+
else
|
| 300 |
+
$thumbnail_html = wp_get_attachment_image($thumbnail_id, "{$this->post_type}-{$this->id}-thumbnail");
|
| 301 |
+
if (!empty($thumbnail_html)) {
|
| 302 |
+
$ajax_nonce = wp_create_nonce("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
|
| 303 |
+
$content = sprintf($set_thumbnail_link, $thumbnail_html);
|
| 304 |
+
$content .= sprintf('<p class="hide-if-no-js"><a href="#" id="remove-%1$s-%2$s-thumbnail" onclick="MultiPostThumbnailsRemoveThumbnail(\'%2$s\', \'%1$s\', \'%4$s\');return false;">%3$s</a></p>', $this->post_type, $this->id, esc_html__( "Remove {$this->label}" ), $ajax_nonce);
|
| 305 |
+
}
|
| 306 |
+
$content_width = $old_content_width;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
return $content;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
/**
|
| 313 |
+
* Set/remove the post thumbnail. AJAX handler.
|
| 314 |
+
*
|
| 315 |
+
* @return string Updated post thumbnail HTML.
|
| 316 |
+
*/
|
| 317 |
+
public function set_thumbnail() {
|
| 318 |
+
global $post_ID; // have to do this so get_upload_iframe_src() can grab it
|
| 319 |
+
$post_ID = intval($_POST['post_id']);
|
| 320 |
+
if ( !current_user_can('edit_post', $post_ID))
|
| 321 |
+
die('-1');
|
| 322 |
+
$thumbnail_id = intval($_POST['thumbnail_id']);
|
| 323 |
+
|
| 324 |
+
check_ajax_referer("set_post_thumbnail-{$this->post_type}-{$this->id}-{$post_ID}");
|
| 325 |
+
|
| 326 |
+
if ($thumbnail_id == '-1') {
|
| 327 |
+
delete_post_meta($post_ID, "{$this->post_type}_{$this->id}_thumbnail_id");
|
| 328 |
+
die($this->post_thumbnail_html(null));
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
if ($thumbnail_id && get_post($thumbnail_id)) {
|
| 332 |
+
$thumbnail_html = wp_get_attachment_image($thumbnail_id, 'thumbnail');
|
| 333 |
+
if (!empty($thumbnail_html)) {
|
| 334 |
+
update_post_meta($post_ID, "{$this->post_type}_{$this->id}_thumbnail_id", $thumbnail_id);
|
| 335 |
+
die($this->post_thumbnail_html($thumbnail_id));
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
die('0');
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
}
|
| 343 |
+
endif;
|
inc/class-post-header-images.php
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Add post specific header images
|
| 5 |
+
*
|
| 6 |
+
* @copyright Copyright (c), Ryan Hellyer
|
| 7 |
+
* @license http://www.gnu.org/licenses/gpl.html GPL
|
| 8 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 9 |
+
* @since 1.0
|
| 10 |
+
*/
|
| 11 |
+
class Post_Header_Images {
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Class constructor
|
| 15 |
+
*
|
| 16 |
+
* Adds methods to appropriate hooks
|
| 17 |
+
*
|
| 18 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 19 |
+
* @since 1.0
|
| 20 |
+
*/
|
| 21 |
+
public function __construct() {
|
| 22 |
+
|
| 23 |
+
// Add filters
|
| 24 |
+
add_filter( 'theme_mod_header_image', array( $this, 'header_image_filter' ) );
|
| 25 |
+
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/*
|
| 29 |
+
* Filter for modifying the output of get_header()
|
| 30 |
+
*
|
| 31 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 32 |
+
* @since 1.0
|
| 33 |
+
* @param string $url The header image URL
|
| 34 |
+
* @global $post Used for accessing the current post/page ID
|
| 35 |
+
* @return string
|
| 36 |
+
*/
|
| 37 |
+
public function header_image_filter( $url ) {
|
| 38 |
+
|
| 39 |
+
global $post;
|
| 40 |
+
|
| 41 |
+
// Bail out now if not in post or page
|
| 42 |
+
if ( !is_single() && !is_page() )
|
| 43 |
+
return $url;
|
| 44 |
+
|
| 45 |
+
// Grab current post ID
|
| 46 |
+
$post_ID = $post->ID;
|
| 47 |
+
|
| 48 |
+
// Grab the post thumbnail ID
|
| 49 |
+
$post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id( 'post', 'custom-header', $post_ID );
|
| 50 |
+
|
| 51 |
+
// If no post thumbnail ID set, then use default
|
| 52 |
+
if ( '' == $post_thumbnail_id )
|
| 53 |
+
return $url;
|
| 54 |
+
|
| 55 |
+
// Grab URL from WordPress
|
| 56 |
+
$url = wp_get_attachment_image_src( $post_thumbnail_id, 'full' );
|
| 57 |
+
$url = $url[0];
|
| 58 |
+
|
| 59 |
+
return $url;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
}
|
index.php
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/*
|
| 3 |
+
Plugin Name: Unique Headers
|
| 4 |
+
Plugin URI: http://pixopoint.com/
|
| 5 |
+
Description: Unique Headers
|
| 6 |
+
Version: 1.0
|
| 7 |
+
Author: Ryan Hellyer / Metronet
|
| 8 |
+
Author URI: http://pixopoint.com/
|
| 9 |
+
|
| 10 |
+
------------------------------------------------------------------------
|
| 11 |
+
Copyright Ryan Hellyer
|
| 12 |
+
|
| 13 |
+
This program is free software; you can redistribute it and/or modify
|
| 14 |
+
it under the terms of the GNU General Public License as published by
|
| 15 |
+
the Free Software Foundation; either version 2 of the License, or
|
| 16 |
+
(at your option) any later version.
|
| 17 |
+
|
| 18 |
+
This program is distributed in the hope that it will be useful,
|
| 19 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 20 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 21 |
+
GNU General Public License for more details.
|
| 22 |
+
|
| 23 |
+
You should have received a copy of the GNU General Public License
|
| 24 |
+
along with this program; if not, write to the Free Software
|
| 25 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 26 |
+
*/
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Do not continue processing since file was called directly
|
| 31 |
+
*
|
| 32 |
+
* @since 1.0
|
| 33 |
+
* @author Ryan Hellyer <ryan@metronet.no>
|
| 34 |
+
*/
|
| 35 |
+
if ( !defined( 'ABSPATH' ) )
|
| 36 |
+
die( 'Eh! What you doin in here?' );
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Load classes
|
| 40 |
+
*
|
| 41 |
+
* @since 1.0
|
| 42 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 43 |
+
*/
|
| 44 |
+
require( 'inc/class-category-header-images.php' );
|
| 45 |
+
require( 'inc/class-post-header-images.php' );
|
| 46 |
+
require( 'inc/class-multi-post-thumbnails.php' );
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Define constants
|
| 50 |
+
*
|
| 51 |
+
* @since 1.0
|
| 52 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 53 |
+
*/
|
| 54 |
+
define( 'UNIQUEHEADERS_DIR', dirname( __FILE__ ) . '/' ); // Plugin folder DIR
|
| 55 |
+
define( 'UNIQUEHEADERS_URL', WP_PLUGIN_URL . '/' . basename( UNIQUEHEADERS_DIR ) . '' ); // Plugin folder URL
|
| 56 |
+
define( 'UNIQUEHEADERS_OPTION', 'hyper-headers' );
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Instantiate classes
|
| 60 |
+
*
|
| 61 |
+
* @since 1.0
|
| 62 |
+
* @author Ryan Hellyer <ryan@pixopoint.com>
|
| 63 |
+
*/
|
| 64 |
+
new Category_Header_Images();
|
| 65 |
+
new Post_Header_Images();
|
| 66 |
+
new MultiPostThumbnails(
|
| 67 |
+
array(
|
| 68 |
+
'label' => __( 'Custom Header', 'unique_headers' ),
|
| 69 |
+
'id' => 'custom-header',
|
| 70 |
+
'post_type' => 'post'
|
| 71 |
+
)
|
| 72 |
+
);
|
| 73 |
+
new MultiPostThumbnails(
|
| 74 |
+
array(
|
| 75 |
+
'label' => __( 'Custom Header', 'unique_headers' ),
|
| 76 |
+
'id' => 'custom-header',
|
| 77 |
+
'post_type' => 'page'
|
| 78 |
+
)
|
| 79 |
+
);
|
readme.txt
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=== Unique Headers ===
|
| 2 |
+
Contributors: ryanhellyer, metronet
|
| 3 |
+
Tags: header, metronet, pixopoint, headers, image, header-image, header-images, taxonomy, posts, pages, taxonomies, post, page, unique
|
| 4 |
+
Donate link: http://pixopoint.com/donate/
|
| 5 |
+
Requires at least: 3.4
|
| 6 |
+
Stable tag: 1.0
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
Adds the ability to use unique custom headers on individual pages, posts or categories.
|
| 10 |
+
|
| 11 |
+
== Description ==
|
| 12 |
+
|
| 13 |
+
The <a href="http://pixopoint.com/products/unique-headers/">Unique Headers Plugin</a> adds the ability to use unique custom headers on
|
| 14 |
+
individual pages, posts or categories. This plugin makes use of the excellent <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a> for handling header images for categories.
|
| 15 |
+
|
| 16 |
+
The creation of this plugin was sponsored by the <a href="http://www.dss.dep.no/">Norwegian Government Administration Services (G.A.S.)</a> and <a href="http://metronet.no/">Metronet</a>.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
== Installation ==
|
| 20 |
+
|
| 21 |
+
After you've downloaded and extracted the files:
|
| 22 |
+
|
| 23 |
+
1. Upload the complete 'unique-headers' folder to the '/wp-content/plugins/' directory OR install via the plugin installer
|
| 24 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
| 25 |
+
3. Install and activate the <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a> to add support for changing images for category listings.
|
| 26 |
+
4. And yer done!
|
| 27 |
+
|
| 28 |
+
Now you will see sections for changing your custom headers on the posts, pages and category listings.
|
| 29 |
+
|
| 30 |
+
Visit the <a href="http://pixopoint.com/products/unique-headers/">Unique Headers Plugin</a> for more information.
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
== Frequently Asked Questions ==
|
| 34 |
+
|
| 35 |
+
= I can't change the image on my categories, what's wrong? =
|
| 36 |
+
|
| 37 |
+
You need to install the <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a>. WordPress does not support
|
| 38 |
+
the taxonomy meta data which this plugin needs to use to store the custom header image URL. As soon as you install that plugin, the category image
|
| 39 |
+
functionality should beign working.
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
= Where's the settings page? =
|
| 43 |
+
|
| 44 |
+
There isn't one.
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
= Does it work in older versions of WordPress? =
|
| 48 |
+
|
| 49 |
+
Probably, but we only support the latest version of WordPress.
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
= I need custom functionality. Can we pay you to build it for us? =
|
| 53 |
+
|
| 54 |
+
No, I'm too busy. Having said that, if you want to pay me a small fortune then I could <a href="http://pixopoint.com/contact/">probably be persuaded</a>.
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
== Screenshots ==
|
| 58 |
+
|
| 59 |
+
1. The custom image uploader for posts/pages, when using the <a href="http://pixopoint.com/products/unique-headers/">Unique Headers Plugin</a>
|
| 60 |
+
2. The custom image uploader for categories, when using the <a href="http://pixopoint.com/products/unique-headers/">Unique Headers Plugin</a> and <a href="http://wordpress.org/extend/plugins/taxonomy-metadata/">Taxonomy Metadata plugin</a>
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
== Changelog ==
|
| 64 |
+
|
| 65 |
+
Version 1.0: Initial release<br />
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
= Credits =
|
| 69 |
+
|
| 70 |
+
Thanks to the following for help with the development of this plugin:<br />
|
| 71 |
+
* <a href="http://metronet.no/">Metronet</a> - Plugin sponsor<br />
|
| 72 |
+
* <a href="http://www.dss.dep.no/">Norwegian Government Administration Services (G.A.S.)</a> - Plugin sponsor<br />
|
screenshot-1.png
ADDED
|
Binary file
|
screenshot-2.png
ADDED
|
Binary file
|
scripts/multi-post-thumbnails-admin.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function MultiPostThumbnailsSetThumbnailHTML(html, id, post_type){
|
| 2 |
+
jQuery('.inside', '#' + post_type + '-' + id).html(html);
|
| 3 |
+
};
|
| 4 |
+
|
| 5 |
+
function MultiPostThumbnailsSetThumbnailID(thumb_id, id, post_type){
|
| 6 |
+
var field = jQuery('input[value=_' + post_type + '_' + id + '_thumbnail_id]', '#list-table');
|
| 7 |
+
if ( field.size() > 0 ) {
|
| 8 |
+
jQuery('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(thumb_id);
|
| 9 |
+
}
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
function MultiPostThumbnailsRemoveThumbnail(id, post_type, nonce){
|
| 13 |
+
jQuery.post(ajaxurl, {
|
| 14 |
+
action:'set-' + post_type + '-' + id + '-thumbnail', post_id: jQuery('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
|
| 15 |
+
}, function(str){
|
| 16 |
+
if ( str == '0' ) {
|
| 17 |
+
alert( setPostThumbnailL10n.error );
|
| 18 |
+
} else {
|
| 19 |
+
MultiPostThumbnailsSetThumbnailHTML(str, id, post_type);
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
);
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
function MultiPostThumbnailsSetAsThumbnail(thumb_id, id, post_type, nonce){
|
| 27 |
+
var $link = jQuery('a#' + post_type + '-' + id + '-thumbnail-' + thumb_id);
|
| 28 |
+
|
| 29 |
+
$link.text( setPostThumbnailL10n.saving );
|
| 30 |
+
jQuery.post(ajaxurl, {
|
| 31 |
+
action:'set-' + post_type + '-' + id + '-thumbnail', post_id: post_id, thumbnail_id: thumb_id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
|
| 32 |
+
}, function(str){
|
| 33 |
+
var win = window.dialogArguments || opener || parent || top;
|
| 34 |
+
$link.text( setPostThumbnailL10n.setThumbnail );
|
| 35 |
+
if ( str == '0' ) {
|
| 36 |
+
alert( setPostThumbnailL10n.error );
|
| 37 |
+
} else {
|
| 38 |
+
$link.show();
|
| 39 |
+
$link.text( setPostThumbnailL10n.done );
|
| 40 |
+
$link.fadeOut( 2000, function() {
|
| 41 |
+
jQuery('tr.' + post_type + '-' + id + '-thumbnail').hide();
|
| 42 |
+
});
|
| 43 |
+
win.MultiPostThumbnailsSetThumbnailID(thumb_id, id, post_type);
|
| 44 |
+
win.MultiPostThumbnailsSetThumbnailHTML(str, id, post_type);
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
);
|
| 48 |
+
}
|
scripts/my-uploads.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jQuery(document).ready(function() {
|
| 2 |
+
|
| 3 |
+
jQuery('#upload_image_button').click(function() {
|
| 4 |
+
formfield = jQuery('#upload_image').attr('name');
|
| 5 |
+
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
|
| 6 |
+
return false;
|
| 7 |
+
});
|
| 8 |
+
|
| 9 |
+
window.send_to_editor = function(html) {
|
| 10 |
+
imgurl = jQuery('img',html).attr('src');
|
| 11 |
+
jQuery('#upload_image').val(imgurl);
|
| 12 |
+
tb_remove();
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
});
|
