<div dir="ltr">Yes, TGM is great and all, but it's a bit heavy. Rolling your own isn't very hard to do.<div><br></div><div>I'll use the Slides theme I made as an example. It has no config screen, using just the Customizer for the options. One of those customizer sections I called "Plugins".</div>
<div><br></div><div>Slides supports the Simple Page Ordering plugin as an option. This works well with this theme in particular for various reasons. So, to prompt the user to install it, I made a special customizer control with a link to install the plugin. Here's the code for that control:</div>
<div><br></div><div>(Note: The theme is unfinished, in the extreme, so it lacks may things like correct I18N support and such at present, this is just an example bit of code to demonstrate the point.)</div><div><br></div>
<div><br></div><div><div>if (class_exists('WP_Customize_Control')) {</div><div><span class="" style="white-space:pre"> </span>class Slides_Customize_PluginCheck_Control extends WP_Customize_Control {</div><div><span class="" style="white-space:pre"> </span>public $type = 'none';</div>
<div><br></div><div><span class="" style="white-space:pre"> </span>public function render_content() {</div><div><span class="" style="white-space:pre"> </span>if ( ! class_exists( 'Simple_Page_Ordering' ) ) {</div>
<div><span class="" style="white-space:pre"> </span>?></div><div><p>The Slides theme has special functionality to support use of the <a href="<a href="http://wordpress.org/plugins/simple-page-ordering/">http://wordpress.org/plugins/simple-page-ordering/</a>">Simple Page Ordering</a> plugin. You can install this plugin to get support for drag/drop of your posts/slides and thus allow reordering of them to be done easily.</p></div>
<div><span class="" style="white-space:pre"> </span><?php</div><div><span class="" style="white-space:pre"> </span>$plugins = get_plugins();</div><div><span class="" style="white-space:pre"> </span>$uris = wp_list_pluck($plugins, 'PluginURI');</div>
<div><br></div><div><span class="" style="white-space:pre"> </span>if ( ( $plugin_file = array_search('<a href="http://10up.com/plugins/simple-page-ordering-wordpress/">http://10up.com/plugins/simple-page-ordering-wordpress/</a>', $uris) ) !== false ) {</div>
<div><span class="" style="white-space:pre"> </span>// plugin installed, but not active</div><div><span class="" style="white-space:pre"> </span>?></div><div><p>Plugin already installed, but not activated. <a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin_file), 'activate-plugin_'.$plugin_file); ?>">Click here to activate the Simple Page Ordering plugin</a></p></div>
<div><span class="" style="white-space:pre"> </span><?php</div><div><span class="" style="white-space:pre"> </span>} else {</div><div><span class="" style="white-space:pre"> </span>// plugin not installed</div>
<div><span class="" style="white-space:pre"> </span>require_once ABSPATH . 'wp-admin/includes/plugin-install.php';</div><div><span class="" style="white-space:pre"> </span>$info = plugins_api('plugin_information', array('slug' => 'simple-page-ordering' ));</div>
<div><span class="" style="white-space:pre"> </span>if ( is_wp_error( $info ) ) {</div><div><span class="" style="white-space:pre"> </span>// TODO</div><div><span class="" style="white-space:pre"> </span>}</div>
<div><span class="" style="white-space:pre"> </span>?></div><div><p>Plugin not installed. <a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=simple-page-ordering'), 'install-plugin_simple-page-ordering');<span class="" style="white-space:pre"> </span>?>">Click here to install the Simple Page Ordering plugin</a></p></div>
<div><span class="" style="white-space:pre"> </span><?php</div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span>} else {</div><div><span class="" style="white-space:pre"> </span>echo '<p>'.__('Simple Page Ordering plugin installed and active!','slides') .'</p>';</div>
<div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span>}</div><div>}</div><div><br></div><div><br></div>
<div><br></div><div>Bit big, but follow it through. </div><div><br></div><div>First, the code checks to see if the plugin is already installed and activated by simply checking for the class_exists. Easy.</div><div><br></div>
<div>Next, if the class isn't there, it checks for the plugin by calling get_plugins and looking for the specific Plugin URI for that plugin. That part of the code is heavy, but this only shows up on the Customizer screen, so it's only infrequently done. Not a big deal. This is so if the plugin is installed but not active, then an activation link is built and displayed to the user. Clicking the link activates the already-installed plugin.</div>
<div><br></div><div>Finally, if the plugin is not installed, an installation link is built. Same deal, one-click to install the pugin.</div><div><br></div><div>Now, this is a simplistic example. I'm just using basic a href links here. You could use buttons, or style it differently to fit with your theme's own configuration. Whatever, the point being that a) detecting a plugin is pretty easy and b) building activate and install links for a one-click approach is also easy. Making the theme detect plugins and change behavior accordingly isn't at all hard to do. Making it easy for the user to install the plugin separately and then for the theme to take advantage of that can be any sort of user-experience you want.</div>
<div><br></div><div>Having a plugin built into the theme, and then have to deactivate it in order to re-install it and upgrade it and so on, well, that's only a "better" experience from the point of view of the initial usage. It doesn't consider maintenance, or additional learning curve for other developers who have no experience with your theme previously, or site maintainers who do know about plugins and themes but don't know that your theme is doing something strange with one of them. </div>
<div><br></div><div>Best to keep that separation solid, but do the integration in a non-threatening and user-friendly way. Give the user a one-click experience. It's not difficult to do.</div><div><br></div><div class="gmail_extra">
<br clear="all"><div>-Otto</div>
<br><br><div class="gmail_quote">On Wed, Nov 13, 2013 at 6:25 PM, Mario Peshev <span dir="ltr"><<a href="mailto:mario@peshev.net" target="_blank">mario@peshev.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">In addition to the TGM recommendation, Otto's <a href="http://ottopress.com/2012/themeplugin-dependencies/" target="_blank">http://ottopress.com/2012/themeplugin-dependencies/</a></div><div class="gmail_extra">
<span class=""><font color="#888888"><br clear="all">
<div><br>Mario Peshev<br>WordPress Engineer, Open Source Consultant<br><a href="http://www.linkedin.com/in/mpeshev" target="_blank">http://www.linkedin.com/in/mpeshev</a><br><div><a href="http://me.peshev.net/" target="_blank">http://me.peshev.net</a></div>
<div><br></div></div></font></span><div><div class="h5">
<br><br><div class="gmail_quote">On Thu, Nov 14, 2013 at 2:24 AM, WordPress (thinkupthemes) <span dir="ltr"><<a href="mailto:wordpress@thinkupthemes.com" target="_blank">wordpress@thinkupthemes.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Why are you including the plugin in your theme? Why not just use TGM to recommend it as an install after the theme is activated?<br>
<br>
Afzaal<br>
<br></blockquote></div></div></div></div></blockquote></div></div></div></div>