Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Admin to Work with New UI #31

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
601 changes: 296 additions & 305 deletions EED_Promotions.module.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions EEW_Promotions.widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public function form($instance)

<p>
<label for="<?php echo $this->get_field_id('title'); ?>">
<?php _e('Title:', 'event_espresso'); ?>
<?php esc_html_e('Title:', 'event_espresso'); ?>
</label>
<input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" width="20" value="<?php echo $instance['title']; ?>" />
</p>
<!-- <p>-->
<!-- <label for="--><?php // echo $this->get_field_id('yes_or_no_question'); ?><!--">-->
<!-- --><?php // _e('Yes or No?', 'event_espresso'); ?>
<!-- --><?php // esc_html_e('Yes or No?', 'event_espresso'); ?>
<!-- </label>-->
<!-- --><?php
// echo EEH_Form_Fields::select(
Expand Down
16 changes: 8 additions & 8 deletions EE_Promotions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ public static function promotion_stati($stati_translation)
{
$promotion_stati = array(
EE_Promotion::upcoming => array(
__('upcoming', 'event_espresso'),
__('upcoming', 'event_espresso'),
esc_html__('upcoming', 'event_espresso'),
esc_html__('upcoming', 'event_espresso'),
),
EE_Promotion::active => array(
__('active', 'event_espresso'),
__('active', 'event_espresso'),
esc_html__('active', 'event_espresso'),
esc_html__('active', 'event_espresso'),
),
EE_Promotion::expired => array(
__('expired', 'event_espresso'),
__('expired', 'event_espresso'),
esc_html__('expired', 'event_espresso'),
esc_html__('expired', 'event_espresso'),
),
EE_Promotion::unavailable => array(
__('unavailable', 'event_espresso'),
__('unavailable', 'event_espresso'),
esc_html__('unavailable', 'event_espresso'),
esc_html__('unavailable', 'event_espresso'),
),
);
return array_merge($stati_translation, $promotion_stati);
Expand Down
12 changes: 4 additions & 8 deletions EE_Promotions_Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,9 @@ class EE_Promotions_Config extends EE_Config_Base
protected $_affects_tax = false;


/**
* constructor
*
* @return EE_Promotions_Config
*/
public function __construct()
{
add_action('AHEE__EE_Config___load_core_config__end', array($this, 'init'));
add_action('AHEE__EE_Config___load_core_config__end', array($this, 'init'), 99);
}


Expand All @@ -68,15 +63,16 @@ public function init()
if ($initialized) {
return;
}
$initialized = true;
$this->scopes = $this->_get_scopes();
$this->label = new stdClass();
$this->label->singular = apply_filters(
'FHEE__EE_Promotions_Config____construct__label_singular',
__('Promotion Code', 'event_espresso')
esc_html__('Promotion Code', 'event_espresso')
);
$this->label->plural = apply_filters(
'FHEE__EE_Promotions_Config____construct__label_plural',
__('Promotion Codes', 'event_espresso')
esc_html__('Promotion Codes', 'event_espresso')
);
}

Expand Down
102 changes: 102 additions & 0 deletions admin/promotions/PromotionsDatepicker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php


/**
* Class PromotionsDatepicker
*
* @author Brent Christensen
* @since $VID:$
*/
class PromotionsDatepicker
{
/**
* @var string
*/
private $date_string;

/**
* id of the parent container of section where datepicker input resides
*
* @var string
*/
private $container;

/**
* whether for a start or end date
*
* @var string
*/
private $context;

/**
* used for the HTML input name and id
*
* @var string
*/
private $id;

/**
* @var string
*/
private $reset_label;

/**
* @var string
*/
private $trigger_label;


/**
* @param string $date_string
* @param string $context
* @param string $container
* @param string $id
* @param string $trigger_label
*/
public function __construct(
string $date_string,
string $context,
string $container,
string $id,
string $trigger_label
) {
$this->date_string = $date_string;
$this->context = $context;
$this->container = $container;
$this->id = $id;
$this->trigger_label = $trigger_label;
$this->reset_label = esc_html__('reset date input', 'event_espresso');
}


public function getHtml(): string
{
return "
<div class='ee-input-sidebar__wrapper'>
<div class='ee-input-sidebar ee-input-sidebar--after'>
<input type='text'
data-context='$this->context'
data-container='$this->container'
class='ee-input-width--reg ee-datepicker'
id='$this->id'
name='$this->id'
value='$this->date_string'
>
<button class='button button--secondary button--icon-only ee-aria-tooltip ee-toggle-datepicker'
aria-label='$this->trigger_label'
data-target='#$this->id'
onclick='return false'
tabindex='-1'
>
<span class='dashicons dashicons-calendar' ></span >
</button >
</div >
<button class='button button--secondary button--icon-only ee-aria-tooltip clear-dtt'
aria-label='$this->reset_label'
data-field='#$this->id'
>
<span class='dashicons dashicons-editor-removeformatting' ></span >
</button >
</div >";
}
}
38 changes: 19 additions & 19 deletions admin/promotions/Promotions_Admin_List_Table.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ protected function _setup_data()
protected function _set_properties()
{
$this->_wp_list_args = array(
'singular' => __('Promotion', 'event_espresso'),
'plural' => __('Promotion', 'event_espresso'),
'singular' => esc_html__('Promotion', 'event_espresso'),
'plural' => esc_html__('Promotion', 'event_espresso'),
'ajax' => true,
'screen' => $this->_admin_page->get_current_screen()->id
);

$this->_columns = array(
'cb' => '<input type="checkbox" />',
'id' => __('ID', 'event_espresso'),
'name' => __('Name', 'event_espresso'),
'code' => __('Code', 'event_espresso'),
'applies_to' => __('Applies To', 'event_espresso'),
'valid_from' => __('Valid From', 'event_espresso'),
'valid_until' => __('Valid Until', 'event_espresso'),
'amount' => __('Discount', 'event_espresso'),
'redeemed' => __('Uses', 'event_espresso'),
'attributes' => '<span class="small-text">' . __('Attributes', 'event_espresso') . '</span >',
'actions' => __('Actions', 'event_espresso')
'id' => esc_html__('ID', 'event_espresso'),
'name' => esc_html__('Name', 'event_espresso'),
'code' => esc_html__('Code', 'event_espresso'),
'applies_to' => esc_html__('Applies To', 'event_espresso'),
'valid_from' => esc_html__('Valid From', 'event_espresso'),
'valid_until' => esc_html__('Valid Until', 'event_espresso'),
'amount' => esc_html__('Discount', 'event_espresso'),
'redeemed' => esc_html__('Uses', 'event_espresso'),
'attributes' => '<span class="small-text">' . esc_html__('Attributes', 'event_espresso') . '</span >',
'actions' => esc_html__('Actions', 'event_espresso')
);

$this->_primary_column = 'ID';
Expand Down Expand Up @@ -112,7 +112,7 @@ public function column_id(EE_Promotion $item)
public function column_name(EE_Promotion $item)
{
$edit_link = EEH_URL::add_query_args_and_nonce(array( 'action' => 'edit', 'PRO_ID' => $item->ID() ), EE_PROMOTIONS_ADMIN_URL);
$content = EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID()) ? '<a href="' . $edit_link . '" title="' . __('Edit Promotion', 'event_espresso') . '">' . $item->name() . '</a>' : $item->name();
$content = EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID()) ? '<a href="' . $edit_link . '" title="' . esc_html__('Edit Promotion', 'event_espresso') . '">' . $item->name() . '</a>' : $item->name();
$content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status(), false, 'sentence') . '</span>';
return $content;
}
Expand All @@ -134,8 +134,8 @@ public function column_applies_to(EE_Promotion $item)

public function column_attributes(EE_Promotion $item)
{
echo $item->is_exclusive() ? '<span class="dashicons dashicons-awards" title="' . __('Exclusive Promotion - can NOT be combined with others', 'event_espresso') . '"></span>' : '';
echo $item->is_global() ? '<span class="dashicons dashicons-admin-site" title="' . __('Global Promotion - applies to ALL scope items', 'event_espresso') . '"></span>' : '';
echo $item->is_exclusive() ? '<span class="dashicons dashicons-awards" title="' . esc_html__('Exclusive Promotion - can NOT be combined with others', 'event_espresso') . '"></span>' : '';
echo $item->is_global() ? '<span class="dashicons dashicons-admin-site" title="' . esc_html__('Global Promotion - applies to ALL scope items', 'event_espresso') . '"></span>' : '';
}


Expand Down Expand Up @@ -206,11 +206,11 @@ public function column_actions(EE_Promotion $item)
$edit_link = EEH_URL::add_query_args_and_nonce($edit_query_args, EE_PROMOTIONS_ADMIN_URL);
$dupe_link = EEH_URL::add_query_args_and_nonce($dupe_query_args, EE_PROMOTIONS_ADMIN_URL);
if (EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID())) {
$action_links[] = '<a href="' . $edit_link . '" title="' . __('Edit Promotion', 'event_espresso') . '"><div class="dashicons dashicons-edit clickable ee-icon-size-20"></div></a>';
$action_links[] = '<a href="' . $edit_link . '" title="' . esc_html__('Edit Promotion', 'event_espresso') . '"><div class="dashicons dashicons-edit clickable ee-icon-size-20"></div></a>';
}

if (EE_Registry::instance()->CAP->current_user_can('ee_edit_promotion', 'espresso_promotions_edit_promotion', $item->ID())) {
$action_links[] = '<a href="' . $dupe_link. '" title="' . __('Duplicate Promotion', 'event_espresso') . '"><div class="ee-icon ee-icon-clone clickable ee-icon-size-16"></div></a>';
$action_links[] = '<a href="' . $dupe_link. '" title="' . esc_html__('Duplicate Promotion', 'event_espresso') . '"><div class="ee-icon ee-icon-clone clickable ee-icon-size-16"></div></a>';
}
} else {
$restore_query_args = array(
Expand All @@ -219,7 +219,7 @@ public function column_actions(EE_Promotion $item)
);
$restore_link = EEH_URL::add_query_args_and_nonce($restore_query_args, EE_PROMOTIONS_ADMIN_URL);
if (EE_Registry::instance()->CAP->current_user_can('ee_delete_promotion', 'espresso_promotions_delete_promotion', $item->ID())) {
$action_links[] = '<a href="' . $restore_link. '" title="' . __('Restore Promotion', 'event_espresso') . '"><div class="dashicons dashicons-backup ee-icon-size-18"></div></a>';
$action_links[] = '<a href="' . $restore_link. '" title="' . esc_html__('Restore Promotion', 'event_espresso') . '"><div class="dashicons dashicons-backup ee-icon-size-18"></div></a>';
}
}

Expand All @@ -228,7 +228,7 @@ public function column_actions(EE_Promotion $item)
'PRO_ID' => $item->ID()
);
$trash_link = EEH_URL::add_query_args_and_nonce($trash_query_args, EE_PROMOTIONS_ADMIN_URL);
$trash_text = $this->_view == 'trash' ? __('Delete Promotion permanently', 'event_espresso') : __('Trash Promotion', 'event_espresso');
$trash_text = $this->_view == 'trash' ? esc_html__('Delete Promotion permanently', 'event_espresso') : esc_html__('Trash Promotion', 'event_espresso');
$trash_class = $this->_view == 'trash' ? ' red-icon' : '';
if (EE_Registry::instance()->CAP->current_user_can('ee_delete_promotion', 'espresso_promotions_delete_promotion', $item->ID())) {
$action_links[] = $this->_view == 'trash' && $item->redeemed() > 0 ? '' : '<a href="' . $trash_link . '" title="' . $trash_text . '"><div class="dashicons dashicons-trash clickable ee-icon-size-18' . $trash_class . '"></div></a>';
Expand Down
Loading