Anda di halaman 1dari 3

www.LetsNurture.

com
WordPress Automatically Install Plugins with Themes
Just add this code in your themes function.php
// Plugin install with theme
function presscore_register_required_plugins() {

/**
* Array of plugin arrays. Required eys are name and slug.
* !f the source is "#$ from the .org repo% then source is also required.
*/

&plugins ' array(
// (ontact )rom *
array(
+name+ ', +(ontact )orm *+%
+slug+ ', +contact-form-*+%
+required+ ', true
)%

// Ad.anced (ustom )ields
array(
+name+ ', +Ad.anced (ustom )ields+%
+slug+ ', +ad.anced-custom-fields+%
+required+ ', true
)
)/

// (hange this to your theme te0t domain% used for internationalising
strings
&theme_te0t_domain ' 1A"23A24_5#"4/

/**
* Array of configuration settings. Amend each line as needed.
* !f you want the default strings to 6e a.aila6le under your own theme
domain%
* lea.e the strings uncommented.
* 7ome of the strings are added into a sprintf% so see the comments at the
* end of each line for what each argument will 6e.
*/
&config ' array(
+domain+ ', &theme_te0t_domain% // $e0t domain - liely want to 6e the
same as your theme.
+default_path+ ', PR477(#R4_P132!"7_8!R% // 8efault a6solute path to pre-
pacaged plugins
+parent_menu_slug+ ', +themes.php+% // 8efault parent menu slug
+parent_url_slug+ ', +themes.php+% // 8efault parent 3R1 slug
For More Information And Solutions like this you can visit our website http://phprocks.letsnurture.com
www.LetsNurture.com
+menu+ ', +install-required-plugins+% // 9enu slug
+has_notices+ ', true% // 7how admin notices or not
+is_automatic+ ', false% // Automatically acti.ate plugins after
installation or not
+message+ ', ++% // 9essage to output right 6efore the plugins ta6le
+strings+ ', array(
+page_title+ ', __( +!nstall Required Plugins+% &theme_te0t_domain )%
+menu_title+ ', __( +!nstall Plugins+% &theme_te0t_domain )%
+installing+ ', __( +!nstalling Plugin: ;s+% &theme_te0t_domain )% // ;<&s
' plugin name
+oops+ ', __( +7omething went wrong with the plugin AP!.+%
&theme_te0t_domain )%
+notice_can_install_required+ ', _n_noop( +$his theme requires the
following plugin: ;<&s.+% +$his theme requires the following plugins:
;<&s.+ )% // ;<&s ' plugin name(s)
+notice_can_install_recommended+ ', _n_noop( +$his theme recommends the
following plugin: ;<&s.+% +$his theme recommends the following plugins:
;<&s.+ )% // ;<&s ' plugin name(s)
+notice_cannot_install+ ', _n_noop( +7orry% 6ut you do not ha.e the
correct permissions to install the ;s plugin. (ontact the administrator of
this site for help on getting the plugin installed.+% +7orry% 6ut you do
not ha.e the correct permissions to install the ;s plugins. (ontact the
administrator of this site for help on getting the plugins installed.+
)% // ;<&s ' plugin name(s)
+notice_can_acti.ate_required+ ', _n_noop( +$he following required plugin
is currently inacti.e: ;<&s.+% +$he following required plugins are
currently inacti.e: ;<&s.+ )% // ;<&s ' plugin name(s)
+notice_can_acti.ate_recommended+ ', _n_noop( +$he following recommended
plugin is currently inacti.e: ;<&s.+% +$he following recommended plugins
are currently inacti.e: ;<&s.+ )% // ;<&s ' plugin name(s)
+notice_cannot_acti.ate+ ', _n_noop( +7orry% 6ut you do not ha.e the
correct permissions to acti.ate the ;s plugin. (ontact the administrator of
this site for help on getting the plugin acti.ated.+% +7orry% 6ut you do
not ha.e the correct permissions to acti.ate the ;s plugins. (ontact the
administrator of this site for help on getting the plugins acti.ated.+
)% // ;<&s ' plugin name(s)
+notice_as_to_update+ ', _n_noop( +$he following plugin needs to 6e
updated to its latest .ersion to ensure ma0imum compati6ility with this
theme: ;<&s.+% +$he following plugins need to 6e updated to their latest
.ersion to ensure ma0imum compati6ility with this theme: ;<&s.+ )% // ;<&s
' plugin name(s)
+notice_cannot_update+ ', _n_noop( +7orry% 6ut you do not ha.e the correct
permissions to update the ;s plugin. (ontact the administrator of this site
for help on getting the plugin updated.+% +7orry% 6ut you do not ha.e the
correct permissions to update the ;s plugins. (ontact the administrator of
this site for help on getting the plugins updated.+ )% // ;<&s ' plugin
name(s)
+install_lin+ ', _n_noop( +=egin installing plugin+% +=egin installing
For More Information And Solutions like this you can visit our website http://phprocks.letsnurture.com
www.LetsNurture.com
plugins+ )%
+acti.ate_lin+ ', _n_noop( +Acti.ate installed plugin+% +Acti.ate
installed plugins+ )%
+return+ ', __( +Return to Required Plugins !nstaller+% &theme_te0t_domain
)%
+plugin_acti.ated+ ', __( +Plugin acti.ated successfully.+%
&theme_te0t_domain )%
+complete+ ', __( +All plugins installed and acti.ated successfully. ;s+%
&theme_te0t_domain )% // ;<&s ' dash6oard lin
+nag_type+ ', +updated+ // 8etermines admin notice type - can only 6e
+updated+ or +error+
)
)/

tgmpa( &plugins% &config )/

>
add_action( +tgmpa_register+% +presscore_register_required_plugins+ )/

require_once( +class-tgm-plugin-acti.ation.php+ )/
Note :Each pluin can take an array
E. !ontact form " and Advanced custom Fields
Add this file in your themes
#ownload Form here class!tgm!plugin!acti"ation.php
https$%%drive.oole.com%file%d%&'(!L)*u+,'-./nhs)0hLME1&23k%edit4usp5sharin
For More Information And Solutions like this you can visit our website http://phprocks.letsnurture.com

Anda mungkin juga menyukai