PluginProbe
Property Hive / trunk
Property Hive vtrunk
2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 1.4.63 All 259 releases
propertyhive / includes / class-ph-salient.php

class-ph-salient.php in Property Hive trunk, at includes/class-ph-salient.php

133 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 class PH_Salient {
8
9 public function __construct()
10 {
11 add_action( 'init', array( $this, 'register_widgets' ), 1 );
12 }
13
14 public function register_widgets()
15 {
16 if ( !class_exists('Salient_Core') )
17 {
18 return;
19 }
20
21 $widgets = array(
22 'Property Search Form',
23 'Property Images',
24 'Property Image',
25 'Property Gallery',
26 'Property Address Name Number',
27 'Property Address Street',
28 'Property Address Line 2',
29 'Property Address Town City',
30 'Property Address County',
31 'Property Address Postcode',
32 'Property Address Full',
33 'Property Price',
34 'Property Price Qualifier',
35 'Property Features',
36 'Property Summary Description',
37 'Property Full Description',
38 'Property Actions',
39 'Property Meta',
40 'Property Availability',
41 'Property Type',
42 'Property Bedrooms',
43 'Property Bathrooms',
44 'Property Reception Rooms',
45 'Property Reference Number',
46 'Property Floor Area',
47 'Property Tenure',
48 'Property Council Tax Band',
49 'Property Let Available Date',
50 'Property Deposit',
51 'Property Map',
52 'Property Map Link',
53 'Property Street View',
54 'Property Floorplans',
55 'Property EPCs',
56 'Property Enquiry Form',
57 /*'Property Enquiry Form Link',*/
58 'Property Brochures Link',
59 'Property Embedded Virtual Tours',
60 /*'Property Virtual Tours Link',*/
61 /*'Property Office Name',
62 'Property Office Telephone Number',
63 'Property Office Email Address',
64 'Property Office Address',
65 'Property Negotiator Name',
66 'Property Negotiator Telephone Number',
67 'Property Negotiator Email Address',
68 'Property Negotiator Photo',
69 'Back To Search',
70 'Property Search Result Count',
71 'Property Search Order',*/
72 );
73
74 $widgets = apply_filters( 'propertyhive_salient_widgets', $widgets );
75
76 foreach ( $widgets as $widget )
77 {
78 $widget_dir = 'salient-widgets';
79 $widget_dir = apply_filters( 'propertyhive_salient_widget_directory', dirname(__FILE__) . "/" . $widget_dir, $widget );
80 if ( file_exists( $widget_dir . "/" . sanitize_title($widget) . ".php" ) )
81 {
82 require_once( $widget_dir . "/" . sanitize_title($widget) . ".php" );
83 }
84 }
85 }
86 }
87
88 new PH_Salient();
89
90 function ph_extract_font_style_from_salient_font_container( $font_container = '' )
91 {
92 $style = '';
93
94 if ( empty($font_container) || !function_exists('vc_parse_multi_attribute') )
95 {
96 return $style;
97 }
98
99 $font_container = vc_parse_multi_attribute($font_container);
100
101 if ( !empty($font_container) )
102 {
103 foreach ( $font_container as $key => $value ) {
104 if ( 'tag' !== $key && strlen( $value ) ) {
105 if ( preg_match( '/description/', $key ) ) {
106 continue;
107 }
108 if ( 'font_size' === $key || 'line_height' === $key ) {
109 $value = preg_replace( '/\s+/', '', $value );
110 }
111 if ( 'font_size' === $key ) {
112 $pattern = '/^(\d*(?:\.\d+)?)\s*(px|\%|in|cm|mm|em|rem|ex|pt|pc|vw|vh|vmin|vmax)?$/';
113 // allowed metrics: http://www.w3schools.com/cssref/css_units.asp
114 preg_match( $pattern, $value, $matches );
115 $value = isset( $matches[1] ) ? (float) $matches[1] : (float) $value;
116 $unit = isset( $matches[2] ) ? $matches[2] : 'px';
117 $value = $value . $unit;
118 }
119 if ( strlen( $value ) > 0 ) {
120 $styles[] = str_replace( '_', '-', $key ) . ': ' . $value;
121 }
122 }
123 }
124 }
125
126 if ( ! empty( $styles ) ) {
127 $style = 'style="' . esc_attr( implode( ';', $styles ) ) . '"';
128 } else {
129 $style = '';
130 }
131
132 return $style;
133 }