Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt/panel/core/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt/panel/core/tinymce.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");
define ( 'TINYMCE_PATH' , get_template_directory_uri().'/panel/js/tinymce.js');
/*
	===========================================================
		Enqueue Styles for WordPress Visual Editor
	===========================================================
*/
function mwp_shortcodes_mce_css(){
	global $pagenow;
	if ($pagenow == 'post-new.php' || ( $pagenow == 'post.php' ) && ($_GET['action'] == 'edit')) {
		wp_enqueue_style( 'font-awesome',  get_template_directory_uri() .'/css/assets.css', array(), '4.7.0' );
		wp_enqueue_style('editor-icons', get_template_directory_uri() .'/panel/css/button.css', array(), '4.2.2' );
	}
}
add_action('admin_enqueue_scripts', 'mwp_shortcodes_mce_css');

function mwp_theme_add_editor_styles() {
	global $pagenow;
	if ($pagenow == 'post-new.php' || ( $pagenow == 'post.php' ) && ($_GET['action'] == 'edit')) {
		add_editor_style( get_template_directory_uri() .'/panel/css/editor-style.css' );
	}
}
add_action( 'admin_init', 'mwp_theme_add_editor_styles' );

/*
	===========================================================
		Add Page Break button in WordPress Visual Editor 
	===========================================================
*/
add_filter( 'mce_buttons', 'mwp_add_page_break_button', 1, 2 ); // 1st row
function mwp_add_page_break_button( $buttons, $id ){
	
    if ( 'content' != $id )
        return $buttons;
    array_splice( $buttons, 13, 0, 'wp_page' );
  
    return $buttons;
}
/*
	===========================================================
		Add Markup in WordPress Visual Editor 
	===========================================================
*/
function mwp_mce_markup( $initArray ) {
    $ext = 'i[id|name|class|style]';
    if ( isset( $initArray['extended_valid_elements'] ) ) {
        $initArray['extended_valid_elements'] .= ',' . $ext;
    } else {
        $initArray['extended_valid_elements'] = $ext;
    }
    return $initArray;
}
add_filter( 'tiny_mce_before_init', 'mwp_mce_markup' );

function allow_nbsp_in_tinymce( $mceInit ) {
    $mceInit['entities'] = '160,nbsp,38,amp,60,lt,62,gt';
    return $mceInit;
}
add_filter( 'tiny_mce_before_init', 'allow_nbsp_in_tinymce' );

/*
	===========================================================
					The Styles
	===========================================================
*/
add_filter( 'mce_buttons_2', 'mwp_custom_fonts_editor_buttons' );
function mwp_custom_fonts_editor_buttons( $buttons ) {
    array_unshift( $buttons, 'styleselect' );
	array_unshift( $buttons, 'backcolor' );
	array_unshift( $buttons, 'fontselect' ); // Add Font Select
	array_unshift( $buttons, 'fontsizeselect' ); // Add Font Size Select
    return $buttons;
}
/*
	===========================================================
					The Fonts Sizes
	===========================================================
*/
add_filter( 'tiny_mce_before_init', 'mwp_mce_font_sizes' );
function mwp_mce_font_sizes( $initArray ){
    $initArray['fontsize_formats'] = "9px 10px 12px 13px 14px 15px 16px 17px 18px 19px 20px 21px 22px 24px 28px 32px 36px";
    return $initArray;
}
/*
	=====================================================
					The Custom Styles
	=====================================================
*/ 
add_filter( 'tiny_mce_before_init', 'mwp_mce_before_init' );
function mwp_mce_before_init( $init ) {
    $style_formats = array(
        array(
            'title' => 'Unstyled List',
            'selector' => 'ul',
            'classes' => 'unstyled',
        ),
		array(
            'title' => 'Inline List',
            'selector' => 'ul',
            'classes' => 'list-inline'
        ),
		array(
            'title' => 'Bootstrap Table',
            'selector' => 'table',
            'classes' => 'table'
        ),
		array(
            'title' => 'Bootstrap Table Striped rows',
            'selector' => 'table',
            'classes' => 'table table-striped'
        ),
		array(
            'title' => 'Bootstrap Table Bordered',
            'selector' => 'table',
            'classes' => 'table table-bordered'
        ),
		array(
            'title' => 'Bootstrap Table Hover rows',
            'selector' => 'table',
            'classes' => 'table table-hover'
        ),
		array(
            'title' => 'Bootstrap Table Bordered & Striped',
            'selector' => 'table',
            'classes' => 'table table-striped table-bordered'
        ),
		array(
            'title' => 'Custom H2 Blue',
            'selector' => 'h2',
            'classes' => 'heading-h2-1'
        ),
		array(
            'title' => 'Custom H2 Red',
            'selector' => 'h2',
            'classes' => 'heading-h2-2'
        ),
		array(
            'title' => 'Custom H2 Green',
            'selector' => 'h2',
            'classes' => 'heading-h2-3'
        ),
		array(
            'title' => 'Custom H2 Yollow',
            'selector' => 'h2',
            'classes' => 'heading-h2-4'
        ),
		array(
            'title' => 'Custom H3 Blue',
            'selector' => 'h3',
            'classes' => 'heading-h3-1'
        ),
		array(
            'title' => 'Custom H3 Red',
            'selector' => 'h3',
            'classes' => 'heading-h3-2'
        ),
		array(
            'title' => 'Custom H3 Green',
            'selector' => 'h3',
            'classes' => 'heading-h3-3'
        ),
		array(
            'title' => 'Custom H3 Yollow',
            'selector' => 'h3',
            'classes' => 'heading-h3-4'
        ),
    );
    $init['style_formats'] = json_encode( $style_formats );
    return $init;
}
/*
	=====================================================
				Google Fonts and Custom Fonts
	=====================================================
*/
add_filter( 'tiny_mce_before_init', 'mwp_mce_google_fonts_array' );
function mwp_mce_google_fonts_array( $initArray ) {

	$theme_advanced_fonts = 'Arial=Arial;';
	$custom_font_1_key		= null;
	$custom_font_1_value	= null;
	$custom_font_2_key		= null;
	$custom_font_2_value	= null;
	$custom_font_3_key		= null;
	$custom_font_3_value	= null;
		
	$custom_font_1	= mwp_option('typo-custom-font1-name');
	$custom_font_2	= mwp_option('typo-custom-font2-name');
	$custom_font_3	= mwp_option('typo-custom-font3-name');
		
	if (!empty($custom_font_1)) {
		$custom_font_1_key 		= mwp_option('typo-custom-font1-name').':custom';
		$custom_font_1_value 	= mwp_option('typo-custom-font1-name').'='.mwp_option('typo-custom-font1-name').';';
	} else {
		$custom_font_1_key 		= '';
		$custom_font_1_value 	= '';
	}
	if (!empty($custom_font_2)) {
		$custom_font_2_key 		= mwp_option('typo-custom-font2-name').':custom';
		$custom_font_2_value 	= mwp_option('typo-custom-font2-name').'='.mwp_option('typo-custom-font2-name').';';
	} else {
		$custom_font_2_key 		= '';
		$custom_font_2_value 	= '';
	}
	if (!empty($custom_font_3)) {
		$custom_font_3_key 		= mwp_option('typo-custom-font3-name').':custom';
		$custom_font_3_value 	= mwp_option('typo-custom-font3-name').'='.mwp_option('typo-custom-font3-name').';';
	} else {
		$custom_font_3_key 		= '';
		$custom_font_3_value 	= '';
	}
	if (is_rtl()) {
		$font_list = array(			
			'0' 	=> 'Droid Arabic Kufi=Droid Arabic Kufi;',
			'1'		=> 'Droid Arabic Naskh=Droid Arabic Naskh;',
			'2' 	=> 'Thabit=Thabit;',
			'3'  	=> 'Cairo=Cairo;',
			'4'		=> 'Amiri=Amiri;',
			'5'		=> 'Changa=Changa;',
			'6'		=> 'Lateef=Lateef;',
			'7' 	=> 'Reem Kufi=Reem Kufi;',
			'8' 	=> 'Lalezar=Lalezar;',
			'9' 	=> 'Scheherazade=Scheherazade;',
			'10' 	=> 'Baloo Bhaijaan=Baloo Bhaijaan;',
			'11' 	=> 'Mada=Mada;',
			'12' 	=> 'Lemonada=Lemonada;',
			'13' 	=> 'El Messiri=El Messiri;',
			'14' 	=> 'Harmattan=Harmattan;',
			'15' 	=> 'Aref Ruqaa=Aref Ruqaa;',
			'16' 	=> 'Mirza=Mirza;',
			'17' 	=> 'Rakkas=Rakkas;',
			'18' 	=> 'Katibeh=Katibeh;',
			'19' 	=> 'Jomhuria=Jomhuria;',
			'20' 	=> $custom_font_1_value,
			'21' 	=> $custom_font_2_value,
			'22' 	=> $custom_font_3_value,
		);
	} else {
		$font_list = array(			
			'0' 	=> 'Lato=Lato;',
			'1' 	=> 'Droid Sans=Droid Sans;',
			'2' 	=> 'Vollkorn=Ubuntu;',
			'3' 	=> 'Ubuntu=Ubuntu;',
			'4' 	=> 'PT Serif=PT Serif;',
			'5' 	=> 'Old Standard TT=Old Standard TT;',
			'6' 	=> 'Open Sans=Open Sans;',
			'7' 	=> 'Josefin Slab=Josefin Slab;',
			'8' 	=> 'Roboto=Roboto;',
			'9' 	=> $custom_font_1_value,
			'10' 	=> $custom_font_2_value,
			'11' 	=> $custom_font_3_value,
		);
	}
	$clean_array = array_filter($font_list);
	foreach ($clean_array as $index => $value) {
		$theme_advanced_fonts .= $value;
	}
	
	$initArray['font_formats'] = $theme_advanced_fonts;
    return $initArray;
}
/*
	=====================================================
						Load CSS
				Google Fonts and Custom Fonts
	=====================================================
*/
add_action( 'admin_init', 'mwp_add_editor_styles' );
function mwp_add_editor_styles() {
    
	$custom_font_1_key		= null;
	$custom_font_1_value	= null;
	$custom_font_2_key		= null;
	$custom_font_2_value	= null;
	$custom_font_3_key		= null;
	$custom_font_3_value	= null;
	
	$custom_font_1	= mwp_option('typo-custom-font1-name');
	$custom_font_2	= mwp_option('typo-custom-font2-name');
	$custom_font_3	= mwp_option('typo-custom-font3-name');
	
	if (!empty($custom_font_1)) {
		$custom_font_1_key 		= $custom_font_1.':custom';
		$custom_font_1_value 	= $custom_font_1;
	}
	if (!empty($custom_font_2)) {
		$custom_font_2_key 		= $custom_font_2.':custom';
		$custom_font_2_value 	= $custom_font_2;
	}
	if (!empty($custom_font_3)) {
		$custom_font_3_key 		= $custom_font_3.':custom';
		$custom_font_3_value 	= $custom_font_3;
	}
	if (is_rtl()) {
		$fonts = array(	
			'0' 	=> 'Droid Arabic Kufi',
			'1'		=> 'Droid Arabic Naskh',
			'2' 	=> 'Thabit',
			'3' 	=> 'Cairo',
			'4' 	=> 'Amiri',
			'5' 	=> 'Changa',
			'6' 	=> 'Lateef',
			'7' 	=> 'Reem Kufi',
			'8' 	=> 'Lalezar',
			'9' 	=> 'Scheherazade',
			'10' 	=> 'Baloo Bhaijaan',
			'11' 	=> 'Mada',
			'12' 	=> 'Lemonada',
			'13' 	=> 'El Messiri',
			'14' 	=> 'Harmattan',
			'15' 	=> 'Aref Ruqaa',
			'16'	=> 'Mirza',
			'17' 	=> 'Rakkas',
			'18' 	=> 'Katibeh',
			'19' 	=> 'Jomhuria',
			'20' 	=> $custom_font_1_value,
			'21' 	=> $custom_font_2_value,
			'22' 	=> $custom_font_3_value,	
		);
	} else {
		$fonts = array(	
			'0' 	=>  'Lato',
			'1' 	=>  'Droid Sans',
			'2' 	=>  'Vollkorn',
			'3' 	=>  'Ubuntu',
			'4' 	=>  'PT Serif',
			'5' 	=>  'Old Standard TT',
			'6' 	=>  'Open Sans',
			'7' 	=>  'Josefin Slab',
			'8' 	=>  'Roboto',
			'9' 	=> $custom_font_1_value,
			'10' 	=> $custom_font_2_value,
			'11' 	=> $custom_font_3_value,	
		);	
	}
	
	$list = array();
	$font_size = '300,400,500,700,900';
	
	foreach ($fonts as $index => $font) {
		if ( $font == $custom_font_1_value || $font == $custom_font_2_value || $font == $custom_font_3_value ) {
			// no font load
		} else {	
			$list[$font] = $font_size;
		}
	}
	$google_fonts_url = mwp_google_fonts_url(array_filter($list), 'latin,latin-ext');
	global $pagenow;
	if ($pagenow == 'post-new.php' || ( $pagenow == 'post.php' ) && ($_GET['action'] == 'edit')) {
		add_editor_style( array($google_fonts_url, 'editor-style.css') );
	}
}
/*
	================================================
		Hooks functions into the correct filters
	================================================
*/
function mwp_add_new_editor_btn() {
	if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
		return;
	}
	if ( get_user_option('rich_editing') == 'true' ) {
		add_filter( 'mce_external_plugins', 'mwp_add_plugin_script' );
		add_filter( 'mce_buttons_3', 'mwp_register_button' );
	}
}
/*
	========================================
		Register new button in the editor
	========================================
*/
function mwp_register_button($buttons) {
	array_push(
	$buttons,
	"fbv",
	"docs",
	"|",
	"error",
	"info",
	"notice",
	"success",
	"|",
	"btn",
	"dlist",
	"dllistv",
	"|",
	"bullet_button",
	"proscons");
	return $buttons;
}
/*
	========================================
		Declare scripts for new buttons
	========================================
*/
function mwp_add_plugin_script($plugin_array) {
	$buttons = array(
	"ytube",
	"dailym",
	"vim",
	"fbv",
	"insta",
	"error",
	"info",
	"notice",
	"success",
	"advert",
	"btn",
	"docs",
	"mcode",
	"dlist",
	"dllistv",
	"bullet_button",
	"proscons",
	);
	foreach ($buttons as $btn) {
		$plugin_array[$btn] = TINYMCE_PATH;
	}
	return $plugin_array;
}
add_action('init', 'mwp_add_new_editor_btn');

/*
	==============================
		Refresh Tinymce Version
	==============================
*/
function mwp_refresh_mce($ver) {
	$ver += 2;
	return $ver;
}
add_filter( 'tiny_mce_version', 'mwp_refresh_mce');

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists