Page map
-galerie -fmulticurl() -infobox avec vignette, texte et lien wikipedia + -bouton shotcode flickr -bugfixes
This commit is contained in:
484
functions.php
484
functions.php
@@ -108,14 +108,14 @@ function custom_class( $classes ) {
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
/**/
|
||||
// Bouton Shortcode Zenphoto dans l'éditeur
|
||||
|
||||
// Bouton Shortcode zenphoto dans l'éditeur
|
||||
|
||||
function register_button( $buttons ) {
|
||||
function register_button_zp( $buttons ) {
|
||||
array_push( $buttons, "|", "zenphoto" );
|
||||
return $buttons;
|
||||
}
|
||||
function add_plugin( $plugin_array ) {
|
||||
function add_plugin_zp( $plugin_array ) {
|
||||
$plugin_array['zenphoto'] = get_stylesheet_directory_uri() . '/js/short-zenphoto.js';
|
||||
return $plugin_array;
|
||||
}
|
||||
@@ -126,13 +126,36 @@ function my_zenphoto_button() {
|
||||
}
|
||||
|
||||
if ( get_user_option('rich_editing') == 'true' ) {
|
||||
add_filter( 'mce_external_plugins', 'add_plugin' );
|
||||
add_filter( 'mce_buttons', 'register_button' );
|
||||
add_filter( 'mce_external_plugins', 'add_plugin_zp' );
|
||||
add_filter( 'mce_buttons', 'register_button_zp' );
|
||||
}
|
||||
|
||||
}
|
||||
add_action('init', 'my_zenphoto_button');
|
||||
|
||||
// Bouton Shortcode Flickr dans l'éditeur
|
||||
|
||||
function register_button_flk( $buttons ) {
|
||||
array_push( $buttons, "|", "flickr" );
|
||||
return $buttons;
|
||||
}
|
||||
function add_plugin_flk( $plugin_array ) {
|
||||
$plugin_array['flickr'] = get_stylesheet_directory_uri() . '/js/short-flickr.js';
|
||||
return $plugin_array;
|
||||
}
|
||||
function my_flickr_button() {
|
||||
|
||||
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_user_option('rich_editing') == 'true' ) {
|
||||
add_filter( 'mce_external_plugins', 'add_plugin_flk' );
|
||||
add_filter( 'mce_buttons', 'register_button_flk' );
|
||||
}
|
||||
|
||||
}
|
||||
add_action('init', 'my_flickr_button');
|
||||
|
||||
function RelativeTime() {
|
||||
|
||||
@@ -383,11 +406,56 @@ function date_archive ($chaine) {
|
||||
return $chaine;
|
||||
}
|
||||
|
||||
/* Images externes (pas de Retina) */
|
||||
|
||||
function picture_handler($atts, $content=null) {
|
||||
|
||||
global $coord;
|
||||
$display_exif = dess_setting('dess_display_exif');
|
||||
$display_gps = dess_setting('dess_display_gps');
|
||||
|
||||
extract(shortcode_atts(array(
|
||||
"image" => $atts[0],
|
||||
"url"=>"", //setting default value
|
||||
"caption"=>"" //setting default value
|
||||
), $atts));
|
||||
|
||||
/*
|
||||
[picture image="http://www.photo-nature-21.fr/Benelux/2008-10-18_Bouquetin_9965.jpg" url="http://www.photo-nature-21.fr/Benelux/2008-10-18_Bouquetin_9965.jpg" caption="Bouquetin"]
|
||||
*/
|
||||
/*
|
||||
Pas d'exifs pour les images distantes.
|
||||
|
||||
$pict_size = getimagesize(htmlentities($image));
|
||||
$meta = creator_get_exif( $image ); // l 1323
|
||||
preprint($meta);
|
||||
$exif_array = img_wp_exif( $meta ); // l 1240
|
||||
preprint($exif_array);*/
|
||||
|
||||
|
||||
$links = (($caption != "") ? '<div id="pictures_' . $rnd . '" style="width: ' . ($pict_size[0] + 10) . 'px" class="wp-caption aligncenter">' : '');
|
||||
|
||||
$links .= (($url != "") ? '<a href="' . $url . '" class="' . (($lb == true) ? $selector : '') . '"title="' . $title . '">' : '');
|
||||
$links .= '<img class="';
|
||||
$links .= (($caption == "") ? 'aligncenter size-medium"' : '"');
|
||||
$links .= 'src="' . $image . '" alt="' . $title . '" />';
|
||||
$links .= (($url != "") ? '</a>' : '');
|
||||
|
||||
$links .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
|
||||
|
||||
//$links .= (($display_exif == true) ? "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>" : '');
|
||||
|
||||
return $links;
|
||||
}
|
||||
add_shortcode( 'picture', 'picture_handler' );
|
||||
|
||||
|
||||
function flickr_handler($atts, $content=null) {
|
||||
|
||||
global $coord;
|
||||
$api_key = "3884af4190ac97a95fd4777dba0d9f21";
|
||||
$display_exif = dess_setting('dess_display_exif');
|
||||
$display_gps = dess_setting('dess_display_gps');
|
||||
|
||||
extract(shortcode_atts(array(
|
||||
"pid" => $atts[0],
|
||||
@@ -400,9 +468,6 @@ function flickr_handler($atts, $content=null) {
|
||||
$pid=$e[5];
|
||||
}
|
||||
|
||||
//echo $pid . " - ". $version . " - ". $caption . " - ". $url . "<br>";
|
||||
// 27868468454 - Medium - - https://www.flickr.com/photos/funnymac/27868468454/
|
||||
|
||||
/*
|
||||
[flickr url="https://www.flickr.com/photos/funnymac/27868468454/"]
|
||||
|
||||
@@ -450,7 +515,6 @@ function flickr_handler($atts, $content=null) {
|
||||
break;
|
||||
}
|
||||
|
||||
//echo $img_sd . " - ". $img_hd . "<br>";
|
||||
/*
|
||||
$link = ! empty( $atts['link'] ) ? $atts['link'] : '';
|
||||
$link = filter_var($link, FILTER_SANITIZE_URL);
|
||||
@@ -474,14 +538,13 @@ function flickr_handler($atts, $content=null) {
|
||||
$info = array();
|
||||
*/
|
||||
|
||||
/* lb ???? */
|
||||
|
||||
// 1220 -610
|
||||
$lb = toBool($lb);
|
||||
$rnd = rand (1000, 9999);
|
||||
$selector = dess_setting('dess_lightbox_select');
|
||||
|
||||
|
||||
|
||||
$url1 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getSizes';
|
||||
$url1 .= '&api_key='.$api_key;
|
||||
$url1 .= '&photo_id='.$pid;
|
||||
@@ -490,7 +553,6 @@ function flickr_handler($atts, $content=null) {
|
||||
|
||||
$result = file_get_contents($url1);
|
||||
$response = json_decode($result, true);
|
||||
//preprint($response);
|
||||
|
||||
$taille = $response['sizes']['size'];
|
||||
|
||||
@@ -517,7 +579,6 @@ function flickr_handler($atts, $content=null) {
|
||||
|
||||
$result2 = file_get_contents($url2);
|
||||
$response2 = json_decode($result2, true);
|
||||
//var_dump($response2);
|
||||
|
||||
$title = $response2['photo']['title']['_content'];
|
||||
$date = $response2['photo']['dates']['taken'];
|
||||
@@ -534,16 +595,6 @@ function flickr_handler($atts, $content=null) {
|
||||
$tags[] = utf8_encode(ucfirst($i));
|
||||
}
|
||||
|
||||
$img = array(
|
||||
'medium' => $mediumSRC,
|
||||
'large' => $largeSRC
|
||||
//'titre' => $title,
|
||||
//'date' => $date,
|
||||
//'latitude' => $lat,
|
||||
//'longitude' => $long,
|
||||
//'tags' => $tags
|
||||
);
|
||||
|
||||
/* EXIF */
|
||||
|
||||
$url3 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getExif';
|
||||
@@ -560,7 +611,6 @@ function flickr_handler($atts, $content=null) {
|
||||
|
||||
$meta = array();
|
||||
foreach ($exif as $val) {
|
||||
//preprint($val);
|
||||
|
||||
if ($val['tag'] == 'FNumber') $meta['aperture'] = $val['raw']['_content'];
|
||||
//if ($val['tag'] == 'xxx') $meta['credit'] = $val['raw']['_content'];
|
||||
@@ -586,47 +636,26 @@ function flickr_handler($atts, $content=null) {
|
||||
|
||||
}
|
||||
|
||||
//preprint($exifs);
|
||||
/*
|
||||
$meta = zp_query_exif( $zp_image );
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif rouge'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
*/
|
||||
//$meta = zp_query_exif( $zp_image ); //745 $meta['keywords'] =>
|
||||
$exif_array = img_wp_exif( $meta ); //1214
|
||||
//echo "exif_array";
|
||||
//preprint($exif_array);
|
||||
|
||||
|
||||
$links = (($caption != "") ? '<div id="flickr_' . $rnd . '" style="width: ' . ($w_mediumSRC + 10) . 'px" class="wp-caption aligncenter">' : '');
|
||||
|
||||
$links .= '<a href="' . $largeSRC . '" class="' . (($lb == true) ? $selector : '') . '"title="' . $title . '">';
|
||||
$links .= '<img class="';
|
||||
$links .= (($caption == "") ? 'aligncenter size-medium"' : '"');
|
||||
|
||||
//$links .= 'srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="' . $img . '" />';
|
||||
//$links .= 'srcset="' . $small . ', " ' . $flickr_size[3] . ' 2x" alt="' . $img . '" />';
|
||||
$links .= 'srcset="' . $mediumSRC . ', ' . $largeSRC . ' 2x' . '" alt="' . $title . '" />';
|
||||
|
||||
$links .= 'srcset="' . $mediumSRC . ', ' . $largeSRC . ' 2x' . '" alt="' . $title . '" />';
|
||||
$links .= '</a>';
|
||||
|
||||
$links .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
|
||||
|
||||
$links .= "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
|
||||
/*
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
$content = str_replace($matches[$i][0], $matches[$i][0] . $exifs, $content);
|
||||
$matches2 = array();
|
||||
*/
|
||||
if (($meta['longitude'] != "") && ($meta['latitude'] != "")) {
|
||||
if ($meta['caption'] != "") $fichier = $meta['caption'];
|
||||
else if ($meta['title'] != "") $fichier = $meta['title'];
|
||||
//else $fichier = end(explode("/", $court));
|
||||
array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier));
|
||||
}
|
||||
$links .= (($display_exif == true) ? "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>" : '');
|
||||
|
||||
if (($meta['longitude'] != "") && ($meta['latitude'] != "")) {
|
||||
if ($meta['caption'] != "") $fichier = $meta['caption'];
|
||||
else if ($meta['title'] != "") $fichier = $meta['title'];
|
||||
//else $fichier = end(explode("/", $court));
|
||||
array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier));
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
@@ -657,22 +686,18 @@ function zenphoto_handler($atts, $content=null) {
|
||||
$caption = ! empty( $atts['caption'] ) ? $atts['caption'] : '';
|
||||
$caption = filter_var($caption, FILTER_SANITIZE_STRING);
|
||||
|
||||
//echo "album: " . $album . " image: " . $image . "<br>";
|
||||
|
||||
$rnd = rand (1000, 9999);
|
||||
|
||||
//$size = 610;
|
||||
|
||||
$folder = false;
|
||||
//echo "folder1: " . $folder . "<br>";
|
||||
$zenphoto_img = "";
|
||||
|
||||
// Si ALBUM mais pas IMAGE
|
||||
//echo "album2: " . $album . " image2: " . $image . "<br>";
|
||||
|
||||
//if (($album != "") && ($image == "")) {
|
||||
require('../Connections/cnx.php');
|
||||
|
||||
require('../Connections/cnx.php');
|
||||
|
||||
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
|
||||
if (mysqli_connect_errno()) {
|
||||
@@ -738,16 +763,6 @@ function zenphoto_handler($atts, $content=null) {
|
||||
else $zenphoto_link = '<a href="' . $zenphoto_url . $album . '">';
|
||||
|
||||
$zenphoto_img .= $zenphoto_link;
|
||||
/*
|
||||
$zenphoto_img .= '<picture data-picture data-alt="">
|
||||
<!--[if IE 9]><video style="display: none;"><![endif]-->
|
||||
<source class="image_standard" srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_' . $size . '_watermark.jpg, ' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_FULL' . '_watermark.jpg 2x">
|
||||
<source class="image_medium" srcset="" media="(max-width: 767px)">
|
||||
<source class="image_small" srcset="" media="(max-width: 767px)">
|
||||
<!--[if IE 9]></video><![endif]-->
|
||||
<img class="aligncenter" srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_' . $size . '_watermark.jpg" ' . $zp_size[3] . 'alt="' . $img . '" />
|
||||
</picture>';
|
||||
*/
|
||||
$zenphoto_img .= '<img class="';
|
||||
$zenphoto_img .= (($caption == "") ? 'aligncenter size-medium"' : '"');
|
||||
$zenphoto_img .= 'srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="' . $img . '" />';
|
||||
@@ -804,9 +819,9 @@ Array
|
||||
- [13] => a:1:{s:5:"fr_FR";s:24:"2014-10-21_PontDArc_0406";} *title*
|
||||
[14] => *EXIFLensType*
|
||||
- [15] => EF17-40mm f/4L USM *EXIFLensInfo*
|
||||
- [16] => 1: Normal (0 degr<67>) *EXIFOrientation*
|
||||
- [16] => 1: Normal (0 degr<67>) *EXIFOrientation*
|
||||
- [17] => Bruno Pesenti *credit*
|
||||
- [18] => bruno@clicclac.info *copyright*
|
||||
- [18] => bruno@clicclac.info *copyright*
|
||||
- [19] => *id*
|
||||
)
|
||||
*/
|
||||
@@ -1075,10 +1090,11 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
|
||||
// `1049`
|
||||
|
||||
//$pattern = '/<div id=[^>]*>(.*?)\<\/div>/';
|
||||
$pattern = '/<div id=\"(zp|attachment)_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
|
||||
//$pattern = '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is';
|
||||
$pattern = '/<div id=\"(zp|attachment)_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/'; //ok
|
||||
//$pattern = '/<div id=\"attachment_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
|
||||
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
|
||||
//var_dump($matches);
|
||||
//preprint($matches);
|
||||
/*
|
||||
echo "matches[0][0]"; //<div id="attachment_1049">...</div>
|
||||
echo "matches[0][1]"; // 1114
|
||||
@@ -1192,37 +1208,31 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
|
||||
} // else zenphoto
|
||||
|
||||
// Autres sources que WP et ZP
|
||||
elseif (substr_count($ancien, 'jpg') > 0) {
|
||||
elseif ((substr_count($ancien, 'jpg') > 0) and (substr_count($ancien, 'flickr') == 0)) {
|
||||
|
||||
//echo "court2: " . $court . "<br>";
|
||||
$meta = creator_get_exif( $court );
|
||||
//$flk_size = getimagesize(htmlentities($filename3));
|
||||
//echo "long2: " . $ancien . "<br>";
|
||||
//$meta = creator_get_exif( $court );
|
||||
|
||||
// si $court est déjà dans $matches3 (si l'image est déjà dans un DIV)
|
||||
/*
|
||||
Flicker (portrait):
|
||||
<a href="https://flic.kr/p/Cn2dTd"><img src="https://farm2.staticflickr.com/1704/23866728514_76a72305a9_c.jpg" portrait /></a>
|
||||
if (in_multiarray($court, $matches3) == false) {
|
||||
$meta = creator_get_exif( $court );
|
||||
//preprint($meta);
|
||||
|
||||
Flicker (paysage) vautour avec branche:
|
||||
<a href="https://flic.kr/p/DPRf6e"><img src="https://farm2.staticflickr.com/1544/24826683615_3967bc60d2_c.jpg" /></a>
|
||||
|
||||
1600x1066 https://www.flickr.com/photos/funnymac/24826683615/sizes/o/
|
||||
https://c2.staticflickr.com/2/1544/24826683615_c42292df06_o.jpg
|
||||
BBCODE [url=https://flic.kr/p/DPRf6e][img]https://c1.staticflickr.com/2/1544/24826683615_558bff1744_h.jpg[/img][/url]
|
||||
|
||||
|
||||
800x533 https://www.flickr.com/photos/funnymac/24826683615/sizes/c/
|
||||
https://c2.staticflickr.com/2/1544/24826683615_3967bc60d2_c.jpg
|
||||
|
||||
$atts['link'] = $link;
|
||||
$atts['small'] = $small;
|
||||
$atts['big'] = $big;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
//$content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content);
|
||||
$string = substr_replace($matches4[$i][0], $matches4[$i][0] . $exifs, -6, 0);
|
||||
//echo $string;
|
||||
|
||||
}
|
||||
*/
|
||||
//$anc = str_replace("/></a>", "class='aligncenter' style='width: " . (($portrait === false) ? "610" : "408") . "px;' /></a>", $ancien) . "\r\n";
|
||||
//$anc = str_replace("/></a>", "class='aligncenter' /></a>", $ancien) . "\r\n";
|
||||
|
||||
} // else
|
||||
|
||||
$exif = "";
|
||||
|
||||
} // for
|
||||
@@ -1234,7 +1244,6 @@ add_action('the_content','addexif');
|
||||
|
||||
|
||||
function img_wp_exif( $exif_array ) {
|
||||
//preprint($exif_array);
|
||||
/*
|
||||
Array
|
||||
(
|
||||
@@ -1324,7 +1333,7 @@ function creator_get_exif( $file ) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
//echo "file: " . $file . "<br>";
|
||||
echo "file: " . $file . "<br>";
|
||||
|
||||
list( , , $sourceImageType ) = getimagesize( $file );
|
||||
|
||||
@@ -1364,6 +1373,7 @@ function creator_get_exif( $file ) {
|
||||
|
||||
if ( ! empty( $info['APP13'] ) ) {
|
||||
$iptc = iptcparse( $info['APP13'] );
|
||||
preprint($iptc);
|
||||
|
||||
// Headline, "A brief synopsis of the caption."
|
||||
if ( ! empty( $iptc['2#105'][0] ) ) {
|
||||
@@ -1396,8 +1406,10 @@ function creator_get_exif( $file ) {
|
||||
elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
|
||||
$meta['credit'] = trim( $iptc['2#080'][0] );
|
||||
|
||||
if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) // created date and time
|
||||
// created date and time
|
||||
if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) {
|
||||
$meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
|
||||
}
|
||||
|
||||
if ( ! empty( $iptc['2#116'][0] ) ) // copyright
|
||||
$meta['copyright'] = trim( $iptc['2#116'][0] );
|
||||
@@ -1412,7 +1424,7 @@ function creator_get_exif( $file ) {
|
||||
if ( is_callable( 'exif_read_data' )) {
|
||||
$exif = @exif_read_data( $file );
|
||||
|
||||
//preprint($exif);
|
||||
preprint($exif);
|
||||
|
||||
if ( ! empty( $exif['ImageDescription'] ) ) {
|
||||
mbstring_binary_safe_encoding();
|
||||
@@ -1453,8 +1465,10 @@ function creator_get_exif( $file ) {
|
||||
$meta['camera'] = trim( $exif['Model'] );
|
||||
}
|
||||
if ( empty( $meta['created_timestamp'] ) && ! empty( $exif['DateTimeDigitized'] ) ) {
|
||||
//if ( ! empty( $exif['DateTimeDigitized'] ) ) {
|
||||
$meta['created_timestamp'] = ctc_exif_date2ts( $exif['DateTimeDigitized'] );
|
||||
//$meta['created_timestamp'] = wp_exif_date2ts( $exif['DateTimeDigitized'] );
|
||||
$meta['created_timestamp'] = $exif['DateTimeDigitized'];
|
||||
//$meta['created_timestamp'] = $exif['DateTimeDigitized'];
|
||||
}
|
||||
if ( ! empty( $exif['FocalLength'] ) ) {
|
||||
$meta['focal_length'] = (string) geo_frac2dec( $exif['FocalLength'] ) . " mm";
|
||||
@@ -1560,6 +1574,150 @@ function gps($coordinate, $hemisphere) {
|
||||
}
|
||||
|
||||
|
||||
function mapgallery( $attr ) {
|
||||
/*
|
||||
$atts = shortcode_atts( array(
|
||||
'order' => 'ASC',
|
||||
'ids' => '',
|
||||
'orderby' => 'menu_order ID',
|
||||
'id' => $post ? $post->ID : 0,
|
||||
'itemtag' => $html5 ? 'figure' : 'dl',
|
||||
'icontag' => $html5 ? 'div' : 'dt',
|
||||
'captiontag' => $html5 ? 'figcaption' : 'dd',
|
||||
'columns' => 3,
|
||||
'size' => 'thumbnail',
|
||||
'include' => '',
|
||||
'exclude' => '',
|
||||
'link' => ''
|
||||
), $attr, 'mapgallery' );
|
||||
*/
|
||||
|
||||
//$columns = $attr['columns'];
|
||||
$size_class = $attr['size'];
|
||||
//$itemtag = $attr['itemtag'];
|
||||
//$icontag = $attr['icontag'];
|
||||
//$captiontag = $attr['captiontag'];
|
||||
$link = $attr['link'];
|
||||
|
||||
$itemtag = tag_escape( $attr['itemtag'] );
|
||||
$captiontag = tag_escape( $attr['captiontag'] );
|
||||
$icontag = tag_escape( $attr['icontag'] );
|
||||
$valid_tags = wp_kses_allowed_html( 'post' );
|
||||
if ( ! isset( $valid_tags[ $itemtag ] ) ) {
|
||||
$itemtag = 'dl';
|
||||
}
|
||||
if ( ! isset( $valid_tags[ $captiontag ] ) ) {
|
||||
$captiontag = 'dd';
|
||||
}
|
||||
if ( ! isset( $valid_tags[ $icontag ] ) ) {
|
||||
$icontag = 'dt';
|
||||
}
|
||||
|
||||
$instance = 1;
|
||||
$columns = intval( $attr['columns'] );
|
||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||
$float = is_rtl() ? 'right' : 'left';
|
||||
$selector = "gallery-{$instance}";
|
||||
|
||||
$selecteur = dess_setting('dess_lightbox_select');
|
||||
|
||||
//if ( apply_filters( 'use_default_gallery_style', ! $html5 ) ) {
|
||||
$gallery_style = "
|
||||
<style type='text/css'>
|
||||
#{$selector} {
|
||||
margin: auto;
|
||||
}
|
||||
#{$selector} .gallery-item {
|
||||
float: {$float};
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
width: {$itemwidth}%;
|
||||
}
|
||||
#{$selector} img {
|
||||
border: 2px solid #cfcfcf;
|
||||
}
|
||||
#{$selector} .gallery-caption {
|
||||
margin-left: 0;
|
||||
}
|
||||
/* see gallery_shortcode() in wp-includes/media.php */
|
||||
</style>\n\t\t";
|
||||
//}
|
||||
echo $gallery_style;
|
||||
|
||||
//$ids = implode(',',$attr['ids']); // '70,69,68,67'
|
||||
|
||||
$gallery_div = "<div id='$selector' class='gallery galleryid-map gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
//"<div id='gallery-1' class='gallery galleryid-27 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>";
|
||||
//$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
|
||||
|
||||
$output .= $gallery_div;
|
||||
|
||||
$gallery_div .= "<{$itemtag} class='gallery-item'>";
|
||||
|
||||
$i = 0;
|
||||
foreach ( $attr['ids'] as $id ) {//
|
||||
|
||||
$attribut = wp_prepare_attachment_for_js( $id );
|
||||
/*
|
||||
'description' => string 'Description' (length=11)
|
||||
'caption' => string 'Cascades de la Pleureuse et de la Sauffaz' (length=41)
|
||||
*/
|
||||
|
||||
$image_meta = wp_get_attachment_metadata( $id );
|
||||
|
||||
$orientation = '';
|
||||
if ( isset( $image_meta['height'], $image_meta['width'] ) ) {
|
||||
$orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';
|
||||
}
|
||||
|
||||
$output .= "<{$itemtag} class='gallery-item'>";
|
||||
if ( ! empty( $attr['link'] ) && 'file' === $attr['link'] ) {
|
||||
// lien vers l'image
|
||||
$image_output = "<a href='" . wp_get_attachment_url( $id ) . "' class='{$selecteur}'> " . wp_get_attachment_image($id, $attr['size'], false, $attr ) . "</a>";
|
||||
} elseif ( ! empty( $attr['link'] ) && 'none' === $attr['link'] ) {
|
||||
// pas de lien - juste la vignette
|
||||
$image_output = wp_get_attachment_image( $id, $attr['size'], false, $attr );
|
||||
} else {
|
||||
// lien vers la page attachment
|
||||
$image_output = wp_get_attachment_link( $id, $attr['size'], true, false, false, $attr );
|
||||
}
|
||||
$output .= "<{$icontag} class='gallery-icon {$orientation}'>$image_output</{$icontag}>";
|
||||
/*
|
||||
if ( $captiontag && trim($attribut['caption']) ) {
|
||||
$output .= "
|
||||
<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
|
||||
" . wptexturize($attribut['caption']) . "
|
||||
</{$captiontag}>";
|
||||
}
|
||||
*/
|
||||
$cible = "<a href='javascript:void(0);' class='cible' onclick='jumpToMarker(" . $i . ")'><i class='ion-ios-location'></i></a>";
|
||||
if ( $captiontag && trim($attribut['caption']) ) {
|
||||
$output .= "
|
||||
<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
|
||||
" . wptexturize($attribut['caption']) . "
|
||||
$cible</{$captiontag}>";
|
||||
}
|
||||
|
||||
$output .= "</{$itemtag}>";
|
||||
|
||||
if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) {
|
||||
$output .= '<br style="clear: both" />';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! $html5 && $columns > 0 && $i % $columns !== 0 ) {
|
||||
$output .= '<br style="clear: both" />';
|
||||
}
|
||||
|
||||
$output .= "
|
||||
</div>\n";
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
|
||||
remove_shortcode('gallery', 'gallery_shortcode');
|
||||
|
||||
add_shortcode('gallery', 'creator_gallery_shortcode');
|
||||
@@ -1740,7 +1898,7 @@ function creator_gallery_shortcode( $attr ) {
|
||||
*/
|
||||
$output = apply_filters( 'gallery_style', $gallery_style . $gallery_div );
|
||||
|
||||
$selector = dess_setting('dess_lightbox_select');
|
||||
$selecteur = dess_setting('dess_lightbox_select');
|
||||
|
||||
$i = 0;
|
||||
foreach ( $attachments as $id => $attachment ) {
|
||||
@@ -1749,7 +1907,7 @@ function creator_gallery_shortcode( $attr ) {
|
||||
if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) {
|
||||
//$image_output = wp_get_attachment_link( $id, $atts['size'], false, false, false, $attr );
|
||||
//$image_output = "<a href='" . wp_get_attachment_url( $id ) . "'> " . wp_get_attachment_image($id, $atts['size'], false, $attr ) . "</a>";
|
||||
$image_output = "<a href='" . wp_get_attachment_url( $id ) . "' class='{$selector}'> " . wp_get_attachment_image($id, $atts['size'], false, $attr ) . "</a>";
|
||||
$image_output = "<a href='" . wp_get_attachment_url( $id ) . "' class='{$selecteur}'> " . wp_get_attachment_image($id, $atts['size'], false, $attr ) . "</a>";
|
||||
} elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) {
|
||||
$image_output = wp_get_attachment_image( $id, $atts['size'], false, $attr );
|
||||
} else {
|
||||
@@ -2211,6 +2369,103 @@ function pa_the_post_thumbnail_exif_data($content) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fmulticurl($query) {
|
||||
|
||||
$url = "https://fr.wikipedia.org/w/api.php";
|
||||
$erreur = array();
|
||||
$fields = array(
|
||||
'action' => 'opensearch',
|
||||
//'search' => $query,
|
||||
'format' => 'json',
|
||||
'profile' => 'strict' //strict, normal, *fuzzy*, classic
|
||||
);
|
||||
|
||||
$fields_string = "";
|
||||
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
|
||||
|
||||
foreach ($query as &$val) {
|
||||
$val = $url . "?" . $fields_string . "search=" . str_replace(" ", "_", trim($val));
|
||||
}
|
||||
|
||||
//create the multiple cURL handle
|
||||
$mh = curl_multi_init();
|
||||
|
||||
$nbr = count($query);
|
||||
|
||||
// set URL and options
|
||||
for($x = 0; $x < $nbr; $x++){
|
||||
|
||||
$ch[$x] = curl_init();
|
||||
|
||||
curl_setopt($ch[$x], CURLOPT_URL, $query[$x]);
|
||||
//curl_setopt($ch[$x], CURLOPT_POST, 1);// set post data to true
|
||||
//curl_setopt($ch[$x], CURLOPT_POSTFIELDS, $fields); // post data
|
||||
|
||||
curl_setopt($ch[$x], CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch[$x], CURLOPT_USERAGENT, 'ClicBot/1.0 (https://clicclac.info/; contact@clicclac.info)');
|
||||
curl_setopt($ch[$x], CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt($ch[$x], CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
curl_multi_add_handle($mh,$ch[$x]);
|
||||
}
|
||||
|
||||
|
||||
$running = null;
|
||||
|
||||
do {
|
||||
curl_multi_exec($mh, $running);
|
||||
} while ($running);
|
||||
|
||||
for($x = 0; $x < $nbr; $x++){
|
||||
$result = curl_multi_getcontent($ch[$x]);
|
||||
$obj[]= json_decode($result, true);
|
||||
|
||||
//get info about the request
|
||||
// $error = curl_getinfo($ch[$x], CURLINFO_HTTP_CODE);
|
||||
// if($error != 200){
|
||||
|
||||
if (curl_errno($ch[$x])) {
|
||||
$erreur[] = array("Url" =>curl_getinfo($ch[$x], CURLINFO_EFFECTIVE_URL), "error_info" => curl_getinfo($ch[$x]));
|
||||
}
|
||||
|
||||
//error handling
|
||||
/*
|
||||
200 : succès de la requête ;
|
||||
301 et 302 : redirection, respectivement permanente et temporaire ;
|
||||
401 : utilisateur non authentifié ;
|
||||
403 : accès refusé ;
|
||||
404 : page non trouvée ;
|
||||
500 et 503 : erreur serveur.
|
||||
*/
|
||||
|
||||
curl_multi_remove_handle($mh, $ch[$x]);
|
||||
curl_close($ch[$x]);
|
||||
}
|
||||
|
||||
curl_multi_close($mh);
|
||||
|
||||
|
||||
for ($a = 0; $a < count($obj); $a++){
|
||||
|
||||
if (is_array($obj[$a])) {
|
||||
|
||||
for ($b = 0; $b < count($obj[$a]); $b++){
|
||||
|
||||
if (empty($obj[$a][$b])) {
|
||||
$obj[$a][$b][0] = "";
|
||||
}
|
||||
}
|
||||
|
||||
} //if
|
||||
|
||||
} //for
|
||||
|
||||
if (count($erreur) > 0) var_dump($erreur);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/*
|
||||
function wp_exif_frac2dec($str) {
|
||||
@list( $n, $d ) = explode( '/', $str );
|
||||
@@ -2218,12 +2473,31 @@ function wp_exif_frac2dec($str) {
|
||||
return $n / $d;
|
||||
return $str;
|
||||
}
|
||||
function wp_exif_date2ts($str) {
|
||||
*/
|
||||
// wp_exif_date2ts
|
||||
if ( ! function_exists( 'wp_exif_date2ts' ) ) :
|
||||
function ctc_exif_date2ts($str) {
|
||||
@list( $date, $time ) = explode( ' ', trim($str) );
|
||||
@list( $y, $m, $d ) = explode( ':', $date );
|
||||
|
||||
return strtotime( "{$y}-{$m}-{$d} {$time}" );
|
||||
}
|
||||
*/
|
||||
endif; //
|
||||
|
||||
|
||||
function safe_array_access($ar){
|
||||
$numargs = func_num_args();
|
||||
$arg_list = func_get_args();
|
||||
$aritterator = $ar;
|
||||
for($i = 1; $i < $numargs; $i++){
|
||||
if (isset($aritterator[$arg_list[$i]]) || array_key_exists($arg_list[$i], $aritterator)){
|
||||
$aritterator = $aritterator[$arg_list[$i]];
|
||||
}else{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
return($aritterator);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user