Last active
October 3, 2017 21:52
-
-
Save maykbrito/58de5139b6ce079be30411e84d05f943 to your computer and use it in GitHub Desktop.
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 | |
/* PARA USAR COM WORDPRESS */ | |
class BeforeAfter { | |
public function __construct(){} | |
public function do_shortcode() | |
{ | |
add_action( 'wp_enqueue_scripts', array($this, 'add_scripts') ); | |
add_shortcode( 'before_after', array($this, 'before_after')); | |
} | |
public function before_after($att) | |
{ | |
$before = array_key_exists("before", $att) ? $att['before'] : ''; | |
$after = array_key_exists("after", $att) ? $att['after'] : ''; | |
if ($before != "" || $after != "") | |
{ | |
return sprintf('<div class="twentytwenty-container beforeafter"><img src="%s" alt="Antes"><img src="%s" alt="Depois" /></div>', $before, $after); | |
} | |
} | |
public function add_scripts() | |
{ | |
wp_enqueue_style( 'beforeafter', esc_url_raw( 'https://s3.amazonaws.com/britonet-backup/beforeafter.css' ), array(), null ); | |
wp_enqueue_script( 'beforeafter', esc_url_raw( 'https://s3.amazonaws.com/britonet-backup/beforeafter.js' ), array('jquery'), null, true ); | |
add_action('wp_footer', array($this, 'custom_js')); | |
} | |
public function custom_js() | |
{ | |
echo '<script>jQuery(window).load(function() { | |
jQuery(".beforeafter").twentytwenty(); | |
});</script>'; | |
} | |
} | |
$bf = new BeforeAfter(); | |
$bf->do_shortcode(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment