Last active
January 25, 2018 09:09
-
-
Save rogerlos/50446162dac60907e4c638a1d44b7e1a to your computer and use it in GitHub Desktop.
Proof of GF errors in form widget
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
<?php | |
/* | |
* You need to run this within a WP environment, with Gravity Forms installed, for the called functions to register. | |
*/ | |
// make sure you have PHP error reporting on | |
error_reporting( E_ALL ); | |
// wordpress widget args array; these are always sent by WP | |
$args = array( | |
'before_widget' => '', | |
'after_widget' => '', | |
'before_title' => '', | |
'after_title' => '', | |
); | |
/* | |
* This mimics $instance sent when only a form is chosen when using the form widget. You can prove this: | |
* | |
* var_dump( $instance ); die(); | |
* | |
* within the actual widget.php 'widget' method and look at the values on screen. | |
*/ | |
$instance = array( | |
'title' => '', | |
'form_id' => '1', | |
'tabindex' => '1', | |
); | |
proof_of_error_widget( $args, $instance ); | |
/* | |
* Lifted straight from gravity forms, changed the function name, eliminated comments and some whitespace, | |
* added comments showing error locations | |
*/ | |
function proof_of_error_widget( $args, $instance ) { | |
extract( $args ); | |
echo $before_widget; | |
$title = apply_filters( 'widget_title', $instance['title'] ); | |
if ( $title ) { | |
echo $before_title . $title . $after_title; | |
} | |
$tabindex = is_numeric( $instance['tabindex'] ) ? $instance['tabindex'] : 1; | |
$form = RGFormsModel::get_form_meta( $instance['form_id'] ); | |
if ( empty( $instance['disable_scripts'] ) && ! is_admin() ) { | |
RGForms::print_form_scripts( $form, $instance['ajax'] ); | |
// Not set ........................ ^^^^^^^^^^^^^^^^^ | |
} | |
$form_markup = RGForms::get_form( | |
$instance['form_id'], | |
$instance['showtitle'], // Not set | |
$instance['showdescription'], // Not set | |
false, | |
null, | |
$instance['ajax'], // Not set | |
$tabindex | |
); | |
echo $form_markup; | |
echo $after_widget; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment