Skip to content

Instantly share code, notes, and snippets.

@juslintek
Created March 1, 2018 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juslintek/6385c408a234308b54b895eaaa977f31 to your computer and use it in GitHub Desktop.
Save juslintek/6385c408a234308b54b895eaaa977f31 to your computer and use it in GitHub Desktop.
LC module for outputting live-composer
<?php
/**
* Plugin Name: Hosting Companies Listing
* Description: Lists Hostinger Post Types In Chosen Formats.
* Version: 1.0
*/
if ( defined( 'DS_LIVE_COMPOSER_URL' ) ) {
add_action( 'dslc_hook_register_modules',
function () {
dslc_register_module( "Hosting_Companies_Listing" );
} );
class Hosting_Companies_Listing extends DSLC_Module {
// Module Attributes
var $module_id = 'Hosting_Companies_Listing';
var $module_title = 'Hosting Companies Listing Tables';
var $module_icon = 'cubes';
var $module_category = 'hostinger';
// Module Options
function options() {
$categories = [];
foreach (
get_terms( [
'taxonomy' => 'hosting_providers_category',
'hide_empty' => false
] ) as $item
) {
$categories[] = [
'label' => $item->name,
'value' => $item->slug
];
}
// The options array
$dslc_options = array(
array(
'label' => __( 'Show On', 'live-composer-page-builder' ),
'id' => 'css_show_on',
'std' => 'desktop tablet phone',
'type' => 'checkbox',
'choices' => array(
array(
'label' => __( 'Desktop', 'live-composer-page-builder' ),
'value' => 'desktop'
),
array(
'label' => __( 'Tablet', 'live-composer-page-builder' ),
'value' => 'tablet'
),
array(
'label' => __( 'Phone', 'live-composer-page-builder' ),
'value' => 'phone'
),
),
),
array(
'label' => __( 'Custom Wrapper Class', 'tudosobresites' ),
'std' => '',
'id' => 'custom_wrapper_class',
'type' => 'text'
),
array(
'label' => __( 'View Type', 'tudosobresites' ),
'id' => 'type',
'std' => 'list',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Mini List', 'live-composer-page-builder' ),
'value' => 'mini-list'
),
array(
'label' => __( 'List', 'live-composer-page-builder' ),
'value' => 'list'
),
array(
'label' => __( 'Table', 'live-composer-page-builder' ),
'value' => 'table'
)
)
),
array(
'label' => __( 'Display Columns', 'tudosobresites' ),
'id' => 'display_columns',
'std' => 'disk_space top_features',
'type' => 'checkbox',
'choices' => [
[
'label' => 'Top Features',
'value' => 'top_features'
],
[
'label' => 'Disk Space',
'value' => 'disk_space'
],
[
'label' => 'Server OS',
'value' => 'server_os'
],
[
'label' => 'Best For',
'value' => 'best_for'
],
[
'label' => 'Server Locations',
'value' => 'server_locations'
],
[
'label' => 'Free Domain',
'value' => 'free_domain'
],
[
'label' => 'Registration .com',
'value' => 'registration_com'
],
[
'label' => 'Renewal .com',
'value' => 'renewal_com'
],
[
'label' => 'Free domain with Hosting',
'value' => 'free_domain_with_hosting'
],
],
'help' => __( 'Select Columns to display', 'tudosobresites' ),
'dependent_controls' => [
'type' => 'table',
],
'tab' => __( 'Display Columns', 'tudosobresites' ),
),
array(
'label' => __( 'Limit', 'tudosobresites' ),
'id' => 'limit',
'std' => 5,
'type' => 'number'
),
array(
'label' => __( 'Load More Button', 'tudosobresites' ),
'id' => 'load_more_button',
'std' => 'off',
'type' => 'select',
'choices' => [
[
'label' => 'Off',
'value' => 'off'
],
[
'label' => 'On',
'value' => 'on'
]
]
),
array(
'label' => __( 'Type of Loading', 'tudosobresites' ),
'id' => 'type_of_loading',
'std' => 'preload',
'type' => 'select',
'choices' => [
[
'label' => 'Preload',
'value' => 'preload'
],
[
'label' => 'Ajax',
'value' => 'ajax'
]
]
),
array(
'label' => __( 'Categories', 'tudosobresites' ),
'id' => 'category',
'std' => 'web-hosting',
'type' => 'select',
'choices' => $categories
),
array(
'label' => __( 'Order By Field', 'tudosobresites' ),
'id' => 'orderby',
'std' => 'rank',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Rank', 'tudosobresites' ),
'value' => 'rank'
),
array(
'label' => __( 'Provider Name', 'tudosobresites' ),
'value' => 'post_title'
),
array(
'label' => __( 'Score/Review', 'tudosobresites' ),
'value' => 'score_review'
),
array(
'label' => __( 'Free Domain', 'tudosobresites' ),
'value' => 'free_domains'
),
array(
'label' => __( 'Price', 'tudosobresites' ),
'value' => 'price'
)
)
),
array(
'label' => __( 'Rank per category', 'tudosobresites' ),
'id' => 'rank_per_category',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
'dependent_controls' => [
'rank_by_category' => 'rank',
],
),
array(
'label' => __( 'Rating per category', 'tudosobresites' ),
'id' => 'rating_per_category',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Sort Order', 'tudosobresites' ),
'id' => 'order',
'std' => 'ASC',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Ascending' ),
'value' => 'ASC'
),
array(
'label' => __( 'Descending' ),
'value' => 'DESC'
),
)
),
array(
'label' => __( 'Is Sortable?', 'tudosobresites' ),
'id' => 'is_sortable',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Show stars', 'tudosobresites' ),
'id' => 'show_stars',
'std' => 'yes',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Is Sticky?', 'tudosobresites' ),
'id' => 'is_sticky',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Show Alternatives Only', 'tudosobresites' ),
'id' => 'show_alternatives_only',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Read Review Link', 'tudosobresites' ),
'id' => 'add_read_review_link',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Price Extension', 'tudosobresites' ),
'id' => 'price_extension',
'std' => 'mo',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Month' ),
'value' => 'mo'
),
array(
'label' => __( 'Year' ),
'value' => 'yr'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Price', 'tudosobresites' ),
'id' => 'add_link_to_price',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Top Features', 'tudosobresites' ),
'id' => 'add_link_to_top_features',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Recommended For', 'tudosobresites' ),
'id' => 'add_link_to_best_for',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Rating', 'tudosobresites' ),
'id' => 'add_link_to_rating',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Disk Space', 'tudosobresites' ),
'id' => 'add_link_to_disk_space',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Traffic', 'tudosobresites' ),
'id' => 'add_link_to_traffic',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Add Link to Rank', 'tudosobresites' ),
'id' => 'add_link_to_rank',
'std' => 'no',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes (Review)' ),
'value' => 'yes'
),
array(
'label' => __( 'Yes (Affiliate)' ),
'value' => 'yes_aff'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Extras', 'tudosobresites' ),
),
array(
'label' => __( 'Custom Title Class', 'tudosobresites' ),
'std' => '',
'id' => 'custom_title_class',
'type' => 'text',
'tab' => __( 'Custom Title', 'tudosobresites' ),
),
array(
'label' => __( 'Custom Title', 'tudosobresites' ),
'std' => '',
'id' => 'custom_title_text',
'type' => 'text',
'tab' => __( 'Custom Title', 'tudosobresites' ),
),
array(
'label' => __( 'Enable Custom Link', 'tudosobresites' ),
'std' => 'no',
'id' => 'enable_custom_link',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Yes' ),
'value' => 'yes'
),
array(
'label' => __( 'No' ),
'value' => 'no'
),
),
'tab' => __( 'Bottom Link', 'tudosobresites' ),
),
array(
'label' => __( 'URL - Custom Link', 'tudosobresites' ),
'std' => '',
'id' => 'custom_full_list_link',
'type' => 'text',
'description' => 'If entered overrides Archive link',
'tab' => __( 'Bottom Link', 'tudosobresites' ),
),
array(
'label' => __( 'Text - Custom Link', 'tudosobresites' ),
'std' => 'Full Website Builders Comparison',
'id' => 'custom_link_text',
'type' => 'text',
'tab' => __( 'Bottom Link', 'tudosobresites' ),
),
/* Styling */
array(
'label' => __( 'Align', 'live-composer-page-builder' ),
'id' => 'css_align',
'std' => 'center',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'text-align',
'section' => 'styling',
),
array(
'label' => __( 'BG Color', 'live-composer-page-builder' ),
'id' => 'css_bg_color',
'std' => '',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'background-color',
'section' => 'styling',
),
array(
'label' => __( 'Border Color', 'live-composer-page-builder' ),
'id' => 'css_border_color',
'std' => '',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'border-color',
'section' => 'styling',
),
array(
'label' => __( 'Border Width', 'live-composer-page-builder' ),
'id' => 'css_border_width',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'border-width',
'section' => 'styling',
'ext' => 'px',
),
array(
'label' => __( 'Borders', 'live-composer-page-builder' ),
'id' => 'css_border_trbl',
'std' => 'top right bottom left',
'type' => 'checkbox',
'choices' => array(
array(
'label' => __( 'Top', 'live-composer-page-builder' ),
'value' => 'top'
),
array(
'label' => __( 'Right', 'live-composer-page-builder' ),
'value' => 'right'
),
array(
'label' => __( 'Bottom', 'live-composer-page-builder' ),
'value' => 'bottom'
),
array(
'label' => __( 'Left', 'live-composer-page-builder' ),
'value' => 'left'
),
),
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'border-style',
'section' => 'styling',
),
array(
'label' => __( 'Border Radius', 'live-composer-page-builder' ),
'id' => 'css_border_radius',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'border-radius',
'section' => 'styling',
'ext' => 'px',
),
array(
'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
'id' => 'css_margin_bottom',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'margin-bottom',
'section' => 'styling',
'ext' => 'px',
'min' => - 150,
'max' => 150
),
array(
'label' => __( 'Minimum Height', 'live-composer-page-builder' ),
'id' => 'css_min_height',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'min-height',
'section' => 'styling',
'ext' => 'px',
'min' => 0,
'max' => 1000,
'increment' => 5
),
array(
'label' => __( 'Padding Vertical', 'live-composer-page-builder' ),
'id' => 'css_padding_vertical',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'padding-top,padding-bottom',
'section' => 'styling',
'ext' => 'px'
),
array(
'label' => __( 'Padding Horizontal', 'live-composer-page-builder' ),
'id' => 'css_padding_horizontal',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'padding-left,padding-right',
'section' => 'styling',
'ext' => 'px'
),
array(
'label' => __( 'Force 100% Width', 'live-composer-page-builder' ),
'id' => 'css_force_width',
'std' => 'auto',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'Enabled', 'live-composer-page-builder' ),
'value' => '100%'
),
array(
'label' => __( 'Disabled', 'live-composer-page-builder' ),
'value' => 'auto'
),
),
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting',
'affect_on_change_rule' => 'width',
'section' => 'styling',
),
/* Custom Title Options */
array(
'label' => __( 'Color', 'live-composer-page-builder' ),
'id' => 'title_color',
'std' => '#4d4d4d',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'color',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Color - Hover', 'live-composer-page-builder' ),
'id' => 'title_color_hover',
'std' => '',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'color',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Font Size', 'live-composer-page-builder' ),
'id' => 'title_font_size',
'std' => '24',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'font-size',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Font Weight', 'live-composer-page-builder' ),
'id' => 'css_title_font_weight',
'std' => '300',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'font-weight',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
'ext' => '',
'min' => 100,
'max' => 900,
'increment' => 100
),
array(
'label' => __( 'Font Family', 'live-composer-page-builder' ),
'id' => 'css_title_font_family',
'std' => 'Roboto',
'type' => 'font',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'font-family',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Line Height', 'live-composer-page-builder' ),
'id' => 'title_line_height',
'std' => '29',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'line-height',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
'id' => 'title_margin',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'margin-bottom',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Text Transform', 'live-composer-page-builder' ),
'id' => 'css_title_text_transform',
'std' => 'none',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'None', 'live-composer-page-builder' ),
'value' => 'none'
),
array(
'label' => __( 'Capitalize', 'live-composer-page-builder' ),
'value' => 'capitalize'
),
array(
'label' => __( 'Uppercase', 'live-composer-page-builder' ),
'value' => 'uppercase'
),
array(
'label' => __( 'Lowercase', 'live-composer-page-builder' ),
'value' => 'lowercase'
),
),
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'text-transform',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Text Align', 'live-composer-page-builder' ),
'id' => 'css_title_text_align',
'std' => 'center',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .custom-title',
'affect_on_change_rule' => 'text-align',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
),
/* Custom Link Options */
array(
'label' => __( 'Color', 'live-composer-page-builder' ),
'id' => 'css_cl_color',
'std' => '#1989db',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'color',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Color - Hover', 'live-composer-page-builder' ),
'id' => 'css_cl_color_hover',
'std' => 'rgb(93, 144, 226)',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'color',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Font Size', 'live-composer-page-builder' ),
'id' => 'css_cl_font_size',
'std' => '18',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'font-size',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Font Weight', 'live-composer-page-builder' ),
'id' => 'css_cl_font_weight',
'std' => '400',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'font-weight',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
'ext' => '',
'min' => 100,
'max' => 900,
'increment' => 100
),
array(
'label' => __( 'Font Family', 'live-composer-page-builder' ),
'id' => 'css_cl_font_family',
'std' => 'Roboto',
'type' => 'font',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'font-family',
'section' => 'styling',
'tab' => __( 'Custom Title', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Line Height', 'live-composer-page-builder' ),
'id' => 'css_cl_line_height',
'std' => '38',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'line-height',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Margin Top', 'live-composer-page-builder' ),
'id' => 'css_cl_margin_top',
'std' => '15',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'margin-top',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Margin Bottom', 'live-composer-page-builder' ),
'id' => 'css_cl_margin_bottom',
'std' => '0',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'margin-bottom',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
'ext' => 'px'
),
array(
'label' => __( 'Text Transform', 'live-composer-page-builder' ),
'id' => 'css_cl_text_transform',
'std' => 'none',
'type' => 'select',
'choices' => array(
array(
'label' => __( 'None', 'live-composer-page-builder' ),
'value' => 'none'
),
array(
'label' => __( 'Capitalize', 'live-composer-page-builder' ),
'value' => 'capitalize'
),
array(
'label' => __( 'Uppercase', 'live-composer-page-builder' ),
'value' => 'uppercase'
),
array(
'label' => __( 'Lowercase', 'live-composer-page-builder' ),
'value' => 'lowercase'
),
),
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'text-transform',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
),
array(
'label' => __( 'Text Align', 'live-composer-page-builder' ),
'id' => 'css_cl_text_align',
'std' => 'center',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .more-info-link',
'affect_on_change_rule' => 'text-align',
'section' => 'styling',
'tab' => __( 'Custom Link', 'live-composer-page-builder' ),
),
/**
* Features List Links
*/
array(
'label' => __( 'Link Color', 'live-composer-page-builder' ),
'id' => 'css_list_link_color',
'std' => '#000',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .features-list a',
'affect_on_change_rule' => 'color',
'section' => 'styling',
'tab' => __( 'Features List Links', 'tudosobresites' ),
),
array(
'label' => __( 'Link - Hover Color', 'live-composer-page-builder' ),
'id' => 'css_list_link_color_hover',
'std' => '#000',
'type' => 'color',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .features-list a:hover',
'affect_on_change_rule' => 'color',
'section' => 'styling',
'tab' => __( 'Features List Links', 'tudosobresites' ),
),
array(
'label' => __( 'Link - Text Shadow', 'live-composer-page-builder' ),
'id' => 'css_list_link_text_shadow',
'std' => '',
'type' => 'text_shadow',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .features-list a',
'affect_on_change_rule' => 'text-shadow',
'section' => 'styling',
'tab' => __( 'Features List Links', 'tudosobresites' ),
),
/**
* Column Widths
*/
array(
'label' => __( 'Rank Column Width', 'tudosobresites' ),
'id' => 'css_rank_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .rank-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Provider Column Width', 'tudosobresites' ),
'id' => 'css_provider_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .logo-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Top Features Column Width', 'tudosobresites' ),
'id' => 'css_top_features_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .top-features-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Recommended For Column Width', 'tudosobresites' ),
'id' => 'css_recommended_for_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .best-for-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Disk Space Column Width', 'tudosobresites' ),
'id' => 'css_disk_space_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .disk-space-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Disk Space Column Width', 'tudosobresites' ),
'id' => 'css_disk_space_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .traffic-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Overall Rating Column Width', 'tudosobresites' ),
'id' => 'css_overall_rating_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .rating-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'Price Column Width', 'tudosobresites' ),
'id' => 'css_price_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .price-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
array(
'label' => __( 'More Column Width', 'tudosobresites' ),
'id' => 'css_more_column_width',
'std' => 'auto',
'type' => 'slider',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .read-more-column-heading',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'ext' => '%',
'tab' => __( 'Column Widths', 'tudosobresites' ),
),
/**
* Center Column Content Aligns
*/
array(
'label' => __( 'Rank Column - Align', 'tudosobresites' ),
'id' => 'css_rank_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .rank-column',
'affect_on_change_rule' => 'text-align',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Provider Column - Align', 'tudosobresites' ),
'id' => 'css_provider_column_align',
'std' => 'left',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .logo-column',
'affect_on_change_rule' => 'text-align',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Top Features Column - Align', 'tudosobresites' ),
'id' => 'css_top_features_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .top-features-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Recommended For Column - Align', 'tudosobresites' ),
'id' => 'css_recommended_for_column_align',
'std' => 'auto',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .best-for-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Disk Space Column - Align', 'tudosobresites' ),
'id' => 'css_disk_space_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .disk-space-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Disk Space Column - Align', 'tudosobresites' ),
'id' => 'css_disk_space_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .traffic-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Overall Rating Column - Align', 'tudosobresites' ),
'id' => 'css_overall_rating_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .rating-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'Price Column - Align', 'tudosobresites' ),
'id' => 'css_price_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .price-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
array(
'label' => __( 'More Column - Align', 'tudosobresites' ),
'id' => 'css_more_column_align',
'std' => 'inherit',
'type' => 'text_align',
'refresh_on_change' => false,
'affect_on_change_el' => '.tudosobresites_hosting .read-more-column',
'affect_on_change_rule' => 'width',
'section' => 'styling',
'tab' => __( 'Column Aligns', 'tudosobresites' ),
),
);
// Return the array
$dslc_options = array_merge( $dslc_options, $this->shared_options( 'animation_options', array( 'hover_opts' => false ) ) );
$dslc_options = array_merge( $dslc_options, $this->presets_options() );
return apply_filters( 'dslc_module_options', $dslc_options, $this->module_id );
}
/**
* @return string
*/
function add_protocol_preamble() {
return strtolower( substr( $_SERVER["SERVER_PROTOCOL"], 0, strpos( $_SERVER["SERVER_PROTOCOL"], '/' ) ) ) . '://';
}
function average_rating_per_category( $post, $category, $options, $rating_fields ) {
if ( $options['rating_per_category'] == 'yes' ) {
$rank_category = (object) [ 'term_id' => $category->term_id ];
$ratings_data_list = get_field( 'rating_groups', $post->ID );
$ratings_data = current( $ratings_data_list );
foreach ( $ratings_data_list as $rating_data_item ) {
if ( $rating_data_item['hosting_category']->term_id === $category->term_id ) {
$rank_category = $rating_data_item['hosting_category'];
$ratings_data = $rating_data_item;
break;
}
}
$ratings = array_filter( $ratings_data, function ( $key ) {
return strpos( $key, 'ratings' ) !== false;
}, ARRAY_FILTER_USE_KEY );
if ( ! empty( $rank_category ) && $rank_category->term_id === $category->term_id ) {
$average_rating = average( $ratings );
if ( ! empty( $average_rating ) ) {
if ( $options['type'] === 'mini-list' || $options['show_stars'] === 'no' ) {
?>
<span class="simple-rating">
<?php echo $average_rating; ?>
</span>
<?php
} else {
?>
<span class="simple-rating" data-score="<?php echo $average_rating ?>">
<span class="star-ratings-css">
<span class="star-ratings-css-top"
style="width: <?php echo $average_rating * 10 ?>%">
<span>&#xf005;</span>
<span>&#xf005;</span>
<span>&#xf005;</span>
<span>&#xf005;</span>
<span>&#xf005;</span>
</span>
<span class="star-ratings-css-bottom">
<span>&#xf006;</span>
<span>&#xf006;</span>
<span>&#xf006;</span>
<span>&#xf006;</span>
<span>&#xf006;</span>
</span>
</span>
<span class="numeric-rating"><?php echo number_format( $average_rating, 1 ) ?></span>
</span>
<?php
}
}
}
} else {
if ( $options['type'] === 'mini-list' || $options['show_stars'] === 'no' ) {
$this->average_rating( $post->ID, $rating_fields );
} else {
$this->simple_rating_generator( $post->ID, $rating_fields );
}
}
}
function average_rating( $ID, $rating_fields ) {
?>
<span class="simple-rating">
<?php
$average_array = [];
if ( $rating_fields ) :
foreach ( $rating_fields as $field_key => $field_data ) :
$value = get_field( $field_data['name'], $ID );
array_push( $average_array, $value );
endforeach;
echo number_format( round( average( $average_array ), 1 ), 1 );
endif; ?>
</span>
<?php
}
function simple_rating_generator( $ID, $rating_fields ) {
$average_array = [];
$average_rating = '';
if ( $rating_fields ) :
foreach ( $rating_fields as $field_key => $field_data ) :
$value = get_field( $field_data['name'], $ID );
array_push( $average_array, $value );
endforeach;
$average_rating = number_format( round( average( $average_array ), 1 ), 1 );
endif;
if ( ! empty( $average_rating ) ):
?>
<span class="simple-rating" data-score="<?php echo $average_rating ?>">
<span class="star-ratings-css">
<span class="star-ratings-css-top"
style="width: <?php echo $average_rating * 10 ?>%">
<span>&#xf005;</span>
<span>&#xf005;</span>
<span>&#xf005;</span>
<span>&#xf005;</span>
<span>&#xf005;</span>
</span>
<span class="star-ratings-css-bottom">
<span>&#xf006;</span>
<span>&#xf006;</span>
<span>&#xf006;</span>
<span>&#xf006;</span>
<span>&#xf006;</span>
</span>
</span>
<span class="numeric-rating"><?php echo $average_rating ?></span>
</span>
<?php
endif;
}
/**
* Renders the module
*
* @param $options
*/
function output( $options ) {
/* Module output starts here */
global $dslc_active, $blog_id;
if ( $dslc_active && is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) {
$dslc_is_admin = true;
} else {
$dslc_is_admin = false;
}
$category = trim( $options['category'] );
$category_object = wp_cache_get( $category, 'hosting-companies-listing' );
if ( ! $category_object ) {
$category_object = get_term_by( 'slug', $category, 'hosting_providers_category' );
wp_cache_set( $category, $category_object, 'hosting-companies-listing', 7 * 24 * 60 * 60 );
}
$category_mod = str_replace( '-', '_', $category );
// Getting data from database
$args = [
'posts_per_page' => $options['limit'],
'post_type' => 'hosting_providers',
'post_status' => 'publish',
'orderby' => $options['orderby'],
'order' => $options['order'],
'tax_query' => [
'relation' => 'AND',
[
'taxonomy' => 'hosting_providers_category',
'field' => 'slug',
'terms' => $category,
]
],
];
if ( ! in_array( $options['orderby'], [ 'post_title' ], true ) ) {
if ( $options['orderby'] === 'rank' ) {
$args['orderby'] = 'meta_value_num';
$args['meta_key'] = $category_mod . '_rank';
$args['meta_query'] = [
'key' => $category_mod . '_rank',
'value' => [ '', null, 0 ],
'compare' => 'NOT IN',
'type' => 'NUMERIC'
];
if ( $options['rank_per_category'] == 'yes' ) {
$args['meta_query'] = [
'relation' => 'AND',
'rank_clause' => [
'key' => "ranking_%_rank_in_category",
'value' => 0,
'compare' => '>',
'type' => 'NUMERIC'
],
[
'key' => "ranking_%_rank_category",
'value' => $category_object->term_id
],
];
$args['meta_key'] = 'ranking_%_rank_in_category';
$args['orderby'] = [
'rank_clause' => 'ASC'
];
}
} else {
$args['orderby'] = 'meta_value';
$args['meta_key'] = $options['orderby'];
}
}
if ( $options['show_alternatives_only'] == 'yes' ) {
/**
* @var WP_Post $post
*/
$post = get_post();
if ( $post->post_type == 'hosting_providers' ) {
$args['post__not_in'] = [ $post->ID ];
$args['orderby'] = 'rand';
$args['meta_query'] = [
'relation' => 'AND',
[
'key' => $category_mod . '_rank',
'value' => [ '', 'NULL', 0 ],
'compare' => 'NOT IN',
'type' => 'NUMERIC'
],
[
'key' => $category_mod . '_rank',
'value' => 5,
'compare' => '<=',
'type' => 'NUMERIC'
]
];
if ( $options['rank_per_category'] == 'yes' ) {
$args['meta_query'] = [
'relation' => 'AND',
'rank_clause' => [
'key' => "ranking_%_rank_in_category",
'value' => [ '', 0 ],
'compare' => 'NOT IN',
'type' => 'NUMERIC'
],
[
'key' => "ranking_%_rank_in_category",
'value' => 5,
'compare' => '<=',
'type' => 'NUMERIC'
],
[
'key' => "ranking_%_rank_category",
'value' => $category_object->term_id
],
];
$args['meta_key'] = 'ranking_%_rank_in_category';
}
}
}
if ( $options['type_of_loading'] == 'preload' && $options['load_more_button'] === 'on' ) {
$args['posts_per_page'] = '-1';
}
// Hardcodes in priority alternatives per site
// TODO: Make it read priority providers from fields
if ( $category == 'web-hosting' ) {
if ( $options['show_alternatives_only'] == 'yes' && $blog_id == 1 && isset( $post ) && stripos( $post->post_name, 'hostinger' ) !== false ) {
$args['post__not_in'][] = 5084; //Siteground ID in hosting.review
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 1 && isset( $post ) && stripos( $post->post_name, 'siteground' ) !== false ) {
$args['post__not_in'][] = 3906; //Hostinger ID in hosting.review
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 1 ) {
$args['post__not_in'][] = 3906; //Hostinger ID in hosting.review
$args['post__not_in'][] = 5084; //Siteground ID in hosting.review
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 5 && isset( $post ) && stripos( $post->post_name, 'hostinger' ) !== false ) {
// Checkling melhoremhospedagem site
$args['post__not_in'][] = 5084; //Weblink ID in melhorem
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 5 && isset( $post ) && stripos( $post->post_name, 'weblink' ) !== false ) {
$args['post__not_in'][] = 3906; //Hostinger ID in melhorem
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 5 ) {
$args['post__not_in'][] = 3906; //Hostinger ID in mehlorem
$args['post__not_in'][] = 5084; //Weblink ID in melhorem
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 20 && isset( $post ) && stripos( $post->post_name, 'hostinger' ) !== false ) {
// Checkling melhoremhospedagem site
$args['post__not_in'][] = 6894; //Niagahoster ID in melhorem
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 20 && isset( $post ) && stripos( $post->post_name, 'niagahoster' ) !== false ) {
$args['post__not_in'][] = 3906; //Hostinger ID in melhorem
} elseif ( $options['show_alternatives_only'] == 'yes' && $blog_id == 20 ) {
$args['post__not_in'][] = 3906; //Hostinger ID in mehlorem
$args['post__not_in'][] = 6894; //Niagahoster ID in melhorem
}
}
$static_cache_html_id = md5( serialize( $args ) . ':' . serialize( $options ) ) . ':hosting_companies_listing';
$html_static_output = wp_cache_get( $static_cache_html_id, 'hosting-companies-listing' );
if ( $html_static_output ) {
echo $html_static_output;
$this->add_scripts( $options );
} else {
$hosting_providers_cache_id = md5( serialize( $args ) ) . ':hosting_providers';
$hosting_providers = wp_cache_get( $hosting_providers_cache_id );
if ( ! $hosting_providers ) {
$hosting_posts_query = new WP_Query( $args );
$hosting_providers = $hosting_posts_query->get_posts();
wp_cache_add( $hosting_providers_cache_id, $hosting_providers, '', WP_OBJECT_CACHE_EXPIRE );
}
$total = count( $hosting_providers );
// Hardcodes in priority alternatives per site
// TODO: Make it read priority providers from fields
if ( $options['show_alternatives_only'] == 'yes' && $category == 'web-hosting' ) {
switch ( $blog_id ) {
case 1:
if ( isset( $post ) && stripos( $post->post_name, 'hostinger' ) !== false ) {
array_unshift( $hosting_providers, get_post( 5084 ) ); //Siteground hosting provider
} elseif ( isset( $post ) && stripos( $post->post_name, 'siteground' ) !== false ) {
array_unshift( $hosting_providers, get_post( 3906 ) ); //Hostinger hosting provider
} else {
array_unshift( $hosting_providers, get_post( 3906 ), get_post( 5084 ) ); //Hostinger, Siteground hosting provider
}
break;
case 5:
if ( isset( $post ) && stripos( $post->post_name, 'hostinger' ) !== false ) {
array_unshift( $hosting_providers, get_post( 5084 ) ); // Weblink hosting provider in melhorem
} elseif ( isset( $post ) && stripos( $post->post_name, 'weblink' ) !== false ) {
array_unshift( $hosting_providers, get_post( 3906 ) ); //Hostinger hosting provider
} else {
array_unshift( $hosting_providers, get_post( 3906 ), get_post( 5084 ) ); //Hostinger, Weblink hosting provider
}
break;
case 20:
if ( isset( $post ) && stripos( $post->post_name, 'hostinger' ) !== false ) {
array_unshift( $hosting_providers, get_post( 6894 ) ); //Niagahoster hosting provider
} elseif ( isset( $post ) && stripos( $post->post_name, 'niagahoster' ) !== false ) {
array_unshift( $hosting_providers, get_post( 3906 ) ); //Hostinger hosting provider
} else {
array_unshift( $hosting_providers, get_post( 3906 ), get_post( 6894 ) ); //Hostinger, Niagahoster hosting provider
}
break;
}
$hosting_providers = array_slice( $hosting_providers, 0, $options['limit'] );
}
if ( $total === 0 && $dslc_is_admin ) {
?>
<div class="dslc-notification dslc-red">
<?php _e( 'Something wrong with criteria.', 'tudosobresites' ); ?>
<?php _e( 'Fix criteria or add some records matching criteria.', 'tudosobresites' ); ?>
<?php _e( 'Check if records wanted are attached to selected categories.', 'tudosobresites' ); ?>
<span class="dslca-refresh-module-hook dslc-icon dslc-icon-refresh"></span>
</div>
<?php
} else {
ob_start();
$all_acf_groups = acf_get_field_groups();
$rating_group_id = null;
foreach ( $all_acf_groups as $group_key => $group ) {
if ( $group['title'] === 'Rating' ) {
$rating_group_id = $all_acf_groups[ $group_key ]['ID'];
continue;
}
}
$rating_fields = acf_get_fields( $rating_group_id );
if ( class_exists( 'NumberFormatter' ) ) {
$number_formatter = new NumberFormatter( substr( get_locale(), 0, 2 ), \NumberFormatter::CURRENCY );
} else {
$locale = substr( get_locale(), 0, 2 );
$number_formatter = new \Symfony\Component\Intl\NumberFormatter\NumberFormatter( $locale, 2 );
}
?>
<div class="tudosobresites_hosting <?php echo $options['type'] ?><?php echo ' ' . $options['custom_wrapper_class'] ?><?php echo $options['is_sticky'] === 'yes' ? ' sticky' : '' ?>"
itemscope itemtype="http://schema.org/Table">
<?php if ( ! empty( $options['custom_title_text'] ) ): ?>
<h3 class="custom-title <?php echo $options['custom_title_class'] ?>"
itemprop="about"><?php echo do_shortcode( $options['custom_title_text'] ) ?></h3>
<?php endif; ?>
<table>
<?php
foreach ( $hosting_providers as $key => $hosting_provider ):
// Print table heading if content type is table
if ( $key === 0 && $options['type'] === 'table' ):
?>
<thead>
<tr>
<th class="rank-column-heading size-rank<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo __( 'Rank', 'tudosobresites' ) ?></th>
<th class="logo-column-heading"><?php echo __( 'Provider', 'tudosobresites' ) ?></th>
<?php if ( strpos( $options['display_columns'], 'top_features' ) !== false ): ?>
<th class="top-features-column-heading<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo
__( 'Top Features', 'tudosobresites' )
?></th>
<?php endif; ?>
<?php if ( strpos( $options['display_columns'], 'disk_space' ) !== false ): ?>
<th class="disk-space-column-heading<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo
__( 'Disk Space', 'tudosobresites' );
?></th>
<?php endif; ?>
<?php if ( strpos( $options['display_columns'], 'best_for' ) !== false ): ?>
<th class="best-for-column-heading<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo
__( 'Recommended For', 'tudosobresites' );
?></th>
<?php endif; ?>
<?php if ( strpos( $options['display_columns'], 'traffic' ) !== false ): ?>
<th class="traffic-column-heading<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo
__( 'Traffic', 'tudosobresites' );
?></th>
<?php endif; ?>
<th class="rating-column-heading<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo
__( 'Overall Rating', 'tudosobresites' )
?></th>
<th class="price-column-heading<?php echo $options['is_sortable'] === 'yes' ? ' sortable' : '' ?>"><?php echo
__( 'Price from', 'tudosobresites' )
?></th>
<th class="read-more-column-heading"><?php echo
__( 'More', 'tudosobresites' )
?></th>
</tr>
</thead>
<?php
endif;
// Print table content
if ( $key === 0 ) {
?>
<tbody>
<?php
}
$provider_internal_url = get_the_permalink( $hosting_provider->ID );
$rating_unformated = get_field( 'score_review', $hosting_provider->ID, true );
$rating = number_format( $rating_unformated, 1 );
$affiliate_link = get_field( 'visit', $hosting_provider->ID, true );
$rank_link_type = trim( $options['add_link_to_rank'] );
$best_for_link_type = trim( $options['add_link_to_best_for'] );
$disk_space_link_type = trim( $options['add_link_to_disk_space'] );
$price_link_type = trim( $options['add_link_to_price'] );
$rating_link_type = trim( $options['add_link_to_rating'] );
$top_features_link_type = trim( $options['add_link_to_top_features'] );
$traffic_link_type = trim( $options['add_link_to_traffic'] );
$rank_has_link = in_array( $rank_link_type, [ 'yes', 'yes_aff' ] );
$best_for_has_link = in_array( $best_for_link_type, [ 'yes', 'yes_aff' ] );
$disk_space_has_link = in_array( $disk_space_link_type, [ 'yes', 'yes_aff' ] );
$price_has_link = in_array( $price_link_type, [ 'yes', 'yes_aff' ] );
$rating_has_link = in_array( $rating_link_type, [ 'yes', 'yes_aff' ] );
$top_features_has_link = in_array( $top_features_link_type, [ 'yes', 'yes_aff' ] );
$traffic_has_link = in_array( $traffic_link_type, [ 'yes', 'yes_aff' ] );
$url = get_permalink( $hosting_provider->ID );
$read_review_title = $link_title = sprintf( __( 'Read %s review', 'tudosobresites' ), $hosting_provider->post_title );
$check_affiliate_title = sprintf( __( 'Checkout %s offer', 'tudosobresites' ), $hosting_provider->post_title );
if ( in_array( $options['type'], [ 'list', 'mini-list' ] ) ):
?>
<tr <?php
if ( $options['type_of_loading'] === 'preload' && $options['load_more_button'] === 'on' && $options['limit'] <= $key ) {
echo 'class="hidden"';
}
?>>
<td class="rank-column">
<?php if ( $rank_has_link ): ?>
<a href="<?php echo $rank_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $rank_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $rank_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif; ?>
<?php if ( $options['show_alternatives_only'] == 'yes' ): ?>
#<?php echo $key + 1 ?>
<?php else: ?>
#<?php echo $this->get_rank( $hosting_provider, $category_object, $options ) ?>
<?php endif; ?>
<?php if ( $rank_has_link ): ?>
</a>
<?php endif; ?>
</td>
<td class="logo-column">
<a href="<?php echo $affiliate_link ?>"
title="<?php echo $hosting_provider->post_title ?>"
target="_blank"
rel="nofollow"
class="<?php echo sanitize_title( $hosting_provider->post_title ) . '-listing-logo-link' ?>"
><?php echo
wp_get_attachment_image(
get_field(
'logo',
$hosting_provider->ID,
true
)['ID'],
$options['type'] === 'mini-list' ? 'logo-size-mini' : 'logo-size-small'
)
?>
</a>
</td>
<td class="rating-column"><?php if ( $rating_has_link ): ?>
<a href="<?php echo $rating_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $rating_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $rating_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
><?php endif;
//$this->average_rating_per_category( $hosting_provider, $category_object, $options, $rating_fields );
?><?php if ( $rating_has_link ): ?></a><?php endif; ?>
</td>
<td class="read-more-column">
<?php if ( $options['add_read_review_link'] == 'yes' ): ?>
<a href="<?php echo $affiliate_link ?>"
title="<?php echo $link_title ?>"
rel="nofollow"
target="_blank"
class="regular-button-style custom<?php if ( $options['type'] === 'list' ): ?> small<?php else: ?> mini<?php endif; ?><?php echo ' ' . sanitize_title( $hosting_provider->post_title ) . '-visit-site-button' ?>"
>
<?php echo __( 'Visit Site', 'tudosobresites' ) ?>
</a>
<a
href="<?php echo $provider_internal_url ?>"
class="text-center<?php if ( $options['type'] === 'list' ): ?>font-size-14<?php else: ?>font-size-12<?php endif; ?><?php echo ' ' . sanitize_title( $hosting_provider->post_title ) . '-read-review-link' ?>"
title="<?php echo sprintf( __( 'Read %s Review', 'tudosobresites' ), $hosting_provider->post_title ) ?>"
><?php echo __( 'Read Review', 'tudosobresites' ) ?></a>
<?php else: ?>
<a href="<?php echo strpos( $url, 'http' ) !== false ?
$url :
$this->add_protocol_preamble() . $url
?>"
title="<?php echo $link_title ?>"
class="regular-button-style custom<?php if ( $options['type'] === 'list' ): ?> small<?php else: ?> mini<?php endif; ?> <?php echo ' ' . sanitize_title( $hosting_provider->post_title ) . '-read-review-link' ?>"
rel="nofollow"
><span class="type-inline"><?php echo __( 'Review', 'tudosobresites' ) ?></span></a>
<?php endif; ?>
</td>
</tr>
<?php
else:
?>
<?php $link_title = sprintf( __( 'Checkout %s offer', 'tudosobresites' ), $hosting_provider->post_title ) ?>
<tr <?php
if ( $options['type_of_loading'] === 'preload' && $options['load_more_button'] === 'on' && $options['limit'] <= $key ) {
echo 'class="hidden"';
}
?>>
<?php /* Rank Column */ ?>
<td class="rank-column size-rank"><?php if ( $rank_has_link ): ?>
<a href="<?php echo $rank_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $rank_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $rank_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif; ?>
#<?php echo( $options['show_alternatives_only'] == 'yes' ? $key : $this->get_rank( $hosting_provider, $category_object, $options ) ); ?>
<?php if ( $rank_has_link ): ?>
</a>
<?php endif; ?></td>
<?php /* Logo Column */ ?>
<td class="logo-column">
<a href="<?php echo $affiliate_link ?>"
title="<?php echo $hosting_provider->post_title ?>"
target="_blank"
rel="nofollow"
class="<?php echo sanitize_title( $hosting_provider->post_title ) . '-listing-logo-link' ?>"
>
<?php echo wp_get_attachment_image( get_field( 'logo', $hosting_provider->ID, true )['ID'], 'logo-size-small' ) ?>
</a>
</td>
<?php /* Top Features Column */ ?>
<?php if ( strpos( $options['display_columns'], 'top_features' ) !== false ): ?>
<td class="top-features-column">
<?php if ( have_rows( 'top_features', $hosting_provider->ID ) ): ?>
<ul class="features-list">
<?php $i = 0; ?>
<?php while ( have_rows( 'top_features', $hosting_provider->ID ) ): the_row( true ); ?>
<?php $i ++; ?>
<li>
<?php if ( $top_features_has_link ): ?>
<a href="<?php echo $top_features_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url; ?>"
class="<?php echo sanitize_title( $hosting_provider->post_title ) . '-listing-features-link' ?>"
title="<?php echo sprintf( __( 'See %s`s %s', 'tudosobresites' ), $hosting_provider->post_title, get_sub_field( 'feature_name' ) ) ?>"
<?php if ( $top_features_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif; ?>
<?php the_sub_field( 'feature_name' ); ?>
<?php if ( $top_features_has_link ): ?>
</a>
<?php endif; ?>
</li>
<?php if ( $i === 3 ) {
break;
} ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</td>
<?php endif; ?>
<?php /* Disk Space Column */ ?>
<?php if ( strpos( $options['display_columns'], 'disk_space' ) !== false ): ?>
<td class="disk-space-column">
<?php if ( $disk_space_has_link ): ?>
<a href="<?php echo $disk_space_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $disk_space_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $disk_space_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif;
// Its inverse, so this is right, when checked its limited, unchecked unlimited.
$unlimited_disk = get_field( 'unlimited_disk_space', $hosting_provider->ID );
$disk_space = get_field_object( 'disk_space', $hosting_provider->ID );
echo $unlimited_disk ? __( 'Unlimited', 'tudosobresites' ) : ( empty( $disk_space['value'] ) ? __( 'Unknown', 'tudosobresites' ) : $disk_space['value'] . ' ' . $disk_space['append'] );
if ( $disk_space_has_link ) {
echo "</a>";
}
?></td>
<?php endif; ?>
<?php /* Best for Column */ ?>
<?php if ( strpos( $options['display_columns'], 'best_for' ) !== false ): ?>
<td class="best-for-column"><?php
if ( $best_for_has_link ): ?>
<a href="<?php echo $best_for_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $best_for_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $best_for_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif;
$best_for = get_field( 'best_for', $hosting_provider->ID );
echo $best_for;
if ( $best_for_has_link ) {
echo "</a>";
}
?></td>
<?php endif; ?>
<?php /* Traffic Column */
if ( strpos( $options['display_columns'], 'traffic' ) !== false ): ?>
<td class="disk-space-column"><?php if ( $traffic_has_link ): ?>
<a href="<?php echo $traffic_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $traffic_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $traffic_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif;
// Its inverse, so this is right, when checked its limited, unchecked unlimited.
$unlimited = get_field( 'unlimited_traffic', $hosting_provider->ID );
$traffic = get_field_object( 'traffic', $hosting_provider->ID );
echo $unlimited ? __( 'Unlimited', 'tudosobresites' ) : ( empty( $traffic['value'] ) ? __( 'Unknown', 'tudosobresites' ) : $traffic['value'] . ' ' . $traffic['append'] );
if ( $traffic_has_link ) {
echo "</a>";
}
?></td>
<?php endif; ?>
<?php /* Rating Column */ ?>
<td class="rating-column"><?php if ( $rating_has_link ): ?>
<a href="<?php echo $rating_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $rating_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $rating_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif;
//$this->average_rating_per_category( $hosting_provider, $category_object, $options, $rating_fields );
if ( $rating_has_link ) {
echo "</a>";
}
?></td>
<?php /* Price Column */ ?>
<td class="price-column">
<span class="price-container">
<?php if ( $price_has_link ): ?>
<a href="<?php echo $price_link_type == 'yes_aff' ? $affiliate_link : $provider_internal_url ?>"
title="<?php echo $price_link_type == 'yes_aff' ? $check_affiliate_title : $read_review_title ?>"
<?php if ( $price_link_type == 'yes_aff' ): ?>
rel="nofollow"
target="_blank"
<?php endif; ?>
class="black-font"
>
<?php endif;
/**
* @var array $prices_repeater_field_value
*/
$prices_repeater_field_value = get_field( 'pricing', $hosting_provider->ID );
if ( is_array( $prices_repeater_field_value ) ) {
$prices = array_filter( get_field( 'pricing', $hosting_provider->ID ), function ( $value, $key ) use ( $category ) {
return is_object( $value['category'] ) ? strcmp( $value['category']->slug, $category ) === 0 : false;
}, ARRAY_FILTER_USE_BOTH );
usort( $prices, function ( $a, $b ) {
return $a['price'] > $b['price'];
} );
$matching_price = current( $prices );
echo $number_formatter->formatCurrency( $matching_price['price'], $matching_price['currency']['value'] );
}
?><?php
if ( $options['price_extension'] === 'yr' ): ?>
<sub>/<?php echo __( 'yr', 'tudosobresites' ); ?></sub>
<?php else: ?>
<sub>/<?php echo __( 'mo', 'tudosobresites' ); ?></sub>
<?php endif; ?>
</span>
<?php if ( $price_has_link ): ?>
</a>
<?php endif; ?>
</td>
<?php /* Read Review Column */ ?>
<td class="read-review-column text-right">
<?php if ( $options['add_read_review_link'] == 'yes' ): ?>
<a href="<?php echo $affiliate_link ?>"
title="<?php echo $check_affiliate_title ?>"
rel="nofollow"
target="_blank"
class="regular-button-style custom <?php echo sanitize_title( $hosting_provider->post_title ) . '-visit-site-button' ?>"
><?php echo __( 'Visit Site', 'tudosobresites' ) ?></a>
<a
href="<?php echo $provider_internal_url ?>"
class="text-center <?php echo sanitize_title( $hosting_provider->post_title ) . '-read-review-link' ?>"
title="<?php echo $read_review_title ?>"
><span class="display-mobile display-tablet display-small type-inline"><?php echo __( 'Review', 'tudosobresites' ) ?></span><span
class="display-desktop type-inline"><?php echo __( 'Read Review', 'tudosobresites' ) ?></span></a>
<?php else: ?>
<a href="<?php echo strpos( $url, 'http' ) !== false ?
$url :
$this->add_protocol_preamble() . $url
?>"
title="<?php echo $read_review_title ?>"
class="regular-button-style custom <?php echo sanitize_title( $hosting_provider->post_title ) . '-read-review-link' ?>"
><span class="display-mobile display-tablet display-small type-inline"><?php echo __( 'Review', 'tudosobresites' ) ?></span><span
class="display-desktop type-inline"><?php echo __( 'Read Review', 'tudosobresites' ) ?></span></a>
<?php endif; ?>
</td>
</tr>
<?php
endif;
if ( $key === $total - 1 ) {
?>
</tbody>
<?php
}
/// Print table content end
endforeach;
wp_reset_postdata();
?>
</table>
<?php
if ( $options['load_more_button'] === 'off' && ( $options['type'] === 'mini-list' || $options['enable_custom_link'] === 'yes' ) ) {
$archive_link = get_post_type_archive_link( get_post_type( $hosting_providers[0]->ID ) );
if ( ! empty( $options['custom_full_list_link'] ) ) {
$archive_link = $options['custom_full_list_link'];
}
?>
<a href="<?php echo $archive_link ?>"
class="more-info-link"
title="<?php echo empty( $options['custom_link_text'] ) ? __( 'Full Hosting Comparison', 'tudosobresites' ) : sprintf( __( 'Go to %s', 'tudosobresites' ), $options['custom_link_text'] ) ?>"
><?php echo empty( $options['custom_link_text'] ) ? __( 'Full Hosting Comparison', 'tudosobresites' ) : $options['custom_link_text'] ?></a>
<?php
} elseif ( $options['load_more_button'] === 'on' && $options['limit'] < $total ) {
?>
<a href="#"
class="more-info-link load-more-providers"
data-type_of_loading="<?php echo $options['type_of_loading'] ?>"
data-limit="<?php echo $options['limit'] ?>"
data-category="<?php echo $options['category'] ?>"
data-page="2"
data-display_columns="<?php echo $options['display_columns'] ?>"
data-type="<?php echo $options['type'] ?>"
data-order="<?php echo $options['order'] ?>"
data-orderby="<?php $options['orderby'] ?>"
data-rank_per_category="<?php echo $options['rank_per_category'] ?>"
data-show_alternatives_only="<?php echo $options['show_alternatives_only'] ?>"
data-add_read_review_link="<?php echo $options['show_alternatives_only'] ?>"
title="<?php _e( 'Load more providers', 'tudosobresites' ) ?>"
><?php _e( 'Load more', 'tudosobresites' ) ?></a>
<?php
}
?>
</div>
<?php
$html_static_output = ob_get_clean();
wp_cache_set( $static_cache_html_id, $html_static_output, 'hosting-companies-listing', 7 * 24 * 60 * 60 );
echo $html_static_output;
$this->add_scripts( $options );
}
}
}
function get_rank( $post, $category, $options ) {
if ( $options['rank_per_category'] == 'yes' ) {
while ( have_rows( 'ranking', $post->ID ) ) {
the_row( true );
$rank_category = get_sub_field( 'rank_category' );
if ( ! empty( $rank_category ) && $rank_category->term_id === $category->term_id ) {
return get_sub_field( 'rank_in_category' );
break;
}
}
}
return get_field( str_replace( '-', '_', $category->slug ) . '_rank', $post->ID );
}
function add_scripts( $options ) {
$local_uri_path = trailingslashit( str_replace( get_stylesheet_directory(), get_stylesheet_directory_uri(), dirname( __FILE__ ) ) );
$unCache = is_user_logged_in() ? '?' . uniqid() : '';
if ( $options['is_sortable'] === 'yes' && ! wp_script_is( 'table-sorting' ) ) {
wp_enqueue_script( 'table-sorting', $local_uri_path . 'assets/script.js' . $unCache, [
'jquery-core'
], '1.0', true );
}
if ( $options['load_more_button'] === 'on' && ! wp_script_is( 'hosting-companies-listing-load-more' ) ) {
wp_enqueue_script( 'hosting-companies-listing-load-more', $local_uri_path . 'assets/load-more.js' . $unCache, [
'jquery-core'
], '1.0', true );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment