AffiliateWP
3 years ago
Beaver
3 years ago
BuddyBoss
3 years ago
Contracts
3 years ago
Elementor
2 years ago
LearnDash
3 years ago
LearnDashGroup
3 years ago
LifterLMS
3 years ago
MemberPress
3 years ago
ThriveAutomator
2 years ago
TutorLMS
3 years ago
User
3 years ago
AbstractIntegration.php
3 years ago
DiviServiceProvider.php
2 years ago
IntegrationService.php
2 years ago
DiviServiceProvider.php
43 lines
| 1 | <?php |
| 2 | namespace SureCart\Integrations; |
| 3 | |
| 4 | use SureCartCore\ServiceProviders\ServiceProviderInterface; |
| 5 | |
| 6 | class DiviServiceProvider implements ServiceProviderInterface { |
| 7 | /** |
| 8 | * {@inheritDoc} |
| 9 | * |
| 10 | * @param \Pimple\Container $container Service Container. |
| 11 | */ |
| 12 | public function register( $container ) { |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * {@inheritDoc} |
| 17 | * |
| 18 | * @param \Pimple\Container $container Service Container. |
| 19 | */ |
| 20 | public function bootstrap( $container ) { |
| 21 | add_filter( 'surecart/shortcode/render', [ $this, 'handleDiviShortcode' ], 10, 4 ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * If divi is active, only load the assets on the current request. |
| 26 | * |
| 27 | * @param string $content Content of Shortcode. |
| 28 | * @param string $atts Attributes of Shortcode. |
| 29 | * @param string $atts Shortcode Tag. |
| 30 | * @param string $form Form Object if present. |
| 31 | * |
| 32 | * @return string $content Content of Shortcode || The Shortcode itself. |
| 33 | */ |
| 34 | public function handleDiviShortcode( $content, $atts, $name, $form = false ) { |
| 35 | |
| 36 | if ( 'sc_form' !== $name || empty( $atts['id'] ) || empty( $_GET['et_pb_preview'] )) { |
| 37 | return $content; |
| 38 | } |
| 39 | |
| 40 | return '[sc_form id="' . $atts['id'] . '"]'; |
| 41 | } |
| 42 | } |
| 43 |