Fix #221 Bug with Image type icon for Player Performance props @danfisher85

This commit is contained in:
Brian Miyaji
2017-11-19 19:28:48 +11:00
parent e705911a41
commit bc8b1229e6

View File

@@ -145,13 +145,16 @@ class SportsPress_Icons {
$post_type = get_post_type( $id );
if ( 'sp_performance' !== $post_type ) return $content;
// Detect if image uploaded
$is_uploaded = isset( $_POST['thumbnail_id'] );
// Enqueue scripts
wp_enqueue_script( 'sp_iconpicker', SP()->plugin_url() . '/assets/js/admin/iconpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_ICONS_VERSION, true );
wp_enqueue_script( 'sp_iconpicker', SP()->plugin_url() . '/assets/js/admin/iconpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_ICONS_VERSION, true );
// Get selected icon
$has_icon = has_post_thumbnail( $id );
$selected = get_post_meta( $id, 'sp_icon', true );
if ( $has_icon ) $selected = null;
else $selected = $is_uploaded ? null : get_post_meta( $id, 'sp_icon', true );
// Generate icon selector
$icons = '';
@@ -169,8 +172,8 @@ class SportsPress_Icons {
$content = '<p><strong>' . __( 'Select Icon', 'sportspress' ) . '</strong></p>
<p class="sp-icons">' . $icons . '</p>
<div class="sp-para sp-custom-colors' . ( $has_icon ? ' hidden' : '' ) . '"><label data-sp-colors="' . $value . '"><strong>' . __( 'Customize', 'sportspress' ) . '</strong><br></label>' . $color . '</div>
<div class="sp-custom-thumbnail' . ( $has_icon ? '' : ' hidden' ) . '">' . $content . '</div>';
<div class="sp-para sp-custom-colors' . ( null == $selected ? ' hidden' : '' ) . '"><label data-sp-colors="' . $value . '"><strong>' . __( 'Customize', 'sportspress' ) . '</strong><br></label>' . $color . '</div>
<div class="sp-custom-thumbnail' . ( null == $selected ? '' : ' hidden' ) . '">' . $content . '</div>';
return $content;
}