diff --git a/modules/sportspress-icons.php b/modules/sportspress-icons.php index 06df2aa9..e70e29c9 100644 --- a/modules/sportspress-icons.php +++ b/modules/sportspress-icons.php @@ -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 = '
' . __( 'Select Icon', 'sportspress' ) . '
- - '; + + '; return $content; }