<?php
/**
 * Content filters
 *
 * @package Multi
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
}

/**
 * Removes inline styles from tag cloud
 *
 * @param string $input The tag cloud markup.
 */
function multimagazine_remove_inline_style_tagcloud( $input ) {
	return preg_replace( '/style=\"font-size: .+pt;\"/', '', $input );
}
add_filter( 'wp_generate_tag_cloud', 'multimagazine_remove_inline_style_tagcloud' );

/**
 * Wraps tables in an element so they become responsive
 *
 * @param string $content Table markup.
 */
function multimagazine_table_filter( $content ) {
	$find        = array( '<table', '</table>' );
	$replacement = array( '<div class="table"><table', '</table></div>' );
	return str_replace( $find, $replacement, $content );
}
add_action( 'the_content', 'multimagazine_table_filter', 10, 1 );

/**
 * Saves display css property from being filtered by wp_kses
 *
 * @param String $styles CSS code.
 */
function multimagazine_save_css_display( $styles ) {
	$styles[] = 'display';
	return $styles;
}

add_filter( 'safe_style_css', 'multimagazine_save_css_display' );
