Last active
August 29, 2015 13:57
-
-
Save ximosa/9861078 to your computer and use it in GitHub Desktop.
Abrir y cerrar shorcode contoogle de jquery para wordpress
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
/** | |
* añadir esto a tu init.js si tienes uno o crera uno y añadir ver | |
http://codex.wordpress.org/Function_Reference/wp_enqueue_script | |
añadir | |
jQuery(document).ready(function(){ | |
jQuery(".toggle_content").hide(); | |
jQuery(".toggle_title").click(function() { | |
jQuery(this).toggleClass("toggle_active").next().slideToggle('fast'); | |
return false; | |
}); | |
}); | |
*/ | |
function shortcode_toggle($atts, $content = null){ | |
str_replace(array("<br />[", "<br/>[", "<br>["), "[", $content); | |
str_replace(array("]<br />", "]<br/>", "]<br>"), "]", $content); | |
$content = trim(do_shortcode($content)); | |
extract(shortcode_atts(array("title" => ''), $atts)); | |
return '<div class="toggle_title">'.$title.'</div><div class="toggle_content">'.$content.'</div>'; | |
} | |
add_shortcode('toggle', 'shortcode_toggle'); | |
/** | |
* como podemos insertar | |
[toggle title="abrir"]Aqui tu contenido...[/toggle] | |
<div class="toggle_title">Abrir</div><div class="toggle_content">Aqui tu contenido...</div> | |
*/ | |
/** | |
* ahora añadimos css | |
<style> | |
.toggle_title{ | |
background: #F7F7F7; | |
height: 29px; | |
font-size: 14px; | |
color: #5e6069; | |
cursor: pointer; | |
padding: 3px 0 0 48px; | |
user-select: none; | |
-webkit-user-select: none; | |
-moz-user-select: none; | |
width: 100%; | |
} | |
.toggle_active{ | |
background: #F7F7F7;; | |
height: 29px; | |
width: 100%; | |
} | |
.toggle_content{ | |
background: #CFE4E6; | |
color: #515151; | |
border-left: 1px solid #DEDEDE; | |
border-bottom: 1px solid #DEDEDE; | |
border-right: 1px solid #DEDEDE; | |
overflow: auto; | |
margin: -3px 0 15px; | |
padding: 5px 15px; | |
width: 100%; | |
} | |
</style> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment