A WordPress plugin that seamlessly integrates Vue.js applications into WordPress sites.
This plugin allows you to embed Vue.js applications within WordPress pages and posts using a simple shortcode. It handles all the necessary script loading and provides a clean integration between WordPress and Vue.js.
- Simple shortcode integration
- Automatic script and style loading
- Environment variable support
- Customizable container element
- WordPress hooks for extending functionality
- Upload the plugin files to the
/wp-content/plugins/wp-vue-wrapper
directory, or install the plugin through the WordPress plugins screen. - Activate the plugin through the 'Plugins' screen in WordPress.
- Use the shortcode
[vue-wp-app]
in your posts or pages to embed the Vue application.
Simply add the shortcode to any post or page:
You can customize the container element and pass additional attributes: [vue-app id="custom-app-id" class="custom-class"]
The plugin uses environment variables for configuration. Create a .env
file in the plugin root directory with your settings:
The plugin includes a command-line tool for easy customization of the plugin name and prefixes. This tool allows you to quickly rename the plugin and update all function names, constants, and text domains to match your branding.
From the plugin directory, run:
./wpvue init "Your Plugin Name"
For example:
./wpvue init "Customer Portal"
The tool will:
-
Generate appropriate prefixes based on your plugin name:
- Function prefix (e.g.,
customer_portal_
) - Text domain (e.g.,
customer_portal
) - Constants prefix (e.g.,
CUSTOMER_PORTAL_
) - App constants prefix (e.g.,
CUSTOMER_PORTAL_APP_
) - REST API prefix (e.g.,
customer-portal
) - Script handle prefix (e.g.,
customer-portal-
) - JavaScript global variable (e.g.,
customerPortalSettings
)
- Function prefix (e.g.,
-
Replace all occurrences of the default prefixes:
- Default function prefix:
vue_wp_app_
- Default text domain:
wp-vue-wrapper
- Default constants prefix:
VUE_WP_APP_
- Default app constants prefix:
VUE_APP_
- Default REST API prefix:
vue-wp-app
- Default script handle prefix:
vue-wp-
- Default JavaScript global:
vueWpSettings
- Default function prefix:
-
Rename the main plugin file to match your new prefix
Before making any changes, the tool will display a summary of all replacements and ask for confirmation. This gives you a chance to review the changes before they are applied.
- Node.js and npm
- WordPress development environment
- Clone this repository to your WordPress plugins directory
- Run
npm install
to install dependencies - Run
npm run dev
for development mode with hot-reload - Run
npm run build
to build for production
wp-vue-wrapper.php
- Main plugin file with WordPress integrationsrc/
- Vue.js application source filesdist/
- Compiled Vue.js application (generated after build).env
- Environment configuration
The plugin provides several WordPress filters and actions for extending functionality:
wp_vue_wrapper_shortcode_atts
- Filter shortcode attributeswp_vue_wrapper_container
- Filter the container HTML
Developed by TenGate and as free to use under the GPL v2 or later.