Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //agregar codigo a funtions.php
- function my_spintax( $string ) {
- $data = preg_match_all( "/\{(((?>[^\{\}]+)|(?R))*)\}/x", $string, $match );
- if ( !empty( $match ) ) {
- foreach ( $match as $key => $value ) {
- if ( !empty( $value ) ) {
- foreach ( $value as $values ) {
- $v = explode( "|", $values );
- $i = array_rand( $v );
- $string = str_replace( $values, str_replace( array( "{", "}" ), "", $v[ $i ] ), $string );
- }
- }
- }
- }
- return $string;
- }
- //ejemplo de shortcode para spintax
- [my_spintax("{Based in|Located in|Situated in} London {and working|and running sessions} {through|via|over} skype {all around the world|all across the globe|worldwide|all over the world} {at Space to Evolve|at Space to Evolve} {our entire focus is to|our number one aim is to} {help you to|assist you to|guide you to} {lising the greatest vision|live the highest calling} of your life.")]
- Fuente: https://wordpress.org/support/topic/spintax-function-not-working/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement