Single v1
-commentaires cachés -settings -3 lightbox -enqueue js et css
This commit is contained in:
624
functions.php
624
functions.php
@@ -1,6 +1,13 @@
|
||||
<?php load_theme_textdomain('CreatorThemeRes-child', get_template_directory() . '-child/languages'); ?>
|
||||
<?php
|
||||
|
||||
$serial = "I-JHF68ABWM4B2";
|
||||
update_option( 'mfrh_pro', array( 'subscr_id' => $serial ) );
|
||||
update_option( 'mfrh_pro_status', _( "Your subscription is manually enabled." ) );
|
||||
update_option( 'mfrh_pro_serial', _( $serial ) );
|
||||
set_transient( 'mfrh_validated', $serial, 3600 * 24 * 100 );
|
||||
|
||||
|
||||
/*
|
||||
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
|
||||
|
||||
@@ -9,11 +16,65 @@ function enqueue_parent_styles() {
|
||||
}
|
||||
*/
|
||||
/**/
|
||||
|
||||
//add_action( 'init', 'add_author_rules' );
|
||||
/*
|
||||
function add_author_rules() {
|
||||
add_rewrite_rule(
|
||||
"en-cours-2-page-?([0-9]{1,})/?",
|
||||
"index.php?page_id=804&toto=$matches[1]",
|
||||
"top");
|
||||
$wp_rewrite->flush_rules();
|
||||
}
|
||||
*/
|
||||
|
||||
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_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', get_template_directory_uri() . '/css/featherlight.min.css' );
|
||||
//wp_enqueue_script('featherlight', get_template_directory_uri() . '/js/featherlight.min.js', array( 'jquery' ) );
|
||||
wp_enqueue_style( 'featherlight', 'http://cdn.rawgit.com/noelboss/featherlight/1.7.0/release/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( '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-gallery', 'http://cdn.rawgit.com/noelboss/featherlight/1.3.4/release/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
|
||||
}
|
||||
}
|
||||
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',
|
||||
@@ -37,7 +98,6 @@ function custom_class( $classes ) {
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
||||
function RelativeTime() {
|
||||
|
||||
$jour = get_the_date('U');
|
||||
@@ -182,16 +242,23 @@ function display ($filename,$album) {
|
||||
}
|
||||
|
||||
function displayRetina ($filename,$album) {
|
||||
// 6_2012.jpg
|
||||
// 4_2014_180_thumb.jpg 4_2014_360_thumb.jpg
|
||||
$path = "../zenphoto/cache/" . $album . "/";
|
||||
|
||||
global $ppage;
|
||||
|
||||
if ($ppage == "1") {
|
||||
$fullpath = "../../zenphoto/";
|
||||
}
|
||||
else {
|
||||
$fullpath = "../../../zenphoto/";
|
||||
}
|
||||
$file = explode(".", $filename);
|
||||
|
||||
//$a = $path . $filename;
|
||||
$thumbpath = "../zenphoto/cache/" . $album . "/";
|
||||
$a = $path . $filename;
|
||||
//echo $a. "<br>";
|
||||
|
||||
$file_sd = $path . $file[0] . "_180_thumb.jpg";
|
||||
$file_hd = $path . $file[0] . "_360_thumb.jpg";
|
||||
$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";
|
||||
@@ -204,7 +271,7 @@ function displayRetina ($filename,$album) {
|
||||
$th_sd = true;
|
||||
$size_sd = getimagesize($file_sd, $info);
|
||||
$thumb['sd'] = array(
|
||||
'url' => "../" . $file_sd,
|
||||
'url' => "../../" . $file_sd,
|
||||
'width' => $size_sd[0],
|
||||
'height' => $size_sd[1]
|
||||
);
|
||||
@@ -213,7 +280,7 @@ function displayRetina ($filename,$album) {
|
||||
$th_hd = true;
|
||||
$size_hd = getimagesize($file_hd, $info);
|
||||
$thumb['hd'] = array(
|
||||
'url' => "../" . $file_hd,
|
||||
'url' => "../../" . $file_hd,
|
||||
'width' => $size_hd[0],
|
||||
'height' => $size_hd[1]
|
||||
);
|
||||
@@ -231,15 +298,13 @@ function displayRetina ($filename,$album) {
|
||||
}
|
||||
|
||||
$display = '<div class="album">';
|
||||
$display .= '<div class="thumb">';
|
||||
$display .= '<a href="../../zenphoto/albums/'.$album.'/'.$filename.'" title="'.date_archive($filename).'" class="wraptocenter swipebox" />';
|
||||
$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 .= '<img src="../zenphoto/zp-core/i.php?a='.$album.'&i='.$filename.'&s=180" class="img_archive" />';
|
||||
|
||||
$display .= '<!--[if IE 9]></video><![endif]-->';
|
||||
$display .= '<img srcset="' . $thumb['sd']['url'] . '" width="' . $thumb['sd']['width'] . '" height="' . $thumb['sd']['height'] . '"alt="">';
|
||||
$display .= '</picture>';
|
||||
@@ -247,10 +312,11 @@ function displayRetina ($filename,$album) {
|
||||
$display .= '</a>';
|
||||
$display .= '</div>';
|
||||
$display .= '<div class="albumdesc">';
|
||||
$display .= '<a href="../../zenphoto/index.php?album='.$album.'&image='.$filename.'" title= "'.date_archive($filename).'" class="" />';
|
||||
$display .= '<a href="../../zenphoto/index.php?album='.$album.'&image='.$filename.'" title= "'.date_archive($filename).'" class="">';
|
||||
$display .= '<span class="exif">'.date_archive($filename).'</span>';
|
||||
$display .= '</a></div>';
|
||||
$display .= '</div>';
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
@@ -275,4 +341,534 @@ function date_archive ($chaine) {
|
||||
return $chaine;
|
||||
}
|
||||
|
||||
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"]
|
||||
//taille des photos dans Worpress, theme Twenty Ten Child : 610x406
|
||||
|
||||
$selector = dess_setting('dess_lightbox_select');
|
||||
|
||||
$host = (($_SERVER['HTTPS'] != "") ? "https" : "http") . '://' . $_SERVER['HTTP_HOST'] . '/zenphoto/';
|
||||
|
||||
//$zenphoto_url2 = get_option( 'zenphoto_url' );
|
||||
$zenphoto_url2 = 'http://macbook-pro.lcal/zenphoto/';
|
||||
|
||||
//echo $zenphoto_url2 . "<br>";
|
||||
//preprint($zenphoto_url2);
|
||||
//echo substr_count($zenphoto_url2, "https");
|
||||
//echo $_SERVER['HTTPS'];
|
||||
|
||||
if (substr_count($zenphoto_url2, "https") == 1) {
|
||||
//echo "toto";
|
||||
$zenphoto_url = (($_SERVER['HTTPS'] != "") ? substr_replace($zenphoto_url2, 'https', 0, 4) : $zenphoto_url2);
|
||||
}
|
||||
$zenphoto_url = $host;
|
||||
//echo $zenphoto_url;
|
||||
|
||||
//$size = get_option( 'img_size' );
|
||||
$size = 610;
|
||||
|
||||
$folder = false;
|
||||
$zenphoto_img = "";
|
||||
//preprint($atts);
|
||||
$a = $atts['image'];
|
||||
$b = zp_query($a); // ligne 808
|
||||
|
||||
if (isset($atts['folder'])) {
|
||||
if ($atts['folder'] == "true") $folder = true;
|
||||
}
|
||||
|
||||
$img = substr($atts['image'], 0, strlen($atts['image']) - 4);
|
||||
|
||||
$filename = $zenphoto_url . 'cache/' . $atts['album'] . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
|
||||
|
||||
$zp_size = getimagesize(htmlentities($filename));
|
||||
|
||||
//if ($folder == false) $zenphoto_link = '<a rel="lightbox" href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '">';
|
||||
//if ($folder == false) $zenphoto_link = '<a href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '" class="entry-content">';
|
||||
if ($folder == false) $zenphoto_link = '<a href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '" class="' . $selector . '">';
|
||||
else $zenphoto_link = '<a href="' . $zenphoto_url . $atts['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/' . $atts['album'] . '/' . $img . '_' . $size . '_watermark.jpg, ' . $zenphoto_url . 'cache/' . $atts['album'] . '/' . $img . '_' . ($size * 2) . '_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/' . $atts['album'] . '/' . $img . '_' . $size . '_watermark.jpg" ' . $zp_size[3] . 'alt="' . $img . '" />
|
||||
</picture>';
|
||||
$zenphoto_img .= '</a>';
|
||||
|
||||
/*
|
||||
if ($b['image_meta']['description'] != "") {
|
||||
$caption = "";
|
||||
$caption .= '<p class="wp-caption-text aligncenter" style="width:' . $zp_size[0] . 'px">';
|
||||
$caption .= $b['image_meta']['description'] . '</p>';
|
||||
|
||||
$zenphoto_img .= $caption;
|
||||
}
|
||||
*/
|
||||
|
||||
return $zenphoto_img;
|
||||
}
|
||||
|
||||
add_shortcode( 'zenphoto', 'zenphoto_handler' );
|
||||
|
||||
function zp_query($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`, `EXIFGPSLatitude`, `EXIFGPSLatitudeRef`, `EXIFGPSLongitude`, `EXIFGPSLongitudeRef`, `EXIFGPSAltitude`, `EXIFGPSAltitudeRef`, `desc`, `title` FROM `" . $zp_prefix . "images` WHERE `filename` = \"$zpimage\"";
|
||||
//echo $excquery;
|
||||
if ($result = $mysqli->query($excquery)) {
|
||||
$exif = $result->fetch_row();
|
||||
$result->close();
|
||||
}
|
||||
|
||||
//preprint($exif);
|
||||
|
||||
/*
|
||||
Array
|
||||
(
|
||||
[0] => Canon EOS 7D
|
||||
[1] => 2011:06:30 20:43:30
|
||||
[2] => 1/400 sec
|
||||
[3] => f/6,3
|
||||
[4] => 640
|
||||
[5] => 600 mm
|
||||
[6] => lat
|
||||
[7] => lat ref
|
||||
[8] => long
|
||||
[9] => long ref
|
||||
[10] => alt
|
||||
[11] => alt ref
|
||||
[12] => desc
|
||||
[13] => title
|
||||
)*/
|
||||
$meta = array();
|
||||
$meta['image_meta']['camera'] = $exif[0];
|
||||
$meta['image_meta']['created_timestamp'] = $exif[1];
|
||||
$meta['image_meta']['shutter_speed'] = $exif[2];
|
||||
$meta['image_meta']['aperture'] = $exif[3];
|
||||
$meta['image_meta']['iso'] = $exif[4];
|
||||
$meta['image_meta']['focal_length'] = $exif[5];
|
||||
$meta['image_meta']['latitude'] = $exif[6];
|
||||
$meta['image_meta']['latitude_ref'] = $exif[7];
|
||||
$meta['image_meta']['longitude'] = $exif[8];
|
||||
$meta['image_meta']['longitude_ref'] = $exif[9];
|
||||
$meta['image_meta']['altitude'] = $exif[10];
|
||||
$meta['image_meta']['altitude_ref'] = $exif[11];
|
||||
|
||||
if ($exif[12] != "") {
|
||||
$desc = explode(':', $exif[12]);
|
||||
$description = explode('"', end($desc));
|
||||
//print_r($description);
|
||||
$meta['image_meta']['description'] = utf8_encode($description[1]);
|
||||
}
|
||||
else $meta['image_meta']['description'] = "";
|
||||
|
||||
if ($exif[13] != "") {
|
||||
//echo "exif: " . $exif[13] . "<br>";
|
||||
// a:1:{s:5:"fr_FR";s:30:"2011-05-15_GP-France-2011_9798";}
|
||||
|
||||
$titr = explode(':', $exif[13]);
|
||||
//echo count($titr) . "<br>";
|
||||
|
||||
if (count($titr) == 1) {
|
||||
//print_r($titr);
|
||||
//$titr[0]
|
||||
$meta['image_meta']['title'] = utf8_encode($titr[0]);
|
||||
}
|
||||
else {
|
||||
$titre = explode('"', end($titr));
|
||||
//print_r($titre);
|
||||
//$titre[1]
|
||||
$meta['image_meta']['title'] = utf8_encode($titre[1]);
|
||||
}
|
||||
/*
|
||||
echo "titr: ";
|
||||
print_r($titr);
|
||||
echo "<br>";
|
||||
|
||||
$titre = explode('"', end($titr));
|
||||
print_r($titre);
|
||||
|
||||
foreach ($titr as $var) {
|
||||
echo "<i>" . $var . "</i><br>";
|
||||
}
|
||||
|
||||
*/
|
||||
//$meta['image_meta']['title'] = utf8_encode($titre[1]);
|
||||
}
|
||||
else $meta['image_meta']['title'] = "";
|
||||
|
||||
//echo "<br><br>";
|
||||
$meta['image_meta']['file'] = $image;
|
||||
|
||||
//preprint($meta['image_meta']);
|
||||
|
||||
/*
|
||||
[camera] => Canon EOS-1D Mark IV
|
||||
[created_timestamp] => 2014:10:21 14:42:26
|
||||
[shutter_speed] => 1/80 sec
|
||||
[aperture] => f/9
|
||||
[iso] => 320
|
||||
[focal_length] => 17 mm
|
||||
[latitude] => 44,381861666667
|
||||
[latitude_ref] => N
|
||||
[longitude] => 4,4162216666667
|
||||
[longitude_ref] => E
|
||||
[altitude] => 104,1771m
|
||||
[altitude_ref] =>
|
||||
[description] =>
|
||||
[title] =>
|
||||
*/
|
||||
return $meta;
|
||||
}
|
||||
|
||||
function add_class_lightbox($content) {
|
||||
|
||||
$selector = dess_setting('dess_lightbox_select');
|
||||
|
||||
//$selector = "gallery";
|
||||
//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
|
||||
foreach ($matches as $val)
|
||||
{
|
||||
$slimbox_caption = '';
|
||||
|
||||
$post = get_post($val[5]);
|
||||
$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>';
|
||||
//echo "string" . "<br>" . $string;
|
||||
//$replace = '<a href="' . $val[1] . '.' . $val[2] . '" class="gallery" title="' . $slimbox_caption . '"><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>';
|
||||
//echo "replace" . "<br>" . $replace;
|
||||
$content = str_replace( $string, $replace, $content);
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
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">←</span> %title', 'Previous post link', 'CreatorThemeRes-child' ) ); ?>
|
||||
<?php next_post_link( '%link', _x( '%title <span class="meta-nav">→</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
|
||||
*/
|
||||
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() )
|
||||
twentythirteen_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">' . $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">' . $tag_list . '</span>';
|
||||
}
|
||||
|
||||
// Post author
|
||||
if ( 'post' == get_post_type() ) {
|
||||
printf( '<span class="author vcard"><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( 'twentythirteen_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.
|
||||
*/
|
||||
function twentythirteen_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"><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;
|
||||
|
||||
/**
|
||||
* Create a definition list containing EXIF data of featured image (if exists)
|
||||
*
|
||||
* @param string $post ID
|
||||
* @return echo definition list
|
||||
*/
|
||||
function pa_the_post_thumbnail_exif_data($postID = NULL) {
|
||||
// if $postID not specified, then get global post and assign ID
|
||||
if (!$postID) {
|
||||
global $post;
|
||||
$postID = $post->ID;
|
||||
}
|
||||
if (has_post_thumbnail($postID)) {
|
||||
// get the meta data from the featured image
|
||||
$postThumbnailID = get_post_thumbnail_id( $postID );
|
||||
$photoMeta = wp_get_attachment_metadata( $postThumbnailID );
|
||||
|
||||
// if the shutter speed is not equal to 0
|
||||
if ($photoMeta['image_meta']['shutter_speed'] != 0) {
|
||||
|
||||
// Convert the shutter speed to a fraction
|
||||
if ((1 / $photoMeta['image_meta']['shutter_speed']) > 1) {
|
||||
if ((number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1)) == 1.3
|
||||
or number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1) == 1.5
|
||||
or number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1) == 1.6
|
||||
or number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1) == 2.5) {
|
||||
$photoShutterSpeed = "1/" . number_format((1 / $photoMeta['image_meta']['shutter_speed']), 1, '.', '') . " second";
|
||||
} else {
|
||||
$photoShutterSpeed = "1/" . number_format((1 / $photoMeta['image_meta']['shutter_speed']), 0, '.', '') . " second";
|
||||
}
|
||||
} else {
|
||||
$photoShutterSpeed = $photoMeta['image_meta']['shutter_speed'] . " seconds";
|
||||
}
|
||||
// print our definition list
|
||||
?>
|
||||
<dl>
|
||||
<dt>Date Taken</dt>
|
||||
<dd><?php echo date("d M Y, H:i:s", $photoMeta['image_meta']['created_timestamp']); ?></dd>
|
||||
<dt>Camera</dt>
|
||||
<dd><?php echo $photoMeta['image_meta']['camera']; ?></dd>
|
||||
<dt>Focal Length</dt>
|
||||
<dd><?php echo $photoMeta['image_meta']['focal_length']; ?>mm</dd>
|
||||
<dt>Aperture</dt>
|
||||
<dd>f/<?php echo $photoMeta['image_meta']['aperture']; ?></dd>
|
||||
<dt>ISO</dt>
|
||||
<dd><?php echo $photoMeta['image_meta']['iso']; ?></dd>
|
||||
<dt>Shutter Speed</dt>
|
||||
<dd><?php echo $photoShutterSpeed; ?></dd>
|
||||
</dl>
|
||||
<?php
|
||||
// if shutter speed exif is 0 then echo error message
|
||||
} else {
|
||||
echo '<p>EXIF data not found</p>';
|
||||
}
|
||||
// if no featured image, echo error message
|
||||
} else {
|
||||
echo '<p>Featured image not found</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//http://cssmary.com/wordpress/customizer-api-child-theme/
|
||||
|
||||
function childtheme_customize_register( $wp_customize ) {
|
||||
// remove
|
||||
$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
|
||||
$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_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',
|
||||
),
|
||||
)));
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
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');
|
||||
|
||||
//wp_prepare_attachment_for_js($attachment_id)
|
||||
function wp_get_attachment( $attachment_id ) {
|
||||
|
||||
$attachment = get_post( $attachment_id );
|
||||
return array(
|
||||
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
|
||||
'caption' => $attachment->post_excerpt,
|
||||
'description' => $attachment->post_content,
|
||||
'href' => get_permalink( $attachment->ID ),
|
||||
'src' => $attachment->guid,
|
||||
'title' => $attachment->post_title
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user