2017 © Pedro Peláez
 

wordpress-plugin wp-vc-template-manager

Easily add version-controlled templates to your Visual Composer project

image

khromov/wp-vc-template-manager

Easily add version-controlled templates to your Visual Composer project

  • Sunday, February 8, 2015
  • by khromov
  • Repository
  • 4 Watchers
  • 17 Stars
  • 377 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Visual Composer Template Manager

This plugin provides a framework for creating themes and plugins that utilize the built-in template function in Visual Composer (as of version 4.4), (*1)

It works by loading templates from files in your theme (and optionally plugin) folders, making it possible to version control templates in a simple way., (*2)

Building templates

Building a template is easy. Start out by creating a layout in Visual Composer. (For example, by creating a new page with the layout you want.), (*3)

When you are done, click the "Classic mode" button to return to the TinyMCE WYSISYG, and then click on the Text tab. Now you can copy the content of your layout into a template!, (*4)

Workflow:
Visual workflow of text above, (*5)

Using in a theme

To bundle templates with your theme, create the folder:, (*6)

/your-theme/vc_templates

Then, create a file, for example:, (*7)

/your-theme/vc_templates/my-template.php

The only requirement is that the file has a .php extension., (*8)

Paste the template you got from the "Building templates" section above, and you will see a new template called "My Template" after you click on Templates > Default Templates in Visual Composer. You're done!, (*9)

Workflow:
Visual explanation of text above, (*10)

Using in a plugin

If you want to use this in a plugin, use the vctm_template_locations filter to add a custom path in which templates will be searched., (*11)

If your plugin directory is:, (*12)

/my-plugin/

Create the folder vc_templates/, (*13)

/my-plugin/vc_templates

Add the following code to your main plugin file:, (*14)

add_filter('vctm_template_locations', function($locations)
{
    //Add custom plugin path location
    $locations[] = plugin_dir_path( __FILE__ ) . 'my_templates/';

    //Return
    return $locations;
});

Forking the base plugin

You can fork this plugin by simply changing the folder name and removing the row starting with "GitHub Theme URI" from the plugin header., (*15)

You can then add your templates in the vc_templates/ folder of the plugin., (*16)

The hook prefix can be modified by changing the $VCTM_PREFIX variable in the main plugin file., (*17)

The translation textdomain can be changed with the vctm_textdomain filter:, (*18)

add_filter('vctm_textdomain', function($textdomain)
{
    return 'my_custom_textdomain';
});

Removing default templates

Visual Composer ships with a lot of default templates. If you wish to remove these and only keep the ones you add with this plugin, add the following code in your themes functions.php file, or a plugin:, (*19)

add_action('vctm_disable_builtin_templates', '__return_true');

Known issues

Due to a bug in Visual Composer (as of 4.4.1), it is not possible to reorder the templates. They will always be ordered in alphabetical order. We hope to solve this with future versions of VC., (*20)

Hooks

This plugin exposes hooks to control almost anything., (*21)

vctm_disable_builtin_templates

Lets you disable VC:s own built-in templates, (*22)

Parameters: $current_value - Boolean
Return value: Boolean, (*23)

vctm_template_locations

Lets you register custom template locations for use in plugins and themes., (*24)

Parameters: $locations - Array of current paths which will be looked in for templates
Return value: Array of current locations (Append your location to existing array), (*25)

vctm_<TEMPLATE_SOURCE>_name_<TEMPLATE_NAME>

Lets you change the name that is displayed in VC for a given template, (*26)

Dynamic value: TEMPLATE_SOURCE - The source of the template. "theme" if it came from the theme, "vctm" if it came from the VCTM plugin and "plugin" if it came from a third party plugin using the vctm_template_locations hook. (Don't register multiple paths where template names can collide - you won't be able to filter them.)
Dynamic value: TEMPLATE_NAME - The name of the template, without extension. Example: my_template
Parameters: $current_name - The auto-generated name
Return value: String - new name, (*27)

vctm_<TEMPLATE_SOURCE>_class_<TEMPLATE_NAME>

Lets you change the HTML class which wraps the plugin in the VC modal. Lets you set the template icon through CSS., (*28)

Dynamic value: TEMPLATE_SOURCE - The source of the template. "theme" if it came from the theme, "vctm" if it came from the VCTM plugin and "plugin" if it came from a third party plugin using the vctm_template_locations hook. (Don't register multiple paths where template names can collide - you won't be able to filter them.)
Dynamic value: TEMPLATE_NAME - The name of the template, without extension. Example: my_template
Parameters: $current_class_name - The auto-generated class name
Return value: String - new name, (*29)

vctm_<TEMPLATE_SOURCE>_content_<TEMPLATE_NAME>

Lets you dynamically alter the contents of a template, for example to perform pre-processing., (*30)

Dynamic value: TEMPLATE_SOURCE - The source of the template. "theme" if it came from the theme, "vctm" if it came from the VCTM plugin and "plugin" if it came from a third party plugin using the vctm_template_locations hook. (Don't register multiple paths where template names can collide - you won't be able to filter them.)
Dynamic value: TEMPLATE_NAME - The name of the template, without extension. Example: my_template
Parameters: $current_content - The template content
Return value: String - new template content, (*31)

Miscellaneous

Template name generation

We generate a "nice" template name based on the file name. Dashes and underscores are replaced with spaces and each word is capitalized. You can override it with the vctm_<TEMPLATE_SOURCE>_name_<TEMPLATE_NAME> filter., (*32)

GitHub updater

This plugin supports GitHub updater., (*33)

Composer

This plugin supports Composer through the composer/installers package., (*34)

The Versions

08/02 2015

dev-master

9999999-dev

Easily add version-controlled templates to your Visual Composer project

  Sources   Download

GPL2

The Requires

 

wordpress vcs visual composer

26/01 2015

1.0

1.0.0.0

Easily add version-controlled templates to your Visual Composer project

  Sources   Download

GPL2

The Requires

 

wordpress vcs visual composer