Files
creator-child/functions.php
Bruno Pesenti 8f5e96857a infobox avec vignette et info wikipedia
pour ZP, Flickr et WP sur single.php
2017-02-26 19:50:29 +01:00

2678 lines
92 KiB
PHP
Raw Blame History

<?php load_theme_textdomain('CreatorThemeRes-child', get_template_directory() . '-child/languages'); ?>
<?php
$serial = "I-JHF68ABWM4B2";
update_option( 'wr2x_pro', array( 'subscr_id' => $serial ) );
update_option( 'wr2x_pro_status', _( "Your subscription is manually enabled." ) );
update_option( 'wr2x_pro_serial', _( $serial ) );
set_transient( 'wr2x_validated', $serial, 3600 * 24 * 100 );
function google_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
//wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', false, '3.1.1');
wp_register_script('jquery', get_stylesheet_directory_uri() . '/js/jquery.min.js', false, '3.1.1');
wp_enqueue_script('jquery');
}
}
add_action('init', 'google_jquery');
function enqueue_my_scripts() {
$lightbox_choice = dess_setting('dess_lightbox_choice');
if ($lightbox_choice == 'c') {
//featherlight : http://noelboss.github.io/featherlight/
//selector: class="gallery"
//wp_enqueue_script('jquery'); //include jQuery version bundled with Wordpress in your page
//wp_enqueue_style( 'featherlight', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.0/release/featherlight.min.css' );
wp_enqueue_style( 'featherlight', get_stylesheet_directory_uri() . '/css/featherlight.min.css' );
//wp_enqueue_style( 'featherlight-gallery', 'http://cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.gallery.min.css' );
wp_enqueue_style( 'featherlight-gallery', get_stylesheet_directory_uri() . '/css/featherlight.gallery.min.css' );
wp_enqueue_style( 'featherlight2', get_stylesheet_directory_uri() . '/css/my-featherlight.css' );
//wp_enqueue_script( 'featherlight', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.0/release/featherlight.min.js', array( 'jquery' ), '',true );
wp_enqueue_script( 'featherlight', get_stylesheet_directory_uri() . '/js/featherlight.min.js', array( 'jquery' ), '',true );
//wp_enqueue_script( 'featherlight-gallery', 'http://cdn.rawgit.com/noelboss/featherlight/1.3.4/release/featherlight.gallery.min.js', array( 'jquery', 'featherlight' ), '',true );
wp_enqueue_script( 'featherlight-gallery', get_stylesheet_directory_uri() . '/js/featherlight.gallery.min.js', array( 'jquery', 'featherlight' ), '',true );
wp_enqueue_script( 'featherlight-script', get_stylesheet_directory_uri() . '/js/featherlight.js', array( 'jquery', 'featherlight' ), '',true );
}
if ($lightbox_choice == 'b') {
//colorbox : http://www.jacklmoore.com/colorbox/
//selector: class="slideshow" (ou "gallery")
wp_enqueue_script( 'colorbox', get_stylesheet_directory_uri() . '/js/jquery.colorbox-min.js', array( 'jquery' ), '',false );
wp_enqueue_style( 'colorbox', get_stylesheet_directory_uri() . '/css/colorbox.css' );
wp_enqueue_script( 'colorbox-options', get_stylesheet_directory_uri() . '/js/my-colorbox.js', array( 'jquery', 'colorbox' ), '',true );
}
if ($lightbox_choice == 'a') {
//meow-box
}
//ionicons: http://ionicons.com
//wp_enqueue_style( 'ionicons', 'http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css' );
wp_enqueue_style( 'ionicons', get_stylesheet_directory_uri() . '/css/ionicons.min.css' );
//wp_enqueue_script( 'googlemaps', '<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB7cAx3NSH4dPM3Sx2oQeud7Zr-KaGXmLk&callback=initMap" type="text/javascript"></script>';
}
add_action( 'wp_enqueue_scripts', 'enqueue_my_scripts' );
function my_theme_enqueue_styles() {
//$parent_style = 'CreatorThemeRes-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
$parent_style = 'parent_style';
//wp_enqueue_style( 'genericons', get_stylesheet_directory_uri() . '/genericons/genericons.css' );
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
add_filter( 'body_class', 'custom_class' );
function custom_class( $classes ) {
/*
if ( is_page_template( 'page-example.php' ) ) {
$classes[] = 'example';
}
*/
if (is_archive()) {
$classes[] = 'page-template-tpl-blog';
}
return $classes;
}
// Bouton Shortcode Zenphoto dans l'éditeur
function register_button_zp( $buttons ) {
array_push( $buttons, "|", "zenphoto" );
return $buttons;
}
function add_plugin_zp( $plugin_array ) {
$plugin_array['zenphoto'] = get_stylesheet_directory_uri() . '/js/short-zenphoto.js';
return $plugin_array;
}
function my_zenphoto_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_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');
/*
accueil.php
archive.php
index.php
tpl-blog.php
*/
function RelativeTime() {
$jour = get_the_date('U');
$aujourdhui = date('U');
$delta = round(($aujourdhui - $jour) / (3600 * 24));
if ($delta == 0) $text = "aujourd'hui";
elseif ($delta == 1) $text = __("yesterday", 'CreatorThemeRes-child');
elseif ($delta == 2) $text = __("the day before yesterday", 'CreatorThemeRes-child');
elseif ($delta == 3) $text = __("two days ago", 'CreatorThemeRes-child');
elseif (($delta > 3) and ($delta <= 7)) $text = sprintf( __('%1$s days ago', 'CreatorThemeRes-child'), $delta );
elseif (($delta > 7) and ($delta <= 14)) {
$nb = round ($delta / 7);
if ($nb < 2) $text = sprintf( __('%1$s week ago', 'CreatorThemeRes-child'), $nb );
else $text = sprintf( __('%1$s weeks ago', 'CreatorThemeRes-child'), $nb );
}
else $text = get_the_date();
/*
printf( __( '%1$s', 'CreatorThemeRes-child' ),
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">'.$text.'</a>',
get_permalink(),
esc_attr( get_the_date() . ' ' . get_the_time() )
)
);
*/
echo $text;
}
/*
livre-d-or.php
*/
function getRandomFile($start_dir) {
chdir($start_dir);
$dir = opendir('.');
while (($myfile = readdir($dir)) !==false) {
if ($myfile != '.' && $myfile != '..' && is_file($myfile) && $myfile != 'resource.frk') {
$files[] = $myfile;
}
}
closedir($dir);
chdir('../');
srand ((float) microtime() * 10000000);
$file = array_rand($files);
return $files[$file];
}
/*
ce-mois.php
ce-mois-ci.php
*functions.php - date_archive()
*/
function mois2 ($mois) {
switch ($mois)
{
case 00:
$mois = "00";
break;
case 1:
$mois = __('January','CreatorThemeRes-child');
break;
case 2:
$mois = __('February','CreatorThemeRes-child');
break;
case 3:
$mois = __('March','CreatorThemeRes-child');
break;
case 4:
$mois = __('April','CreatorThemeRes-child');
break;
case 5:
$mois = __('May','CreatorThemeRes-child');
break;
case 6:
$mois = __('June','CreatorThemeRes-child');
break;
case 7:
$mois = __('July','CreatorThemeRes-child');
break;
case 8:
$mois = __('August','CreatorThemeRes-child');
break;
case 9:
$mois = __('September','CreatorThemeRes-child');
break;
case 10:
$mois = __('October','CreatorThemeRes-child');
break;
case 11:
$mois = __('November','CreatorThemeRes-child');
break;
case 12:
$mois = __('December','CreatorThemeRes-child');
break;
}
return $mois;
}
/*
ce-mois-ci.php
*/
function displayRetina ($filename,$album) {
global $ppage;
if ($ppage == "1") {
$fullpath = "../../zenphoto/";
}
else {
$fullpath = "../../../zenphoto/";
}
$file = explode(".", $filename);
$thumbpath = "../zenphoto/cache/" . $album . "/";
$a = $path . $filename;
$file_sd = $thumbpath . $file[0] . "_180_thumb.jpg";
$file_hd = $thumbpath . $file[0] . "_360_thumb.jpg";
/*
$file_sd = $path . $file[0] . "_180_watermark.jpg";
$file_hd = $path . $file[0] . "_360_watermark.jpg";
*/
$th_sd = false;
$th_hd = false;
if (file_exists($file_sd)) {
$th_sd = true;
$size_sd = getimagesize($file_sd, $info);
$thumb['sd'] = array(
'url' => "../../" . $file_sd,
'width' => $size_sd[0],
'height' => $size_sd[1]
);
}
if (file_exists($file_hd)) {
$th_hd = true;
$size_hd = getimagesize($file_hd, $info);
$thumb['hd'] = array(
'url' => "../../" . $file_hd,
'width' => $size_hd[0],
'height' => $size_hd[1]
);
}
if (($th_sd == true) && ($th_hd == true)) {
$standard = $thumb['sd']['url'] . ', ' . $thumb['hd']['url'] . ' 2x';
}
elseif ($th_sd == true) {
$standard = $thumb['sd']['url'];
}
elseif ($th_hd == true) {
$standard = $thumb['hd']['url'] . ' 2x';
}
$display = '<div class="album">';
$display .= '<div class="holder">';
$display .= '<a href="' . $fullpath . 'albums/'.$album.'/'.$filename.'" title="'.date_archive($filename).'" class="gallery">';
$display .= '<picture data-picture data-alt="">';
$display .= '<!--[if IE 9]><video style="display: none;"><![endif]-->';
$display .= '<source class="image_standard" srcset="' . $standard . '">';
$display .= '<!--[if IE 9]></video><![endif]-->';
$display .= '<img srcset="' . $thumb['sd']['url'] . '" width="' . $thumb['sd']['width'] . '" height="' . $thumb['sd']['height'] . '"alt="">';
$display .= '</picture>';
$display .= '</a>';
$display .= '</div>';
$display .= '<div class="albumdesc">';
$display .= '<a href="../../zenphoto/index.php?album='.$album.'&amp;image='.$filename.'" title= "'.date_archive($filename).'" class="">';
$display .= '<span class="exif">'.date_archive($filename).'</span>';
$display .= '</a></div>';
$display .= '</div>';
return $display;
}
/*
*functions.php - displayRetina() displayRetina()
*/
function date_archive ($chaine) {
$pieces = explode(".", $chaine);
$b = explode("_", $pieces[0]);
$mois = $b[0];
$an = $b[1];
$chaine = mois2($mois) . ' '. $an;
return $chaine;
}
/* SHORTCODE: 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' );
/* SHORTCODE: Images sur Flickr */
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],
"version"=>"Medium 800", //setting default value
"caption"=>"", //setting default value
"url"=>""
), $atts));
if($url != ""){
$e=explode("/",$url);
$pid=$e[5];
}
switch (strtolower($version)) {
case "square":
$img_sd = "Square";
$img_hd = "Large Square";
break;
case "large square":
$img_sd = "Square";
$img_hd = "Large Square";
break;
case "small":
$img_sd = "Small";
$img_hd = "Medium";
break;
case "small 320":
$img_sd = "Small 320";
$img_hd = "Medium 640";
break;
case "medium":
$img_sd = "Medium";
$img_hd = "Large";
break;
case "medium 640":
$img_sd = "Small 320";
$img_hd = "Medium 640";
break;
case "medium 800":
$img_sd = "Medium 800";
$img_hd = "Large 1600";
break;
case "large":
$img_sd = "Medium";
$img_hd = "Large";
break;
case "large 1600":
$img_sd = "Medium 800";
$img_hd = "Large 1600";
break;
}
/*
$link = ! empty( $atts['link'] ) ? $atts['link'] : '';
$link = filter_var($link, FILTER_SANITIZE_URL);
$small = ! empty( $atts['small'] ) ? $atts['small'] : '';
$small = filter_var($small, FILTER_SANITIZE_URL);
$big = ! empty( $atts['big'] ) ? $atts['big'] : '';
$big = filter_var($big, FILTER_SANITIZE_URL);
$alt = ! empty( $atts['alt'] ) ? $atts['alt'] : '';
$alt = filter_var($alt, FILTER_SANITIZE_URL);
// Notice: Undefined index: caption
$caption = ! empty( $atts['caption'] ) ? $atts['caption'] : '';
// Sanitize
$caption = filter_var($caption, FILTER_SANITIZE_STRING);
$lb = ! empty( $atts['lb'] ) ? $atts['lb'] : '';
$lb = filter_var($lb, FILTER_SANITIZE_STRING);
$info = array();
*/
//https://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=3884af4190ac97a95fd4777dba0d9f21&photo_id=27868468454&format=json&nojsoncallback=1
/* 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;
$url1 .= '&format=json';
$url1 .= '&nojsoncallback=1';
$result = file_get_contents($url1);
$response = json_decode($result, true);
$taille = $response['sizes']['size'];
// Vignette wikipedia Small (240x160) Large Square (150x150)
$vignette = "Small";
foreach ($taille as $val) {
if ($val['label'] == $img_sd) {
$mediumSRC = $val['source'];
$w_mediumSRC = $val['width'];
$h_mediumSRC = $val['height'];
}
if ($val['label'] == $img_hd) {
$largeSRC = $val['source'];
$w_largeSRC = $val['width'];
$h_largeSRC = $val['height'];
}
if ($val['label'] == $vignette) {
$wikiSRC = $val['source'];
$w_wikiSRC = $val['width'];
$h_wikiSRC = $val['height'];
}
}
$wikiIMG = '<img id="lettrineImage" src="' . $wikiSRC . '" alt=" " height="' . $h_wikiSRC . '" width="' . $w_wikiSRC . '" />';
/* Info de l'image */
$url2 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getInfo';
$url2 .= '&api_key='.$api_key;
$url2 .= '&photo_id='.$pid;
$url2 .= '&format=json';
$url2 .= '&nojsoncallback=1';
$result2 = file_get_contents($url2);
$response2 = json_decode($result2, true);
$title = $response2['photo']['title']['_content'];
$date = $response2['photo']['dates']['taken'];
$lat = $response2['photo']['location']['latitude'];
$long = $response2['photo']['location']['longitude'];
$tag = $response2['photo']['tags']['tag'];
$descrip = $response2['photo']['description']['_content'];
$copy = $response2['photo']['owner']['username'];
$desc = preg_replace('/[\x00-\x1F\x7F]/u', ' ', $descrip); //UTF-8
$tags = array();
foreach ($tag as $val) {
//$i = $val['_content'];
$i = $val['raw'];
$tags[] = utf8_encode(ucfirst($i));
}
/* EXIF */
$url3 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getExif';
$url3 .= '&api_key='.$api_key;
$url3 .= '&photo_id='.$pid;
$url3 .= '&format=json';
$url3 .= '&nojsoncallback=1';
$result3 = file_get_contents($url3);
$response3 = json_decode($result3, true);
$exif = $response3['photo']['exif'];
$meta = array();
foreach ($exif as $val) {
if ($val['tag'] == 'FNumber') $meta['aperture'] = $val['raw']['_content'];
if ($val['tag'] == 'Model') $meta['camera'] = $val['raw']['_content'];
if ($val['tag'] == 'DateTimeOriginal') $meta['created_timestamp'] = strtotime($val['raw']['_content']);
if ($val['tag'] == 'FocalLength') $meta['focal_length'] = $val['raw']['_content'];
if ($val['tag'] == 'ISO') $meta['iso'] = $val['raw']['_content'];
if ($val['tag'] == 'ExposureTime') $meta['shutter_speed'] = $val['raw']['_content'];
if ($val['tag'] == 'Orientation') $meta['orientation'] = $val['raw']['_content'];
//if ($val['tag'] == 'xxx') $meta['credit'] = $val['raw']['_content'];
//if ($val['tag'] == 'xxx') $meta['caption'] = $val['raw']['_content'];
//if ($val['tag'] == 'xxx') $meta['copyright'] = $val['raw']['_content'];
//if ($val['tag'] == 'xxx') $meta['title'] = $val['raw']['_content'];
$meta['credit'] = $copy;
$meta['title'] = $title;
$meta['latitude'] = $lat;
$meta['longitude'] = $long;
$meta['keywords'] = $tags;
$meta['medium'] = $mediumSRC;
$meta['large'] = $largeSRC;
$meta['wiki'] = $wikiIMG;
$meta['desc'] = $desc;
//$meta['latitudeRef']
//$meta['longitudeRef']
//$meta['altitude']
}
$exif_array = img_wp_exif( $meta ); //1214
$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="' . $mediumSRC . ', ' . $largeSRC . ' 2x' . '" alt="' . $title . '" />';
$links .= '</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>" : '');
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, $pid, $meta['desc'], $meta['wiki']));
}
return $links;
}
add_filter( 'the_content', 'do_shortcode');
add_shortcode( 'flickr', 'flickr_handler' );
/* SHORTCODE: Images sur Zenphoto */
function zenphoto_handler($atts, $content=null) {
//utilise le cacheManager de zenphoto (extensions/utilitaires/cacheManager)
// ** Utilisation **
// [zenphoto album="lievres" image="2008-08-18_Lievre_8927.jpg"]
// [zenphoto album="sports-mecaniques/gp-france" image="2010-05-23_gp-france-2010_5321.jpg"]
// [zenphoto album="lievres"]
//
//taille des photos dans Worpress, theme Twenty Ten Child : 610x406
$selector = dess_setting('dess_lightbox_select');
$zenphoto_url = dess_setting('dess_zenphoto');
$size = dess_setting('dess_zp_size');
$album = ! empty( $atts['album'] ) ? $atts['album'] : '';
$album = filter_var($album, FILTER_SANITIZE_STRING);
$image = ! empty( $atts['image'] ) ? $atts['image'] : '';
$image = filter_var($image, FILTER_SANITIZE_STRING);
$caption = ! empty( $atts['caption'] ) ? $atts['caption'] : '';
$caption = filter_var($caption, FILTER_SANITIZE_STRING);
$rnd = rand (1000, 9999);
//$size = 610;
$folder = false;
$zenphoto_img = "";
// Si ALBUM mais pas IMAGE
//echo "album2: " . $album . " image2: " . $image . "<br>";
//if (($album != "") && ($image == "")) {
require('../Connections/cnx.php');
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
// Trouver l'ID de l'album
$album_id_query = "SELECT `id` FROM `" . $zp_prefix . "albums` WHERE `folder` = '" . $atts['album'] . "'";
if ($result = $mysqli->query($album_id_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$album_id = $row[0];
}
else {
_e("Unknow album.", 'CreatorThemeRes-child' );
}
$result->close();
}
$img_query = "SELECT `desc`, `title`, `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "'";
if ($result = $mysqli->query($img_query)) {
if ($mysqli->affected_rows != 0) {
$capt = $result->fetch_row();
}
else {
_e("Unknow image.", 'CreatorThemeRes-child' );
}
$result->close();
}
if (($album != "") && ($image == "")) {
// Trouver le filename de la plus récente image de l'album
$img_album_query = "SELECT `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "' ORDER BY `id` DESC LIMIT 1";
if ($result = $mysqli->query($img_album_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$img_album = $row[0];
}
else {
_e("Unknow image.", 'CreatorThemeRes-child' );
}
$result->close();
}
$image = $img_album;
$folder = true;
} // album != ""
if ($capt[0] != "") $title = $capt[0];
elseif ($capt[1] != "") $title = $capt[1];
elseif ($capt[2] != "") $title = $capt[2];
$img = substr($image, 0, strlen($image) - 4);
/*
$sizewiki = "180_thumb";
$imgwiki = 'cache/' . $album . '/' . urlencode($img) . '_' . $sizewiki . '.jpg';
$filewiki = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . $imgwiki;
$zp_size = "";
$zp_size = getimagesize(htmlentities($filewiki));
//var_dump($filewiki);
//$wikiSRC = '<img id=\"lettrineImage\" ' . $zp_size[3] . ' src=\"'. $zenphoto_url . $imgwiki . '\" />';
$wikiSRC = '<img id=\"lettrineImage\" src=\"'. $zenphoto_url . $imgwiki . '\" ' . $zp_size[3] . ' />';
var_dump($wikiSRC);
*/
//var_dump($coord);
//array_push($coord, array($meta['latitude']);
/*
'<img id=\"lettrineImage\" src=\"http://macbook-pro.local/zenphoto/cache/bihoreau/2008-09-08_BihoreauGris_1889_180_thumb.jpg\" width="180" height="120" />' (length=153)
<img id=\"lettrineImage\" width="180" height="120"src=\"http://macbook-pro.local/zenphoto/\" />' (length=95)
<img id=\"lettrineImage\" width="180" height="120"src=\"http://macbook-pro.local/zenphoto/cache/paysages/2014-10-21_pontdarc_0406_180_thumb.jpg\" />' (length=148)
2014-10-21_pontdarc_0406_180_thumb.jpg
2014-10-21_pontdarc_0406_300_thumb.jpg
$wikiIMG = '<img id=\"lettrineImage\" src=\"' . $wikiSRC . '\" alt=\"\" height=\"' . $h_wikiSRC . '\" width=\"' . $w_wikiSRC . '\" />';
//array_push($coord, array(number_format($lat, 6), number_format($long, 6), $meta['title'], $attach, $meta['description'], $thumbnail));
*/
$filename = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . 'cache/' . $album . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
$zp_size = getimagesize(htmlentities($filename));
$zenphoto_img = (($caption != "") ? '<div id="zp_' . $rnd . '" style="width: ' . ($zp_size[0] + 10) . 'px" class="wp-caption aligncenter">' : '');
if ($folder == false) $zenphoto_link = '<a href="' . $zenphoto_url . 'albums/' . $album . '/' . $image . '" class="' . $selector . '" title="' . $title . '">';
else $zenphoto_link = '<a href="' . $zenphoto_url . $album . '">';
$zenphoto_img .= $zenphoto_link;
$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 . '" />';
$zenphoto_img .= '</a>';
$zenphoto_img .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
return $zenphoto_img;
}
add_shortcode( 'zenphoto', 'zenphoto_handler' );
/*
* thumb_ZP_wiki: crée la vignette (zenphoto) pour infobox wikipedia
*
* add_exif()
*/
function thumb_ZP_wiki ($image, $album) {
$zenphoto_url = dess_setting('dess_zenphoto');
$img = substr($image, 0, strlen($image) - 4);
$sizewiki = "180_thumb";
$imgwiki = 'cache/' . $album . '/' . urlencode($img) . '_' . $sizewiki . '.jpg';
$filewiki = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . $imgwiki;
$zp_size = "";
$zp_size = getimagesize(htmlentities($filewiki));
$wikiSRC = '<img id="lettrineImage" src="'. $zenphoto_url . $imgwiki . '" ' . $zp_size[3] . ' />';
return $wikiSRC;
}
/*
* zp_query_exif: récupère les exifs depuis la bdd zenphoto
*
*functions.php - zenphoto_handler2() add_exif()
*/
function zp_query_exif($zpimage) {
$exif = array();
require('../Connections/cnx.php');
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
$excquery = "SELECT `EXIFModel`, `EXIFDateTimeOriginal`, `EXIFExposureTime`, `EXIFFNumber`, `EXIFISOSpeedRatings`, `EXIFFocalLength`, ";
$excquery .= "`EXIFGPSLatitude`, `EXIFGPSLatitudeRef`, `EXIFGPSLongitude`, `EXIFGPSLongitudeRef`, `EXIFGPSAltitude`, `EXIFGPSAltitudeRef`, ";
$excquery .= "`desc`, `title`, `EXIFLensType`, `EXIFLensInfo`, `EXIFOrientation`, `credit`, `copyright`, `id` ";
$excquery .= "FROM `" . $zp_prefix . "images` WHERE `filename` = \"$zpimage\"";
if ($result = $mysqli->query($excquery)) {
$exif = $result->fetch_row();
$result->close();
}
/*
Array
(
- [0] => Canon EOS-1D Mark IV
- [1] => 2014:10:21 14:42:26
- [2] => 1/80 sec
- [3] => f/9
- [4] => 320
- [5] => 17 mm
- [6] => 44,381861666667
- [7] => N
- [8] => 4,4162216666667
- [9] => E
- [10] => 104,1771m
[11] => *AltitudeRef*
- [12] => a:1:{s:5:"fr_FR";s:10:"Pont d'Arc";} *desc*
- [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*
- [17] => Bruno Pesenti *credit*
- [18] => bruno@clicclac.info *copyright*
- [19] => *id*
)
*/
$meta = array(
'aperture' => 0,
'credit' => '',
'camera' => '',
'caption' => '',
//'description' => '',
'created_timestamp' => 0,
'copyright' => '',
'focal_length' => 0,
'iso' => 0,
'shutter_speed' => 0,
'title' => '',
'orientation' => 0,
'latitude' => 0,
'longitude' => 0,
'altitude' => 0,
'lens' => '',
'keywords' => array(),
);
if ( ! empty( $exif[3] ) ) {
$meta['aperture'] = str_replace(",", ".", $exif[3]);
}
if ( ! empty( $exif[17] ) ) {
if (((stripos($exif[17], "pesenti")) === true) || ($exif[17] == "")) $meta['credit'] = $exif[17];
}
if ( ! empty( $exif[0] ) ) {
$meta['camera'] = $exif[0];
}
//caption (ZP desc (Description)
/*
if ( ! empty( $exif[12] ) ) {
$desc = explode(':', $exif[12]);
$description = explode('"', end($desc));
$meta['description'] = utf8_encode($description[1]);
}
*/
if ( ! empty( $exif[12] ) ) {
$v = unserialize($exif[12]);
$caption = reset($v);
$meta['caption'] = utf8_encode($caption);
//var_dump($meta['caption']);
}
if ( ! empty( $exif[1] ) ) {
//$meta['created_timestamp'] = $exif[1];
$meta['created_timestamp'] = strtotime($exif[1]);
}
//*copyright
if ( ! empty( $exif[5] ) ) {
$meta['focal_length'] = $exif[5];
}
if ( ! empty( $exif[4] ) ) {
$meta['iso'] = $exif[4];
}
if ( ! empty( $exif[2] ) ) {
$shutter = explode(' ', $exif[2]);
$meta['shutter_speed'] = $shutter[0];
}
//title (ZP title (Titre)
if ( ! empty( $exif[13] ) ) {
$z = $exif[13]; // str
$w = unserialize($z); // arr
if ($w != false) $titre = reset($w);
elseif (($w == false) && is_string($z)) $titre = $z;
/*
$titr = explode(':', $exif[13]);
if (count($titr) == 1) {
$meta['title'] = utf8_encode($titr[0]);
}
else {
$titre = explode('"', end($titr));
$meta['title'] = utf8_encode($titre[1]);
}
*/
$meta['title'] = utf8_encode($titre);
}
if ( ! empty( $exif[16] ) ) {
$meta['orientation'] = $exif[16];
}
if ( ! empty( $exif[6] ) ) {
$lat = floatval(str_replace(",", ".", $exif[6]));
$meta['latitude'] = number_format($lat, 6);
}
if ( ! empty( $exif[8] ) ) {
$long = floatval(str_replace(",", ".", $exif[8]));
$meta['longitude'] = number_format($long, 6);
}
if ( ! empty( $exif[10] ) ) {
$alt = floatval(str_replace(",", ".", $exif[10]));
$meta['altitude'] = number_format($alt);
}
if ( ! empty( $exif[15] ) ) {
$meta['lens'] = $exif[15];
}
if ( ! empty( $exif[18] ) ) {
$meta['copyright'] = $exif[18];
}
//keywords
if ( ! empty( $exif[19] ) ) {
//imageid
$img = $exif[19];
$result2 = $mysqli->query("SELECT `tagid` FROM `" . $zp_prefix . "obj_to_tag` WHERE `type`='images' AND `objectid`='$img'");
if ($result2) {
while ($row = $result2->fetch_row()) {
$result3 = $mysqli->query("SELECT `name` FROM `" . $zp_prefix . "tags` WHERE `id`='" . $row[0] . "'");
$dbtag = $result3->fetch_row();
if ($dbtag) $tags[] = utf8_encode(ucfirst($dbtag[0]));
}
}
$meta['keywords'] = $tags;
}
//preprint($meta);
return $meta;
}
/*
* add_class_lightbox: FILTER
*
* - Ajoute la class pour les lightbox
* - Recherche des données pour wikipédia (pour images WP)
*/
function add_class_lightbox($content) {
global $coord;
$selector = dess_setting('dess_lightbox_select');
//Check the page for link images direct to image (no trailing attributes)
$string = '/<a href="(.*?).(jpg|jpeg|png|gif|bmp|ico)"><img(.*?)class="(.*?)wp-image-(.*?)" \/><\/a>/i';
preg_match_all( $string, $content, $matches, PREG_SET_ORDER);
//Check which attachment is referenced
$i = 0;
foreach ($matches as $val) {
// Ajoute la class pour les lightbox
$slimbox_caption = '';
$post = get_post($val[5]);
//var_dump($post);
$slimbox_caption = esc_attr( $post->post_content );
//Replace the instance with the lightbox and title(caption) references. Won't fail if caption is empty.
$string = '<a href="' . $val[1] . '.' . $val[2] . '"><img' . $val[3] . 'class="' . $val[4] . 'wp-image-' . $val[5] . '" /></a>';
$replace = '<a href="' . $val[1] . '.' . $val[2] . '" class="' . $selector . '" ' . (($slimbox_caption != "") ? 'title="' . $slimbox_caption . '"' : '') .'><img' . $val[3] . 'class="' . $val[4] . 'wp-image-' . $val[5] . '" /></a>';
$content = str_replace( $string, $replace, $content);
// Recherche des données pour wikipédia
//$attach = $matches[$i][5];
//$photo = wp_get_attachment_metadata( $attach );
$photo = wp_get_attachment_metadata( $post->ID );
$exifs = $photo['image_meta'];
if ((safe_array_access($exifs, 'latitude')) && (safe_array_access($exifs, 'longitude'))) {
//if ((isset($exifs['latitude'])) && (isset($exifs['longitude']))) {
$attribut = wp_prepare_attachment_for_js( $post->ID );
//var_dump($attribut);
$lat = gps($exifs['latitude'], trim($exifs['latitude_ref']));
$long = gps($exifs['longitude'], trim($exifs['longitude_ref']));
/**/
$attach = $attribut['id'];
$caption = "";
$capt = $attribut['caption'];
echo "capt: $capt<br>";
$title = $attribut['title'];
echo "title: $title<br>";
$alt = $attribut['alt'];
$image = $attribut['url'];
$description = $attribut['description'];
echo "description: $description<br>";
$thumbnail = $attribut['sizes']['thumbnail'];
$thumbnailWiki = '<img id="lettrineImage" src="' . $thumbnail['url'] . '" alt="' . $attribut['alt'] . '" height="' . $thumbnail['height'] . '" width="' . $thumbnail['width'] . '" />';
// ??????
//$gallery[] = $attach;
if ($capt != "") $caption = $capt;
elseif ($title != "") $caption = $title;
var_dump($caption, $description);
// On crée le tableau $coord qui regroupe toutes les données pour le waypoint (lat,long, titre, n° attachment, description, vignette)
array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnailWiki));
} //if
$i++;
}
return $content;
}
add_filter('the_content', 'add_class_lightbox', 2);
if ( ! function_exists( 'creator_post_nav' ) ) :
/**
* Display navigation to next/previous post when applicable.
*
* @since Twenty Thirteen 1.0
*
* single.php
*/
function creator_post_nav() {
global $post;
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous )
return;
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'CreatorThemeRes-child' ); ?></h1>
<div class="nav-links">
<?php previous_post_link( '%link', _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', 'CreatorThemeRes-child' ) ); ?>
<?php next_post_link( '%link', _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link', 'CreatorThemeRes-child' ) ); ?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;
if ( ! function_exists( 'creator_entry_meta' ) ) :
/**
* Print HTML with meta information for current post: categories, tags, permalink, author, and date.
*
* Create your own twentythirteen_entry_meta() to override in a child theme.
*
* @since Twenty Thirteen 1.0
*
* single.php
*/
function creator_entry_meta() {
if ( is_sticky() && is_home() && ! is_paged() )
echo '<span class="featured-post">' . esc_html__( 'Sticky', 'CreatorThemeRes-child' ) . '</span>';
if ( ! has_post_format( 'link' ) && 'post' == get_post_type() )
creator_entry_date();
// Translators: used between list items, there is a space after the comma.
$categories_list = get_the_category_list( __( ', ', 'CreatorThemeRes-child' ) );
if ( $categories_list ) {
echo '<span class="categories-links"><i class="ionicons ion-briefcase"></i> ' . $categories_list . '</span>';
}
// Translators: used between list items, there is a space after the comma.
$tag_list = get_the_tag_list( '', __( ', ', 'CreatorThemeRes-child' ) );
if ( $tag_list ) {
echo '<span class="tags-links"><i class="ionicons ion-pricetags"></i> ' . $tag_list . '</span>';
}
// Post author
if ( 'post' == get_post_type() ) {
printf( '<span class="author vcard"><i class="ionicons ion-person"></i> <a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'CreatorThemeRes-child' ), get_the_author() ) ),
get_the_author()
);
}
}
endif;
if ( ! function_exists( 'creator_entry_date' ) ) :
/**
* Print HTML with date information for current post.
*
* Create your own twentythirteen_entry_date() to override in a child theme.
*
* @since Twenty Thirteen 1.0
*
* @param boolean $echo (optional) Whether to echo the date. Default true.
* @return string The HTML-formatted post date.
*
* functions.php - creator_entry_meta()
*/
function creator_entry_date( $echo = true ) {
if ( has_post_format( array( 'chat', 'status' ) ) )
$format_prefix = _x( '%1$s on %2$s', '1: post format name. 2: date', 'twentythirteen' );
else
$format_prefix = '%2$s';
$date = sprintf( '<span class="date"><i class="ionicons ion-calendar"></i> <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a></span>',
esc_url( get_permalink() ),
esc_attr( sprintf( __( 'Permalink to %s', 'twentythirteen' ), the_title_attribute( 'echo=0' ) ) ),
esc_attr( get_the_date( 'c' ) ),
esc_html( sprintf( $format_prefix, get_post_format_string( get_post_format() ), get_the_date() ) )
);
if ( $echo )
echo $date;
return $date;
}
endif;
/*
* addexif: FILTER
*
* - filtre les #id attachment et zp
* - filtre les liens a zenphoto et wordpress
* - rajoute les exifs sous les images, les données géo
* - remplit le tableau $coord
*/
function addexif ($content) {
global $post;
global $coord;
$postID = $post->ID;
$display_exif = dess_setting('dess_display_exif');
$display_gps = dess_setting('dess_display_gps');
$zenphoto_coord = false;
if ($display_exif == true) {
$matches3 = array();
// Le caption
//$pattern = '/<p .*?class="wp-caption-text">(.*?)<\/p>/';
//$pattern = '/<div id=[^>]*>(.*?)\<\/div>/';
// `attachment_1049` `width: 810px` `wp-caption aligncenter`
//$pattern = '/<div id=\"?([^\"]*)\" style=\"?([^\"]*)\" class=\"?([^\"]*)\">/';
// `attachment_1049`
//$pattern = '/<div id=\"?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
// `1049`
//$pattern = '/<div id=[^>]*>(.*?)\<\/div>/';
//$pattern = '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is';
//$pattern = '/<div id=\"attachment_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
$pattern = '/<div id=\"(zp|attachment)_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/'; //ok
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
// Pour tous les DIV (attachment) on cherche les <A HREF>
for ($i = 0; $i <= (count($matches) - 1); $i++) {
$pattern2 = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
preg_match_all($pattern2, $matches[$i][0] , $matches2, PREG_SET_ORDER);
array_push($matches3, array($matches2[0][1], $matches[$i][0]));
$court = $matches2[0][1];
$pid = "";
if (substr_count($court, "wordpress") > 0) {
$meta = creator_get_exif( $court );
//var_dump($meta);
/*
//var_dump($matches2);
$attach = $matches[$i][2];
$pid = $attach;
//$attribut = wp_prepare_attachment_for_js( $image->ID );
$attribut = wp_prepare_attachment_for_js( $attach );
//var_dump($attribut);
//$attach = $attribut['id'];
$caption = "";
//$capt = $attribut['caption'];
//$title = $attribut['title'];
$alt = $attribut['alt'];
//$image = $attribut['url'];
$description = $attribut['description'];
$thumbnail = $attribut['sizes']['thumbnail'];
//$thumbnail = '<img src="' . $thumbnail['url'] . '" alt="' . $attribut['alt'] . '" height="' . $thumbnail['height'] . '" width="' . $thumbnail['width'] . '" />';
$img_thumb_ZP_wiki = '<img id="lettrineImage" src="' . $thumbnail['url'] . '" alt="' . $attribut['alt'] . '" height="' . $thumbnail['height'] . '" width="' . $thumbnail['width'] . '" />';
if ($capt != "") $caption = $capt;
elseif ($title != "") $caption = $title;
// On crée le tableau $coord qui regroupe toutes les données pour le waypoint (lat,long, titre, n° attachment, description, vignette)
//array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnail));
*/
}
elseif (substr_count($court, "zenphoto") > 0) {
$img = explode("/", $court);
$zp_image = end($img);
$zp_album = prev($img);
$img_thumb_ZP_wiki = thumb_ZP_wiki($zp_image, $zp_album);
$meta = zp_query_exif( $zp_image );
$zenphoto_coord = true;
}
$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));
if ($zenphoto_coord == true) {
array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['caption'], $img_thumb_ZP_wiki));
}
}
} // for
} // ($display_exif == true)
$pattern2 = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
preg_match_all($pattern2, $content , $matches4, PREG_SET_ORDER);
for ($i = 0; $i <= (count($matches4) - 1); $i++) {
$ancien = $matches4[$i][0];
$court = $matches4[$i][1];
// si source wordpress
if (substr_count($ancien, "wordpress") > 0) {
/*
$patternWP = '#wp-image-[0-9]{1,4}#';
if (preg_match($patternWP, $ancien, $matches5) === 1) {
$attachment = substr($matches5[0],9);
*/
// si $court est déjà dans $matches3 (si l'image est déjà dans un DIV)
if (in_multiarray($court, $matches3) == false) {
$meta = creator_get_exif( $court );
$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);
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));
}
} // if in_multiarray
} //if wordpress
// si source zenphoto
elseif ((substr_count($ancien, 'zenphoto') != 0) and (substr_count($ancien, '<img') != 0)){
// bug: si 2x la même image, les exifs sont affichés 2x
// si $court est déjà dans $matches3 (si l'image est déjà dans un DIV)
if (in_multiarray($court, $matches3) == false) {
$patternZP = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
preg_match($patternZP, $ancien , $matches2);
$img = explode("/", $matches2[1]);
$zp_image = end($img);
$zp_album = prev($img);
var_dump($zp_image, $zp_album);
$img_thumb_ZP_wiki = thumb_ZP_wiki($zp_image, $zp_album);
var_dump($img_thumb_ZP_wiki);
$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>";
$content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content);
$exifs = "";
if (($meta['longitude'] != "") && ($meta['latitude'] != "")) {
if ($meta['caption'] != "") $fichier = $meta['caption'];
else if ($meta['title'] != "") $fichier = $meta['title'];
else $fichier = end(explode("/", $court));
$pid = "";
echo "fichier: " . $fichier;
array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier, $pid, $meta['caption'], $img_thumb_ZP_wiki));
}
} // if in_multiarray
} // else zenphoto
// Autres sources que WP et ZP
elseif ((substr_count($ancien, 'jpg') > 0) and (substr_count($ancien, 'flickr') == 0)) {
//echo "court2: " . $court . "<br>";
//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)
/*
if (in_multiarray($court, $matches3) == false) {
$meta = creator_get_exif( $court );
//preprint($meta);
$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
return $content;
}
add_action('the_content','addexif');
/*
* img_wp_exif: crée la chaine d'affichages des exifs et des données GPS
*
*entree $exif_array (tableau avec tous les exifs
*retourne array($exifInfo, $exifGPS, $geo_link):
* -$exifInfo: chaine qui affiche les exifs
* -$exifGPS: données gps pour $exifInfo
* -$geo_link: image globe avec lien vers googlemaps.com
*
* functions.php - flickr_handler() add_exif()
*/
function img_wp_exif( $exif_array ) {
/*
Array
(
[aperture] => 10
[credit] =>
[camera] => Canon EOS 5D Mark III
[caption] =>
[created_timestamp] => 1454520944
[copyright] =>
[focal_length] => 118
[iso] => 800
[shutter_speed] => 1/200
[title] => Etang des Fontaines
[orientation] => 1
[latitude] => 47.109745
[longitude] => 5.0787033333333
[keywords] => Array
(
[0] => Etang
[1] => coucher de soleil
)
[latitudeRef] => N
[longitudeRef] => E
[altitude] => 206.5042
)
*/
$exifInfo = "";
$exifGPS = "";
$geo_link = "";
// Si données GPS:
if ($exif_array['aperture'] != "") {
// bloc exif (avec icones)
$exifInfo .= "<span class='exif-data'><i class='ionicons ion-calendar'></i>" . date(__("F j, Y, g:i a",'CreatorThemeRes-child'),$exif_array['created_timestamp']) . "</span>";
$exifInfo .= "<span class='exif-data'><i class='ionicons ion-camera'></i>" . $exif_array['camera'] . "</span>";
$exifInfo .= "<span class='exif-data'><i class='ionicons ion-ios-stopwatch'></i>" . $exif_array['shutter_speed'] . "</span>";
$exifInfo .= "<span class='exif-data'><i class='ionicons ion-aperture'></i>" . $exif_array['aperture'] . "</span>";
$exifInfo .= "<span class='exif-data'><i class='ionicons ion-flash'></i>" . $exif_array['iso'] . "</span>";
$exifInfo .= "<span class='exif-data'><i class='ionicons ion-eye'></i>";
$exifInfo .= (($exif_array['lens'] != "") ? $exif_array['lens'] : $exif_array['focal_length']);
$exifInfo .= "</span>";
/*
// lien exif (texte)
$exifInfo = "";
$exifInfo = __('The','CreatorThemeRes-child') . " " . date(__("F j, Y, g:i a",'CreatorThemeRes-child'),$exif_array['created_timestamp']);
$exifInfo .= ' - ' . $exif_array['shutter_speed'];
$exifInfo .= '<i class="ionicons ion-aperture"></i>' . __(' at ','CreatorThemeRes-child') . "f/" . $exif_array['aperture'];
$exifInfo .= ' - ' .$exif_array['iso'].' ISO - ';
$exifInfo .= (($exif_array['lens'] != "") ? __('Lens: ','CreatorThemeRes-child') . $exif_array['lens'] : __('Focal: ','CreatorThemeRes-child') . $exif_array['focal_length'] . "mm");
*/
}
// Si données GPS:
if ($exif_array['latitude'] != "") {
// lien lat/long/alt (avec icones)
$exifGPS .= "<span class='exif-data'><i class='ionicons ion-ios-location'></i>" . $exif_array['latitude'] . "</span>";
$exifGPS .= "<span class='exif-data'><i class='ionicons ion-ios-location-outline'></i>" . $exif_array['longitude'] . "</span>";
$exifGPS .= "<span class='exif-data'><i class='ionicons ion-image'></i>" . $exif_array['altitude'] . "</span>";
// lien lat/long/alt (texte)
//$exifGPS .= __('Latitude: ','CreatorThemeRes-child') . $exif_array['latitude'] . __(' Longitude: ','CreatorThemeRes-child') . $exif_array['longitude'] . __(' Altitude: ','CreatorThemeRes-child') . number_format($exif_array['altitude']) . 'm';
//lien vers Googlemaps (globe) <!-- iCon by oNlineWebFonts.Com -->
$geo_link = '<a href="http://maps.google.com/maps?q=' . $exif_array['latitude'] . '+' . $exif_array['longitude'] . '&amp;z=11">';
//$geo_link .= '<img src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />';
$geo_link .= '<img src="data:image/svg+xml;base64,CjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDEwMDAgMTAwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMTAwMCAxMDAwIiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPG1ldGFkYXRhPiBTdmcgVmVjdG9yIEljb25zIDogaHR0cDovL3d3dy5vbmxpbmV3ZWJmb250cy5jb20vaWNvbiA8L21ldGFkYXRhPgogIDxnPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAuMDAwMDAwLDQ1NC4wMDAwMDApIHNjYWxlKDAuMTAwMDAwLC0wLjEwMDAwMCkiPjxwYXRoIGQ9Ik00NDQ4LjUsNDQxNy42Yy01ODAuOS03MS41LTEwODYtMjIxLjEtMTYwNi4yLTQ3NC43QzE1MDIuNywzMjg2LjEsNTM4LjEsMjA2MS40LDIxMC44LDYwNC44Yy0xMDguNC00ODkuOS0xNDMuMS0xMjA1LjItNzgtMTY5MC43YzkzLj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uMiw2MzcuOC0xNDQ1LjcsNzM5LjctMTUyMS42eiBNODEzMS4yLTI1NDYuOWMtMTkuNS0xODguNi0xMDYuMi00ODUuNS0xNjQuOC01NjUuN2MtMjguMi0zNi45LTk3LjUtMTEwLjYtMTUzLjktMTYyLjZjLTg0LjYtNzUuOS0xMTIuNy05MS0xNDAuOS03MS41Yy01OC41LDM0LjctNTYuNCwxNjIuNiw0LjQsMzE0LjNjMjguMiw3NS45LDU4LjUsMTcxLjIsNjcuMiwyMTIuNGMxOS41LDk1LjQsNTQuMiwxMzYuNiwxNjAuNCwxODIuMWM2Mi44LDMwLjQsOTUuNCw2NSwxNDAuOSwxNjAuNEM4MTE4LjItMjMyNy45LDgxNTIuOS0yMzU2LjEsODEzMS4yLTI1NDYuOXoiIHN0eWxlPSJmaWxsOiNhOWI3YjciPjwvcGF0aD48L2c+PC9nPjwvc3ZnPgogIA==" width="16" height="16">';
$geo_link .= '</a>';
}
return array($exifInfo, $exifGPS, $geo_link);
}
/*
* creator_get_exif: récupère les exifs (et données GPS) pour les images WP
*
* entree $file (str)
* retourne $meta (array)
*
* functions.php - add_exif()
*/
function creator_get_exif( $file ) {
/*
if ( ! file_exists( $file ) ) {
echo "pas de fichier";
return false;
}
*/
//echo "file: " . $file . "<br>";
list( , , $sourceImageType ) = getimagesize( $file );
/*
* EXIF contains a bunch of data we'll probably never need formatted in ways
* that are difficult to use. We'll normalize it and just extract the fields
* that are likely to be useful. Fractions and numbers are converted to
* floats, dates to unix timestamps, and everything else to strings.
*/
$meta = array(
'aperture' => 0,
'credit' => '',
'camera' => '',
'caption' => '',
'created_timestamp' => 0,
'copyright' => '',
'focal_length' => 0,
'iso' => 0,
'shutter_speed' => 0,
'title' => '',
'orientation' => 0,
'latitude' => 0,
'longitude' => 0,
'latitude' => 0,
'altitude' => 0,
'lens' => '',
'keywords' => array(),
);
$iptc = array();
/*
* Read IPTC first, since it might contain data not available in exif such
* as caption, description etc.
*/
if ( is_callable( 'iptcparse' ) ) {
getimagesize( $file, $info );
if ( ! empty( $info['APP13'] ) ) {
$iptc = iptcparse( $info['APP13'] );
//preprint($iptc);
// Headline, "A brief synopsis of the caption."
if ( ! empty( $iptc['2#105'][0] ) ) {
$meta['title'] = trim( $iptc['2#105'][0] );
/*
* Title, "Many use the Title field to store the filename of the image,
* though the field may be used in many ways."
*/
} elseif ( ! empty( $iptc['2#005'][0] ) ) {
$meta['title'] = trim( $iptc['2#005'][0] );
}
if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
$caption = trim( $iptc['2#120'][0] );
mbstring_binary_safe_encoding();
$caption_length = strlen( $caption );
reset_mbstring_encoding();
if ( empty( $meta['title'] ) && $caption_length < 80 ) {
// Assume the title is stored in 2:120 if it's short.
$meta['title'] = $caption;
}
$meta['caption'] = $caption;
}
if ( ! empty( $iptc['2#110'][0] ) ) // credit
$meta['credit'] = trim( $iptc['2#110'][0] );
elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
$meta['credit'] = trim( $iptc['2#080'][0] );
// 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] );
if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array
$meta['keywords'] = array_values( $iptc['2#025'] );
}
}
}
//if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
if ( is_callable( 'exif_read_data' )) {
$exif = @exif_read_data( $file );
//preprint($exif);
if ( ! empty( $exif['ImageDescription'] ) ) {
mbstring_binary_safe_encoding();
$description_length = strlen( $exif['ImageDescription'] );
reset_mbstring_encoding();
if ( empty( $meta['title'] ) && $description_length < 80 ) {
// Assume the title is stored in ImageDescription
$meta['title'] = trim( $exif['ImageDescription'] );
}
if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) {
$meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
}
if ( empty( $meta['caption'] ) ) {
$meta['caption'] = trim( $exif['ImageDescription'] );
}
} elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) {
$meta['caption'] = trim( $exif['Comments'] );
}
if ( empty( $meta['credit'] ) ) {
if ( ! empty( $exif['Artist'] ) ) {
$meta['credit'] = trim( $exif['Artist'] );
} elseif ( ! empty($exif['Author'] ) ) {
$meta['credit'] = trim( $exif['Author'] );
}
}
if ( empty( $meta['copyright'] ) && ! empty( $exif['Copyright'] ) ) {
$meta['copyright'] = trim( $exif['Copyright'] );
}
if ( ! empty( $exif['FNumber'] ) ) {
$meta['aperture'] = "f/" . round( geo_frac2dec( $exif['FNumber'] ), 2 );
}
if ( ! empty( $exif['Model'] ) ) {
$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'];
}
if ( ! empty( $exif['FocalLength'] ) ) {
$meta['focal_length'] = (string) geo_frac2dec( $exif['FocalLength'] ) . " mm";
}
if ( ! empty( $exif['ISOSpeedRatings'] ) ) {
$meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings'];
$meta['iso'] = trim( $meta['iso'] );
}
if ( ! empty( $exif['ExposureTime'] ) ) {
//$meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] );
$meta['shutter_speed'] = $exif['ExposureTime'];
}
if ( ! empty( $exif['Orientation'] ) ) {
$meta['orientation'] = $exif['Orientation'];
}
if ( ! empty( $exif['GPSLatitude'] ) ) {
$lat = gps($exif['GPSLatitude'], trim( $exif['GPSLatitudeRef'] ));
$meta['latitude'] = number_format($lat, 6);
}
if ( ! empty( $exif['GPSLongitude'] ) ) {
$long = gps($exif['GPSLongitude'], trim( $exif['GPSLongitudeRef'] ));
$meta['longitude'] = number_format($long, 6);
}
/*
if ( ! empty( $exif['GPSLatitudeRef'] ) ) {
$meta['latitudeRef'] = trim( $exif['GPSLatitudeRef'] );
}
if ( ! empty( $exif['GPSLongitudeRef'] ) ) {
$meta['longitudeRef'] = trim( $exif['GPSLongitudeRef'] );
}
*/
if ( ! empty( $exif['GPSAltitude'] ) ) {
$meta['altitude'] = number_format(geo_frac2dec($exif['GPSAltitude']));
}
if ( ! empty( $exif['UndefinedTag:0xA434'] ) ) {
$meta['lens'] = trim($exif['UndefinedTag:0xA434']);
}
// [UndefinedTag:0xA434] => 10.0-22.0 mm
// [UndefinedTag:0xA434] => EF500mm f/4L IS USM +1.4x
}
foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) {
if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) {
$meta[ $key ] = utf8_encode( $meta[ $key ] );
}
}
foreach ( $meta['keywords'] as $key => $keyword ) {
if ( ! seems_utf8( $keyword ) ) {
$meta['keywords'][ $key ] = utf8_encode( $keyword );
}
}
//$meta = wp_kses_post_deep( $meta );
/**
* Filters the array of meta data read from an image's exif data.
*
* @since 2.5.0
* @since 4.4.0 The `$iptc` parameter was added.
*
* @param array $meta Image meta data.
* @param string $file Path to image file.
* @param int $sourceImageType Type of image.
* @param array $iptc IPTC data.
*/
//return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc );
return $meta;
}
/*
* Convertisseurs de valeurs GPS (latitude, longitude, altitude (+Ref))
*
* geo_frac2dec() - functions.php: creator_get_exif() geo_single_fracs2dec()
* gps() - functions.php: add_class_lightbox() creator_get_exif() - tpl-carte.php
* geo_single_fracs2dec() -
* ctc_exif_date2ts() - functions.php: creator_get_exif()
*/
function geo_single_fracs2dec($fracs) {
return geo_frac2dec($fracs[0]) +
geo_frac2dec($fracs[1]) / 60 +
geo_frac2dec($fracs[2]) / 3600;
}
function geo_frac2dec($str) {
@list( $n, $d ) = explode( '/', $str );
if ( !empty($d) )
return $n / $d;
return $str;
}
function gps($coordinate, $hemisphere) {
for ($i = 0; $i < 3; $i++) {
$part = explode('/', $coordinate[$i]);
if (count($part) == 1) {
$coordinate[$i] = $part[0];
} else if (count($part) == 2) {
$coordinate[$i] = floatval($part[0])/floatval($part[1]);
} else {
$coordinate[$i] = 0;
}
}
list($degrees, $minutes, $seconds) = $coordinate;
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
return $sign * ($degrees + $minutes/60 + $seconds/3600);
}
// 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; //
/*
* mapgallery: affiche la galerie sur la Page Map
*
* entree $attr (array) shortcode gallery
* retourne $output (str)
*
* tpl-carte.php
*/
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');
/**
* Builds the Gallery shortcode output. (*** Modifié pour ajouter des liens vers lightbox***)
*
* This implements the functionality of the Gallery Shortcode for displaying
* WordPress images on a post.
*
* @since 2.5.0
*
* @staticvar int $instance
*
* @param array $attr {
* Attributes of the gallery shortcode.
*
* @type string $order Order of the images in the gallery. Default 'ASC'. Accepts 'ASC', 'DESC'.
* @type string $orderby The field to use when ordering the images. Default 'menu_order ID'.
* Accepts any valid SQL ORDERBY statement.
* @type int $id Post ID.
* @type string $itemtag HTML tag to use for each image in the gallery.
* Default 'dl', or 'figure' when the theme registers HTML5 gallery support.
* @type string $icontag HTML tag to use for each image's icon.
* Default 'dt', or 'div' when the theme registers HTML5 gallery support.
* @type string $captiontag HTML tag to use for each image's caption.
* Default 'dd', or 'figcaption' when the theme registers HTML5 gallery support.
* @type int $columns Number of columns of images to display. Default 3.
* @type string|array $size Size of the images to display. Accepts any valid image size, or an array of width
* and height values in pixels (in that order). Default 'thumbnail'.
* @type string $ids A comma-separated list of IDs of attachments to display. Default empty.
* @type string $include A comma-separated list of IDs of attachments to include. Default empty.
* @type string $exclude A comma-separated list of IDs of attachments to exclude. Default empty.
* @type string $link What to link each image to. Default empty (links to the attachment page).
* Accepts 'file', 'none'.
* }
* @return string HTML content to display gallery.
*/
function creator_gallery_shortcode( $attr ) {
$post = get_post();
static $instance = 0;
$instance++;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
if ( empty( $attr['orderby'] ) ) {
$attr['orderby'] = 'post__in';
}
$attr['include'] = $attr['ids'];
}
/**
* Filters the default gallery shortcode output.
*
* If the filtered output isn't empty, it will be used instead of generating
* the default gallery template.
*
* @since 2.5.0
* @since 4.2.0 The `$instance` parameter was added.
*
* @see gallery_shortcode()
*
* @param string $output The gallery output. Default empty.
* @param array $attr Attributes of the gallery shortcode.
* @param int $instance Unique numeric ID of this gallery shortcode instance.
*/
$output = apply_filters( 'post_gallery', '', $attr, $instance );
if ( $output != '' ) {
return $output;
}
$html5 = current_theme_supports( 'html5', 'gallery' );
$atts = shortcode_atts( array(
'order' => 'ASC',
'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, 'gallery' );
$id = intval( $atts['id'] );
if ( ! empty( $atts['include'] ) ) {
$_attachments = get_posts( array( 'include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( ! empty( $atts['exclude'] ) ) {
$attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
} else {
$attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
}
if ( empty( $attachments ) ) {
return '';
}
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment ) {
$output .= wp_get_attachment_link( $att_id, $atts['size'], true ) . "\n";
}
return $output;
}
$itemtag = tag_escape( $atts['itemtag'] );
$captiontag = tag_escape( $atts['captiontag'] );
$icontag = tag_escape( $atts['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';
}
$columns = intval( $atts['columns'] );
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
$float = is_rtl() ? 'right' : 'left';
$selector = "gallery-{$instance}";
$gallery_style = '';
/**
* Filters whether to print default gallery styles.
*
* @since 3.1.0
*
* @param bool $print Whether to print default gallery styles.
* Defaults to false if the theme supports HTML5 galleries.
* Otherwise, defaults to true.
*/
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";
}
$size_class = sanitize_html_class( $atts['size'] );
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
/**
* Filters the default gallery shortcode CSS styles.
*
* @since 2.5.0
*
* @param string $gallery_style Default CSS styles and opening HTML div container
* for the gallery shortcode output.
*/
$output = apply_filters( 'gallery_style', $gallery_style . $gallery_div );
$selecteur = dess_setting('dess_lightbox_select');
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
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='{$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 {
$image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr );
}
$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'>";
$output .= "
<{$icontag} class='gallery-icon {$orientation}'>
$image_output
</{$icontag}>";
if ( $captiontag && trim($attachment->post_excerpt) ) {
$output .= "
<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
" . wptexturize($attachment->post_excerpt) . "
</{$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;
}
/*
* childtheme_customize_register(): modifie la page des options du thème child
*
* entree
* retourne
*
*
*/
//http://cssmary.com/wordpress/customizer-api-child-theme/
function childtheme_customize_register( $wp_customize ) {
// remove settings
$remove_socials = array('google-plus','instagram','pinterest','linkedin');
for($i=0;$i<count($remove_socials);$i++) {
$wp_customize->remove_setting( 'dess_'.$remove_socials[$i] );
$wp_customize->remove_control( 'dess_'.$remove_socials[$i] );
}
$wp_customize->remove_setting( 'dess_hoursup' );
$wp_customize->remove_control( 'dess_hoursup' );
$wp_customize->remove_setting( 'dess_tel' );
$wp_customize->remove_control( 'dess_tel' );
// add settings
$add_socials = array('500px','flickr','rss','mail');
for($i=0;$i<count($add_socials);$i++) {
$name = str_replace('-',' ',ucfirst($add_socials[$i]));
$wp_customize->add_setting('dess_'.$add_socials[$i], array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_url',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_'.$add_socials[$i], array(
'settings' => 'dess_'.$add_socials[$i],
'label' => $name.' URL',
'section' => 'sm_section',
'type' => 'text',
)));
}
$wp_customize->get_setting( 'dess_rss' )->default = get_bloginfo('rss2_url');
// new section
$wp_customize->add_section('settings_section', array(
'title' => __('Settings','creator'),
'capability' => 'edit_theme_options',
'description' => __('Theme settings','CreatorThemeRes-child')
)
);
// new options
$wp_customize->add_setting('dess_zenphoto', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_zenphoto', array(
'settings' => 'dess_zenphoto',
'label' => __('Zenphoto path','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting('dess_zp_size', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_zp_size', array(
'settings' => 'dess_zp_size',
'label' => __('Zenphoto image size (px)','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting('dess_social_size', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_social_size', array(
'settings' => 'dess_social_size',
'label' => __('Socials icons size (16 or 32px)','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting('dess_lightbox_select', array(
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'dess_sanitize_html',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_lightbox_select', array(
'settings' => 'dess_lightbox_select',
'label' => __('Lightbox selector (class="xxx")','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'text',
)));
$wp_customize->add_setting( 'dess_lightbox_choice', array(
'default' => 'b',
) );
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_lightbox_choice', array(
'label' => __('Choice of lightbox','CreatorThemeRes-child'),
'section' => 'settings_section',
'settings' => 'dess_lightbox_choice',
'type' => 'radio',
'choices' => array(
'a' => 'Meow box',
'b' => 'Colorbox',
'c' => 'Featherlight',
),
)));
$wp_customize->add_setting( 'dess_display_exif', array(
'default' => 'trlue',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( 'dess_display_exif', array(
'settings' => 'dess_display_exif',
'label' => __('Display EXIFs','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'dess_display_gps', array(
'default' => 'false',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( 'dess_display_gps', array(
'settings' => 'dess_display_gps',
'label' => __('Display Geo datas','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'dess_display_meta', array(
'default' => 'false',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
) );
$wp_customize->add_control( 'dess_display_meta', array(
'settings' => 'dess_display_meta',
'label' => __('Display meta (single)','CreatorThemeRes-child'),
'section' => 'settings_section',
'type' => 'checkbox',
) );
}
add_action( 'customize_register', 'childtheme_customize_register', 12);
/*
function choice_a_callback( $control ) {
if ( $control->manager->get_setting('dess_lightbox_choice')->value() == 'a' ) {
return true;
} else {
return false;
}
}
function choice_b_callback( $control ) {
if ( $control->manager->get_setting('dess_lightbox_choice')->value() == 'b' ) {
return true;
} else {
return false;
}
}
function choice_c_callback( $control ) {
if ( $control->manager->get_setting('dess_lightbox_choice')->value() == 'c' ) {
return true;
} else {
return false;
}
}
*/
/*
* show_bookmark_list(): SHORCODE modifie la liste des liens (wp_list_bookmarks())
*
*/
function show_bookmark_list(){ ?>
<ul>
<?php
$args = array(
'title_before' => '<h3>',
'title_after' => '</h3>',
);
wp_list_bookmarks( $args ); ?>
</ul>
<?php
}
add_shortcode('show_bookmark_list', 'show_bookmark_list');
/*
* in_multiarray(): vérifie si un élément est présent dans un tableau muntidimensionnel
*
* entree $elem (str) $array(array) shortcode gallery
* retourne true ou false
*
* functions.php - add_exif()
*/
function in_multiarray($elem, $array) {
$top = sizeof($array) - 1;
$bottom = 0;
while($bottom <= $top) {
if($array[$bottom] == $elem)
return true;
else
if(is_array($array[$bottom]))
if(in_multiarray($elem, ($array[$bottom])))
return true;
$bottom++;
}
return false;
}
/*
* toBool(): dit si une chaine est vrai (ou fausse)
*
* entree $var (str) ("1", "true", "on", "yes", "y" retournera true)
* retourne true ou false
*
* functions.php - flickr_handler()
*/
function toBool($var) {
//flickr
if (!is_string($var)) return (bool) $var;
switch (strtolower($var)) {
case '1':
case 'true':
case 'on':
case 'yes':
case 'y':
return true;
default:
return false;
}
}
/*** UTILE ou INUTILE ??? ***/
/**
* Ajoute les données GPS aux métadata lors de l'importation du média
*/
/*
* add_geo_exif(): FILTRE Ajoute les données GPS aux métadata lors de l'importation du média
*
* entree $var (str) ("1", "true", "on", "yes", "y" retournera true)
* retourne true ou false
*
* functions.php
*/
function add_geo_exif($meta,$file,$sourceImageType) {
$exif = @exif_read_data( $file );
if (!empty($exif['GPSLatitude']))
$meta['latitude'] = $exif['GPSLatitude'] ;
if (!empty($exif['GPSLatitudeRef']))
$meta['latitude_ref'] = trim( $exif['GPSLatitudeRef'] );
if (!empty($exif['GPSLongitude']))
$meta['longitude'] = $exif['GPSLongitude'] ;
if (!empty($exif['GPSLongitudeRef']))
$meta['longitude_ref'] = trim( $exif['GPSLongitudeRef'] );
return $meta;
}
add_filter('wp_read_image_metadata', 'add_geo_exif','',3);
/*
* fmulticurl(): recherche et récupère des infos sur Wikipedia
*
* entree $query (array) (tableau contenant les données à rechercher sur wikipedia (1 entrée/image))
* retourne $obj (array)
*
* single.php - tpl-carte.php
*/
function fmulticurl($query) {
$url = "https://fr.wikipedia.org/w/api.php";
$erreur = array();
/* contruction de la requete opensearch */
$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.'&';
}
/* nettoyage expressions à rechercher */
/**/
echo "requete avant clean_req_wiki<br>";
var_dump($query);
$wiki = clean_req_wiki($query);
//$wiki = $query;
/**/
echo "requete apres clean_req_wiki<br>";
var_dump($wiki);
/* constructions des requetes */
foreach ($wiki as &$val) {
//$val = $url . "?" . $fields_string . "search=" . str_replace(" ", "_", trim($val));
$val = $url . "?" . $fields_string . "search=" . $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, $wiki[$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);
/* OK Remplace les entrées vides par ""
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
*/
echo "retour de la requete<br>";
var_dump($obj);
for ($a = 0; $a < count($obj); $a++){
/*
$req = str_replace("_", " ", $obj[$a][0]);
$req = " " . $req . " ";
*/
$req = $query[$a];
/*
if (is_array($obj[$a])) {
for ($b = 0; $b < count($obj[$a]); $b++){
if (empty($obj[$a][$b])) {
$obj[$a][$b][0] = "";
}
} //for
} //if
*/
foreach ($obj[$a][2] as $key => $val) {
//if (stripos(substr($val, 0, 50), $req) !== false) echo "<b>matche $key</b>";
//echo "nettoyage du retour de la requete<br>";
//var_dump($val, $req);
if (stripos(substr($val, 0, 50), $req) === false) {
unset($obj[$a][1][$key]);
unset($obj[$a][3][$key]);
unset($obj[$a][2][$key]);
}
}
} //for
if (count($erreur) > 0) var_dump($erreur);
//echo "retour de la function multicurl<br>";
//var_dump($obj);
return $obj;
}
/*
* safe_array_access(): recherche et récupère des infos sur Wikipedia
*
* entree $query (array) (tableau contenant les données à rechercher sur wikipedia (1 entrée/image))
* retourne $obj (array)
*
* single.php - tpl-carte.php
*/
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);
}
/*
* clean_req_wiki(): nettoie la requete pour Wikipedia
*
* entree $req (array) (tableau contenant les données à rechercher sur wikipedia (1 entrée/image))
* retourne $q (array) (supprime les tags, les articles en début d'expression, les accents, trim , remplace les " " par "_"
*
* functions.php - fmulticurl()
*/
function clean_req_wiki ($req) {
$v = array();
foreach($req as $val) {
//echo $val . " - ";
$z = strip_tags($val);
//$y= supp_article($z);
$y= supprime_article($z);
$x = str_to_noaccent($y);
//$w = addslashes($x); // mets pont d'arcole avant pont d'arc
//$v = strtolower($w);
$v = str_replace(" ", "_", $x);
$q[] = trim($v);
}
echo "<br>";
return $q;
}
/*
* str_to_noaccent(): remplace les lettres accentuées par leur équivalent sans accent
*
* entree $str (str)
* retourne $str (str)
*
* functions.php - clean_req_wiki()
*/
function str_to_noaccent($str) {
$str = preg_replace('#Ç#', 'C', $str);
$str = preg_replace('#ç#', 'c', $str);
$str = preg_replace('#è|é|ê|ë#', 'e', $str);
$str = preg_replace('#È|É|Ê|Ë#', 'E', $str);
$str = preg_replace('#à|á|â|ã|ä|å#', 'a', $str);
$str = preg_replace('#@|À|Á|Â|Ã|Ä|Å#', 'A', $str);
$str = preg_replace('#ì|í|î|ï#', 'i', $str);
$str = preg_replace('#Ì|Í|Î|Ï#', 'I', $str);
$str = preg_replace('#ð|ò|ó|ô|õ|ö#', 'o', $str);
$str = preg_replace('#Ò|Ó|Ô|Õ|Ö#', 'O', $str);
$str = preg_replace('#ù|ú|û|ü#', 'u', $str);
$str = preg_replace('#Ù|Ú|Û|Ü#', 'U', $str);
$str = preg_replace('#ý|ÿ#', 'y', $str);
$str = preg_replace('#Ý#', 'Y', $str);
return ($str);
}
/*
* supprime_article(): supprime les articles en début d'expression
*
*
* entree $str (str)
* retourne $m (str)
*
* functions.php - clean_req_wiki()
*/
function supprime_article($str) {
//supprime les articles en début de chaine
//supprime expressions entre parentheses
$pattern = "#^(le|la|les|un|une|du|de|des|ce|ces|cette|cet)\s#mUis";
$pattern2 = "#^([l|d|s|t]')#mUis";
$pattern3 = "#\\([^)]*\\)#";
$k = preg_replace($pattern, " ", $str);
$l = preg_replace($pattern2, " ", $k);
$m = preg_replace($pattern3, "", $l);
return trim($m);
}
function preprint($s, $return=false) {
$x = "<pre>";
$x .= print_r($s, 1);
$x .= "</pre>";
if ($return) return $x;
else print $x;
}
?>