id = 'features';
$this->label = __( 'Features', 'propertyhive' );
add_filter( 'propertyhive_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'propertyhive_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'propertyhive_admin_field_pro_features', array( $this, 'pro_features_setting' ) );
}
public function get_settings() {
$settings = array(
array( 'title' => __( 'Active Features', 'propertyhive' ), 'type' => 'title', 'desc' => '', 'id' => 'pro_active_features_settings' )
);
$settings[] = array(
'type' => 'pro_features',
);
$settings[] = array( 'type' => 'sectionend', 'id' => 'pro_active_features_settings');
return $settings;
}
public function pro_features_setting()
{
$features = get_ph_pro_features();
echo '
';
// filters
$categories = array(
'' => 'All',
'import' => 'Property Import',
'export' => 'Portal Feeds',
'website' => 'Website Tools',
'crm' => 'CRM Tools',
'data-bridges' => 'Data Bridges',
'free' => 'Free',
);
$selected_category = '';
if ( isset($_GET['profilter']) && array_key_exists(sanitize_text_field($_GET['profilter']), $categories) )
{
$selected_category = sanitize_text_field($_GET['profilter']);
}
echo '
';
// Check if AI Property Search is in list. If not, it can't have been launched yet and to show promo instead
/*$ai_property_search_found = false;
foreach ( $features as $feature )
{
$slug = explode("/", $feature['wordpress_plugin_file']);
$slug = $slug[0];
if ( strpos($slug, 'propertyhive-ai-property-search') !== false )
{
$ai_property_search_found = true;
break;
}
}*/
// list of features
echo '
';
echo '
';
$i = 0;
foreach ( $features as $feature )
{
/*if ( $i == 0 && $ai_property_search_found === false )
{
// Show ad
$feature_status = false;
if ( is_dir( WP_PLUGIN_DIR . '/' . $slug ) )
{
$feature_status = 'installed';
}
if ( is_plugin_active( $feature['wordpress_plugin_file'] ) )
{
$feature_status = 'active';
}
echo '
';
echo ' ';
++$i;
}*/
$slug = explode("/", $feature['wordpress_plugin_file']);
$slug = $slug[0];
if ( $slug == 'propertyhive-template-assistant' )
{
echo '
' . ( ( isset($feature['dashicon']) && !empty($feature['dashicon']) ) ? ' ' : '' ) . esc_html($feature['name']) . '
FREE
';
$links = array();
$links[] = 'This feature has moved.
' . esc_html(__( 'Read More', 'propertyhive' )) . ' ';
echo '
';
echo implode(" | ", $links);
echo '
';
echo '
';
echo '
';
echo '
';
echo ' ';
continue;
}
$feature_status = false;
if ( is_dir( WP_PLUGIN_DIR . '/' . $slug ) )
{
$feature_status = 'installed';
}
if ( is_plugin_active( $feature['wordpress_plugin_file'] ) )
{
$feature_status = 'active';
}
echo '
' . ( ( isset($feature['dashicon']) && !empty($feature['dashicon']) ) ? ' ' : '' ) . esc_html($feature['name']) . ' ' .
( $pro ? '
PRO ' : '' ) .
( !$pro ? '
FREE ' : '' ) . '
';
$links = array();
if ( isset($feature['description']) && !empty($feature['description']) )
{
$links[] = '
';
}
if ( isset($feature['url']) && !empty($feature['url']) )
{
$links[] = '
' . esc_html(__( 'Details', 'propertyhive' )) . ' ';
}
if ( isset($feature['docs_url']) && !empty($feature['docs_url']) )
{
$links[] = '
' . esc_html(__( 'Docs', 'propertyhive' )) . ' ';
}
if ( $feature_status == 'active' )
{
$transient = get_site_transient( 'update_plugins' );
if ( isset($transient->response) && is_array($transient->response) && isset($transient->response[$feature['wordpress_plugin_file']]) && isset($transient->response[$feature['wordpress_plugin_file']]->new_version) )
{
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $feature['wordpress_plugin_file'] );
if ( version_compare($plugin_data['Version'], $transient->response[$feature['wordpress_plugin_file']]->new_version, '<') )
{
$links[] = '
' . esc_html(__( 'Update', 'propertyhive' )) . '';
}
}
}
echo '
';
echo implode(" | ", $links);
echo '
';
echo '
';
echo '
';
if ( !$can_use )
{
echo '
';
}
echo '
';
echo ' ';
++$i;
}
echo '
';
echo '
';
}
/**
* Output the settings
*/
public function output() {
global $current_section, $hide_save_button;
$hide_save_button = true;
$settings = $this->get_settings();
PH_Admin_Settings::output_fields( $settings );
}
}
endif;
return new PH_Settings_Features();