0

I am newby on php. I re-write a code to add a custom class, but always got an error.

Parse error: syntax error, unexpected T_STRING in D:\MYWEB\InstantWP_4.3.1\iwpserver\htdocs\wordpress\wp-content\plugins\js_composer\include\templates\shortcodes\vc_column.php on line 41

My code is like this:

 if (vc_shortcode_custom_css_has_property( $css, array('border', 'background') )) {
$css_classes[]='vc_col-has-fill'; 
 }

  $wrapper_attributes = array();

 $css_class = preg_replace( '/\s+/', ' ', apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, implode( ' ', array_filter( $css_classes ) ), $this->settings['base'], $atts ) );
 $wrapper_attributes[] = 'class="' . esc_attr( trim( $css_class ) ) . '"';

 $output .= '<div ' . implode( ' ', $wrapper_attributes ) esc_attr( trim( vc_shortcode_custom_css_class( $css ) ) ). '>';
 $output .= '<div class="vc_column-inner">';
 $output .= '<div class="wpb_wrapper">';
 $output .= wpb_js_remove_wpautop( $content );
 $output .= '</div>';
 $output .= '</div>';
 $output .= '</div>';

 echo $output;

Line 41 is like this:

 $output .= '<div ' . implode( ' ', $wrapper_attributes ) esc_attr( trim( vc_shortcode_custom_css_class( $css ) ) ). '>';

Really appreciate for any help

Thank you

Mailmulah
  • 63
  • 2
  • 9
  • You're missing a period on that line, before "esc_attr": `$wrapper_attributes ) . esc_attr( `. It might be helpful to grab an IDE that will highlight the source of syntax errors, if you're not using one already. – Andy Hoffner Mar 17 '16 at 21:38
  • You might want to write this as a seperate plugin. Update VC and your code is gone, isn't it? – kero Mar 17 '16 at 21:52
  • I want to change the custom class from second level (near inner-class) to first level. – Mailmulah Mar 17 '16 at 21:58
  • Added periode as you said, error is dissappear, but new class trow outside the div.

    it should be like this:
    – Mailmulah Mar 17 '16 at 22:01

2 Answers2

1

I think you forgot "." between implode(...) and esc_attr(...) on line 41.

Line 41, should be:

$output .= '<div ' . implode( ' ', $wrapper_attributes ) . esc_attr( trim( vc_shortcode_custom_css_class( $css ) ) ). '>';
Mentos1386
  • 308
  • 4
  • 9
0

You havent declared $output before you expand the variable.

Replace it with this:

 $output = '<div ' . implode( ' ', $wrapper_attributes ) esc_attr( trim( vc_shortcode_custom_css_class( $css ) ) ). '>';

or add it like this

$output = '';
$output .= '<div ' . implode( ' ', $wrapper_attributes ) esc_attr( trim( vc_shortcode_custom_css_class( $css ) ) ). '>';

Good luck :) (We've all been there)

25r43q
  • 613
  • 4
  • 16
  • Unfortunatelly, same error like before. – Mailmulah Mar 17 '16 at 21:56
  • Mentos spotted another error. Remove the dot in " .= " on line 41 and add it before esc_attr. Unfortunately you have issues in how you build the css classes as well. But adding the dot before esc_attr and removing the . in .= on L41 will solve some of the issues. Try echoing implode( ' ', $wrapper_attributes ) as well as esc_attr( trim( vc_shortcode_custom_css_class( $css ) ) ) to see where the fault is – 25r43q Mar 17 '16 at 22:05
  • error is dissappear, but new class throw outside the div.

    it should be like this:
    – Mailmulah Mar 17 '16 at 22:24
  • Great idea. I am using your idea and work perfect. Thanks.! – Mailmulah Mar 18 '16 at 01:42