生命不息,奋斗不止/创造价值-传递价值-获得价值
所谓迷茫,就是才华配不上梦想 每一个让你难堪的现在,都有一个不够努力的曾经

主题整合 WPBakery Page Builder

If you are theme author you may want to integrate WPBakery Page Builder (formerly Visual Composer) right into your WordPress theme.

Separate “In Stock” license is required for each of your themes that are for sale. You can read more about getting the “In Stock” license here.

To meet new theme submission requirements follow this steps:

  1. Include TGM Activation class into your theme PHP files (ex. in functions.php file)
  2. Add settings for TGM Activation class and hook them to the tgmpa_register action
  3. Call vc_set_as_theme() function to initialize WPBakery Page Builder as a part of your theme
  1. <?php
  2. /**
  3. * Include the TGM_Plugin_Activation class.
  4. */
  5. require_oncedirname(__FILE__) . ‘/class-tgm-plugin-activation.php’;
  6. add_action(‘tgmpa_register’, ‘my_theme_register_js_composer_plugins’);
  7. /**
  8. * Register the required plugins for this theme.
  9. *
  10. * The variable passed to tgmpa_register_plugins() should be an array of plugin
  11. * arrays.
  12. *
  13. * This function is hooked into tgmpa_init, which is fired within the
  14. * TGM_Plugin_Activation class constructor.
  15. */
  16. functionmy_theme_register_js_composer_plugins(){
  17. /**
  18. * Array of plugin arrays. Required keys are name and slug.
  19. * If the source is NOT from the .org repo, then source is also required.
  20. */
  21. $plugins=array(
  22. // This is an example of how to include a plugin pre-packaged with a theme
  23. array(
  24. ‘name’=>‘WPBakery Visual Composer’, // The plugin name
  25. ‘slug’=>‘js_composer’, // The plugin slug (typically the folder name)
  26. ‘source’=>get_stylesheet_directory() . ‘/js_composer.zip’, // The plugin source
  27. ‘required’=>true, // If false, the plugin is only ‘recommended’ instead of required
  28. ‘version’=>‘3.7’, // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented
  29. ‘force_activation’=>false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  30. ‘force_deactivation’=>false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  31. ‘external_url’=>, // If set, overrides default API URL and points to an external URL
  32. )
  33. );
  34. // Change this to your theme text domain, used for internationalising strings
  35. $theme_text_domain=‘tgmpa’;
  36. /**
  37. * Array of configuration settings. Amend each line as needed.
  38. * If you want the default strings to be available under your own theme domain,
  39. * leave the strings uncommented.
  40. * Some of the strings are added into a sprintf, so see the comments at the
  41. * end of each line for what each argument will be.
  42. */
  43. $config=array(
  44. ‘domain’=>$theme_text_domain, // Text domain – likely want to be the same as your theme.
  45. ‘default_path’=>, // Default absolute path to pre-packaged plugins
  46. ‘parent_menu_slug’=>‘themes.php’, // Default parent menu slug
  47. ‘parent_url_slug’=>‘themes.php’, // Default parent URL slug
  48. ‘menu’=>‘install-required-plugins’, // Menu slug
  49. ‘has_notices’=>true, // Show admin notices or not
  50. ‘is_automatic’=>false, // Automatically activate plugins after installation or not
  51. ‘message’=>, // Message to output right before the plugins table
  52. ‘strings’=>array(
  53. ‘page_title’=>__(‘Install Required Plugins’, $theme_text_domain),
  54. ‘menu_title’=>__(‘Install Plugins’, $theme_text_domain),
  55. ‘installing’=>__(‘Installing Plugin: %s’, $theme_text_domain), // %1$s = plugin name
  56. ‘oops’=>__(‘Something went wrong with the plugin API.’, $theme_text_domain),
  57. ‘notice_can_install_required’=>_n_noop(‘This theme requires the following plugin: %1$s.’, ‘This theme requires the following plugins: %1$s.’), // %1$s = plugin name(s)
  58. ‘notice_can_install_recommended’=>_n_noop(‘This theme recommends the following plugin: %1$s.’, ‘This theme recommends the following plugins: %1$s.’), // %1$s = plugin name(s)
  59. ‘notice_cannot_install’=>_n_noop(‘Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.’, ‘Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.’), // %1$s = plugin name(s)
  60. ‘notice_can_activate_required’=>_n_noop(‘The following required plugin is currently inactive: %1$s.’, ‘The following required plugins are currently inactive: %1$s.’), // %1$s = plugin name(s)
  61. ‘notice_can_activate_recommended’=>_n_noop(‘The following recommended plugin is currently inactive: %1$s.’, ‘The following recommended plugins are currently inactive: %1$s.’), // %1$s = plugin name(s)
  62. ‘notice_cannot_activate’=>_n_noop(‘Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.’, ‘Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.’), // %1$s = plugin name(s)
  63. ‘notice_ask_to_update’=>_n_noop(‘The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.’, ‘The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.’), // %1$s = plugin name(s)
  64. ‘notice_cannot_update’=>_n_noop(‘Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.’, ‘Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.’), // %1$s = plugin name(s)
  65. ‘install_link’=>_n_noop(‘Begin installing plugin’, ‘Begin installing plugins’),
  66. ‘activate_link’=>_n_noop(‘Activate installed plugin’, ‘Activate installed plugins’),
  67. ‘return’=>__(‘Return to Required Plugins Installer’, $theme_text_domain),
  68. ‘plugin_activated’=>__(‘Plugin activated successfully.’, $theme_text_domain),
  69. ‘complete’=>__(‘All plugins installed and activated successfully. %s’, $theme_text_domain), // %1$s = dashboard link
  70. ‘nag_type’=>‘updated’ // Determines admin notice type – can only be ‘updated’ or ‘error’
  71. )
  72. );
  73. tgmpa($plugins, $config);
  74. }
  75. /**
  76. * Force Visual Composer to initialize as “built into the theme”. This will hide certain tabs under the Settings->Visual Composer page
  77. */
  78. add_action(‘vc_before_init’, ‘your_prefix_vcSetAsTheme’);
  79. functionyour_prefix_vcSetAsTheme(){
  80. vc_set_as_theme();
  81. }
  82. ?>

 

That’s it! You can check results in Pages->Add new, if you completed all steps correctly, you should see blue WPBakery Page Builder button there now.

赞(0)
未经允许不得转载:jack361博客 » 主题整合 WPBakery Page Builder

如果你爱我或恨我,请↓

联系我