Sindbad~EG File Manager
<?php
/*
* Security : blocking direct access
* Source : http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");
/*
* Jetpack : Defer Scripts
*
*/
add_filter('script_loader_tag', 'mwp_jetpack_defer_attribute', 10, 2);
function mwp_jetpack_defer_attribute($tag, $handle) {
if (!is_admin()) {
if ( 'postmessage' !== $handle )
if ( 'jetpack_resize' !== $handle )
if ( 'jetpack_likes_queuehandler' !== $handle )
if ( 'likes-post-count' !== $handle )
if ( 'likes-post-count-jetpack' !== $handle )
if ( 'jquery.wpcom-proxy-request' !== $handle )
if ( 'likes-post-count-wpcom' !== $handle )
if ( 'jetpack-twitter-timeline' !== $handle )
if ( 'jetpack-iframe-embed' !== $handle )
if ( 'mustache' !== $handle )
if ( 'wpcom-notes-common' !== $handle )
if ( 'wpcom-notes-admin-bar' !== $handle )
if ( 'jetpack-modules-list-table' !== $handle )
if ( 'views.jetpack-modules' !== $handle )
if ( 'models.jetpack-modules' !== $handle )
if ( 'backbone' !== $handle )
if ( 'underscore' !== $handle )
if ( 'wp-util' !== $handle )
if ( 'wpgroho.js' !== $handle )
if ( 'grofiles-cards' !== $handle )
if ( 'jetpack_related-posts' !== $handle )
if ( 'grofiles-cards' !== $handle )
return $tag;
return str_replace( ' src', ' defer="defer" src', $tag );
} else {
return $tag;
}
}
/*
* Jetpack
*
* Remove all CSS & JS
*
*/
if (mwp_option('jetpack-remove-css-js') == 1) :
add_filter( 'jetpack_implode_frontend_css', '__return_false' );
add_action('wp_print_styles', 'mwp_jetpack_remove_all_jp_css' );
function mwp_jetpack_remove_all_jp_css() {
wp_deregister_style( 'AtD_style' ); // After the Deadline
wp_deregister_style( 'jetpack_likes' ); // Likes
wp_deregister_style( 'jetpack_related-posts' ); // Related Posts
wp_deregister_style( 'jetpack-carousel' ); // Carousel
wp_deregister_style( 'grunion.css' ); // Contact form
wp_deregister_style( 'the-neverending-homepage' ); // Infinite Scroll
wp_deregister_style( 'infinity-twentyten' ); // Infinite Scroll - Twenty Ten
wp_deregister_style( 'infinity-twentyeleven' ); // Infinite Scroll - Twenty Eleven
wp_deregister_style( 'infinity-twentytwelve' ); // Infinite Scroll - Twenty Twelve
wp_deregister_style( 'infinity-twentythirteen' ); // Infinite Scroll - Twenty Thirteen
wp_deregister_style( 'infinity-twentyfourteen' ); // Infinite Scroll - Twenty Fourteen
wp_deregister_style( 'infinity-twentyfifteen' ); // Infinite Scroll - Twenty Fifteen
wp_deregister_style( 'noticons' ); // Notes
wp_deregister_style( 'post-by-email' ); // Post by Email
wp_deregister_style( 'publicize' ); // Publicize
wp_deregister_style( 'sharedaddy' ); // Sharing
wp_deregister_style( 'sharing' ); // Sharing
wp_deregister_style( 'stats_reports_css' ); // Stats
wp_deregister_style( 'jetpack-widgets' ); // Widgets
wp_deregister_style( 'jetpack-slideshow' ); // Slideshows
wp_deregister_style( 'presentations' ); // Presentation shortcode
wp_deregister_style( 'jetpack-subscriptions' ); // Subscriptions
wp_deregister_style( 'tiled-gallery' ); // Tiled Galleries
wp_deregister_style( 'widget-conditions' ); // Widget Visibility
wp_deregister_style( 'jetpack_display_posts_widget' ); // Display Posts Widget
wp_deregister_style( 'gravatar-profile-widget' ); // Gravatar Widget
wp_deregister_style( 'widget-grid-and-list' ); // Top Posts widget
wp_deregister_style( 'jetpack-widgets' ); // Widgets
wp_deregister_style( 'jetpack_css-rtl' );
}
// Removing devicepx-jetpack.js & photon.js for WordPress
add_action( 'wp_enqueue_scripts', 'mwp_disable_devicepx' );
function mwp_disable_devicepx() {
wp_dequeue_script( 'devicepx' );
wp_dequeue_script( 'jetpack-photon' );
}
endif;
/*
* Disable Jetpack's Photon module for the_content() only
*
*/
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) :
if (mwp_option('jetpack-skip-image') == 1) {
add_filter('the_content', 'mwp_single_jetpack_disable', 0);
function mwp_single_jetpack_disable($content){
add_filter( 'jetpack_photon_skip_image', '__return_true');
return $content;
}
}
endif;
/*
* FOR WHO CARE ABOUT SEO
*
* Post Thumbnail - SEO Images For JetPack photon
*
*/
function mwp_thumbnail_remove_jetpack_filter($post_id) {
$videos_ids = mwp_option('category-videos');
if (!empty($videos_ids) && in_category($videos_ids) ) {
// return;
} else {
if (mwp_option('jetpack-skip-image') == 0) {
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
$photon_removed = remove_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ) );
$image_url = get_post_meta($post_id, 'mwp_thumbnail_url' , true);
if(!empty($image_url)) {
$image = $image_url;
} else {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
$image = $thumbnail['0'];
}
echo '<div itemscope itemtype="http://schema.org/ImageObject"><meta itemprop="image" content="'.esc_url($image).'"></div>';
if ( $photon_removed ) {
add_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 );
}
}
}
}
}
/*
* FOR WHO CARE ABOUT SEO
*
* SEO Images For JetPack photon (ImageObject Structured Data)
* https://stackoverflow.com/a/22649915/2535061
*
*/
function mwp_seo_image_jetpack_care( $content ) {
if (mwp_option('thumbnail-type') == 8) {
$pattern = '#<img.+?src="([^"]*)".*?alt *= *[\"\']?([^\"\']*)[\"\']?.*?/?>#i';
$replacement = '$0<span itemscope itemtype="http://schema.org/ImageObject"><meta itemprop="image" content="$1"></span>';
$content = preg_replace( $pattern, $replacement , $content );
}
return $content;
}
add_filter( 'the_content', 'mwp_seo_image_jetpack_care', 11 );
/**
* Photon Experiments
* Change Photon image quality
*
*/
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) :
function mwp_photon_experiments() {
if (function_exists('mwp_option')) {
add_filter( 'jetpack_photon_post_image_args', 'mwp_photon_experiments_quality', 100, 2 );
add_filter( 'jetpack_images_get_images', 'mwp_jetpack_default_thumbnail', 10, 3 );
if (mwp_option('thumbnail-type') == 8) :
add_filter( 'jetpack_photon_url', 'jetpack_photon_url', 15, 3 );
endif;
}
}
add_action( 'plugins_loaded', 'mwp_photon_experiments', 20 );
function mwp_photon_experiments_quality( $args, $image ) {
$get_quality = mwp_option('thumbnail-quality');
if (!empty($get_quality)) {
$quality = $get_quality;
} else {
$quality = 80;
}
$args['quality'] = $quality;
return $args;
}
function mwp_jetpack_default_thumbnail( $media, $post_id, $args ) {
if ( $media ) {
return $media;
} else {
$permalink = get_permalink( $post_id );
$url = apply_filters( 'jetpack_photon_url', mwp_option('thumbnail-default') );
return array( array(
'type' => 'image',
'from' => 'custom_fallback',
'src' => esc_url( $url ),
'href' => $permalink,
) );
}
}
endif;
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists