Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sgssandhu committed Jan 15, 2019
1 parent 479f5d3 commit ab225f9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 92 deletions.
91 changes: 0 additions & 91 deletions custom-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,99 +369,8 @@ function aione_slider_docs_callback(){
$id = get_the_ID();
echo '[aione-slider id="'.$id.'"]';
}
/**
* Aione Slider Shortcode Callback
*
*/
add_shortcode( 'aione-slider', 'aione_slider_shortcode' );
function aione_slider_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => '',
'class' => '',
), $atts, 'aione-slider' );

$output = '';
$slider_id = $atts['id'];

if ( get_post_status ( $slider_id ) == 'publish' ) {
if ( get_post_type( $slider_id ) == 'aione-slider' ) {
$slides = get_field('aione_slider_images', $slider_id);

$settings = get_post_meta($atts['id'], 'aione-slider-settings', true );
$skip_settings = array(
'theme',
'caption',
'caption_title',
'caption_description',
'caption_link',
'URLhashListener',
);
$slider_classes = array('slider','owl-carousel');
$slider_data = array();

if(is_array($settings)){
foreach($settings as $setting_key => $setting_value){
if(in_array($setting_key, $skip_settings)){
continue;
}
$setting_key = strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', $setting_key));
$slider_data[] = 'data-'.$setting_key.'="'.$setting_value.'" ';
}
}

$slider_classes[] = $settings['theme'];
$slider_classes = implode(" ",$slider_classes);
$slider_data = implode(" ",$slider_data);





/*
echo '<div style="display:none">';
echo "<br>caption === ".$settings['caption'];
echo "<br>caption_title === ".$settings['caption_title'];
echo "<br>caption_description === ".$settings['caption_description'];
echo "<br>caption_link === ".$settings['caption_link'];
echo '</div>';
echo "<pre>";
print_r($slider_classes);
echo "</pre>";
*/

if(!empty($slides)):
$output .= '<div id="aione_slider_'.$atts['id'].'" class="'.$slider_classes.'" '.$slider_data.'>';
foreach ($slides as $key => $slide) {
$output .= '<div class="slider-item">';
$output .= '<div class="slider-image">';
$output .= '<img src="'.@$slide['url'].'" alt="'.@$slide['alt'].'" />';
$output .= '</div>';
if($settings['caption']){
$output .= '<div class="slider-caption">';
if($settings['caption_title']){
$output .= '<h3 class="caption-title">'.@$slide['title'].'</h3>';
}
if($settings['caption_description']){
$output .= '<p class="caption-description">'.@$slide['caption'].'</p>';
}
$output .= '</div>';
}
$output .= '</div>';
}
$output .= '</div>';
endif;
$output .='<div class="aione-clear"></div>';
} else {
$output .= '<div class="aione-message warning">Invalid Slider</div>';
}
} else {
$output .= '<div class="aione-message warning">Invalid Slider</div>';
}
return $output;
}

/**
* Register Aione Slider Custom Field "Gallery"
*
Expand Down
3 changes: 3 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ function clean_script_tag( $input ) {
//Register Aione Slider
require get_template_directory() . '/includes/register-aione-slider.php';

// Shortcodes
require get_template_directory() . '/includes/shortcodes.php';

//Custom template tags for this theme.
require get_template_directory() . '/includes/template-tags.php';

Expand Down
95 changes: 95 additions & 0 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/**
* Aione Slider Shortcode
*/
add_shortcode( 'aione-slider', 'aione_slider_shortcode' );
function aione_slider_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => '',
'class' => '',
), $atts, 'aione-slider' );

$output = '';
$slider_id = $atts['id'];

if ( get_post_status ( $slider_id ) == 'publish' ) {
if ( get_post_type( $slider_id ) == 'aione-slider' ) {
$slides = get_field('aione_slider_images', $slider_id);

$settings = get_post_meta($atts['id'], 'aione-slider-settings', true );
$skip_settings = array(
'theme',
'caption',
'caption_title',
'caption_description',
'caption_link',
'URLhashListener',
);
$slider_classes = array('slider','owl-carousel');
$slider_data = array();

if(is_array($settings)){
foreach($settings as $setting_key => $setting_value){
if(in_array($setting_key, $skip_settings)){
continue;
}
/*
if( $setting_key == 'data-animation' ){
if( $setting_value == 'push-left'){
}
}
*/
$setting_key = strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', $setting_key));
$slider_data[] = 'data-'.$setting_key.'="'.$setting_value.'" ';
}
}

$slider_classes[] = $settings['theme'];
$slider_classes = implode(" ",$slider_classes);
$slider_data = implode(" ",$slider_data);

/*
echo '<div style="display:none">';
echo "<br>caption === ".$settings['caption'];
echo "<br>caption_title === ".$settings['caption_title'];
echo "<br>caption_description === ".$settings['caption_description'];
echo "<br>caption_link === ".$settings['caption_link'];
echo '</div>';
echo "<pre>";
print_r($slider_classes);
echo "</pre>";
*/

if(!empty($slides)):
$output .= '<div id="aione_slider_'.$atts['id'].'" class="'.$slider_classes.'" '.$slider_data.'>';
foreach ($slides as $key => $slide) {
$output .= '<div class="slider-item">';
$output .= '<div class="slider-image">';
$output .= '<img src="'.@$slide['url'].'" alt="'.@$slide['alt'].'" />';
$output .= '</div>';
if($settings['caption']){
$output .= '<div class="slider-caption">';
if($settings['caption_title']){
$output .= '<h3 class="caption-title">'.@$slide['title'].'</h3>';
}
if($settings['caption_description']){
$output .= '<p class="caption-description">'.@$slide['caption'].'</p>';
}
$output .= '</div>';
}
$output .= '</div>';
}
$output .= '</div>';
endif;
$output .='<div class="aione-clear"></div>';
} else {
$output .= '<div class="aione-message warning">Invalid Slider</div>';
}
} else {
$output .= '<div class="aione-message warning">Invalid Slider</div>';
}
return $output;
}
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Theme URI: https://github.com/darlic/aione
Author: OXO Solutions®
Author URI: https://oxosolutions.com
Description: Multipurpose All-in-One fastest Wordpress Theme developed for Darlic® Platform using AioneFramework, The 100 Column Grid system
Version: 7.3.0.0
Version: 7.3.0.1
License: GNU General Public License v3.0 or later
License URI: https://github.com/Darlic/aione/blob/master/LICENSE
Text Domain: aione
Expand Down

0 comments on commit ab225f9

Please sign in to comment.