Last active
March 28, 2018 16:32
-
-
Save spkellydev/b5a8b3e8d6bdb2f12c6690e689ebd5bf to your computer and use it in GitHub Desktop.
FAQ schema class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FAQ | |
{ | |
public $html = ''; | |
function __construct ( ) | |
{ | |
add_shortcode( 'sl9-faq', array( $this, 'shortcode' ) ); | |
} | |
function shortcode ( $atts, $content=null ) | |
{ | |
$a = shortcode_atts( array( | |
"question" => '' | |
), $atts ); | |
$html .= '<article itemscope itemtype="http://schema.org/Question">'; | |
$html .= '<h3 itemprop="name">' . sanitize_text_field($a['question']) . '</h3>'; | |
$html .= '<section itemprop="suggestedAnswer acceptedAnswer" itemscope itemtype="http://schema.org/Answer">'; | |
$html .= '<p itemprop="text">'. esc_html__($content) .'</p>'; | |
$html .= '</section>'; | |
$html .= '</article>'; | |
return $html; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Summary: Timeline block will provide predictable timeline blocks with responsiveness. | |
* | |
* Description: Shortcode Usage: | |
* PARENT: [sl9-tl class="my-class"] | |
* [sl9-tl-step class="my-other-class"]Content[/sl9-tl-step] | |
* ENDPARENT: [/sl9-tl] | |
*/ | |
require_once 'Shortcode.interface.php'; | |
class TimelineStep implements ShortcodeInterface | |
{ | |
public function __construct( ) | |
{ | |
add_shortcode( 'sl9-tl', array( $this, 'shortcode_parent' ) ); | |
add_shortcode( 'sl9-tl-step', array( $this, 'shortcode' ) ); | |
} | |
public function shortcode ( $atts, $content=null ) | |
{ | |
$a = shortcode_atts( array( | |
'class' => ' ', | |
'title' => '', | |
'side' => ' left ', | |
'step' => '', | |
'image_id' => null | |
), $atts); | |
$html .= '<div><div class="step-image step-clip-path-'. $a['side'] .' pull-'. self::sideReverse( $a['side'] ) .'">'; | |
if ( $a['image_id'] ) { | |
$html .= do_shortcode( '[vc_single_image img_size="full" alignment="center" onclick="link_image" animation="animate-when-visible" css_animation="el-fade" image="'. $a['image_id'] .'"]' ); | |
} | |
$html .= '</div>'; | |
$html .= '<div data-step="'. $a['step'] .'" class="step ' . $a['side'] . $a['class'] .'">'; | |
$html .= '<div class="tmc-step-content">'; | |
$html .= '<h3>'. $a['title'] .'</h3>'; | |
$html .= '<p>'. $content .'</p></div></div></div>'; | |
return $html; | |
} | |
public function shortcode_parent ( $atts, $content=null ) | |
{ | |
$a = shortcode_atts( array( | |
'class' => ' ', | |
'title' => '', | |
'side' => ' left ' | |
), $atts); | |
$html = '<section class="tmc-steps">'; | |
$html .= do_shortcode($content); | |
$html .= '</section>'; | |
return $html; | |
} | |
protected static function sideReverse ( string $side ) | |
{ | |
switch ( $side ) { | |
case 'left': | |
return 'right'; | |
break; | |
case 'right': | |
return 'left'; | |
break; | |
default: | |
return 'Error: Please enter either "right" or "left" as a string.'; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment