'', 'set' => '', 'number' => '' ), $atts, 'mtg_card' ); $name = sanitize_text_field($atts['name']); $set = sanitize_text_field($atts['set']); $number = sanitize_text_field($atts['number']); $cache_key = 'mtg_card_' . md5($name . $set . $number); $card_data = get_transient($cache_key); if ($card_data === false) { $api_url = "https://api.scryfall.com/cards/named?fuzzy={$name}&set={$set}"; if (!empty($set) && !empty($number)) { $api_url = "https://api.scryfall.com/cards/{$set}/{$number}"; } $response = wp_remote_get($api_url); if (is_wp_error($response)) { return 'Failed to retrieve card data'; } $body = wp_remote_retrieve_body($response); $card_data = json_decode($body, true); if (isset($card_data['object']) && $card_data['object'] === 'error') { return 'Card not found'; } set_transient($cache_key, $card_data, 12 * HOUR_IN_SECONDS); } $scryfall_name = esc_html($card_data['name']); $front_image = esc_url($card_data['image_uris']['normal']); $output = '') . '">'; $output .= $scryfall_name; $output .= ''; return $output; } add_shortcode('mtg_card', 'mtg_card_shortcode'); function symbol_shortcode($atts) { // Extract the attributes passed to the shortcode, if any $atts = shortcode_atts(array( 'type' => 'default', // Default value for 'type' attribute ), $atts, 'symbol'); // Process the attributes or generate output $symbol_type = esc_attr($atts['type']); $output = ''; // HTML for the mana symbols based on the symbol type switch ($symbol_type) { case 'blue': $output = ''; break; case 'red': $output = ''; break; case 'green': $output = ''; break; case 'black': $output = ''; break; case 'white': $output = ''; break; case 'colorless': $output = ''; break; case '1': $output = ''; break; case '2': $output = ''; break; case '3': $output = ''; break; case '4': $output = ''; break; case '5': $output = ''; break; case 'tap': $output = ''; break; case 'untap': $output = ''; break; default: $output = ' '; break; } return $output; } // Register the shortcode add_shortcode('symbol', 'symbol_shortcode'); // Enqueue the external stylesheet for mana symbols function enqueue_mana_styles() { wp_enqueue_style('mana-styles', '//cdn.jsdelivr.net/npm/mana-font@latest/css/mana.css'); } add_action('wp_enqueue_scripts', 'enqueue_mana_styles'); ?>