Skip to content

Commit a558576

Browse files
author
Antti Kuosmanen
committed
Add form specific hooks to wplf_form
1 parent ffa5232 commit a558576

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

classes/class-cpt-wplf-form.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,17 @@ function wplf_form( $id, $content = '', $xclass = '', $attributes = [] ) {
500500
global $post;
501501

502502
if ( 'publish' === get_post_status( $id ) || 'true' === $_GET['preview'] ) {
503+
$form = get_post( $id );
503504
if ( empty( $content ) ) {
504505
// you can override the content via parameter
505-
$content = get_post( $id )->post_content;
506+
$content = $form->post_content;
506507
}
507508

509+
// filter content html
510+
$content = apply_filters( 'wplf_form', $content );
511+
$content = apply_filters( "wplf_{$form->post_name}_form", $content );
512+
$content = apply_filters( "wplf_{$form->ID}_form", $content );
513+
508514
ob_start();
509515
?>
510516
<form
@@ -542,7 +548,7 @@ class="libre-form libre-form-<?php echo esc_attr( $id . ' ' . $xclass ); ?>"
542548
<?php
543549
// This is where we output the user-input form html. We allow all HTML here. Yes, even scripts.
544550
// @codingStandardsIgnoreStart
545-
echo apply_filters( 'wplf_form', $content );
551+
echo $content;
546552
// @codingStandardsIgnoreEnd
547553
?>
548554
<input type="hidden" name="referrer" value="<?php the_permalink(); ?>">

0 commit comments

Comments
 (0)