コード例 #1
0
ファイル: functions.php プロジェクト: scottnkerr/eeco
 public function shortcode_benefits($atts, $content = null)
 {
     $default_atts = array('style' => '1', 'columns' => '4', 'dividers' => '1', 'image_background' => '1', 'animation' => 'none');
     $attributes = shortcode_atts($default_atts, $atts);
     $attributes['animation'] = in_array($attributes['animation'], array('none', 'scale', 'fade', 'left', 'right', 'bottom', 'top')) ? $attributes['animation'] : $default_atts['animation'];
     $attributes['columns'] = in_array($attributes['columns'], array('1', '2', '3', '4', '5')) ? absint($attributes['columns']) : $default_atts['columns'];
     $attributes['style'] = in_array($attributes['style'], array('1', '2', '3')) ? $attributes['style'] : $default_atts['style'];
     $attributes['dividers'] = apply_filters('dt_sanitize_flag', $attributes['dividers']);
     $attributes['image_background'] = apply_filters('dt_sanitize_flag', $attributes['image_background']);
     $classes = array('benefits-grid', 'wf-container');
     switch ($attributes['style']) {
         case '2':
             $classes[] = 'benefits-style-one';
             break;
         case '3':
             $classes[] = 'benefits-style-two';
             break;
     }
     if ($attributes['image_background']) {
         $classes[] = 'icons-bg';
     }
     if ('none' != $attributes['animation']) {
         $classes[] = 'animation-builder';
     }
     // backup atts
     $backup_atts = self::$atts;
     self::$atts = $attributes;
     $output = sprintf('<section class="%s">%s</section>', esc_attr(implode(' ', $classes)), do_shortcode($content));
     // restore atts
     self::$atts = $backup_atts;
     return $output;
 }