Sindbad~EG File Manager
<?php
/*
Plugin Name: Hover Image - A Visual Composer Extention
Plugin URI: http://wpbakery.com/vc
Description: A Visual Composer Extention that adds the Hover Image Module
Version: 0.1
Author: Theme Island Studios
Author URI: http://themeisland.net
License: GPLv2 or later
*/
/*
This example/starter plugin can be used to speed up Visual Composer plugins creation process.
More information can be found here: http://kb.wpbakery.com/index.php?title=Category:Visual_Composer
In this example all plugin related functions will have a "vc_extend" prefix, make sure to use unique prefix
in your plugin. Otherwise, you (or your users) may experience "Cannot redaclare function" error.
*/
// don't load directly
if (!defined('ABSPATH')) die('-1');
/*
Display notice if Visual Composer is not installed or activated.
*/
if ( !defined('WPB_VC_VERSION') ) { add_action('admin_notices', 'vc_extend_notice'); return; }
function vc_extend_notice() {
$plugin_data = get_plugin_data(__FILE__);
print '
<div class="updated">
<p>'.sprintf(__('<strong>%s</strong> requires <strong><a href="http://bit.ly/vcomposer" target="_blank">Visual Composer</a></strong> plugin to be installed and activated on your site.', 'vc_extend'), $plugin_data['Name']).'</p>
</div>';
}
/*
Load plugin css and javascript files
*/
add_action('wp_enqueue_scripts', 'vc_extend_js_css');
function vc_extend_js_css() {
wp_register_style( 'vc_extend_style', get_template_directory_uri() . '/vc_extend/vc_extend.css' );
wp_enqueue_style( 'vc_extend_style' );
// If you need any javascript files on front end, here is how you can load them.
// wp_register_style( 'vc_extend_js', get_template_directory_uri() . '/vc_extend/vc_extend.js' );
// wp_enqueue_style( 'vc_extend_js' );
// wp_enqueue_script( 'vc_extend_js', get_template_directory_uri() . '/vc_extend/vc_extend.js' );
}
/*
Lets register our shortcode with bartag base and few params (attributes):
* foo
* color
* content
[bartag foo="something" color="#FFF"] Content here [/bartag]
More information can be found here:
http://kb.wpbakery.com/index.php?title=Visual_Composer_tutorial
*/
add_shortcode( 'themesingleimage', 'themesingleimage_func' );
function themesingleimage_func( $atts, $content = null ) {
extract( shortcode_atts( array(
'pb_title' => '',
'img_width' => '100%',
'img_height' => 'auto',
'alignment' => 'left',
'img_height' => '',
'color' => '#6AC9F5',
'opacity' => '0.9',
'start_height' => '40px',
'end_height' => '100%',
//'el_class' => '',
'image' => '',
'img_size' => ''
), $atts ) );
// PRIMARY VARIABLES AND STATEMENTS
if ( $pb_title == NULL ) $pb_title_output = '';
elseif ( $pb_title != NULL ) $pb_title_output = '<h4 class="pb_title">'.$pb_title.'</h4>';
$content = wpb_js_remove_wpautop($content); // fix unclosed/unwanted paragraph tags in $content
//add_image_size( 'new_single_image_thumb', $img_size, true );
$img_id = preg_replace('/[^\d]/', '', $image);
$img = wpb_getImageBySize(array( 'attach_id' => $img_id, 'thumb_size' => $img_size, 'class' => 'image-inner', ));
//if ( $img == NULL ) $img['thumbnail'] = '<img class="' '" src="' '" />'; //' <small>'.__('This is image placeholder, edit your page to replace it.', 'js_composer').'</small>';
$img_attachment = wp_get_attachment_image_src( $img_id, $img_size);
//$img_url = $img_attachment[0];
if ( $img_size == NULL ) $img_output = '<img src="'.$img_attachment[0].'">';
elseif ( $img_size != NULL ) $img_output = $img['thumbnail'];
$css_align = ' vc_align_'.$alignment;
//$img = wpb_getImageBySize( array( 'attach_id' => $img_id, 'thumb_size' => $img_size, ) );
//if ( $img == NULL ) $img['thumbnail'] = '<img class="' '" src="' . vc_asset_url( 'vc/no_image.png' ) . '" />'; //' <small>'.__('This is image placeholder, edit your page to replace it.', 'js_composer').'</small>';
//$img_output = $img['thumbnail'];
//<div class='module-image' style='width:".$img_attachment[1]."; height:".$img_attachment[2].";'>
//wpb_single_image
$sanitized_css_align = esc_attr($css_align);
$sanitized_img_width = esc_attr($img_width);
$sanitized_color = esc_attr($color);
$sanitized_opacity = esc_attr($opacity);
$sanitized_start_height = esc_attr($start_height);
$sanitized_end_height = esc_attr($end_height);
return "
<div class='hover-image wpb_content_element ".$sanitized_css_align."'>
<div class='module-inner' style='width:{$sanitized_img_width};'>
<div class='module-image'>
{$img_output}
</div>
<div class='module-content' style=''>
<div class='content-inner'>
{$pb_title_output}
{$content}
</div>
</div>
<div class='module-background' style='background-color:{$sanitized_color}; opacity:{$sanitized_opacity}'>
</div>
<div class='pb_transitions'>
<div class='pb_css'>
<style>
html:not(.no-csstransitions) .hover-image .module-inner .module-content,
html:not(.no-csstransitions) .hover-image .module-inner .module-background {
height: {$sanitized_start_height};
}
html:not(.no-csstransitions) .hover-image .module-inner:hover .module-content,
html:not(.no-csstransitions) .hover-image .module-inner:hover .module-background {
height: {$sanitized_end_height};
}
</style>
</div>
<div class='pb_jquery'>
<input class='start_position' type='text' value='{$sanitized_start_height}' style='display:none;'>
<input class='end_position' type='text' value='{$sanitized_end_height}' style='display:none;'>
</div>
</div>
</div>
</div>
";
}
/*
Lets call wpb_map function to "register" our custom shortcode within Visual Composer interface.
*/
wpb_map( array(
"name" => __("Hover Image", 'vc_extend'),
"description" => "A Custom Theme Module",
"base" => "themesingleimage",
"class" => "",
"controls" => "full",
"icon" => "icon-wpb-single-image",
"category" => __('Content', 'js_composer'),
//'admin_enqueue_js' => array(plugins_url('vc_extend_admin.js', __FILE__)),
'admin_enqueue_css' => array( get_template_directory_uri() . '/vc_extend/vc_extend.css' ),
"params" => array(
array(
"type" => "textfield",
"heading" => __("Widet Title", "js_composer"),
"param_name" => "pb_title",
"value" => "",
"description" => __("Optional. Add a Title for this Pixel Box.", "js_composer")
),
array(
"type" => "attach_image",
"heading" => __("Image", "js_composer"),
"param_name" => "image",
"value" => "",
"description" => __("Select image from media library.", "js_composer")
),
/*
array(
"type" => "textfield",
"heading" => __("Image Width", "js_composer"),
"param_name" => "img_width",
"value" => "",
"description" => __("Select your image width (ie. 100px, 100%).", "js_composer")
),*/
/*
array(
"type" => "textfield",
"heading" => __("Image Height", "js_composer"),
"param_name" => "img_height",
"value" => "",
"description" => __("Select your image height (ie. 100px, 100%).", "js_composer")
),*/
/* array(
"type" => "dropdown",
"heading" => __("Image alignment", "js_composer"),
"param_name" => "alignment",
"value" => array(__("Align left", "js_composer") => "left",
__("Align right", "js_composer") => "right",
__("Align center", "js_composer") => "center"),
"description" => __("Select image alignment.", "js_composer")
), */
array(
"type" => "colorpicker",
"holder" => "div",
"class" => "",
"heading" => __("Hover Background Color", 'vc_extend'),
"param_name" => "color",
"value" => '#FF0000', //Default Red color
"description" => __("Choose hover content background color", 'vc_extend')
),
/*
array(
"type" => "textfield",
"heading" => __("Scale Image by Height", "js_composer"),
"param_name" => "img_height",
"value" => "",
"description" => __("Optional: This will crop your images based on the height set. Select your image height (default = 'auto').", "js_composer")
),*/
array(
"type" => "textfield",
"heading" => __("Image Size", "js_composer"),
"param_name" => "img_size",
"value" => "",
"description" => __("Select your image size.", "js_composer")
),
/*
array(
"type" => "textfield",
"holder" => "div",
"class" => "",
"heading" => __("Text", 'vc_extend'),
"param_name" => "foo",
"value" => __("Default params value", 'vc_extend'),
"description" => __("Description for foo param.", 'vc_extend')
),
array(
"type" => "textfield",
"heading" => __("Background Opacity", "js_composer"),
"param_name" => "opacity",
"value" => "",
"description" => __("Select hover content background opacity (default = 0.9).", "js_composer")
),
*/
array(
"type" => "textfield",
"heading" => __("Start Height", "js_composer"),
"param_name" => "start_height",
"value" => "",
"description" => __("Select hover content start height (default = -1%).", "js_composer")
),
array(
"type" => "textfield",
"heading" => __("End Height", "js_composer"),
"param_name" => "end_height",
"value" => "",
"description" => __("Select hover content end height (default = 101%).", "js_composer")
),
array(
"type" => "textarea_html",
"holder" => "div",
"class" => "",
"heading" => __("Hover Content Field", 'vc_extend'),
"param_name" => "content",
"value" => __("<p>I am test text block. Click edit button to change this text.</p>", 'vc_extend'),
"description" => __("Enter your content.", 'vc_extend')
),
)
) );
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists