Snippets
Created by
Arifur Rahman
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_CAN_LOAD_FILES_'))
exit;
class VcSimpleAddons extends Module
{
public function __construct()
{
$this->name = 'vcsimpleaddons';
$this->author = 'SmartDataSoft';
$this->tab = 'front_office_features';
$this->version = '1.1.1';
$this->bootstrap = true;
parent::__construct();
JsComposer::add_shortcode('bartag',array(&$this,'renderMyBartag'));
$this->displayName = $this->l('Visual Composer Simple Addons');
$this->description = $this->l('This is a simple visual composer addons');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
public function install()
{
return (parent::install() && $this->registerHook('vcBeforeInit'));
}
public function hookvcBeforeInit() {
$vc = vc_manager();
/*
Add your Visual Composer logic here.
Lets call vc_map function to "register" our custom shortcode within Visual Composer interface.
More info: http://kb.wpbakery.com/index.php?title=Vc_map
*/
if(function_exists("vc_map")){
vc_map( array(
"name" => $vc->l("My Bar Shortcode"),
"description" => $vc->l("Bar tag description text"),
"base" => "bartag",
"class" => "",
"controls" => "full",
// "icon" => plugins_url('assets/asterisk_yellow.png', __FILE__), // or css class name which you can reffer in your css file later. Example: "vc_extend_my_class"
"category" => $vc->l('Content'),
//'admin_enqueue_js' => array(plugins_url('assets/vc_extend.js', __FILE__)), // This will load js file in the VC backend editor
//'admin_enqueue_css' => array(plugins_url('assets/vc_extend_admin.css', __FILE__)), // This will load css file in the VC backend editor
"params" => array(
array(
"type" => "textfield",
"holder" => "div",
"class" => "",
"heading" => $vc->l("Text"),
"param_name" => "foo",
"value" => $vc->l("Default params value"),
"description" => $vc->l("Description for foo param.")
),
array(
"type" => "colorpicker",
"holder" => "div",
"class" => "",
"heading" => $vc->l("Text color"),
"param_name" => "color",
"value" => '#FF0000', //Default Red color
"description" => $vc->l("Choose text color")
),
array(
"type" => "textarea_html",
"holder" => "div",
"class" => "",
"heading" => $vc->l("Content"),
"param_name" => "content",
"value" => $vc->l("<p>I am test text block. Click edit button to change this text.</p>"),
"description" => $vc->l("Enter your content.")
),
)
) );
}
}
/*
Shortcode logic how it should be rendered
*/
public function renderMyBartag( $atts, $content = null ) {
extract( JsComposer::shortcode_atts( array(
'foo' => 'something',
'color' => '#FF0000'
), $atts ) );
$this->loadCssAndJs();
$output = "<div style='color:{$color};' data-foo='${foo}'>{$content}</div>";
return $output;
}
/*
Load plugin css and javascript files which you may need on front end of your site
*/
public function loadCssAndJs() {
$url = __PS_BASE_URI__ . 'modules/vcsimpleaddons/';
$this->context->controller->addCSS("{$url}css/vc_extend.css");
$this->context->controller->addJS("{$url}js/vc_extend.js");
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.