-
-
Save vanbernaert/e9ac6ddaa13de40dde6c to your computer and use it in GitHub Desktop.
Revisions
-
richardW8k revised this gist
Jan 28, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,5 +21,5 @@ function input_to_button( $button, $form ) { $new_button->setAttribute( $attribute->name, $attribute->value ); } $input->parentNode->replaceChild( $new_button, $input ); return $dom->saveHtml( $new_button ); } -
richardvav renamed this gist
Jan 12, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php /** * Filters the next, previous and submit buttons. * Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>. -
richardvav revised this gist
Jan 12, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ * Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>. * @param string $button Contains the <input> tag to be filtered. * @param object $form Contains all the properties of the current form. * @return string The filtered button. */ add_filter( 'gform_next_button', 'input_to_button', 10, 2 ); add_filter( 'gform_previous_button', 'input_to_button', 10, 2 ); -
richardvav revised this gist
Jan 11, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ /** * Filters the next, previous and submit buttons. * Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>. * @param string $button Contains the <input> tag to be filtered. * @param object $form Contains all the properties of the current form. * @return string The filtered submit button. -
richardvav revised this gist
Jan 11, 2014 . 1 changed file with 5 additions and 38 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,46 +1,13 @@ /** * Filters the next, previous and submit buttons. * @param string $button Contains the <input> tag to be filtered. * @param object $form Contains all the properties of the current form. * @return string The filtered submit button. */ add_filter( 'gform_next_button', 'input_to_button', 10, 2 ); add_filter( 'gform_previous_button', 'input_to_button', 10, 2 ); add_filter( 'gform_submit_button', 'input_to_button', 10, 2 ); function input_to_button( $button, $form ) { $dom = new DOMDocument(); $dom->loadHTML( $button ); $input = $dom->getElementsByTagName( 'input' )->item(0); -
richardvav created this gist
Jan 11, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ /** * Filters the next button. * @see input_to_button() * @param string $next_button Contains the <input> tag to be filtered. * @param object $form Contains all the properties of the current form. * @return string The filtered next button. */ add_filter( 'gform_next_button', 'next_input_to_button', 10, 2 ); function next_input_to_button( $next_button, $form ) { GFCommon::log_debug( "next_input_to_button(): {$next_button}" ); return input_to_button( $button = $next_button ); } /** * Filters the previous button. * @see input_to_button() * @param string $previous_button Contains the <input> tag to be filtered. * @param object $form Contains all the properties of the current form. * @return string The filtered previous button. */ add_filter( 'gform_previous_button', 'previous_input_to_button', 5, 2 ); function previous_input_to_button( $previous_button, $form ) { return input_to_button( $button = $previous_button ); } /** * Filters the submit button. * @see input_to_button() * @param string $button Contains the <input> tag to be filtered. * @param object $form Contains all the properties of the current form. * @return string The filtered submit button. */ add_filter( 'gform_submit_button', 'submit_input_to_button', 10, 2 ); function submit_input_to_button( $button, $form ) { return input_to_button( $button ); } /** * Replaces the forms <input> buttons with <button> while maintaining attributes from original <input>. * @param string $button Contains the <input> tag to be filtered. * @return string The filtered button. */ function input_to_button( $button ) { $dom = new DOMDocument(); $dom->loadHTML( $button ); $input = $dom->getElementsByTagName( 'input' )->item(0); $new_button = $dom->createElement( 'button' ); $button_span = $dom->createElement( 'span', $input->getAttribute( 'value' ) ); $new_button->appendChild( $button_span ); $input->removeAttribute( 'value' ); foreach( $input->attributes as $attribute ) { $new_button->setAttribute( $attribute->name, $attribute->value ); } $input->parentNode->replaceChild( $new_button, $input ); return $dom->saveHtml($new_button); }