Skip to content
Snippets Groups Projects
Commit d5438c37 authored by lucha's avatar lucha
Browse files

added ai mu-plugins

parent 1c882aae
No related branches found
No related tags found
No related merge requests found
<?php
/*
* Plugin Name: Ai - Add oembed provider and embed short
* Plugin URI:
* Description: AI -Add Embed
* Version: 1.3
* Author: lechuck, lucha
* Author URI: http://noblogs.org
**/
function wp_embed_handler_google_maps( $matches, $attr, $url, $rawattr ) {
$width = ($rawattr['width']) ? $rawattr['width'] : 425 ;
$height = ($rawattr['height']) ? $rawattr['height'] : 350 ;
$query = add_query_arg(array('output' => 'embed'), $matches[0]);
$embed = '<iframe width="'.esc_attr($width).'" height="'.esc_attr($height).'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.esc_attr($query).'"></iframe>';
return apply_filters( 'embed_googlemaps', $embed, $matches, $attr, $url, $rawattr );
}
function wp_embed_handler_openstreetmap( $matches, $attr, $url, $rawattr ) {
$width = ($rawattr['width']) ? $rawattr['width'] : 425 ;
$height = ($rawattr['height']) ? $rawattr['height'] : 350 ;
$embed = '<iframe width="'.esc_attr($width).'" height="'.esc_attr($height).'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.esc_attr($matches[0]).'"></iframe>';
return apply_filters( 'embed_openstreetmap', $embed, $matches, $attr, $url, $rawattr );
}
/* Returns the Archive.org iframe
Used both by the embed handler and by the special shortcode handler */
function _archive_iframe_build( $id, $height = 480, $width = 640){
return sprintf('<iframe src="https://archive.org/embed/%1$s" width="%3$d" height="%2$d" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe>
', esc_attr($id), esc_attr($height), esc_attr($width));
}
/* This tries to support the shorcode format that is given out by Archive.org.
Don't change it if you don't check what they are using right now.
We will ignore some options.
Example:
[archiveorg peril_of_doc_ock width=640 height=480 frameborder=0
ebkitallowfullscreen=true mozallowfullscreen=true]
*/
function shortcode_archiveorg($atts){
$atts = shortcode_atts(array(
0 => '',
"height" => 480,
"width" => 640
), $atts);
return _archive_iframe_build($atts[0], $atts['height'], $atts['width']);
}
function wp_embed_handler_archive( $matches, $attr, $url, $rawattr ) {
/* while setting width and height from $attr seems a sensible thing to do,
wordpress gives completely wrong sizes. So we won't do it!
*/
$embed = _archive_iframe_build(esc_attr($matches['id']));
return apply_filters( 'embed_archive', $embed, $matches, $attr, $url, $rawattr );
}
function wp_embed_handler_dctptv( $matches, $attr, $url, $rawattr ) {
$width = ($attr['width']) ? $attr['width'] : 480 ;
$height = ($attr['height']) ? $attr['height'] : 396 ;
$embed= sprintf(
'<iframe width="%3$s" scrolling="no" height="%2$s" frameborder="0" src="%1$s" name="dctp-teaser" marginwidth="0" marginheight="0"><br>
</iframe>',esc_attr($matches[0]),esc_attr($height),esc_attr($width));
return apply_filters( 'embed_dctptv', $embed, $matches, $attr, $url, $rawattr );
}
function register_embed_handlers() {
add_shortcode('archiveorg', 'shortcode_archiveorg');
wp_embed_register_handler( 'archive', '#http[s]?://(?:www\.)?archive\.org/.*/(?<id>.*)#i', 'wp_embed_handler_archive' );
wp_embed_register_handler( 'dctptv', '#http(s)?://www.dctp.tv/embed/.*?/#i', 'wp_embed_handler_dctptv' );
wp_embed_register_handler( 'googlemaps', '#http(s)?://maps\.google\.[^\.]+/(.*)#i', 'wp_embed_handler_google_maps');
wp_embed_register_handler( 'openstreetmap', '#http(s)?://www\.openstreetmap\.org/export/embed.html\?(.*)#i', 'wp_embed_handler_openstreetmap');
}
add_action('wp', 'register_embed_handlers');
/* Noembed -- list selected from https://noembed.com/providers */
$noembed = 'https://noembed.com/embed';
$noembed_site = array(
"https?://soundcloud.com/.*/.*",
"https?://www\\.urbandictionary\\.com/define\\.php\\?term=.+",
"https?://(?:www\\.)?vimeo\\.com/.+",
"https?://(?:www\\.)?xkcd\\.com/\\d+/?",
"https?://.*\\.deviantart\\.com/art/.*",
"https?://.*\\.deviantart\\.com/.*#/d.*",
"https?://.*\\.flickr\\.com/photos/.*",
"https?://flic\\.kr/p/.*",
"https?://instagram\\.com/p/.*",
"https?://instagr\\.am/p/.*",
"https?://instagram\\.com/p/.*",
"https?://instagr\\.am/p/.*",
"https?://www\\.slideshare\\.net/.*/.*",
"https?://fr\\.slideshare\\.net/.*/.*",
"https?://de\\.slideshare\\.net/.*/.*",
"https?://es\\.slideshare\\.net/.*/.*",
"https?://pt\\.slideshare\\.net/.*/.*",
"https?://imgur\\.com/(?:[^\\/]+/)?[0-9a-zA-Z]+$",
"https?://bash\\.org/\\?(\\d+)"
);
foreach ($noembed_site as $site){
/* we need to add the php regex delimitators */
wp_oembed_add_provider('#' . $site . '#i', $noembed, true);
}
/* Ted Talks */
wp_oembed_add_provider('http://www.ted.com/talks/*', 'http://www.ted.com/talks/oembed.json', false);
/* arkiwi */
wp_oembed_add_provider('http://www.arkiwi.org/*','http://www.arkiwi.org/oembed/', false );
/* bambuser */
wp_oembed_add_provider('http://*.bambuser.com/*','http://api.bambuser.com/oembed', false);
/* mixcloud */
wp_oembed_add_provider('#https?://(www\.)?mixcloud\.com/.*#i', 'http://mixcloud.com/oembed', true);
?>
<?php
/*
Plugin Name: A/I - Remove password change notification
Description: Disables email notification of password changes
Version: 0.1
Author: Autistici/Inventati
Author URI: https://autistici.org
*/
function wp_password_change_notification() {}
?>
<?php
/**
* Plugin Name: A/I Send SMTP email
* Plugin URI: https://noblogs.org
* Description: Sends mail via SMTP instead than PHP mail function
* Author: Autistici/Inventati
* Author URI: https://autistici.org
* Version: 1.0
*/
// Put your code snippets below this line.
/**
* This function will connect wp_mail to a (possibly authenticated)
* external SMTP server, instead of using the PHP mail() function.
*
* Values are constants set in wp-config.php
*/
if (defined('SMTP_HOST')) {
add_action('phpmailer_init', 'send_smtp_email');
function send_smtp_email($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
// Do not attempt STARTTLS even if the
// server offers it - use SMTPSecure instead.
$phpmailer->SMTPAutoTLS = false;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment