• Resolved wollsale

    (@wollsale)


    Hi,

    I just installed this plugin for wordpress and I’m getting an error :

    I properly install the plugin, register my app for the Linkedin API, get my token key which has been validated.

    I wrote this shortcode in a random page : [li_profile] and when I reload this page, I get this error :

    An exception has been thrown during the rendering of a template (“Undefined variable: atts”)

    For this project, I’m using the Themosis Framework, but it’s not the problem, when I switch with a basic wordpress theme, I get the same issue.

    Any ideas ?

    Thanks in advance,

    W.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Claude Vedovini

    (@cvedovini)

    Hi,

    If you Google that error you will see that is a Symphony error. It’s not related to the plugin.

    Thread Starter wollsale

    (@wollsale)

    Thanks Claude,

    I’m not familiar with php and twig development, I’ve been asked to add this plugin but I can’t understand where this error come from, I’ve installed some plugins and never had this problem before.

    All I understand is that the variable $atts is not defined in plugins/wp-linkedin/wp-linkedin.php :285

    function wp_linkedin_profile($atts='') {
        $atts = wp_linkedin_shortcode_atts(array(
                    'fields' => LINKEDIN_FIELDS,
                    'lang' => LINKEDIN_PROFILELANGUAGE
                // HERE
                ), $atts, 'li_profile');
        extract($atts);
     
        $fields = preg_replace('/\s+/', '', LINKEDIN_FIELDS_BASIC . ',' . $fields);
        $profile = wp_linkedin_get_profile($fields, $lang);
     
        if (is_wp_error($profile)) {
            return wp_linkedin_error($profile);
        } elseif ($profile && is_object($profile)) {
            return wp_linkedin_load_template('profile',
                    array_merge($atts, array('profile' => $profile)));
        }
    }

    but I’m following the instructions on the extension homepage.

    Plugin Author Claude Vedovini

    (@cvedovini)

    that error doesn’t make sense, that variable is defined just above, in the signature of the method

    Thread Starter wollsale

    (@wollsale)

    Yep, it doesn’t make sense, but I’ve change something and now the error actually concerned the function at line 252+ :

    function wp_linkedin_shortcode_atts($pairs, $args, $shortcode) {
      $out = wp_parse_args($args, $pairs);
      if ($shortcode) {
        $out = apply_filters("shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode);
      }
    
      return $out;
    }

    in $out = apply_filters("shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode); the variable $atts wasn’t defined. So I defined it as an empty array and now the code works.

    function wp_linkedin_shortcode_atts($pairs, $args, $shortcode) {
    	$out = wp_parse_args($args, $pairs);
            // edit
    	$atts = array();
    	if ($shortcode) {
    		$out = apply_filters("shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode);
    	}
    
    	return $out;
    }

    Themosis framework, and twig, prevented me from going further.

    • This reply was modified 7 years, 7 months ago by wollsale.
    • This reply was modified 7 years, 7 months ago by wollsale.
    Plugin Author Claude Vedovini

    (@cvedovini)

    I think you found a nice bug, but it’s not what you think ??
    I will release a fix shortly

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can’t render from shortcode [li_profile]’ is closed to new replies.