Can I use GPL plugin code inside my theme

Hi, I’m making a theme, and wanted to add few widgets, and found that there are already some plugins on github with the exact code I need, for example instagram plugin

the way I’m including this in my theme is by just copying the code from php file and adding it to a separate file that I’ll call it from functions.php (the whole code with name of writer and everything)

my question is do I have the right to include it this way in my theme?

Yes, you could use it but remember to include the credits on your item page or on the documentation.
In some cases, you may need to ask permission from the author, you can check the code details if it’s needed

Awesome thanks, it’s not mentioned anywhere I need to ask for permission, just license GPLv2, but I send emails anyway to make sure.
So basically I have to mention any code used that is not mine in the item page? even if it’s under MIT license or other licenses and even if it’s not a plugin, but a separate code, like sliders …etc?