<?php
/**
 * Created by PhpStorm.
 * User: rolan
 * Date: 17/08/2018
 * Time: 10:18
 */


// REMOVE ELEMENT FROM ADMIN MENU
function deuxtorrents_edit_page_removing()
{

    global $user_ID;

    if (current_user_can('editor')) {
        remove_menu_page('index.php');
        remove_menu_page('edit.php');
        remove_menu_page('edit-comments.php');
        remove_menu_page('options-discussion.php');
        remove_menu_page('edit.php?post_type=avada_portfolio');
        remove_menu_page('edit.php?post_type=avada_faq');
        remove_menu_page('edit.php?post_type=acf-field-group');
        remove_menu_page('edit.php?post_type=themefusion_elastic');
    }
}

add_action('admin_menu', 'deuxtorrents_edit_page_removing');

function deuxtorrents_admin_page_removing()
{
    if (current_user_can('editor')) {
        remove_menu_page('avada');
        remove_menu_page('fusion-builder-options');
        remove_menu_page('fusion-white-label-branding-admin');
        remove_menu_page('deuxtorrents-general-settings');
        remove_menu_page('itsec');
        remove_menu_page('wpml');
        remove_menu_page('loco');
    }
}

add_action('admin_init', 'deuxtorrents_admin_page_removing');


add_filter('the_generator', '__return_null');
if (!defined('WP_POST_REVISIONS')) define('WP_POST_REVISIONS', 10);

/*
 * SVG
 */
function cc_mime_types($mimes)
{
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}

add_filter('upload_mimes', 'cc_mime_types');
function fix_svg_thumb_display()
{
    echo '<style>
    td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail { 
      width: 100% !important; 
      height: auto !important; 
    }
    </style>
  ';
}

add_action('admin_head', 'fix_svg_thumb_display');

/*
 * DISPLAY INSECABLE
 */
function allow_nbsp_in_tinymce($mceInit)
{
    $mceInit['entities'] = '160,nbsp,38,amp,60,lt,62,gt';
    $mceInit['entity_encoding'] = 'named';
    return $mceInit;
}

add_filter('tiny_mce_before_init', 'allow_nbsp_in_tinymce');


show_admin_bar(false);

// Disable HSTS
add_action('send_headers', 'add_header_xua');
function add_header_xua()
{
    header('Strict-Transport-Security: max-age=0;');
}

add_filter('xmlrpc_enabled', '__return_false');
remove_action('wp_head', 'rsd_link');