first commit

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-08 12:19:53 -04:00
commit 7c8c8b1c76
4586 changed files with 2050693 additions and 0 deletions
@@ -0,0 +1,71 @@
#arve .arve-wrapper,
#tinymce .arve-wrapper {
display: block;
margin-bottom: 1.5em;
width: 100%;
}
#arve .arve-wrapper::after,
#tinymce .arve-wrapper::after {
content: "";
display: table;
clear: both;
}
#arve .arve-wrapper.alignright,
#tinymce .arve-wrapper.alignright {
margin-top: .4em;
margin-left: 1.5em;
}
#arve .arve-wrapper.alignleft,
#tinymce .arve-wrapper.alignleft {
margin-top: .4em;
margin-right: 1.5em;
}
#arve .arve-embed-container,
#tinymce .arve-embed-container {
position: relative;
display: block;
padding: 0;
padding-bottom: 56.25%;
margin: 0;
height: 0;
overflow: hidden;
}
#arve .arve-thumbnail,
#tinymce .arve-thumbnail,
#arve .arve-play-btn,
#tinymce .arve-play-btn,
#arve .arve-iframe,
#tinymce .arve-iframe {
position: absolute;
padding: 0;
margin: 0;
top: 0;
left: 0;
bottom: 0;
height: 100%;
width: 100%;
border: 0;
}
#arve .arve-video,
#tinymce .arve-video {
padding: 0;
margin: 0;
width: 100%;
}
#arve .arve-promote-link,
#tinymce .arve-promote-link {
float: right;
font-family: "Open Sans", "Sagoe UI", "Arvo", "Lato", Arial, sans-serif;
font-size: .8em;
}
.arve-hidden {
display: none !important;
}
@@ -0,0 +1,50 @@
(function ($) {
'use strict';
function remove_unwanted_stuff() {
$('.arve-wrapper').find('p, .video-wrap, .fluid-width-video-wrapper, .fluid-vids').contents().unwrap();
$('.arve-wrapper br').remove();
$('.arve-iframe, .arve-video').removeAttr('width height style');
$('.wp-block-embed').each( function( index ) {
if ( $(this).has('.arve-wrapper') ) {
$(this).removeClass( 'wp-embed-aspect-16-9 wp-has-aspect-ratio' );
if ( $(this).has('.wp-block-embed__wrapper') ) {
$(this).find('.wp-block-embed__wrapper').contents().unwrap();
}
}
} );
};
function global_id() {
if ( $( 'html[id="arve"]' ).length ) {
return;
}
if ( $( 'html[id]' ).length <= 0 ) {
$( 'html' ).attr( 'id', 'arve' );
} else if ( $( 'body[id]' ).length <= 0 ) {
$( 'body' ).attr( 'id', 'arve' );
} else {
$( 'body' ).wrapInner( '<div id="arve">' );
}
}
remove_unwanted_stuff();
global_id();
$( document ).ready( function() {
remove_unwanted_stuff();
global_id();
} );
}(jQuery));
@@ -0,0 +1 @@
#arve .arve-wrapper,#tinymce .arve-wrapper{display:block;margin-bottom:1.5em;width:100%}#arve .arve-wrapper::after,#tinymce .arve-wrapper::after{content:"";display:table;clear:both}#arve .arve-wrapper.alignright,#tinymce .arve-wrapper.alignright{margin-top:.4em;margin-left:1.5em}#arve .arve-wrapper.alignleft,#tinymce .arve-wrapper.alignleft{margin-top:.4em;margin-right:1.5em}#arve .arve-embed-container,#tinymce .arve-embed-container{position:relative;display:block;padding:0;padding-bottom:56.25%;margin:0;height:0;overflow:hidden}#arve .arve-iframe,#arve .arve-play-btn,#arve .arve-thumbnail,#tinymce .arve-iframe,#tinymce .arve-play-btn,#tinymce .arve-thumbnail{position:absolute;padding:0;margin:0;top:0;left:0;bottom:0;height:100%;width:100%;border:0}#arve .arve-video,#tinymce .arve-video{padding:0;margin:0;width:100%}#arve .arve-promote-link,#tinymce .arve-promote-link{float:right;font-family:"Open Sans","Sagoe UI",Arvo,Lato,Arial,sans-serif;font-size:.8em}.arve-hidden{display:none!important}
@@ -0,0 +1 @@
!function(r){"use strict";function e(){r(".arve-wrapper").find("p, .video-wrap, .fluid-width-video-wrapper, .fluid-vids").contents().unwrap(),r(".arve-wrapper br").remove(),r(".arve-iframe, .arve-video").removeAttr("width height style"),r(".wp-block-embed").each(function(e){r(this).has(".arve-wrapper")&&(r(this).removeClass("wp-embed-aspect-16-9 wp-has-aspect-ratio"),r(this).has(".wp-block-embed__wrapper")&&r(this).find(".wp-block-embed__wrapper").contents().unwrap())})}function t(){r('html[id="arve"]').length||(r("html[id]").length<=0?r("html").attr("id","arve"):r("body[id]").length<=0?r("body").attr("id","arve"):r("body").wrapInner('<div id="arve">'))}e(),t(),r(document).ready(function(){e(),t()})}(jQuery);
@@ -0,0 +1,39 @@
<?php
function arve_register_styles() {
$min = arve_get_min_suffix();
wp_register_style(
ARVE_SLUG,
ARVE_PUBLIC_URL . "arve$min.css",
array(),
ARVE_VERSION
);
}
function arve_register_scripts() {
$min = arve_get_min_suffix();
wp_register_script(
ARVE_SLUG,
ARVE_PUBLIC_URL . "arve$min.js",
array( 'jquery' ),
ARVE_VERSION,
true
);
}
function arve_maybe_enqueue_assets() {
$options = arve_get_options();
if ( $options['always_enqueue_assets'] ) {
wp_enqueue_style( ARVE_SLUG );
wp_enqueue_script( ARVE_SLUG );
wp_enqueue_style( 'arve-pro' );
wp_enqueue_script( 'arve-pro' );
}
}
@@ -0,0 +1,253 @@
<?php
function arve_html_id( $html_attr ) {
if ( ! arve_contains( $html_attr, 'id=' ) ) {
$html_attr .= ' id="arve"';
}
return $html_attr;
}
function arve_get_var_dump( $var ) {
ob_start();
var_dump( $var ); // phpcs:ignore
return ob_get_clean();
};
function arve_get_debug_info( $input_html, $atts, $input_atts ) {
$html = '';
// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['arve-debug-options'] ) ) {
static $show_options_debug = true;
$options = get_option( 'arve_options_main' );
$options['shortcodes'] = get_option( 'arve_options_shortcodes' );
$options['params'] = get_option( 'arve_options_params' );
if ( $show_options_debug ) {
$html .= sprintf( 'Options: <pre>%s</pre>', arve_get_var_dump( $options ) );
}
$show_options_debug = false;
}
$pre_style = ''
. 'background-color: #111;'
. 'color: #eee;'
. 'font-size: 15px;'
. 'white-space: pre-wrap;'
. 'word-wrap: break-word;';
if ( ! empty( $_GET['arve-debug-attr'] ) ) {
$html .= sprintf(
'<pre style="%s">attr[%s]: %s</pre>',
esc_attr( $pre_style ),
esc_html( $_GET['arve-debug-attr'] ),
arve_get_var_dump( $atts[ $_GET['arve-debug-attr'] ] )
);
}
if ( isset( $_GET['arve-debug-atts'] ) ) {
$html .= sprintf( '<pre style="%s">$atts: %s</pre>', esc_attr( $pre_style ), arve_get_var_dump( $input_atts ) );
$html .= sprintf( '<pre style="%s">$arve: %s</pre>', esc_attr( $pre_style ), arve_get_var_dump( $atts ) );
}
if ( isset( $_GET['arve-debug-html'] ) ) {
$html .= sprintf( '<pre style="%s"">%s</pre>', esc_attr( $pre_style ), esc_html( $input_html ) );
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
return $html;
}
function arve_build_meta_html( $a ) {
$meta = '';
if ( ! empty( $a['sources'] ) ) {
$first_source = arve_get_first_array_value( $a['sources'] );
$meta .= sprintf( '<meta itemprop="contentURL" content="%s">', esc_attr( $first_source['src'] ) );
}
if ( ! empty( $a['iframe_src'] ) ) {
$meta .= sprintf( '<meta itemprop="embedURL" content="%s">', esc_attr( $a['iframe_src'] ) );
}
if ( ! empty( $a['upload_date'] ) ) {
$meta .= sprintf( '<meta itemprop="uploadDate" content="%s">', esc_attr( $a['upload_date'] ) );
}
if ( ! empty( $a['duration'] ) ) {
$meta .= sprintf( '<meta itemprop="duration" content="PT%s">', esc_attr( $a['duration'] ) );
}
if ( ! empty( $a['img_src'] ) ) :
$thumbnail = sprintf( '<meta itemprop="thumbnailUrl" content="%s">', esc_attr( $a['img_src'] ) );
$meta .= arve_build_tag(
array(
'name' => 'thumbnail',
'tag' => 'meta',
'attr' => array(
'itemprop' => 'thumbnailUrl',
'content' => $a['img_src'],
),
),
$a
);
endif;
if ( ! empty( $a['title'] ) ) {
$meta .= arve_build_tag(
array(
'name' => 'title',
'tag' => 'meta',
'attr' => array(
'itemprop' => 'name',
'content' => trim( $a['title'] ),
)
),
$a
);
}
if ( ! empty( $a['description'] ) ) {
$meta .= sprintf( '<span itemprop="description" class="arve-description arve-hidden">%s</span>', esc_html( trim( $a['description'] ) ) );
}
return $meta;
}
function arve_build_tag( $args, $a ) {
$args = apply_filters( "nextgenthemes/arve/{$args['name']}", $args, $a );
if ( ! empty( $args['content'] ) ) {
$out = sprintf(
'<%1$s%2$s>%3$s</%1$s>',
esc_html( $args['tag'] ),
arve_attr( $args['attr'] ),
$args['content']
);
} else {
$out = sprintf(
'<%s%s>',
esc_html( $args['tag'] ),
arve_attr( $args['attr'] )
);
}
return $out;
}
function arve_build_promote_link_html( $arve_link ) {
if ( $arve_link ) {
return sprintf(
'<a href="%s" title="%s" class="arve-promote-link" target="_blank">%s</a>',
esc_url( 'https://nextgenthemes.com/plugins/arve-pro/' ),
esc_attr( __( 'Embedded with ARVE Advanced Responsive Video Embedder WordPress plugin', ARVE_SLUG ) ),
esc_html__( 'ARVE', ARVE_SLUG )
);
}
return '';
}
function arve_arve_embed_container( $html, $atts ) {
$attr['class'] = 'arve-embed-container';
if ( false === $atts['aspect_ratio'] ) {
$attr['style'] = 'height:auto;padding:0';
} else {
$attr['style'] = sprintf( 'padding-bottom:%F%%', arve_aspect_ratio_to_percentage( $atts['aspect_ratio'] ) );
}
return sprintf( '<div%s>%s</div>', arve_attr( $attr ), $html );
}
function arve_arve_wrapper( $html, $atts ) {
$element = ( 'link-lightbox' === $atts['mode'] ) ? 'span' : 'div';
return sprintf(
'<%s%s>%s</%s>',
$element,
arve_attr( $atts['wrapper_attr'] ),
$html,
$element
);
}
function arve_video_or_iframe( $atts ) {
switch ( $atts['provider'] ) {
case 'html5':
return arve_create_video_tag( $atts );
default:
return arve_create_iframe_tag( $atts );
}
}
/**
*
*
* @since 2.6.0
*/
function arve_create_iframe_tag( $a ) {
if ( in_array( $a['mode'], array( 'lazyload', 'lazyload-lightbox', 'link-lightbox' ), true ) ) {
$html = sprintf(
'<span class="arve-lazyload"%s></span>',
arve_attr( arve_prefix_array_keys( 'data-', $a['iframe_attr'] ) )
);
} else {
$html = sprintf( '<iframe%s></iframe>', arve_attr( $a['iframe_attr'] ) );
}
return apply_filters( 'arve_iframe_tag', $html, $a, $a['iframe_attr'] );
}
function arve_create_video_tag( $a ) {
$html = sprintf(
'<video%s>%s%s</video>',
arve_attr( $a['video_attr'] ),
$a['video_sources_html'],
$a['video_tracks_html']
);
return apply_filters( 'arve_video_tag', $html, $a, $a['video_attr'] );
}
function arve_error( $message ) {
return sprintf(
'<p><strong>%s</strong> %s</p>',
__( '<abbr title="Advanced Responsive Video Embedder">ARVE</abbr> Error:', ARVE_SLUG ),
$message
);
}
function arve_output_errors( $atts ) {
$errors = '';
foreach ( $atts as $key => $value ) {
if ( is_wp_error( $value ) ) {
$errors .= arve_error( $value->get_error_message() );
}
}
return $errors;
}
@@ -0,0 +1,152 @@
<?php
function arve_is_bool_option( $array ) {
$yes_no = array(
'' => 1,
'yes' => 1,
'no' => 1
);
$check = array_diff_key( $array, $yes_no );
if ( empty( $check ) ) {
return 'bool';
} else {
return $array;
}
}
function arve_get_pre_style() {
return '';
}
function arve_load_plugin_textdomain() {
load_plugin_textdomain(
ARVE_SLUG,
false,
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}
function arve_get_first_array_value( $array ) {
reset( $array );
$key = key( $array );
return $array[ $key ];
}
function arve_prefix_array_keys( $keyprefix, $array ) {
foreach ( $array as $key => $value ) {
$array[ $keyprefix . $key ] = $value;
unset( $array[ $key ] );
}
return $array;
}
function arve_check_filetype( $url, $ext ) {
$check = wp_check_filetype( $url, wp_get_mime_types() );
if ( strtolower( $check['ext'] ) === $ext ) {
return $check['type'];
} else {
return false;
}
}
/**
* Calculates seconds based on youtube times
*
* @param string $yttime The '1h25m13s' part of youtube URLs
*
* @return int Starttime in seconds
*/
function arve_youtube_time_to_seconds( $yttime ) {
$format = false;
$hours = 0;
$minutes = 0;
$seconds = 0;
$pattern['hms'] = '/([0-9]+)h([0-9]+)m([0-9]+)s/'; // hours, minutes, seconds
$pattern['ms'] = '/([0-9]+)m([0-9]+)s/'; // minutes, seconds
$pattern['h'] = '/([0-9]+)h/';
$pattern['m'] = '/([0-9]+)m/';
$pattern['s'] = '/([0-9]+)s/';
foreach ( $pattern as $key => $value ) {
preg_match( $value, $yttime, $result );
if ( ! empty( $result ) ) {
$format = $key;
break;
}
}
switch ( $format ) {
case 'hms':
$hours = $result[1];
$minutes = $result[2];
$seconds = $result[3];
break;
case 'ms':
$minutes = $result[1];
$seconds = $result[2];
break;
case 'h':
$hours = $result[1];
break;
case 'm':
$minutes = $result[1];
break;
case 's':
$seconds = $result[1];
break;
default:
return false;
}
return ( $hours * 60 * 60 ) + ( $minutes * 60 ) + $seconds;
}
/**
* Calculates padding percentage value for a particular aspect ratio
*
* @since 4.2.0
*
* @param string $aspect_ratio '4:3' or percentage value with percent sign
*
* @return float
*/
function arve_aspect_ratio_to_percentage( $aspect_ratio ) {
if ( is_wp_error( $aspect_ratio ) ) {
return 52.25;
}
$a = explode( ':', $aspect_ratio );
return ( ( $a[1] / $a[0] ) * 100 );
}
/**
* Calculates
*
* @since 8.2.0
*/
function arve_calculate_height( $width, $aspect_ratio ) {
$width = (int) $width;
$aspect_ratio = empty( $aspect_ratio ) ? '16:9' : $aspect_ratio;
$percent = arve_aspect_ratio_to_percentage( $aspect_ratio );
if ( $width > 100 && $percent ) {
return ( ( $width / 100 ) * $percent );
}
return false;
}
@@ -0,0 +1,298 @@
<?php
function arve_get_default_aspect_ratio( $aspect_ratio, $provider ) {
$properties = arve_get_host_properties();
if ( empty( $aspect_ratio ) ) {
return $properties[ $provider ]['aspect_ratio'];
}
return $aspect_ratio;
}
function arve_get_html5_attributes() {
return array( 'mp4', 'm4v', 'webm', 'ogv', 'ogg', 'ogm' );
}
function arve_url_query_array( $url ) {
$url = wp_parse_url( $url );
if ( empty( $url['query'] ) ) {
return array();
}
parse_str( $url['query'], $url_params );
return $url_params;
}
function arve_build_iframe_src( $atts ) {
$id = $atts['id'];
$lang = $atts['lang'];
$provider = $atts['provider'];
$options = arve_get_options();
$properties = arve_get_host_properties();
if ( $options['youtube_nocookie'] ) {
$properties['youtube']['embed_url'] = 'https://www.youtube-nocookie.com/embed/%s';
$properties['youtubelist']['embed_url'] = 'https://www.youtube-nocookie.com/embed/videoseries?list=%s';
}
if ( isset( $properties[ $provider ]['embed_url'] ) ) {
$pattern = $properties[ $provider ]['embed_url'];
} else {
$pattern = '%s';
}
if ( 'facebook' === $provider && is_numeric( $id ) ) {
$id = "https://www.facebook.com/facebook/videos/$id/";
} elseif ( 'twitch' === $provider && is_numeric( $id ) ) {
$pattern = 'https://player.twitch.tv/?video=v%s';
} elseif ( 'ted' === $provider && preg_match( '/^[a-z]{2}$/', $lang ) === 1 ) {
$pattern = 'https://embed-ssl.ted.com/talks/lang/' . $lang . '/%s.html';
}
if ( isset( $properties[ $provider ]['url_encode_id'] ) && $properties[ $provider ]['url_encode_id'] ) {
$id = rawurlencode( $id );
}
if ( 'brightcove' === $provider ) {
$src = sprintf( $pattern, $atts['brightcove_account'], $atts['brightcove_player'], $atts['brightcove_embed'], $id );
} else {
$src = sprintf( $pattern, $id );
}
return $src;
}
function arve_id_fixes( $id, $provider ) {
if (
'liveleak' === $provider &&
! arve_starts_with( $id, 'i=' ) &&
! arve_starts_with( $id, 'f=' )
) {
$id = 'i=' . $id;
}
return $id;
}
function arve_aspect_ratio_fixes( $aspect_ratio, $provider, $mode ) {
if ( 'dailymotionlist' === $provider ) {
switch ( $mode ) {
case 'normal':
case 'lazyload':
$aspect_ratio = '640:370';
break;
}
}
return $aspect_ratio;
}
function arve_add_autoplay_query_arg( $src, $a ) {
switch ( $a['provider'] ) {
case 'alugha':
case 'archiveorg':
case 'dailymotion':
case 'dailymotionlist':
case 'facebook':
case 'vevo':
case 'viddler':
case 'vimeo':
case 'youtube':
case 'youtubelist':
$on = add_query_arg( 'autoplay', 1, $src );
$off = add_query_arg( 'autoplay', 0, $src );
break;
case 'twitch':
case 'ustream':
$on = add_query_arg( 'autoplay', 'true', $src );
$off = add_query_arg( 'autoplay', 'false', $src );
break;
case 'livestream':
case 'wistia':
$on = add_query_arg( 'autoPlay', 'true', $src );
$off = add_query_arg( 'autoPlay', 'false', $src );
break;
case 'metacafe':
$on = add_query_arg( 'ap', 1, $src );
$off = remove_query_arg( 'ap', $src );
break;
case 'videojug':
$on = add_query_arg( 'ap', 1, $src );
$off = add_query_arg( 'ap', 0, $src );
break;
case 'veoh':
$on = add_query_arg( 'videoAutoPlay', 1, $src );
$off = add_query_arg( 'videoAutoPlay', 0, $src );
break;
case 'brightcove':
case 'snotr':
$on = add_query_arg( 'autoplay', 1, $src );
$off = remove_query_arg( 'autoplay', $src );
break;
case 'yahoo':
$on = add_query_arg( 'player_autoplay', 'true', $src );
$off = add_query_arg( 'player_autoplay', 'false', $src );
break;
default:
# Do nothing for providers that to not support autoplay or fail with parameters
$on = $src;
$off = $src;
break;
}
if ( $a['autoplay'] ) {
return $on;
} else {
return $off;
}
}
function arve_add_query_args_to_iframe_src( $src, $atts ) {
$options = arve_get_options();
$host = $atts['provider'];
$parameters = wp_parse_args( preg_replace( '!\s+!', '&', trim( $atts['parameters'] ) ) );
$option_parameters = array();
if ( isset( $options['params'][ $host ] ) ) {
$option_parameters = wp_parse_args( preg_replace( '!\s+!', '&', trim( $options['params'][ $host ] ) ) );
}
$parameters = wp_parse_args( $parameters, $option_parameters );
return add_query_arg( $parameters, $src );
}
function arve_maxwidth_when_aligned( $maxwidth, $align ) {
$options = arve_get_options();
if ( $maxwidth < 100 && in_array( $align, array( 'left', 'right', 'center' ), true ) ) {
$maxwidth = (int) $options['align_maxwidth'];
}
return $maxwidth;
}
function arve_get_language_name_from_code( $lang_code ) {
// This list is based on languages available from localize.drupal.org. See
// http://localize.drupal.org/issues for information on how to add languages
// there.
//
// The "Left-to-right marker" comments and the enclosed UTF-8 markers are to
// make otherwise strange looking PHP syntax natural (to not be displayed in
// right to left). See https://www.drupal.org/node/128866#comment-528929.
$lang = array(
'af' => array( 'Afrikaans', 'Afrikaans' ),
'am' => array( 'Amharic', 'አማርኛ' ),
'ar' => array( 'Arabic', /* Left-to-right marker "" */ 'العربية', 'RTL' ),
'ast' => array( 'Asturian', 'Asturianu' ),
'az' => array( 'Azerbaijani', 'Azərbaycanca' ),
'be' => array( 'Belarusian', 'Беларуская' ),
'bg' => array( 'Bulgarian', 'Български' ),
'bn' => array( 'Bengali', 'বাংলা' ),
'bo' => array( 'Tibetan', 'བོད་སྐད་' ),
'bs' => array( 'Bosnian', 'Bosanski' ),
'ca' => array( 'Catalan', 'Català' ),
'cs' => array( 'Czech', 'Čeština' ),
'cy' => array( 'Welsh', 'Cymraeg' ),
'da' => array( 'Danish', 'Dansk' ),
'de' => array( 'German', 'Deutsch' ),
'dz' => array( 'Dzongkha', 'རྫོང་ཁ' ),
'el' => array( 'Greek', 'Ελληνικά' ),
'en' => array( 'English', 'English' ),
'en-x-simple' => array( 'Simple English', 'Simple English' ),
'eo' => array( 'Esperanto', 'Esperanto' ),
'es' => array( 'Spanish', 'Español' ),
'et' => array( 'Estonian', 'Eesti' ),
'eu' => array( 'Basque', 'Euskera' ),
'fa' => array( 'Persian, Farsi', /* Left-to-right marker "" */ 'فارسی', 'RTL' ),
'fi' => array( 'Finnish', 'Suomi' ),
'fil' => array( 'Filipino', 'Filipino' ),
'fo' => array( 'Faeroese', 'Føroyskt' ),
'fr' => array( 'French', 'Français' ),
'fy' => array( 'Frisian, Western', 'Frysk' ),
'ga' => array( 'Irish', 'Gaeilge' ),
'gd' => array( 'Scots Gaelic', 'Gàidhlig' ),
'gl' => array( 'Galician', 'Galego' ),
'gsw-berne' => array( 'Swiss German', 'Schwyzerdütsch' ),
'gu' => array( 'Gujarati', 'ગુજરાતી' ),
'he' => array( 'Hebrew', /* Left-to-right marker "" */ 'עברית', 'RTL' ),
'hi' => array( 'Hindi', 'हिन्दी' ),
'hr' => array( 'Croatian', 'Hrvatski' ),
'ht' => array( 'Haitian Creole', 'Kreyòl ayisyen' ),
'hu' => array( 'Hungarian', 'Magyar' ),
'hy' => array( 'Armenian', 'Հայերեն' ),
'id' => array( 'Indonesian', 'Bahasa Indonesia' ),
'is' => array( 'Icelandic', 'Íslenska' ),
'it' => array( 'Italian', 'Italiano' ),
'ja' => array( 'Japanese', '日本語' ),
'jv' => array( 'Javanese', 'Basa Java' ),
'ka' => array( 'Georgian', 'ქართული ენა' ),
'kk' => array( 'Kazakh', 'Қазақ' ),
'km' => array( 'Khmer', 'ភាសាខ្មែរ' ),
'kn' => array( 'Kannada', 'ಕನ್ನಡ' ),
'ko' => array( 'Korean', '한국어' ),
'ku' => array( 'Kurdish', 'Kurdî' ),
'ky' => array( 'Kyrgyz', 'Кыргызча' ),
'lo' => array( 'Lao', 'ພາສາລາວ' ),
'lt' => array( 'Lithuanian', 'Lietuvių' ),
'lv' => array( 'Latvian', 'Latviešu' ),
'mg' => array( 'Malagasy', 'Malagasy' ),
'mk' => array( 'Macedonian', 'Македонски' ),
'ml' => array( 'Malayalam', 'മലയാളം' ),
'mn' => array( 'Mongolian', 'монгол' ),
'mr' => array( 'Marathi', 'मराठी' ),
'ms' => array( 'Bahasa Malaysia', 'بهاس ملايو' ),
'my' => array( 'Burmese', 'ဗမာစကား' ),
'ne' => array( 'Nepali', 'नेपाली' ),
'nl' => array( 'Dutch', 'Nederlands' ),
'nb' => array( 'Norwegian Bokmål', 'Norsk, bokmål' ),
'nn' => array( 'Norwegian Nynorsk', 'Norsk, nynorsk' ),
'oc' => array( 'Occitan', 'Occitan' ),
'pa' => array( 'Punjabi', 'ਪੰਜਾਬੀ' ),
'pl' => array( 'Polish', 'Polski' ),
'pt-pt' => array( 'Portuguese, Portugal', 'Português, Portugal' ),
'pt-br' => array( 'Portuguese, Brazil', 'Português, Brasil' ),
'ro' => array( 'Romanian', 'Română' ),
'ru' => array( 'Russian', 'Русский' ),
'sco' => array( 'Scots', 'Scots' ),
'se' => array( 'Northern Sami', 'Sámi' ),
'si' => array( 'Sinhala', 'සිංහල' ),
'sk' => array( 'Slovak', 'Slovenčina' ),
'sl' => array( 'Slovenian', 'Slovenščina' ),
'sq' => array( 'Albanian', 'Shqip' ),
'sr' => array( 'Serbian', 'Српски' ),
'sv' => array( 'Swedish', 'Svenska' ),
'sw' => array( 'Swahili', 'Kiswahili' ),
'ta' => array( 'Tamil', 'தமிழ்' ),
'ta-lk' => array( 'Tamil, Sri Lanka', 'தமிழ், இலங்கை' ),
'te' => array( 'Telugu', 'తెలుగు' ),
'th' => array( 'Thai', 'ภาษาไทย' ),
'tr' => array( 'Turkish', 'Türkçe' ),
'tyv' => array( 'Tuvan', 'Тыва дыл' ),
'ug' => array( 'Uyghur', 'Уйғур' ),
'uk' => array( 'Ukrainian', 'Українська' ),
'ur' => array( 'Urdu', /* Left-to-right marker "" */ 'اردو', 'RTL' ),
'vi' => array( 'Vietnamese', 'Tiếng Việt' ),
'xx-lolspeak' => array( 'Lolspeak', 'Lolspeak' ),
'zh-hans' => array( 'Chinese, Simplified', '简体中文' ),
'zh-hant' => array( 'Chinese, Traditional', '繁體中文' ),
);
return $lang[ $lang_code ][1];
}
@@ -0,0 +1,435 @@
<?php
function arve_load_vimeo_api( $a ) {
require_once ARVE_PATH . '/vendor/autoload.php';
return $a;
}
function arve_get_wrapper_id( $a ) {
static $wrapper_ids = array();
$wrapper_id = null;
foreach ( array( 'id', 'mp4', 'm4v', 'webm', 'ogv', 'url', 'random_video_url', 'webtorrent' ) as $att ) {
if ( ! empty( $a[ $att ] ) && is_string( $a[ $att ] ) ) {
$wrapper_id = 'arve-' . $a[ $att ];
$wrapper_id = preg_replace( '/[^a-zA-Z0-9-]/', '', $wrapper_id );
break;
}
}
if ( empty( $wrapper_id ) ) {
return null;
} else {
$wrapper_ids[] = $wrapper_id;
}
if ( in_array( $wrapper_id, $wrapper_ids, true ) ) {
$id_counts = array_count_values( $wrapper_ids );
$id_count = $id_counts[ $wrapper_id ];
if ( $id_count >= 2 ) {
$wrapper_id .= '-' . $id_count;
}
}
return $wrapper_id;
}
function arve_sc_filter_attr( $a ) {
$wrapper_id = arve_get_wrapper_id( $a );
if ( empty( $wrapper_id ) ) {
$a['wrapper_id_error'] = new WP_Error( 'wrapper_id', __( 'Wrapper ID could not be build, please report this bug.', ARVE_SLUG ) );
}
$align_class = empty( $a['align'] ) ? '' : ' align' . $a['align'];
$a['wrapper_attr'] = array(
'class' => "arve-wrapper$align_class",
'data-mode' => $a['mode'],
'data-provider' => $a['provider'],
'id' => $wrapper_id,
'style' => empty( $a['maxwidth'] ) ? false : sprintf( 'max-width:%dpx;', $a['maxwidth'] ),
// Schema.org
'itemscope' => '',
'itemtype' => 'http://schema.org/VideoObject',
);
if ( 'html5' === $a['provider'] ) {
$a['video_attr'] = array(
# WP
'autoplay' => in_array( $a['mode'], array( 'lazyload', 'lazyload-lightbox', 'link-lightbox' ), true ) ? false : $a['autoplay'],
'controls' => $a['controls'],
'controlslist' => $a['controlslist'],
'loop' => $a['loop'],
'preload' => $a['preload'],
'width' => empty( $a['width'] ) ? false : $a['width'],
'height' => empty( $a['height'] ) ? false : $a['height'],
'poster' => empty( $a['img_src'] ) ? false : $a['img_src'],
'src' => empty( $a['video_src'] ) ? false : $a['video_src'],
# ARVE only
'class' => 'arve-video fitvidsignore',
'muted' => $a['muted'],
'playsinline' => $a['playsinline'],
'webkit-playsinline' => $a['playsinline'],
);
} else {
$properties = arve_get_host_properties();
$options = arve_get_options();
$iframe_src = arve_build_iframe_src( $a );
$iframe_src = arve_add_query_args_to_iframe_src( $iframe_src, $a );
$iframe_src = arve_add_autoplay_query_arg( $iframe_src, $a );
if ( 'vimeo' === $a['provider'] && ! empty( $a['start'] ) ) {
$iframe_src .= '#t=' . (int) $a['start'];
}
$a['iframe_attr'] = array(
'allow' => 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture',
'allowfullscreen' => '',
'class' => 'arve-iframe fitvidsignore',
'frameborder' => '0',
'name' => $a['iframe_name'],
'sandbox' => 'allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox',
'scrolling' => 'no',
'src' => $iframe_src,
'width' => empty( $a['width'] ) ? false : $a['width'],
'height' => empty( $a['height'] ) ? false : $a['height'],
);
if ( 'vimeo' === $a['provider'] ) {
$a['iframe_attr']['sandbox'] .= ' allow-forms';
}
if ( false === $a['sandbox'] ) {
$a['iframe_attr']['sandbox'] = false;
}
}
return $a;
}
function arve_sc_filter_validate( $a ) {
$a['align'] = arve_validate_align( $a['align'], $a['provider'] );
$a['mode'] = arve_validate_mode( $a['mode'], $a['provider'] );
$a['autoplay'] = arve_validate_bool( $a['autoplay'], 'autoplay' );
$a['arve_link'] = arve_validate_bool( $a['arve_link'], 'arve_link' );
$a['loop'] = arve_validate_bool( $a['loop'], 'loop' );
$a['controls'] = arve_validate_bool( $a['controls'], 'controls' );
$a['sandbox'] = arve_validate_bool( $a['sandbox'], 'sandbox' );
$a['muted'] = arve_validate_bool( $a['muted'], 'muted' );
$a['playsinline'] = arve_validate_bool( $a['playsinline'], 'playsinline' );
$a['maxwidth'] = (int) $a['maxwidth'];
$a['maxwidth'] = (int) arve_maxwidth_when_aligned( $a['maxwidth'], $a['align'] );
$a['id'] = arve_id_fixes( $a['id'], $a['provider'] );
$a['aspect_ratio'] = arve_get_default_aspect_ratio( $a['aspect_ratio'], $a['provider'] );
$a['aspect_ratio'] = arve_aspect_ratio_fixes( $a['aspect_ratio'], $a['provider'], $a['mode'] );
$a['aspect_ratio'] = arve_validate_aspect_ratio( $a['aspect_ratio'] );
return $a;
}
function arve_sc_filter_set_fixed_dimensions( $a ) {
$width = 480;
$a['width'] = $width;
$a['height'] = arve_calculate_height( $width, $a['aspect_ratio'] );
return $a;
}
function arve_sc_filter_sanitise( $atts ) {
if ( ! empty( $atts['src'] ) ) {
$atts['url'] = $atts['src'];
}
foreach ( $atts as $key => $value ) {
$atts[ $key ] = (string) $value;
if ( '' === $value ) {
$atts[ $key ] = null;
}
}
return $atts;
}
function arve_sc_filter_missing_attribute_check( $atts ) {
# Old shortcodes
if ( ! array_key_exists( 'url', $atts ) ) {
return $atts;
}
$required_attributes = arve_get_html5_attributes();
$required_attributes[] = 'url';
$array = array_intersect_key( $atts, array_flip( $required_attributes ) );
if ( count( array_filter( $array ) ) !== count( $array ) ) {
$atts['missing_atts_error'] = arve_error(
sprintf(
esc_html__( 'The [arve] shortcode needs one of this attributes %s', ARVE_SLUG ),
implode( $required_attributes )
)
);
}
return $atts;
}
function arve_sc_filter_get_media_gallery_thumbnail( $atts ) {
if ( empty( $atts['thumbnail'] ) ) {
return $atts;
}
if ( is_numeric( $atts['thumbnail'] ) ) {
$attchment_id = $atts['thumbnail'];
$atts['img_src'] = arve_get_attachment_image_url_or_srcset( 'url', $attchment_id );
$atts['img_srcset'] = arve_get_attachment_image_url_or_srcset( 'srcset', $attchment_id );
} elseif ( arve_validate_url( $atts['thumbnail'] ) ) {
$atts['img_src'] = $atts['thumbnail'];
} else {
$atts['img_src'] = new WP_Error( 'thumbnail', __( 'Not a valid thumbnail URL or Media ID given', ARVE_SLUG ) );
}
return $atts;
}
function arve_sc_filter_get_media_gallery_video( $atts ) {
$html5_ext = arve_get_html5_attributes();
foreach ( $html5_ext as $ext ) {
if ( ! empty( $atts[ $ext ] ) && is_numeric( $atts[ $ext ] ) ) {
$atts[ $ext ] = wp_get_attachment_url( $atts[ $ext ] );
}
}
return $atts;
}
function arve_sc_filter_detect_provider_and_id_from_url( $atts ) {
$properties = arve_get_host_properties();
if ( ! empty( $atts['provider'] ) || empty( $atts['url'] ) ) {
return $atts;
}
foreach ( $properties as $host_id => $host ) :
if ( empty( $host['regex'] ) ) {
continue;
}
$preg_match = preg_match( '#' . $host['regex'] . '#i', $atts['url'], $matches );
if ( 1 !== $preg_match ) {
continue;
}
foreach ( $matches as $key => $value ) {
if ( is_string( $key ) ) {
$atts['provider'] = $host_id;
$atts[ $key ] = $matches[ $key ];
}
}
endforeach;
return $atts;
}
function arve_sc_filter_detect_query_args( $atts ) {
if ( empty( $atts['url'] ) ) {
return $atts;
}
$to_extract = array(
'brightcove' => array( 'videoId', 'something' ),
);
foreach ( $to_extract as $provider => $parameters ) {
if ( $provider !== $atts['provider'] ) {
return $atts;
}
$query_array = arve_url_query_array( $atts['url'] );
foreach ( $parameters as $key => $parameter ) {
$att_name = $atts['provider'] . "_$parameter";
if ( empty( $query_array[ $parameter ] ) ) {
$atts[ $att_name ] = new WP_Error( $att_name, "$parameter not found in URL" );
} else {
$atts[ $att_name ] = $query_array[ $parameter ];
}
}
}
return $atts;
}
function arve_sc_filter_detect_youtube_playlist( $atts ) {
if (
'youtube' !== $atts['provider'] ||
( empty( $atts['url'] ) && empty( $atts['id'] ) )
) {
return $atts;
}
if ( empty( $atts['url'] ) ) {
# Not a url but it will work
$url = str_replace( array( '&list=', '&amp;list=' ), '?list=', $atts['id'] );
} else {
$url = $atts['url'];
}
$query_array = arve_url_query_array( $url );
if ( empty( $query_array['list'] ) ) {
return $atts;
}
$atts['id'] = strtok( $atts['id'], '?' );
$atts['id'] = strtok( $atts['id'], '&' );
$atts['youtube_playlist_id'] = $query_array['list'];
$atts['parameters'] .= 'list=' . $query_array['list'];
return $atts;
}
function arve_get_video_type( $ext ) {
switch ( $ext ) {
case 'ogv':
case 'ogm':
return 'video/ogg';
default:
return 'video/' . $ext;
}
}
function arve_sc_filter_detect_html5( $atts ) {
if ( ! empty( $atts['provider'] ) && 'html5' !== $atts['provider'] ) {
return $atts;
}
$html5_extensions = arve_get_html5_attributes();
$atts['video_sources_html'] = '';
foreach ( $html5_extensions as $ext ) :
if ( ! empty( $atts[ $ext ] ) ) {
if ( arve_starts_with( $atts[ $ext ], 'https://www.dropbox.com' ) ) {
$atts[ $ext ] = add_query_arg( 'dl', 1, $atts[ $ext ] );
}
$atts['video_sources_html'] .= sprintf( '<source type="%s" src="%s">', arve_get_video_type( $ext ), $atts[ $ext ] );
}
if ( ! empty( $atts['url'] ) && arve_ends_with( $atts['url'], ".$ext" ) ) {
if ( arve_starts_with( $atts['url'], 'https://www.dropbox.com' ) ) {
$atts['url'] = add_query_arg( 'dl', 1, $atts['url'] );
}
$atts['video_src'] = $atts['url'];
}
endforeach;
if ( empty( $atts['video_src'] ) && empty( $atts['video_sources_html'] ) ) {
return $atts;
}
$atts['provider'] = 'html5';
return $atts;
}
function arve_sc_filter_iframe_fallback( $atts ) {
if ( empty( $atts['provider'] ) ) {
$atts['provider'] = 'iframe';
if ( empty( $atts['id'] ) && ! empty( $atts['url'] ) ) {
$atts['id'] = $atts['url'];
}
}
return $atts;
}
function arve_sc_filter_build_tracks_html( $atts ) {
if ( 'html5' !== $atts['provider'] ) {
return $atts;
}
$atts['video_tracks_html'] = '';
for ( $n = 1; $n <= ARVE_NUM_TRACKS; $n++ ) {
if ( empty( $atts[ "track_{$n}" ] ) ) {
return $atts;
}
preg_match( '#-(?<type>captions|chapters|descriptions|metadata|subtitles)-(?<lang>[a-z]{2}).vtt$#i', $atts[ "track_{$n}" ], $matches );
if ( empty( $matches[1] ) ) {
$atts[ "track_{$n}" ] = new WP_Error( 'track', __( 'Track kind or language code could not detected from filename', ARVE_SLUG ) );
return $atts;
}
$label = empty( $atts[ "track_{$n}_label" ] ) ? arve_get_language_name_from_code( $matches['lang'] ) : $atts[ "track_{$n}_label" ];
$attr = array(
'default' => ( 1 === $n ) ? true : false,
'kind' => $matches['type'],
'label' => $label,
'src' => $atts[ "track_{$n}" ],
'srclang' => $matches['lang'],
);
$atts['video_tracks_html'] .= sprintf( '<track%s>', arve_attr( $attr ) );
}
return $atts;
}
@@ -0,0 +1,286 @@
<?php
function arve_shortcode( $a, $content = null ) {
$a = (array) $a;
/**
* Filters the default arve shortcode output.
*
* If the filtered output isn't empty, it will be used instead of generating
* the default video template.
*
* @since 8.8.2
*
* @param string $html Empty variable to be replaced with shortcode markup.
* @param array $atts Attributes of the shortcode.
* @param string $content Video shortcode content.
*/
$override = apply_filters( 'arve_shortcode_overwride', '', $a, $content );
if ( '' !== $override ) {
return $override;
}
return arve_shortcode_arve( $a, $content );
}
function arve_default_maxwidth() {
$options = arve_get_options();
if ( empty( $options['video_maxwidth'] ) ) {
return empty( $GLOBALS['content_width'] ) ? 900 : $GLOBALS['content_width'];
}
return $options['video_maxwidth'];
}
function arve_shortcode_arve( $input_atts, $content = null, $arve_shortcode = true ) {
$errors = '';
$options = arve_get_options();
$properties = arve_get_host_properties();
$input_atts = (array) $input_atts;
$pairs = array(
'align' => $options['align'],
'arve_link' => arve_bool_to_shortcode_string( $options['promote_link'] ),
'aspect_ratio' => null,
'autoplay' => arve_bool_to_shortcode_string( $options['autoplay'] ),
'description' => null,
'duration' => null,
'sandbox' => 'y',
'iframe_name' => null,
'maxwidth' => (string) arve_default_maxwidth(),
'mode' => $options['mode'],
'parameters' => null,
'src' => null, // Just a alias for url to make it simple
'thumbnail' => null,
'title' => null,
'upload_date' => null,
// <video>
'm4v' => null,
'mp4' => null,
'ogv' => null,
'webm' => null,
'preload' => 'metadata',
'playsinline' => null,
'muted' => null,
'controls' => 'y',
'controlslist' => empty( $options['controlslist'] ) ? null : (string) $options['controlslist'],
'loop' => 'n',
// TED only
'lang' => null,
// Vimeo only
'start' => null,
// Old Shortcodes / URL embeds
'id' => null,
'provider' => null,
// deprecated, title should be used
'link_text' => null,
);
for ( $n = 1; $n <= ARVE_NUM_TRACKS; $n++ ) {
$pairs[ "track_{$n}" ] = null;
$pairs[ "track_{$n}_label" ] = null;
}
if ( $arve_shortcode ) {
$pairs['url'] = null;
} else {
$pairs['provider'] = null;
$pairs['id'] = null;
if ( empty( $input_atts['provider'] ) || empty( $input_atts['id'] ) ) {
return arve_error( __( 'id and provider shortcodes attributes are mandatory for old shortcodes. It is recommended to switch to new shortcodes that need only url', ARVE_SLUG ) );
}
}
$atts = shortcode_atts( apply_filters( 'arve_shortcode_pairs', $pairs ), $input_atts, 'arve' );
$errors = arve_output_errors( $atts );
if ( $errors ) {
return $errors . arve_get_debug_info( '', $atts, $input_atts );
}
$html['video'] = arve_video_or_iframe( $atts );
$html['meta'] = arve_build_meta_html( $atts );
$html['ad_link'] = arve_build_promote_link_html( $atts['arve_link'] );
$html['embed_container'] = arve_arve_embed_container( $html['meta'] . $html['video'], $atts );
$normal_embed = arve_arve_wrapper( $html['embed_container'] . $html['ad_link'], $atts );
$output = apply_filters( 'arve_output', $normal_embed, $html, $atts );
if ( empty( $output ) ) {
return arve_error( 'The output is empty, this should not happen', ARVE_SLUG );
} elseif ( is_wp_error( $output ) ) {
return arve_error( $output->get_error_message() );
}
wp_enqueue_style( ARVE_SLUG );
wp_enqueue_script( ARVE_SLUG );
return arve_get_debug_info( $output, $atts, $input_atts ) . $output;
}
/**
* Create all shortcodes at a late stage because people over and over again using this plugin toghter with jetback or
* other plugins that handle shortcodes we will now overwrite all this suckers.
*
* @since 2.6.2
*
* @uses Advanced_Responsive_Video_Embedder_Create_Shortcodes()
*/
function arve_create_shortcodes() {
$options = arve_get_options();
foreach ( $options['shortcodes'] as $provider => $shortcode ) {
$function = function( $atts ) use ( $provider ) {
$atts['provider'] = $provider;
return arve_shortcode_arve( $atts, null, false );
};
add_shortcode( $shortcode, $function );
}
add_shortcode( 'arve', 'arve_shortcode' );
add_shortcode( 'arve-supported', 'arve_shortcode_arve_supported' );
add_shortcode( 'arve-supported-list', 'arve_shortcode_arve_supported_list' );
add_shortcode( 'arve-params', 'arve_shortcode_arve_params' );
}
function arve_shortcode_arve_supported() {
$providers = arve_get_host_properties();
// unset deprecated and doubled
unset( $providers['dailymotionlist'] );
unset( $providers['iframe'] );
$out = '<h3 id="video-host-support">Video Host Support</h3>';
$out .= '<p>The limiting factor of the following features is not ARVE but what the prividers offer.</p>';
$out .= '<table class="table table-sm table-hover">';
$out .= '<tr>';
$out .= '<th></th>';
$out .= '<th>Provider</th>';
$out .= '<th>Requires<br>embed code</th>';
$out .= '<th>SSL</th>';
$out .= '<th>Auto Thumbnail<br>(Pro Addon)</th>';
$out .= '<th>Auto Title<br>(Pro Addon)</th>';
$out .= '</tr>';
$out .= '<tr>';
$out .= '<td></td>';
$out .= '<td colspan="6"><a href="https://nextgenthemes.com/plugins/arve/documentation/#general-iframe-embedding">All providers with responsive iframe embed codes</a></td>';
$out .= '</tr>';
$count = 1;
foreach ( $providers as $key => $values ) {
if ( ! isset( $values['name'] ) ) {
$values['name'] = $key;
}
$out .= '<tr>';
$out .= sprintf( '<td>%d</td>', $count++ );
$out .= sprintf( '<td>%s</td>', esc_html( $values['name'] ) );
$out .= sprintf( '<td>%s</td>', ( isset( $values['requires_src'] ) && $values['requires_src'] ) ? '&#x2713;' : '' );
$out .= sprintf( '<td>%s</td>', ( isset( $values['embed_url'] ) && arve_starts_with( $values['embed_url'], 'https' ) ) ? '&#x2713;' : '' );
$out .= sprintf( '<td>%s</td>', ( isset( $values['auto_thumbnail'] ) && $values['auto_thumbnail'] ) ? '&#x2713;' : '' );
$out .= sprintf( '<td>%s</td>', ( isset( $values['auto_title'] ) && $values['auto_title'] ) ? '&#x2713;' : '' );
$out .= '</tr>';
}
$out .= '<tr>';
$out .= '<td></td>';
$out .= '<td colspan="6"><a href="https://nextgenthemes.com/plugins/arve/documentation/#general-iframe-embedding">All providers with responsive iframe embed codes</a></td>';
$out .= '</tr>';
$out .= '</table>';
return $out;
}
function arve_shortcode_arve_supported_list() {
$list = '';
$providers = arve_get_host_properties();
// unset deprecated and doubled
unset( $providers['dailymotionlist'] );
unset( $providers['iframe'] );
foreach ( $providers as $key => $values ) {
$list .= '* ' . $values['name'] . PHP_EOL;
}
return '<textarea style="width:100%" rows="15">' . $list . '</textarea>';
}
function arve_shortcode_arve_params() {
$attrs = arve_get_settings_definitions();
if ( function_exists( 'arve_pro_get_settings_definitions' ) ) {
$attrs = array_merge( $attrs, arve_pro_get_settings_definitions() );
}
$out = '<table class="table table-hover table-arve-params">';
$out .= '<tr>';
$out .= '<th>Parameter</th>';
$out .= '<th>Function</th>';
$out .= '</tr>';
foreach ( $attrs as $key => $values ) {
if ( isset( $values['hide_from_sc'] ) && $values['hide_from_sc'] ) {
continue;
}
$desc = '';
unset( $values['options'][''] );
unset( $choices );
if ( ! empty( $values['options'] ) ) {
foreach ( $values['options'] as $key => $value ) {
$choices[] = sprintf( '<code>%s</code>', $key );
}
$desc .= __( 'Options: ', ARVE_SLUG ) . implode( ', ', $choices ) . '<br>';
}
if ( ! empty( $values['description'] ) ) {
$desc .= $values['description'];
}
if ( ! empty( $values['meta']['placeholder'] ) ) {
$desc .= $values['meta']['placeholder'];
}
$out .= '<tr>';
$out .= sprintf( '<td>%s</td>', $values['attr'] );
$out .= sprintf( '<td>%s</td>', $desc );
$out .= '</tr>';
}
$out .= '</table>';
return $out;
}
function arve_wp_video_shortcode_override( $out, $attr, $content, $instance ) {
$options = arve_get_options();
if ( ! $options['wp_video_override'] || ! empty( $attr['wmv'] ) || ! empty( $attr['flv'] ) ) {
return $out;
}
if ( ! empty( $attr['poster'] ) ) {
$attr['thumbnail'] = $attr['poster'];
}
return arve_shortcode_arve( $attr, null );
}
@@ -0,0 +1,47 @@
<?php
function arve_get_attachment_image_url_or_srcset( $url_or_srcset, $thumbnail ) {
$found = arve_get_cached_attachment_image_url_or_srcset( $url_or_srcset, $thumbnail );
if ( $found ) {
return $found;
} elseif ( 'url' === $url_or_srcset ) {
return new WP_Error( 'wp thumbnail', __( 'No attachment with that ID', ARVE_SLUG ) );
} else {
return false;
}
}
function arve_get_cached_attachment_image_url_or_srcset( $url_or_srcset, $attachment_id ) {
$options = arve_get_options();
$transient_name = "arve_attachment_image_{$url_or_srcset}_{$attachment_id}";
$transient = get_transient( $transient_name );
$time = (int) $options['wp_image_cache_time'];
if ( false === $transient || $time <= 0 ) {
if ( 'srcset' === $url_or_srcset ) {
$out = wp_get_attachment_image_srcset( $attachment_id, 'small' );
} elseif ( 'url' === $url_or_srcset ) {
$out = wp_get_attachment_image_url( $attachment_id, 'small' );
}
set_transient( $transient_name, (string) $out, $time );
} else {
$out = $transient;
}
return $out;
}
@@ -0,0 +1,140 @@
<?php
function arve_create_url_handlers() {
$properties = arve_get_host_properties();
foreach ( $properties as $provider => $values ) {
$function = function( $matches, $attr, $url, $rawattr ) use ( $provider ) {
return arve_url_detection_to_shortcode( $provider, $matches, $attr, $url, $rawattr );
};
if ( ! empty( $values['regex'] ) ) {
wp_embed_register_handler( 'arve_' . $provider, '#' . $values['regex'] . '#i', $function );
}
}
}
function arve_url_detection_to_shortcode( $provider, $matches, $attr, $url, $rawattr ) {
//* Fix 'Markdown on save enhanced' issue
if ( substr( $url, -4 ) === '</p>' ) {
$url = substr( $url, 0, -4 );
}
$parsed_url = wp_parse_url( $url );
$url_query = array();
$old_atts = array();
$new_atts = array();
if ( ! empty( $parsed_url['query'] ) ) {
parse_str( $parsed_url['query'], $url_query );
}
foreach ( $url_query as $key => $value ) {
if ( arve_starts_with( $key, 'arve-' ) ) {
$key = substr( $key, 5 );
$old_atts[ $key ] = $value;
}
}
unset( $old_atts['param'] );
if ( isset( $url_query['arve'] ) ) {
$new_atts = $url_query['arve'];
}
if ( isset( $url_query['t'] ) ) {
$url_query['start'] = arve_youtube_time_to_seconds( $url_query['t'] );
}
unset( $url_query['arve'] );
if ( 'youtube' === $provider ) {
unset( $url_query['v'] );
unset( $url_query['t'] );
}
//* Pure awesomeness!
$atts = array_merge( (array) $old_atts, (array) $new_atts );
$atts['parameters'] = empty( $url_query ) ? null : build_query( $url_query );
$atts['url'] = $url;
return arve_shortcode_arve( $atts, null );
}
/**
* Remove the WordPress default Oembed support for video providers that ARVE Supports. Array taken from wp-includes/class-oembed.php __construct
*
* @since 5.9.9
*
*/
function arve_oembed_remove_providers() {
// phpcs:disable Squiz.PHP.CommentedOutCode.Found
$wp_core_oembed_shits = array(
'#http://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ),
'#https://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ),
#'#http://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ),
#'#https://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ),
'#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ),
'#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ),
'#https?://(.+\.)?vimeo\.com/.*#i' => array( 'http://vimeo.com/api/oembed.{format}', true ),
'#https?://(www\.)?dailymotion\.com/.*#i' => array( 'http://www.dailymotion.com/services/oembed', true ),
'http://dai.ly/*' => array( 'http://www.dailymotion.com/services/oembed', false ),
#'#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ),
#'#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ),
#'#https?://(.+\.)?smugmug\.com/.*#i' => array( 'http://api.smugmug.com/services/oembed/', true ),
#'#https?://(www\.)?hulu\.com/watch/.*#i' => array( 'http://www.hulu.com/api/oembed.{format}', true ),
#'http://revision3.com/*' => array( 'http://revision3.com/api/oembed/', false ),
#'http://i*.photobucket.com/albums/*' => array( 'http://photobucket.com/oembed', false ),
#'http://gi*.photobucket.com/groups/*' => array( 'http://photobucket.com/oembed', false ),
#'#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'http://www.scribd.com/services/oembed', true ),
#'#https?://wordpress.tv/.*#i' => array( 'http://wordpress.tv/oembed/', true ),
#'#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ),
#'#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ),
'#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ),
#'#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array( 'https://api.twitter.com/1/statuses/oembed.{format}', true ),
'#https?://vine.co/v/.*#i' => array( 'https://vine.co/oembed.{format}', true ),
#'#https?://(www\.)?soundcloud\.com/.*#i' => array( 'http://soundcloud.com/oembed', true ),
#'#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ),
#'#http://instagr(\.am|am\.com)/p/.*#i' => array( 'http://api.instagram.com/oembed', true ),
#'#https?://(www\.)?rdio\.com/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ),
#'#https?://rd\.io/x/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ),
#'#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ),
#'#https?://(.+\.)?imgur\.com/.*#i' => array( 'http://api.imgur.com/oembed', true ),
#'#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'http://api.meetup.com/oembed', true ),
#'#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'http://issuu.com/oembed_wp', true ),
'#https?://(www\.)?collegehumor\.com/video/.*#i' => array( 'http://www.collegehumor.com/oembed.{format}', true ),
#'#https?://(www\.)?mixcloud\.com/.*#i' => array( 'http://www.mixcloud.com/oembed', true ),
'#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'http://www.ted.com/talks/oembed.{format}', true ),
#'#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'http://animoto.com/oembeds/create', true ),
);
foreach ( $wp_core_oembed_shits as $shit => $fuck ) {
wp_oembed_remove_provider( $shit );
}
// Jetpack shit
remove_shortcode( 'dailymotion', 'dailymotion_shortcode' );
remove_filter( 'pre_kses', 'jetpack_dailymotion_embed_reversal' );
remove_filter( 'pre_kses', 'dailymotion_embed_to_shortcode' );
remove_shortcode( 'vimeo', 'vimeo_shortcode' );
remove_filter( 'pre_kses', 'vimeo_embed_to_shortcode' );
wp_embed_unregister_handler( 'jetpack_vine' );
remove_shortcode( 'vine', 'vine_shortcode' );
remove_filter( 'pre_kses', 'youtube_embed_to_short_code' );
remove_shortcode( 'youtube', 'youtube_shortcode' );
remove_shortcode( 'ted', 'shortcode_ted' );
wp_oembed_remove_provider( '!https?://(www\.)?ted.com/talks/view/id/.+!i' );
wp_oembed_remove_provider( '!https?://(www\.)?ted.com/talks/[a-zA-Z\-\_]+\.html!i' );
}
@@ -0,0 +1,106 @@
<?php
function arve_validate_url( $url ) {
if ( arve_starts_with( $url, '//' ) ) {
$url = 'https:' . $url;
}
if ( arve_starts_with( $url, 'http' ) && filter_var( $url, FILTER_VALIDATE_URL ) !== false ) {
return true;
}
return false;
}
function arve_validate_aspect_ratio( $aspect_ratio ) {
if ( empty( $aspect_ratio ) ) {
return $aspect_ratio;
}
$a = explode( ':', $aspect_ratio );
if ( ! empty( $a[0] ) && is_numeric( $a[0] ) && ! empty( $a[1] ) && is_numeric( $a[1] ) ) {
return $aspect_ratio;
}
return new WP_Error(
'Aspect ratio',
sprintf( __( 'Aspect ratio <code>%s</code> is not valid', ARVE_SLUG ), $aspect_ratio )
);
}
function arve_bool_to_shortcode_string( $val ) {
if ( false === $val ) {
return 'n';
}
return (string) $val;
}
function arve_validate_bool( $val, $name ) {
switch ( $val ) {
case 'true':
case '1':
case 'y':
case 'yes':
case 'on':
return true;
case null:
return null;
case 'false':
case '0':
case 'n':
case 'no':
case 'off':
return false;
default:
return new WP_Error(
$name,
sprintf( __( '%1$s <code>%2$s</code> not valid', ARVE_SLUG ), $name, $val )
);
}
}
function arve_validate_align( $align ) {
switch ( $align ) {
case null:
case '':
case 'none':
$align = null;
break;
case 'left':
case 'right':
case 'center':
break;
default:
$align = new WP_Error( 'align', sprintf( __( 'Align <code>%s</code> not valid', ARVE_SLUG ), esc_html( $align ) ) );
break;
}
return $align;
}
function arve_validate_mode( $mode, $provider ) {
if ( 'thumbnail' === $mode ) {
$mode = 'lazyload-lightbox';
}
if ( 'veoh' === $mode ) {
$mode = 'normal';
}
$supported_modes = arve_get_supported_modes();
if ( ! array_key_exists( $mode, $supported_modes ) ) {
$mode = 'normal';
}
return $mode;
}