File: /home/zeusxp5/zenoxpressparking.com/wp-content/themes/zxldfw-tcompanyllcMain/functions/tinymce.php
<?php
/**
* Set of functions to create a better experance for the built-in TinyMCE WordPress editor
*/
if ( ! function_exists( 'webcom_tinymce_enhancement' ) ) {
/**
* Disable HTML validation for TinyMCE
*
* @param array $in Array of editor settings.
* @return array
*/
function webcom_tinymce_enhancement( $in ) {
$in['verify_html'] = false;
// Set a variable to hold the current plugin data.
$plugins = $in['plugins'];
if ( '' === $plugins ) {
// If plugin data is not set, set it to "table".
$plugins = 'table';
} else {
// If plugin data is set, convert string into an array.
$plugins = explode( ',', $plugins );
// Check if table has been set, if not add table.
if ( ! in_array( 'table', $plugins ) ) {
array_push( $plugins, 'table' );
}
// Remove Whitespace from array.
$plugins = array_filter( array_map( 'trim', $plugins ) );
// Convert array back into string.
$plugins = implode( ',', $plugins );
}
$in['plugins'] = $plugins;
$in['table_default_styles'] = '{ width: "100%" }';
return $in;
}
}
if ( ! function_exists( 'fix_no_editor_on_posts_page' ) ) {
/**
* Re-enable Page for Posts Editor
*
* @param object $post Post object.
*/
function fix_no_editor_on_posts_page( $post ) {
if ( $post->ID != get_option( 'page_for_posts' ) ) {
return;
}
remove_action( 'edit_form_after_title', '_wp_posts_page_notice' );
add_post_type_support( 'page', 'editor' );
}
add_action( 'edit_form_after_title', 'fix_no_editor_on_posts_page', 0 );
}
if ( ! function_exists( 'webcom_tinymce_styles' ) ) {
/**
* Add styles/classes to the "Styles" drop-down
*
* @param array $settings Array of editor settings.
* @return array
*/
function webcom_tinymce_styles( $settings ) {
$style_formats = array(
array(
'title' => 'Heading Horizontal Line',
'block' => 'h1',
'classes' => 'horizontal-line',
),
array(
'title' => 'Font Awesome Bullets',
'selector' => 'ul',
'classes' => 'pretty-bullets',
),
);
$settings['style_formats'] = wp_json_encode( $style_formats );
return $settings;
}
}
if ( ! function_exists( 'webcom_tinymce_enhancement_load' ) ) {
/**
* Load TinyMCE enhancements only if the TinyMCE Adcanced plugin is active.
*
*/
function webcom_tinymce_enhancement_load() {
if ( is_plugin_active( 'tinymce-advanced/tinymce-advanced.php' ) ) {
add_filter( 'tiny_mce_before_init', 'webcom_tinymce_enhancement' );
add_filter( 'tiny_mce_before_init', 'webcom_tinymce_styles' );
}
}
add_action( 'admin_init', 'webcom_tinymce_enhancement_load' );
}