• Hello,

    I’m currently developing a WP theme using this plugin and I’ve found some warnings using the “debug mode” that can be easily fixable:

    line 646 (simple-share-buttons-adder.php)

    // if custom attributes have been set
    	 if ($atts['url'] != '') {

    Here we should first check if that index is set in order not to have a warning:

    // if custom attributes have been set
    	if (isset($atts['url']) && $atts['url'] != '') {

    And also… What if we’re developing in local and the file_get_contents function returns an error code? For instance, this URL:
    http://graph.facebook.com/http://localhost

    How to fix it:

    line 869 (simple-share-buttons-adder.php)

    // get results from facebook and return the number of shares
        $htmlFacebookShareDetails = file_get_contents('http://graph.facebook.com/' . $urlCurrentPage);

    Check there is no problem with that and suppress warnings. The whole function:

    // get facebook share count
    function getFacebookShareCount($urlCurrentPage) {
    
    	// get results from facebook and return the number of shares
        $htmlFacebookShareDetails = @file_get_contents('http://graph.facebook.com/' . $urlCurrentPage);
    	if (! $htmlFacebookShareDetails)
    	{
    		$arrFacebookShareDetails = json_decode($htmlFacebookShareDetails, true);
    		$intFacebookShareCount =  $arrFacebookShareDetails['shares'];
    		return ($intFacebookShareCount ) ? $intFacebookShareCount : '0';
    	}
    	else
    		return '0';
    }

    If you think I’m fixing the warnings wrongly, just let me know. Otherwise, I’d be glad if you could add these fixes to the next update of the plugin. Thanks a lot!

    http://wordpress.org/plugins/simple-share-buttons-adder/

  • The topic ‘Fixing warnings’ is closed to new replies.