Sindbad~EG File Manager
<?php
/*
* Security : blocking direct access
* Source : http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");
/*
* AMP Web Push
*
*/
function mwp_amp_web_push_script() {
$web_push = mwp_option('amp-webpush');
if ($web_push == 1) :
echo "<!-- AMP Web Push script -->\n";
echo "<script async custom-element='amp-web-push' src='https://cdn.ampproject.org/v0/amp-web-push-0.1.js'></script>\n";
endif;
}
add_action('amp_post_template_head','mwp_amp_web_push_script');
function mwp_amp_web_push_body() {
$web_push = mwp_option('amp-webpush');
if ($web_push == 1) {
$https = mwp_option('amp-webpush-https');
$domain = mwp_option('amp-webpush-domain');
$label = mwp_option('amp-webpush-label');
$app_id = mwp_option('amp-webpush-appid');
if($https == 1){
if (!empty($domain) && !empty($app_id)) {
echo '<amp-web-push id="amp-web-push" layout="nodisplay" helper-iframe-url="https://'.$domain.'/amp-helper-frame.html?appId='.$app_id.'" permission-dialog-url="https://'.$domain.'/amp-permission-dialog.html?appId='.$app_id.'" service-worker-url="https://'.$domain.'/OneSignalSDKWorker.js?appId='.$app_id.'"></amp-web-push>';
}
} else {
if (!empty($label) && !empty($app_id)) {
echo '<amp-web-push id="amp-web-push" layout="nodisplay" helper-iframe-url="https://'.$label.'.os.tc/amp/helper_frame?appId='.$app_id.'" permission-dialog-url="https://'.$label.'.os.tc/amp/permission_dialog?appId='.$app_id.'" service-worker-url="https://'.$label.'.os.tc/OneSignalSDKWorker.js?appId='.$app_id.'"></amp-web-push>';
}
}
if ($https == 1) {
$local_file_1 = ABSPATH. 'amp-helper-frame.html';
if (!file_exists($local_file_1)) {
$response_1 = wp_remote_get( 'https://cdn.onesignal.com/sdks/amp-distribute/amp-helper-frame.html', array( 'timeout' => 15, 'sslverify' => false ));
if ( is_array( $response_1 ) ) {
global $wp_filesystem;
if (empty($wp_filesystem)) {
require_once (ABSPATH . '/wp-admin/includes/file.php');
WP_Filesystem();
}
if ( !$wp_filesystem->put_contents($local_file_1, $response_1['body'], FS_CHMOD_FILE) ) {
return __('Failed to create file : amp-helper-frame.html');
}
}
}
$local_file_2 = ABSPATH. 'amp-permission-dialog.html';
if (!file_exists($local_file_2)) {
$response_2 = wp_remote_get( 'https://cdn.onesignal.com/sdks/amp-distribute/amp-permission-dialog.html', array( 'timeout' => 15, 'sslverify' => false ));
if ( is_array( $response_2 ) ) {
global $wp_filesystem;
if (empty($wp_filesystem)) {
require_once (ABSPATH . '/wp-admin/includes/file.php');
WP_Filesystem();
}
if ( !$wp_filesystem->put_contents($local_file_2, $response_2['body'], FS_CHMOD_FILE) ) {
return __('Failed to create file : amp-permission-dialog.html');
}
}
}
}
}
}
/*!
* Single
*
* Related CSS
*
*/
function mwp_load_web_push_css_block($post) {
$web_push = mwp_option('amp-webpush');
if ( $web_push == 1 ) {
$css = get_template_directory() . '/amp/css/web-push.css';
mwp_inline_css_file2($css);
}
}
add_filter( 'amp_post_template_css', 'mwp_load_web_push_css_block', 30, 1 );
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists