/**
* @name functions.php
* @uses Functions for the iwy bootstrap3 theme
* @author Joel Garcin
* @copyright IwebYou
* @package IwY Bootstrap
* @version 3.2.3
*/
add_action( 'after_setup_theme', 'my_child_theme_setup' );
function my_child_theme_setup() {
load_child_theme_textdomain( 'child', get_stylesheet_directory() . '/languages' );
}
remove_action( 'init', 'iwy_sidebar_class' );
function iwy_sidebar_class( $sidebar_name ) {
global $sidebars_widgets;
if ( isset($sidebars_widgets[$sidebar_name]) ) {
$count = count($sidebars_widgets[$sidebar_name]);
} else {
$count = 0;
}
switch ( $count ) {
case '1':
$class = 'col-md-12';
break;
case '2':
$class = 'col-md-6 col-sm-6';
break;
case '3':
$class = 'col-md-4';
break;
case '4':
$class = 'col-md-3 col-xs-6';
break;
case '6':
$class = 'col-md-4 col-sm-6';
break;
default:
$class = 'col-md-12';
break;
}
return $class;
}
/**
* Callback function to display galleries (in HTML5)
*
* @param string $content
* @param array $attr
*
* @return string
*/
function iwy_post_gallery($content, $attr) {
global $instance, $post;
$instance ++;
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
if (isset( $attr['orderby'] )) {
$attr ['orderby'] = sanitize_sql_orderby( $attr ['orderby'] );
if (!$attr ['orderby'])
unset( $attr['orderby'] );
}
extract ( shortcode_atts( array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => 'gallery',
'itemtag' => 'figure',
'icontag' => 'div',
'captiontag' => 'figcaption',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
'exclude' => '',
'align' => '',
'link' => 'file'
), $attr ) );
$id = intval( $id );
if ('RAND' == $order)
$orderby = 'none';
if ($include) {
$include = preg_replace('/[^0-9,]+/','', $include );
$_attachments = get_posts( array(
'include' => $include,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $order,
'orderby' => $orderby
) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ($exclude) {
$exclude = preg_replace('/[^0-9,]+/','', $exclude );
$attachments = get_children( array(
'post_parent' => $id,
'exclude' => $exclude,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $order,
'orderby' => $orderby
) );
} else {
$attachments = get_children( array(
'post_parent' => $id,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => $order,
'orderby' => $orderby
) );
}
if (empty( $attachments ))
return;
if (is_feed()) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link( $att_id, $size, true ) . "\n";
return $output;
}
$output = '';
$itemtag = tag_escape( $itemtag );
$captiontag = tag_escape( $captiontag );
$columns = intval ( min( array(
8,
$columns
) ) );
$float = (is_rtl ()) ? 'right' : 'left';
$selector = "gallery-{$instance}";
$size_class = sanitize_html_class( $size );
$output .= "
";
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$comments = get_comments( array(
'post_id' => $id,
'count' => true,
'type' => 'comment',
'status' => 'approve'
) );
$link = wp_get_attachment_image( $id, $size, !(isset( $attr['link'] ) and 'file' == $attr['link']), array('class'=>'img-responsive aligncenter') );
if ( isset($attr['link']) ) {
if ( $attr['link'] == 'none') {
$link = $link;
$modal = '';
} elseif ( $attr['link'] == 'file') {
if ($captiontag and (0 < $comments or trim( $attachment->post_excerpt ))) {
$comments = (0 < $comments) ? sprintf( _n('%d comment','%d comments', $comments, 'iwy'), $comments ) : '';
$excerpt = wptexturize (''. $attachment->post_excerpt .'');
$out = ($comments and $excerpt) ? " $excerpt
$comments " : " $excerpt$comments ";
} else {
$out = '';
}
$link = '' . $link . '';
$modal = '
'. wp_get_attachment_image( $id, 'large') .'
';
}
} else {
$link = '' . $link . '';
$modal = '';
}
$span = 'col-xs-6 col-sm-4 '. floor( 12 / $columns * 3 ) .' col-md-'. floor( 12 / $columns );
$output .= "- <{$itemtag} class=\"gallery-item img-thumbnail img-responsive\">";
$output .= "<{$icontag} class=\"gallery-icon\">{$link}{$icontag}>\n";
if ($captiontag and (0 < $comments or trim ( $attachment->post_excerpt ))) {
$comments = (0 < $comments) ? sprintf( _n ('%d comment','%d comments', $comments, 'iwy'), $comments ) : '';
$excerpt = wptexturize ( $attachment->post_excerpt );
$out = ($comments and $excerpt) ? " $excerpt
$comments " : " $excerpt$comments ";
$output .= "<{$captiontag} class=\"wp-caption-text gallery-caption\">{$out}{$captiontag}>\n";
}
$output .= "{$itemtag}>{$modal} \n";
}
$output .= "
\n";
return ''. $output .'
';
}
add_filter('post_gallery','iwy_post_gallery', 10, 2 );
?>
{"name":"Arkalome.fr","description":"","url":"https:\/\/fr.arkalome.es","home":"https:\/\/fr.arkalome.es","namespaces":["oembed\/1.0","contact-form-7\/v1","yoast\/v1"],"authentication":[],"routes":{"\/":{"namespace":"","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view"}}}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/"}},"\/oembed\/1.0":{"namespace":"oembed\/1.0","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"oembed\/1.0"},"context":{"required":false,"default":"view"}}}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/oembed\/1.0"}},"\/oembed\/1.0\/embed":{"namespace":"oembed\/1.0","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"url":{"required":true},"format":{"required":false,"default":"json"},"maxwidth":{"required":false,"default":600}}}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/oembed\/1.0\/embed"}},"\/contact-form-7\/v1":{"namespace":"contact-form-7\/v1","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"contact-form-7\/v1"},"context":{"required":false,"default":"view"}}}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/contact-form-7\/v1"}},"\/contact-form-7\/v1\/contact-forms":{"namespace":"contact-form-7\/v1","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":[]},{"methods":["POST"],"args":[]}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/contact-form-7\/v1\/contact-forms"}},"\/contact-form-7\/v1\/contact-forms\/(?P\\d+)":{"namespace":"contact-form-7\/v1","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":[]},{"methods":["POST","PUT","PATCH"],"args":[]},{"methods":["DELETE"],"args":[]}]},"\/contact-form-7\/v1\/contact-forms\/(?P\\d+)\/feedback":{"namespace":"contact-form-7\/v1","methods":["POST"],"endpoints":[{"methods":["POST"],"args":[]}]},"\/contact-form-7\/v1\/contact-forms\/(?P\\d+)\/refill":{"namespace":"contact-form-7\/v1","methods":["GET"],"endpoints":[{"methods":["GET"],"args":[]}]},"\/yoast\/v1":{"namespace":"yoast\/v1","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"yoast\/v1"},"context":{"required":false,"default":"view"}}}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/yoast\/v1"}},"\/yoast\/v1\/configurator":{"namespace":"yoast\/v1","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":[]},{"methods":["POST"],"args":[]}],"_links":{"self":"https:\/\/fr.arkalome.es\/wp-json\/yoast\/v1\/configurator"}}},"_links":{"help":[{"href":"http:\/\/v2.wp-api.org\/"}]}}