Advertisement
VictorMisa

Spintax para all import

Apr 29th, 2020
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. //agregar codigo a funtions.php
  2.  
  3. function my_spintax( $string ) {
  4. $data = preg_match_all( "/\{(((?>[^\{\}]+)|(?R))*)\}/x", $string, $match );
  5.  
  6. if ( !empty( $match ) ) {
  7. foreach ( $match as $key => $value ) {
  8. if ( !empty( $value ) ) {
  9. foreach ( $value as $values ) {
  10. $v = explode( "|", $values );
  11. $i = array_rand( $v );
  12. $string = str_replace( $values, str_replace( array( "{", "}" ), "", $v[ $i ] ), $string );
  13. }
  14. }
  15. }
  16. }
  17. return $string;
  18. }
  19.  
  20. //ejemplo de shortcode para spintax
  21. [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.")]
  22.  
  23.  
  24. Fuente: https://wordpress.org/support/topic/spintax-function-not-working/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement