TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.76k stars 429 forks source link

Include third party-premium plugins in the download and install via TGM PA as pre-packaged #673

Closed pareshsojitra closed 7 years ago

pareshsojitra commented 7 years ago

Hi,

Themeforest says include third party-premium plugins in the download and install via TGM PA as pre-packaged.

I have already set zip packages in theme & here is my code.

tgm code.txt screen shot 2017-06-27 at 18 52 56

widoz commented 7 years ago

I've a similar problem but I've not set 'external_url' at all, but the source_type is 'repo' instead of 'bundled'.

I think the problem is because tgmpa work for plugins that are in repo, the index 'source' of the plugin, by default is set to 'repo', when you and me use the 'source' as plugin url.

These are the default arguments used when a plugin is registered within the tgmpa

'name'               => '',      // String
'slug'               => '',      // String
'source'             => 'repo',  // String
'required'           => false,   // Boolean
'version'            => '',      // String
'force_activation'   => false,   // Boolean
'force_deactivation' => false,   // Boolean
'external_url'       => '',      // String
'is_callable'        => '',      // String|Array.

The source index is used to define the type of the plugin: repo, bundled, external. I think the source_type is the correct one to use to define the type of the source instead of the source index that can be used for plugin zip url.

I'm don't know the lib in deep, just made some test and if I change some line of code to switch from source to source_type the Source column show the right text.

pareshsojitra commented 7 years ago
widoz commented 7 years ago

I think it's better to wait for a lib developer because the differences between 'source_type' and 'source' are not quite clear.

By the way, here the diff file. diff.txt

jrfnl commented 7 years ago

Hi @smpdesignmedia,

I haven't tested with your code yet, but would like to ask you to try this: remove the esc_url from around the source and change get_template_directory_uri() to get_stylesheet_directory(). When you want to use a bundled plugin, you should provide TGMPA with the path to the plugin, not the URI. The escaping is also not necessary as TGMPA will escape any variables used for output in the appropriate way when they are echo-ed out.

That should solve your issue.

As a side-note: The external_url has nothing to do with whether a plugin is seen as internal or external, it just provides the link for when a user clicks on the plugin name to read more information about the plugin.

For more details about the configuration, have a look here: http://tgmpluginactivation.com/configuration/

@widoz Please don't change the keys in the array. You will break things ;-)

pareshsojitra commented 7 years ago

Hi,

Thank you so much for your answer, i have try this & its getting a source type as "Pre-Packaged", but there is one issue with it.

Its finding plugin in child theme because i have activated child theme, so i need to do to get plugin by main theme ? can you suggest me.

Thank you.

pareshsojitra commented 7 years ago

Hi,

I have used "get_template_directory()" without esc_url() & its resolved my issue.

Thank you so much for your suggestion.

jrfnl commented 7 years ago

@smpdesignmedia Glad to hear it worked! Thanks for letting us know.