Created
June 22, 2021 18:46
-
-
Save n7studios/dad3127f020f00a9b4838187f7005511 to your computer and use it in GitHub Desktop.
Page Generator Pro: Programmatically Process Spintax
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
/** | |
* Make sure to run this after WordPress' init hook has completed. | |
*/ | |
if ( function_exists( 'Page_Generator_Pro' ) ) { | |
$spin = Page_Generator_Pro()->get_class( 'spintax' )->process( '{Writing|Creating} {content|articles} is {a lot of fun|rewarding experience}.' ); | |
if ( is_wp_error( $spin ) ) { | |
// Something went wrong e.g. invalid spintax | |
// Handle this error as you need | |
echo $spin->get_error_message(); | |
} else { | |
// Output spun text | |
echo $spin; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment