• Resolved momadvisorblog

    (@momadvisorblog)


    Hi Shea!

    Ipm getting this error on front end, can you please help? I don´t know what it means or how to solve it.

    Notice: Undefined variable: social in /home/momadvi5/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(355) : eval()’d code on line 14

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    This is an error in the code of one of your snippets. I can’t tell you which one specifically, but it will have $social somewhere on line 14.

    If you identify which snippet it is and share the code here, I would be happy to try and see how it can be fixed.

    Hi Shea thank you for this amazing plugin.

    The code below returns this error

    Cannot redeclare enable_list_input_mask() (previously declared in F:\Bitnami\wordpress-4.9.8-1\apps\wordpress\htdocs\wp-content\plugins\code-snippets\php\snippet-ops.php(361) : eval()’d code:3)

    What does this error mean?…

    Code:
    // enable input mask for form #44 list field #40 columns 1
    add_filter(‘gform_register_init_scripts_44’, ‘enable_list_input_mask’);
    function enable_list_input_mask($form) {
    $field_id = “40”; //set field id here
    $col_id = array(‘1’); //set column id here
    $mask = “99-9999”; //define mask here, examples at http://www.gravityhelp.com/documentation/page/Input_Mask
    //that’s it nothing more to configure

    $c_sel = array();
    foreach($col_id as $c) {
    $c_sel[] = “.gfield_list_{$field_id}_cell{$c} input”;
    }
    $c_sels = json_encode($c_sel);
    $im_script = “jQuery(sel.join()).mask(‘{$mask}’);”;
    $script = “var sel = {$c_sels}; {$im_script} jQuery(‘#field_{$form[“id”]}_{$field_id}’).on(‘click’, ‘.add_list_item’, function(){{$im_script}});”;
    GFFormDisplay::add_init_script($form[‘id’], ‘list_input_mask’, GFFormDisplay::ON_PAGE_RENDER, $script);
    return $form;
    }
    add_action( ‘gform_enqueue_scripts_44’, ‘list_masked_input_script’, 10, 2 );
    function list_masked_input_script( $form ) {
    wp_enqueue_script( ‘gform_masked_input’, array( ‘jquery’ ), false, true );
    }

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @eaacaadmin,

    It’s difficult to pinpoint the cause of these issues without checking what sort of other code is running on the site, but a simple fix is to not use named functions.

    Here’s an example of your code using anonymous functions:

    // enable input mask for form #44 list field #40 columns 1
    add_filter( 'gform_register_init_scripts_44', function ( $form ) {
    	$field_id = "40"; //set field id here
    	$col_id = array( '1' ); //set column id here
    	$mask = "99 - 9999"; //define mask here, examples at http://www.gravityhelp.com/documentation/page/Input_Mask
    //that's it nothing more to configure
    
    	$c_sel = array();
    	foreach ( $col_id as $c ) {
    		$c_sel[] = " . gfield_list_{
    		$field_id}_cell{
    		$c} input";
    	}
    	$c_sels = json_encode( $c_sel );
    	$im_script = "jQuery( sel . join() ) . mask( '{$mask}');";
    	$script = "var sel = {
    		$c_sels}; {
    		$im_script} jQuery( '#field_{$form["id"]}_{$field_id}').on('click', '.add_list_item', function(){{$im_script}});";
    	GFFormDisplay::add_init_script( $form['id'], 'list_input_mask', GFFormDisplay::ON_PAGE_RENDER, $script );
    	return $form;
    } );
    
    add_action( 'gform_enqueue_scripts_44', function ( $form ) {
    	wp_enqueue_script( 'gform_masked_input', array( 'jquery' ), false, true );
    }, 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘snippet-ops.php(355) : eval()’d code on line 14’ is closed to new replies.