| 1 |
<?php |
| 2 |
/** |
| 3 |
* Salient Property Image Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 9 |
|
| 10 |
class Salient_Property_Image_Widget { |
| 11 |
|
| 12 |
public function __construct() |
| 13 |
{ |
| 14 |
add_action('admin_head', array( $this, 'custom_wpbakery_element_icon' ) ); |
| 15 |
add_action('vc_before_init', array( $this, 'custom_wpbakery_element' ) ); |
| 16 |
} |
| 17 |
|
| 18 |
public function custom_wpbakery_element_icon() |
| 19 |
{ |
| 20 |
echo '<style type="text/css"> |
| 21 |
.wpb_salient_property_image .vc_element-icon:before, |
| 22 |
a[data-tag="salient_property_image"] .vc_element-icon:before { |
| 23 |
font-family: "Dashicons" !important; |
| 24 |
content: "\f161"; |
| 25 |
} |
| 26 |
</style>'; |
| 27 |
} |
| 28 |
|
| 29 |
public function custom_wpbakery_element() |
| 30 |
{ |
| 31 |
$class_name = get_class($this); |
| 32 |
|
| 33 |
$widget_dir = dirname(__FILE__); |
| 34 |
|
| 35 |
$html_template = $widget_dir . '/' . str_replace("_", "-", str_replace(array( "salient_", "_widget" ), "", sanitize_title($class_name))) . '-html.php'; |
| 36 |
|
| 37 |
vc_map( array( |
| 38 |
"name" => __( 'Property Image', 'propertyhive' ), |
| 39 |
"base" => "salient_property_image", |
| 40 |
"class" => "", |
| 41 |
"category" => __( "Property Hive", "propertyhive"), |
| 42 |
"html_template" => $html_template, |
| 43 |
"params" => array( |
| 44 |
array( |
| 45 |
"type" => "textfield", |
| 46 |
"class" => "", |
| 47 |
"heading" => __( 'Image #', 'propertyhive' ), |
| 48 |
"param_name" => "image_number", |
| 49 |
"value" => 1, |
| 50 |
), |
| 51 |
array( |
| 52 |
"type" => "dropdown", |
| 53 |
"class" => "", |
| 54 |
"heading" => __( 'Image Size', 'propertyhive' ), |
| 55 |
"param_name" => "image_size", |
| 56 |
"value" => array( |
| 57 |
__( 'Thumbnail', 'propertyhive' ) => 'thumbnail', |
| 58 |
__( 'Medium', 'propertyhive' ) => 'medium', |
| 59 |
__( 'Large', 'propertyhive' ) => 'large', |
| 60 |
__( 'Full', 'propertyhive' ) => 'full', |
| 61 |
), |
| 62 |
'std' => 'large', |
| 63 |
), |
| 64 |
array( |
| 65 |
"type" => "dropdown", |
| 66 |
"class" => "", |
| 67 |
"heading" => __( 'Image Ratio', 'propertyhive' ), |
| 68 |
"param_name" => "output_ratio", |
| 69 |
"value" => array( |
| 70 |
__( 'Uploaded Ratio', 'propertyhive' ) => '', |
| 71 |
__( '3:2', 'propertyhive' ) => '3:2', |
| 72 |
__( '4:3', 'propertyhive' ) => '4:3', |
| 73 |
__( '16:9', 'propertyhive' ) => '16:9', |
| 74 |
__( 'Square', 'propertyhive' ) => '1:1', |
| 75 |
), |
| 76 |
'std' => '', |
| 77 |
), |
| 78 |
) |
| 79 |
)); |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
new Salient_Property_Image_Widget(); |