Use new code style
This commit is contained in:
@ -34,17 +34,18 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct(array(
|
||||
'singular' => __('Broadcast', 'wp-ultimo'), // singular name of the listed records
|
||||
'plural' => __('Broadcasts', 'wp-ultimo'), // plural name of the listed records
|
||||
'ajax' => true, // does this table support ajax?
|
||||
'add_new' => array(
|
||||
'url' => wu_get_form_url('add_new_broadcast_message'),
|
||||
'classes' => 'wubox',
|
||||
),
|
||||
));
|
||||
|
||||
} // end __construct;
|
||||
parent::__construct(
|
||||
array(
|
||||
'singular' => __('Broadcast', 'wp-ultimo'), // singular name of the listed records
|
||||
'plural' => __('Broadcasts', 'wp-ultimo'), // plural name of the listed records
|
||||
'ajax' => true, // does this table support ajax?
|
||||
'add_new' => array(
|
||||
'url' => wu_get_form_url('add_new_broadcast_message'),
|
||||
'classes' => 'wubox',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the checkbox column to disable the checkboxes on the email types.
|
||||
@ -57,14 +58,11 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
public function column_cb($item) {
|
||||
|
||||
if ($item->get_type() === 'broadcast_email') {
|
||||
|
||||
return '<input type="checkbox" disabled>';
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
return parent::column_cb($item);
|
||||
|
||||
} // end column_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the markup for the type column.
|
||||
@ -81,40 +79,27 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$class = 'wu-bg-gray-200';
|
||||
|
||||
if ($type === 'broadcast_email') {
|
||||
|
||||
$label = __('Email', 'wp-ultimo');
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
if ($type === 'broadcast_notice') {
|
||||
|
||||
$status = $item->get_notice_type();
|
||||
|
||||
$label = __('Notice', 'wp-ultimo');
|
||||
|
||||
if ($status === 'info') {
|
||||
|
||||
$class = 'wu-bg-blue-200';
|
||||
|
||||
} elseif ($status === 'success') {
|
||||
|
||||
$class = 'wu-bg-green-200';
|
||||
|
||||
} elseif ($status === 'warning') {
|
||||
|
||||
$class = 'wu-bg-orange-200';
|
||||
|
||||
} elseif ($status === 'error') {
|
||||
|
||||
$class = 'wu-bg-red-200';
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
}
|
||||
|
||||
return "<span class='wu-py-1 wu-px-2 $class wu-rounded-sm wu-text-gray-700 wu-text-xs wu-font-mono'>{$label}</span>";
|
||||
|
||||
} // end column_type;
|
||||
}
|
||||
/**
|
||||
* Displays the name of the broadcast.
|
||||
*
|
||||
@ -131,7 +116,7 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$url_atts = array(
|
||||
'id' => $item->get_id(),
|
||||
'slug' => $item->get_slug(),
|
||||
'model' => 'broadcast'
|
||||
'model' => 'broadcast',
|
||||
);
|
||||
|
||||
$actions = array(
|
||||
@ -140,8 +125,7 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
);
|
||||
|
||||
return $title . $content . $this->row_actions($actions);
|
||||
|
||||
} // end column_the_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the target customers of the broadcast.
|
||||
@ -182,10 +166,16 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
|
||||
$customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
|
||||
|
||||
$avatar = get_avatar($customer->get_user_id(), 32, 'identicon', '', array(
|
||||
'force_display' => true,
|
||||
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
|
||||
));
|
||||
$avatar = get_avatar(
|
||||
$customer->get_user_id(),
|
||||
32,
|
||||
'identicon',
|
||||
'',
|
||||
array(
|
||||
'force_display' => true,
|
||||
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
|
||||
)
|
||||
);
|
||||
|
||||
$display_name = $customer->get_display_name();
|
||||
|
||||
@ -205,16 +195,21 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
break;
|
||||
default:
|
||||
foreach ($targets as $key => $target) {
|
||||
|
||||
$customer = $target;
|
||||
|
||||
$tooltip_name = $customer->get_display_name();
|
||||
|
||||
$email = $customer->get_email_address();
|
||||
|
||||
$avatar = get_avatar($email, 32, 'identicon', '', array(
|
||||
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
|
||||
));
|
||||
$avatar = get_avatar(
|
||||
$email,
|
||||
32,
|
||||
'identicon',
|
||||
'',
|
||||
array(
|
||||
'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400',
|
||||
)
|
||||
);
|
||||
|
||||
$url_atts = array(
|
||||
'id' => $customer->get_id(),
|
||||
@ -223,11 +218,9 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts);
|
||||
|
||||
$html .= "<div class='wu-flex wu--mr-4'><a role='tooltip' aria-label='{$tooltip_name}' href='{$customer_link}'>{$avatar}</a></div>";
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
|
||||
if ($targets_count < 7) {
|
||||
|
||||
$modal_atts = array(
|
||||
'action' => 'wu_modal_targets_display',
|
||||
'object_id' => $item->get_id(),
|
||||
@ -236,15 +229,20 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
'target_type' => 'customers',
|
||||
);
|
||||
|
||||
$html .= sprintf('<div class="wu-inline-block wu-mr-2">
|
||||
$html .= sprintf(
|
||||
'<div class="wu-inline-block wu-mr-2">
|
||||
<a href="%s" title="%s" class="wubox"><span class="wu-ml-6 wu-uppercase wu-text-xs wu-font-bold"> %s %s</span></a>
|
||||
</div>', wu_get_form_url('view_broadcast_targets', $modal_atts), __('Targets', 'wp-ultimo'), $targets_count, __('Targets', 'wp-ultimo'));
|
||||
</div>',
|
||||
wu_get_form_url('view_broadcast_targets', $modal_atts),
|
||||
__('Targets', 'wp-ultimo'),
|
||||
$targets_count,
|
||||
__('Targets', 'wp-ultimo')
|
||||
);
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$modal_atts = array(
|
||||
'action' => 'wu_modal_targets_display',
|
||||
@ -254,19 +252,23 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
'target_type' => 'customers',
|
||||
);
|
||||
|
||||
$html .= sprintf('<div class="wu-inline-block wu-ml-4">
|
||||
$html .= sprintf(
|
||||
'<div class="wu-inline-block wu-ml-4">
|
||||
<a href="%s" title="%s" class="wubox"><span class="wu-pl-2 wu-uppercase wu-text-xs wu-font-bold"> %s %s</span></a>
|
||||
</div>', wu_get_form_url('view_broadcast_targets', $modal_atts), __('Targets', 'wp-ultimo'), $targets_count, __('Targets', 'wp-ultimo'));
|
||||
</div>',
|
||||
wu_get_form_url('view_broadcast_targets', $modal_atts),
|
||||
__('Targets', 'wp-ultimo'),
|
||||
$targets_count,
|
||||
__('Targets', 'wp-ultimo')
|
||||
);
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
break;
|
||||
|
||||
} // end switch;
|
||||
|
||||
} // end column_target_customers;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the target products of the broadcast.
|
||||
@ -303,16 +305,12 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$image = $product->get_featured_image('thumbnail');
|
||||
|
||||
if ($image) {
|
||||
|
||||
$image = sprintf('<img class="wu-w-7 wu-h-7 wu-bg-gray-200 wu-rounded-full wu-text-gray-600 wu-flex wu-items-center wu-justify-center wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400" src="%s">', esc_attr($image));
|
||||
|
||||
} else {
|
||||
|
||||
$image = '<div class="wu-w-7 wu-h-7 wu-bg-gray-200 wu-rounded-full wu-text-gray-600 wu-flex wu-items-center wu-justify-center wu-border-solid wu-border-1 wu-border-white">
|
||||
<span class="dashicons-wu-image"></span>
|
||||
</div>';
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$name = $product->get_name();
|
||||
|
||||
@ -323,10 +321,8 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$customer_count = (int) 0;
|
||||
|
||||
if ($plan_customers) {
|
||||
|
||||
$customer_count = count($plan_customers);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$description = sprintf(__('%s customer(s) targeted.', 'wp-ultimo'), $customer_count);
|
||||
|
||||
@ -344,19 +340,15 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
</div>
|
||||
</a>";
|
||||
break;
|
||||
|
||||
} // end switch;
|
||||
}
|
||||
|
||||
if ($html) {
|
||||
|
||||
return $html;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$html = '<div class="wu-p-2 wu-mr-1 wu-flex wu-rounded wu-items-center wu-border wu-border-solid wu-border-gray-300 wu-bg-gray-100 wu-relative wu-overflow-hidden">';
|
||||
|
||||
foreach ($products as $product) {
|
||||
|
||||
$url_atts = array(
|
||||
'id' => $product->get_id(),
|
||||
);
|
||||
@ -368,23 +360,17 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$image = $product->get_featured_image('thumbnail');
|
||||
|
||||
if ($image) {
|
||||
|
||||
$image = sprintf('<img class="wu-w-7 wu-h-7 wu-bg-gray-200 wu-rounded-full wu-text-gray-600 wu-flex wu-items-center wu-justify-center wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400" src="%s">', esc_attr($image));
|
||||
|
||||
} else {
|
||||
|
||||
$image = '<div class="wu-w-7 wu-h-7 wu-bg-gray-200 wu-rounded-full wu-text-gray-600 wu-flex wu-items-center wu-justify-center wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400">
|
||||
<span class="dashicons-wu-image wu-p-1 wu-rounded-full"></span>
|
||||
</div>';
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$html .= "<div class='wu-flex wu--mr-4'><a role='tooltip' aria-label='{$product_name}' href='{$product_link}'>{$image}</a></div>";
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
|
||||
if ($product_count > 1 && $product_count < 5) {
|
||||
|
||||
$modal_atts = array(
|
||||
'action' => 'wu_modal_targets_display',
|
||||
'object_id' => $item->get_id(),
|
||||
@ -393,14 +379,19 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
'target_type' => 'products',
|
||||
);
|
||||
|
||||
$html .= sprintf('<div class="wu-inline-block wu-ml-4">
|
||||
<a href="%s" title="%s" class="wubox"><span class="wu-pl-2 wu-uppercase wu-text-xs wu-font-bold"> %s %s</span></a></div>', wu_get_form_url('view_broadcast_targets', $modal_atts), __('Targets', 'wp-ultimo'), $product_count, __('Targets', 'wp-ultimo'));
|
||||
$html .= sprintf(
|
||||
'<div class="wu-inline-block wu-ml-4">
|
||||
<a href="%s" title="%s" class="wubox"><span class="wu-pl-2 wu-uppercase wu-text-xs wu-font-bold"> %s %s</span></a></div>',
|
||||
wu_get_form_url('view_broadcast_targets', $modal_atts),
|
||||
__('Targets', 'wp-ultimo'),
|
||||
$product_count,
|
||||
__('Targets', 'wp-ultimo')
|
||||
);
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$modal_atts = array(
|
||||
'action' => 'wu_modal_targets_display',
|
||||
@ -415,8 +406,7 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
} // end column_target_products;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of columns for this particular List Table.
|
||||
@ -437,8 +427,7 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
);
|
||||
|
||||
return $columns;
|
||||
|
||||
} // end get_columns;
|
||||
}
|
||||
/**
|
||||
* Returns the filters for this page.
|
||||
*
|
||||
@ -472,8 +461,7 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
} // end get_filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the necessary scripts and styles for this admin page.
|
||||
@ -484,8 +472,7 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
public function register_scripts() {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
} // end register_scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pre-selected filters on the filter bar.
|
||||
@ -515,7 +502,5 @@ class Broadcast_List_Table extends Base_List_Table {
|
||||
'count' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
} // end get_views;
|
||||
|
||||
} // end class Broadcast_List_Table;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user