Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taxonomy images error handling #32

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6c5b5c4
Add support for WordPress 3.5+ media modal.
benhuson Oct 14, 2014
37251c0
Spanish Translation for the plugin
davidperezgar Sep 29, 2015
bbc0352
Make images retina sized
jazbek Mar 22, 2014
76e79e6
Stop using deprecated image_resize() function
jazbek Mar 22, 2014
87e6bbe
Set background in modal window to light gray, to avoid color switch
jazbek Mar 23, 2014
06f21da
Fix modal size and default to library tab.
benhuson Oct 8, 2015
e888a32
Merge branch '3.8-compat' into release
benhuson Oct 8, 2015
220f307
Fix 'remove' icon not reshowing by hiding using a class.
benhuson Oct 8, 2015
9fdb230
New style media modal requires WordPress 3.5
benhuson Oct 8, 2015
e837c7d
Merge branch 'media-modal' into release.
benhuson Oct 8, 2015
c405a19
Escape plugin page links text output.
benhuson Oct 8, 2015
b0a3dab
Re-do and fix making images retina sized in admin.
benhuson Oct 8, 2015
3305b88
Adhere to WordPress CSS coding standards and best practices.
benhuson Oct 8, 2015
5a8ec99
Update function names in code snippets to be based on plugin slug.
benhuson Oct 8, 2015
a6283ea
Use 'wp_enqueue_scripts' action instead of deprecated 'wp_print_style…
benhuson Oct 8, 2015
9fbe16d
Add closing slash to <input /> tag to adhere to WordPress HTML code s…
benhuson Oct 8, 2015
e36d114
Update "Set featured image" string to be the same case as for post fe…
benhuson Oct 8, 2015
f131acf
Update .pot file.
benhuson Oct 8, 2015
0b24775
Move JavaScript files to JS folder.
benhuson Oct 9, 2015
3cd058b
Move stylesheets to CSS folder.
benhuson Oct 9, 2015
d2f09ad
Don't make minimum WordPress requirement 3.5 just yet. There are chec…
benhuson Oct 13, 2015
1558e7f
Add retina default.png image.
benhuson Oct 13, 2015
5dd8e09
Use of screen_icon() deprecated since WordPress 3.8
benhuson Oct 13, 2015
6d211ed
Confirmed backwards-compatible as far as WordPress 3.4
benhuson Oct 13, 2015
339a832
Re-color default image and control icons to be more in-keeping with r…
benhuson Oct 13, 2015
731674f
Update version and changelog.
benhuson Oct 13, 2015
6101bc6
Add readme screenshots.
benhuson Oct 15, 2015
6456480
Add Wordpress.org icon and banner images.
benhuson Oct 15, 2015
d6b2e70
Update plugin info.
benhuson Oct 13, 2015
b0de00c
Update readme files.
benhuson Oct 20, 2015
d21b2f8
Add @since docblock for new functions in version 0.9.
benhuson Oct 20, 2015
1778a1e
Remove duplicate Author header info.
benhuson Oct 22, 2015
82354ee
Update screenshot 3 image.
benhuson Nov 10, 2015
2788e98
Stable tag 0.9
benhuson Nov 11, 2015
c17c0ce
Adjust WordPress.org banner images to key focus doesn't clash with RT…
benhuson Nov 12, 2015
095b143
Couple of tweaks to readme.txt including adding a new donate link.
benhuson Nov 12, 2015
c5a2543
Yoda statements.
benhuson Nov 12, 2015
24db942
Add curly braces to if statements.
benhuson Nov 12, 2015
ca1f459
Whitespace adjustments.
benhuson Nov 12, 2015
27bd3b5
Enable add/remove JavaScript click handlers on newly added terms.
benhuson Nov 17, 2015
4278229
Add Taxonomy_Images_Error class.
benhuson Nov 17, 2015
dd34d7b
Use Taxonomy_Images_Error class instead of trigger_error() to check f…
benhuson Nov 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 23 additions & 18 deletions code-snippets.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
<?php

/**
* Tests for various filters.
* @package Taxonomy Images
* @subpackage Code Snippets
*
* The following are a series of example tests to check the output
* of the Taxonomy Images filters.
*/



// Don't actually output any of this!
exit;



/*
/**
* Append the term images to content + excerpt.
*/
function mytheme_append_the_term_images( $content ) {
function taxonomy_images_test_theme_append_the_term_images( $content ) {
return $content . apply_filters( 'taxonomy-images-list-the-terms', '', array(
'image_size' => 'detail',
) );
) );
}
add_filter( 'the_content', 'mytheme_append_the_term_images' );
add_filter( 'the_excerpt', 'mytheme_append_the_term_images' );
add_filter( 'the_content', 'taxonomy_images_test_theme_append_the_term_images' );
add_filter( 'the_excerpt', 'taxonomy_images_test_theme_append_the_term_images' );



/*
/**
* Queried Term Image.
*
* Return html markup representing the image associated with the
Expand All @@ -41,7 +48,7 @@ function mytheme_append_the_term_images( $content ) {

/* Inside a yellow box */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'before' => '<div style="padding:20px;background-color:yellow;">',
'before' => '<div style="padding: 20px; background-color: yellow;">',
'after' => '</div>',
) );
print '<h2>taxonomy-images-queried-term-image - custom wrapper element.</h2>';
Expand All @@ -51,15 +58,15 @@ function mytheme_append_the_term_images( $content ) {
/* Medium Size */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'medium',
) );
) );
print '<h2>taxonomy-images-queried-term-image - medium image size</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';


/* Unrecognized size */
$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array(
'image_size' => 'this-is-probably-not-a-real-image-size',
) );
) );
print '<h2>taxonomy-images-queried-term-image - unknown image size</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';

Expand All @@ -71,14 +78,14 @@ function mytheme_append_the_term_images( $content ) {
'class' => 'my-class-list bunnies turtles',
'src' => 'this-is-where-the-image-lives.png',
'title' => 'Custom Title',
),
) );
),
) );
print '<h2>taxonomy-images-queried-term-image - custom attributes</h2>';
print '<pre>' . htmlentities( $img ) . '</pre>';



/*
/**
* Queried Term Image ID.
*
* Return the id of the image associated with the currently
Expand All @@ -89,14 +96,13 @@ function mytheme_append_the_term_images( $content ) {
* apply_filters() will return it's second parameter.
*/
$img = apply_filters( 'taxonomy-images-queried-term-image-id', 'PLEASE INSTALL PLUGIN' );

print '<h2>taxonomy-images-queried-term-image-id</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';




/*
/**
* Queried Term Image Object.
*
* Return an object representing the image associated with the
Expand All @@ -107,14 +113,13 @@ function mytheme_append_the_term_images( $content ) {
* apply_filters() will return it's second parameter.
*/
$img = apply_filters( 'taxonomy-images-queried-term-image-object', 'PLEASE INSTALL PLUGIN' );

print '<h2>taxonomy-images-queried-term-image-object</h2>';
print '<pre>'; var_dump( $img ); print '</pre>';




/*
/**
* Queried Term Image URL.
*
* Return a url to the image associated with the current queried
Expand Down Expand Up @@ -150,7 +155,7 @@ function mytheme_append_the_term_images( $content ) {



/*
/**
* Queried Term Image Data.
*
* Return an array of data about the image associated with the current
Expand Down
Binary file modified controls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 26 additions & 3 deletions admin.css → css/admin.css
Original file line number Diff line number Diff line change
@@ -1,57 +1,80 @@

.taxonomy-images-modal .create-association .term-name {
font-style: italic;
}

.taxonomy-images-modal .create-association {
display: inline;
}

.taxonomy-images-modal .remove-association {
color: #bc0b0b;
cursor: pointer;
display: none;
text-decoration: underline;
}

.taxonomy-images-modal #tab-type_url,
.taxonomy-images-modal .savesend input {
display: none !important;
}

.taxonomy-image-thumbnail {
display: block;
margin-bottom: 3px;
overflow: hidden;
text-align: center;
width: 77px;
height: 77px;
width: 75px;
height: 75px;
}

.taxonomy-image-thumbnail img {
width: 75px;
height: 75px;
}

.taxonomy-image-control .control {
background: url( controls.png );
background: url( ../controls.png );
background-repeat: no-repeat;
display: block;
float: left;
text-indent: -9999em;
width: 15px;
height: 15px;
}

.taxonomy-image-control .control:hover {
cursor: pointer;
}

.taxonomy-image-control .upload {
background-position: 0 0;
}

.taxonomy-image-control .upload:hover {
background-position: -15px 0;
}

.taxonomy-image-control .remove {
background-position: -30px 0;
}

.taxonomy-image-control .remove:hover {
background-position: -45px 0;
}

.taxonomy-image-control .library {
background-position: -60px 0;
}

.taxonomy-image-control .hide {
visibility: hidden;
}

.taxonomy-image-control .show {
visibility: visible;
}

body.taxonomy-images-modal {
background: #f1f1f1 !important;
}
14 changes: 9 additions & 5 deletions style.css → css/style.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

.taxonomy-images-the-terms {
margin: 10px 0;
padding: 0;
zoom: 1;
}

.taxonomy-images-the-terms:before,
.taxonomy-images-the-terms:after {
clear: both;
Expand All @@ -11,14 +13,16 @@
height: 0;
visibility: hidden;
}

.taxonomy-images-the-terms li,
.taxonomy-images-the-terms a,
.taxonomy-images-the-terms img {
float:left;
margin:0;
padding:0;
float: left;
margin: 0;
padding: 0;
}

.taxonomy-images-the-terms li {
list-style-type:none;
margin:0 10px 10px 0;
list-style-type: none;
margin: 0 10px 10px 0;
}
Binary file modified default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 27 additions & 20 deletions deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
/**
* Deprecated Shortcode.
*
* @return void
* @access private
* @deprecated Deprecated since version 0.7
*
* @return void
* @access private
*/
function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { // DEPRECATED
function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) {
$o = '';
$defaults = array(
'taxonomy' => 'category',
'size' => 'detail',
'template' => 'list'
);
);

extract( shortcode_atts( $defaults, $atts ) );

/* No taxonomy defined return an html comment. */
if ( ! taxonomy_exists( $taxonomy ) ) {
$tax = strip_tags( trim( $taxonomy ) );
return '<!-- taxonomy_image_plugin error: Taxonomy "' . $taxonomy . '" is not defined.-->';
return '<!-- taxonomy_image_plugin error: Taxonomy "' . esc_html( $taxonomy ) . '" is not defined.-->';
}

$terms = get_terms( $taxonomy );
Expand All @@ -34,20 +36,19 @@ function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { // DEP

$img = '';
if ( array_key_exists( $term->term_taxonomy_id, $associations ) ) {
$img = wp_get_attachment_image( $associations[$term->term_taxonomy_id], 'detail', false );
$img = wp_get_attachment_image( $associations[ $term->term_taxonomy_id ], 'detail', false );
}

if( $template === 'grid' ) {
$o.= "\n\t" . '<div class="taxonomy_image_plugin-' . $template . '">';
$o.= "\n\t\t" . '<a style="float:left;" title="' . $title_attr . '" href="' . $url . '">' . $img . '</a>';
$o.= "\n\t" . '</div>';
}
else {
$o.= "\n\t\t" . '<a title="' . $title_attr . '" href="' . $url . '">' . $img . '</a>';;
$o.= "\n\t\t" . '<h2 style="clear:none;margin-top:0;padding-top:0;line-height:1em;"><a href="' . $url . '">' . $title . '</a></h2>';
$o.= $description;
$o.= "\n\t" . '<div style="clear:both;height:1.5em"></div>';
$o.= "\n";
if ( 'grid' == $template ) {
$o .= "\n\t" . '<div class="taxonomy_image_plugin-' . $template . '">';
$o .= "\n\t\t" . '<a style="float: left;" title="' . $title_attr . '" href="' . $url . '">' . $img . '</a>';
$o .= "\n\t" . '</div>';
} else {
$o .= "\n\t\t" . '<a title="' . $title_attr . '" href="' . $url . '">' . $img . '</a>';;
$o .= "\n\t\t" . '<h2 style="clear: none; margin-top: 0; padding-top: 0; line-height: 1em;"><a href="' . $url . '">' . $title . '</a></h2>';
$o .= $description;
$o .= "\n\t" . '<div style="clear: both; height: 1.5em;"></div>';
$o .= "\n";
}
}
}
Expand All @@ -61,29 +62,34 @@ function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { // DEP
* of this plugin 0.5 and under. Please do not use any methods or
* properties directly in your theme.
*
* @access private This class is deprecated. Do not use!!!
* @deprecated Deprecated since version 0.5
* @access private
*/
class taxonomy_images_plugin {

public $settings = array();

public function __construct() {
$this->settings = taxonomy_image_plugin_get_associations();
add_action( 'taxonomy_image_plugin_print_image_html', array( &$this, 'print_image_html' ), 1, 3 );
}

public function get_thumb( $id ) {
return taxonomy_image_plugin_get_image_src( $id );
}

public function print_image_html( $size = 'medium', $term_tax_id = false, $title = true, $align = 'none' ) {
print $this->get_image_html( $size, $term_tax_id, $title, $align );
}

public function get_image_html( $size = 'medium', $term_tax_id = false, $title = true, $align = 'none' ) {
$o = '';
if ( false === $term_tax_id ) {
global $wp_query;
$obj = $wp_query->get_queried_object();
if ( isset( $obj->term_taxonomy_id ) ) {
$term_tax_id = $obj->term_taxonomy_id;
}
else {
} else {
return false;
}
}
Expand All @@ -99,5 +105,6 @@ public function get_image_html( $size = 'medium', $term_tax_id = false, $title =
}
return $o;
}

}
$taxonomy_images_plugin = new taxonomy_images_plugin();
39 changes: 39 additions & 0 deletions includes/error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* Taxonomy Images Error
*
* @package Taxonomy Images
* @author Ben Huson <ben@thewhiteroom.net>
* @copyright Copyright (c) 2015, Ben Huson
* @license GNU General Public License v2 or later http://www.gnu.org/licenses/gpl-2.0.html
* @since 1.0
*/

class Taxonomy_Images_Error {

/**
* Error Constructor
*
* @param string $error_msg Error message.
*/
public function __construct( $error_msg ) {

if ( $this->debug() ) {
trigger_error( $error_msg );
}

}

/**
* Check if debugging is active.
*
* @return boolean
*/
private function debug() {

return defined( 'WP_DEBUG' ) && WP_DEBUG && apply_filters( 'taxonomy_images_trigger_error', true );

}

}
File renamed without changes.
Loading