| 1 |
<?php |
| 2 |
/** |
| 3 |
* PropertyHive Add-Ons |
| 4 |
* |
| 5 |
* @author PropertyHive |
| 6 |
* @category Admin |
| 7 |
* @package PropertyHive/Admin |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! class_exists( 'PH_Settings_Add_Ons' ) ) : |
| 16 |
|
| 17 |
/** |
| 18 |
* PH_Settings_Add_Ons |
| 19 |
*/ |
| 20 |
class PH_Settings_Add_Ons extends PH_Settings_Page { |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
$this->id = 'addons'; |
| 27 |
$this->label = __( 'Add Ons', 'propertyhive' ); |
| 28 |
|
| 29 |
add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
| 30 |
add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) ); |
| 31 |
add_action( 'propertyhive_admin_field_addons', array( $this, 'addons_setting' ) ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get settings array |
| 36 |
* |
| 37 |
* @return array |
| 38 |
*/ |
| 39 |
public function get_settings() { |
| 40 |
|
| 41 |
global $hide_save_button; |
| 42 |
|
| 43 |
$hide_save_button = TRUE; |
| 44 |
|
| 45 |
return apply_filters( 'propertyhive_add_on_settings', array( |
| 46 |
|
| 47 |
array( 'title' => __( 'Add Ons', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'add_on_options' ), |
| 48 |
|
| 49 |
array( |
| 50 |
'type' => 'addons', |
| 51 |
), |
| 52 |
|
| 53 |
array( 'type' => 'sectionend', 'id' => 'add_on_options') |
| 54 |
|
| 55 |
) ); // End add on settings |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Output the settings |
| 60 |
*/ |
| 61 |
public function output() |
| 62 |
{ |
| 63 |
$settings = $this->get_settings(); |
| 64 |
|
| 65 |
PH_Admin_Settings::output_fields( $settings ); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Output list of offices |
| 70 |
* |
| 71 |
* @access public |
| 72 |
* @return void |
| 73 |
*/ |
| 74 |
public function addons_setting() { |
| 75 |
global $post; |
| 76 |
|
| 77 |
$add_ons = @file_get_contents('http://wp-property-hive.com/add-ons-json.php'); |
| 78 |
?> |
| 79 |
<tr> |
| 80 |
<td class="add-ons"> |
| 81 |
|
| 82 |
<style type="text/css"> |
| 83 |
|
| 84 |
.add-ons ul { list-style-type:none; margin:0; padding:0; } |
| 85 |
.add-ons ul li { float:left; width:25%; padding:0 10px; margin-bottom:25px; box-sizing:border-box; } |
| 86 |
.add-ons ul li:nth-child(4n+1) { clear:left; } |
| 87 |
.add-ons ul li .padding { background:#FFF; padding:15px; box-sizing:border-box; border:1px solid #CCC; box-shadow:0px 0px 9px 0px rgba(0,0,0,0.2); -webkit-box-shadow:0px 0px 9px 0px rgba(0,0,0,0.2); } |
| 88 |
.add-ons ul li .thumbnail { text-align:center; } |
| 89 |
|
| 90 |
@media (max-width:1450px) { |
| 91 |
.add-ons ul li { width:33.3333%; } |
| 92 |
.add-ons ul li:nth-child(4n+1) { clear:none; } |
| 93 |
.add-ons ul li:nth-child(3n+1) { clear:left; } |
| 94 |
} |
| 95 |
|
| 96 |
@media (max-width:1024px) { |
| 97 |
.add-ons ul li { width:50%; } |
| 98 |
.add-ons ul li:nth-child(3n+1) { clear:none; } |
| 99 |
.add-ons ul li:nth-child(2n+1) { clear:left; } |
| 100 |
} |
| 101 |
|
| 102 |
@media (max-width:550px) { |
| 103 |
.add-ons ul li { width:100%; padding:0; } |
| 104 |
.add-ons ul li:nth-child(3n+1) { clear:none; } |
| 105 |
.add-ons ul li:nth-child(2n+1) { clear:left; } |
| 106 |
} |
| 107 |
|
| 108 |
</style> |
| 109 |
|
| 110 |
<?php |
| 111 |
if ($add_ons !== FALSE && $add_ons !== '') |
| 112 |
{ |
| 113 |
$add_ons = json_decode($add_ons); |
| 114 |
|
| 115 |
if ($add_ons !== FALSE && !empty($add_ons)) |
| 116 |
{ |
| 117 |
echo '<ul>'; |
| 118 |
|
| 119 |
$i = 0; |
| 120 |
foreach ($add_ons as $add_on) |
| 121 |
{ |
| 122 |
echo '<li> |
| 123 |
<div class="padding"> |
| 124 |
<div class="thumbnail">'; |
| 125 |
if (isset($add_on->image) && $add_on->image != '') |
| 126 |
{ |
| 127 |
echo '<a href="' . $add_on->url . '" target="_blank"><img src="' . $add_on->image . '" alt="' . $add_on->name . '"></a>'; |
| 128 |
} |
| 129 |
echo '</div> |
| 130 |
<div class="details"> |
| 131 |
<h3><a href="' . $add_on->url . '" target="_blank">' . $add_on->name . '</a></h3> |
| 132 |
<p>' . $add_on->description . '</p> |
| 133 |
<br> |
| 134 |
<a href="' . $add_on->url . '" target="_blank" class="button">'. __('View Add On', 'propertyhive') .'</a> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
</li>'; |
| 138 |
|
| 139 |
++$i; |
| 140 |
} |
| 141 |
|
| 142 |
echo '</ul>'; |
| 143 |
} |
| 144 |
else |
| 145 |
{ |
| 146 |
echo '<p>'. __('No add ons are currently available for Property Hive. As add ons become available they will appear here. Please check back soon.', 'propertyhive') . '</p>'; |
| 147 |
} |
| 148 |
} |
| 149 |
else |
| 150 |
{ |
| 151 |
echo '<p>'. __('Unable to retrieve list of add-ons. Please visit the Property Hive add ons page to view a full list of add ons available.', 'propertyhive') . '</p>'; |
| 152 |
|
| 153 |
echo '<br><p><a href="https://wp-property-hive.com/add-ons/" class="button button-primary">'. __('Browse All Add Ons', 'propertyhive') . '</a></p>'; |
| 154 |
} |
| 155 |
?> |
| 156 |
|
| 157 |
</td> |
| 158 |
</tr> |
| 159 |
<?php |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
endif; |
| 164 |
|
| 165 |
return new PH_Settings_Add_Ons(); |
| 166 |
|