Created
June 22, 2021 18:47
-
-
Save n7studios/de597c27147392f13fbbb1fa3fc7b152 to your computer and use it in GitHub Desktop.
Page Generator Pro: Programmatically Process Block 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( 'block_spin' )->process( | |
'#section# | |
#p# | |
#s# | |
Writing content is a lot of fun. | |
Creating articles is a rewarding experience. | |
#/s# | |
#s# | |
When done correctly, it captures the audience’s attention. | |
The audience is immersed in the story, and continue to read. | |
#/s# | |
#/p# | |
#p# | |
#s# | |
It\'s important to add rich media, such as images and video. | |
Images and video add to the audience\'s experience. | |
#/s# | |
#s# | |
Be sure to optimize media for the audience\'s device. | |
However, avoid media that takes a long time to load. | |
#/s# | |
#/p# | |
#/section#' | |
); | |
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