<?php
/**
 * Plugin Name:       Smart Social Media Buttons
 * Description:       A widget for adding social media icon buttons with custom URLs.
 * Requires at least: 6.1
 * Requires PHP:      7.0
 * Version:           1.0.1
 * Author:            LEVIK (WordPress.org: vinadine)
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       smart-social-media-buttons
 *
 * @package CreateBlock
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Registers the block using the metadata loaded from the `block.json` file.
 * Behind the scenes, it registers also all assets so they can be enqueued
 * through the block editor in the corresponding context.
 *
 * @see https://developer.wordpress.org/reference/functions/register_block_type/
 */
function ssmb_create_widget_block_init() {
	register_block_type( __DIR__ . '/build' );
}
add_action( 'init', 'ssmb_create_widget_block_init' );

// Allow SVG Uploads
function ssmb_allow_svg_upload( $mimes ) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter( 'upload_mimes', 'ssmb_allow_svg_upload' );

// Allow SVG tags and attributes for rendering
add_filter( 'wp_kses_allowed_html', function( $tags ) {
    $tags['svg'] = array(
        'xmlns' => true,
        'viewBox' => true,
        'role' => true,
        'aria-hidden' => true,
        'focusable' => true,
        'fill' => true,
        'width' => true,
        'height' => true,
    );
    $tags['path'] = array(
        'd' => true,
        'fill' => true,
    );
    return $tags;
}, 10, 2 );
