@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The abstract class for a admin page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
abstract class Ai1ec_View_Admin_Abstract extends Ai1ec_Base {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_page_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_page_suffix;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_api_registration;
|
||||
|
||||
/**
|
||||
* Standard constructor
|
||||
*
|
||||
* @param Ai1ec_Registry_Object $registry
|
||||
*/
|
||||
public function __construct( Ai1ec_Registry_Object $registry ) {
|
||||
parent::__construct( $registry );
|
||||
$exploded_class = explode( '_', get_class( $this ) );
|
||||
$this->_page_suffix = strtolower( end( $exploded_class ) );
|
||||
$this->_api_registration = $this->_registry->get( 'model.api.api-registration' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the url of the page
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_url() {
|
||||
return add_query_arg(
|
||||
array(
|
||||
'post_type' => AI1EC_POST_TYPE,
|
||||
'page' => AI1EC_PLUGIN_NAME . '-' . $this->_page_suffix,
|
||||
),
|
||||
ai1ec_admin_url( 'edit.php' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the page to the correct menu.
|
||||
*/
|
||||
abstract public function add_page();
|
||||
|
||||
/**
|
||||
* Adds the page to the correct menu.
|
||||
*/
|
||||
abstract public function add_meta_box();
|
||||
|
||||
/**
|
||||
* Display the page html
|
||||
*/
|
||||
abstract public function display_page();
|
||||
|
||||
/**
|
||||
* Handle post, likely to be deprecated to use commands.
|
||||
*/
|
||||
abstract public function handle_post();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Event create/update form backend view layer.
|
||||
*
|
||||
* Manage creation of boxes (containers) for our control elements
|
||||
* and instantiating, as well as updating them.
|
||||
*
|
||||
* @author Time.ly Network, Inc.
|
||||
* @since 2.0
|
||||
* @package Ai1EC
|
||||
* @subpackage Ai1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Add_New_Event extends Ai1ec_Base {
|
||||
|
||||
/**
|
||||
* Create hook to display event meta box when creating or editing an event.
|
||||
*
|
||||
* @wp_hook add_meta_boxes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function event_meta_box_container() {
|
||||
add_meta_box(
|
||||
AI1EC_POST_TYPE,
|
||||
Ai1ec_I18n::__( 'Event Details' ),
|
||||
array( $this, 'meta_box_view' ),
|
||||
AI1EC_POST_TYPE,
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
|
||||
add_meta_box(
|
||||
AI1EC_POST_TYPE . '_features',
|
||||
Ai1ec_I18n::__( 'Empower your calendar, build your community' ),
|
||||
array( $this, 'features_info' ),
|
||||
AI1EC_POST_TYPE,
|
||||
'side',
|
||||
'low'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Event Details meta box to the Add/Edit Event screen in the dashboard.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function features_info( $post ) {
|
||||
$message = __(
|
||||
'<ul class="ai1ec-features-list"><li><a href="https://time.ly/hub" target="_blank">Pull events from other calendars</a></li><li><a href="https://time.ly/hub" target="_blank">Pull events from Facebook</a></li><li><a href="https://time.ly/hub" target="_blank">Add a Newsletter</a></li><li><a href="https://time.ly/hub" target="_blank">Get public event submissions</a></li><li><a href="https://time.ly/hub" target="_blank">Charge people to post events</a></li><li><a href="https://time.ly/hub" target="_blank">Add social sharing</a></li><li><a href="https://time.ly/hub" target="_blank">And more</a></li></ul>',
|
||||
AI1EC_PLUGIN_NAME
|
||||
);
|
||||
|
||||
echo $message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Event Details meta box to the Add/Edit Event screen in the dashboard.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function meta_box_view( $post ) {
|
||||
|
||||
$theme_loader = $this->_registry->get( 'theme.loader' );
|
||||
$empty_event = $this->_registry->get( 'model.event' );
|
||||
|
||||
// ==================
|
||||
// = Default values =
|
||||
// ==================
|
||||
// ATTENTION - When adding new fields to the event remember that you must
|
||||
// also set up the duplicate-controller.
|
||||
// TODO: Fix this duplication.
|
||||
$all_day_event = '';
|
||||
$instant_event = '';
|
||||
$start = $this->_registry->get( 'date.time' );
|
||||
$end = $this->_registry->get( 'date.time', '+1 hour' );
|
||||
$timezone_name = null;
|
||||
$timezones_list = $this->_registry->get( 'date.timezone' )->get_timezones( true );
|
||||
$show_map = false;
|
||||
$google_map = '';
|
||||
$venue = '';
|
||||
$country = '';
|
||||
$address = '';
|
||||
$city = '';
|
||||
$province = '';
|
||||
$postal_code = '';
|
||||
$contact_name = '';
|
||||
$contact_phone = '';
|
||||
$contact_email = '';
|
||||
$contact_url = '';
|
||||
$cost = '';
|
||||
$is_free = '';
|
||||
$cost_type = 'free';
|
||||
$rrule = '';
|
||||
$rrule_text = '';
|
||||
$repeating_event = false;
|
||||
$exrule = '';
|
||||
$exrule_text = '';
|
||||
$exclude_event = false;
|
||||
$exdate = '';
|
||||
$show_coordinates = false;
|
||||
$longitude = '';
|
||||
$latitude = '';
|
||||
$coordinates = '';
|
||||
$ticket_url = '';
|
||||
|
||||
$instance_id = false;
|
||||
if ( isset( $_REQUEST['instance'] ) ) {
|
||||
$instance_id = absint( $_REQUEST['instance'] );
|
||||
}
|
||||
if ( $instance_id ) {
|
||||
add_filter(
|
||||
'print_scripts_array',
|
||||
array( $this, 'disable_autosave' )
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
// on some php version, nested try catch blocks fail and the exception would never be caught.
|
||||
// this is why we use this approach.
|
||||
$excpt = null;
|
||||
$event = null;
|
||||
try {
|
||||
$event = $this->_registry->get(
|
||||
'model.event',
|
||||
get_the_ID(),
|
||||
$instance_id
|
||||
);
|
||||
} catch ( Ai1ec_Event_Not_Found_Exception $excpt ) {
|
||||
$ai1ec_localization_helper = $this->_registry
|
||||
->get( 'p28n.wpml' );
|
||||
$translatable_id = $ai1ec_localization_helper
|
||||
->get_translatable_id();
|
||||
if ( false !== $translatable_id ) {
|
||||
$event = $this->_registry->get(
|
||||
'model.event',
|
||||
$translatable_id,
|
||||
$instance_id
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( null !== $excpt ) {
|
||||
throw $excpt;
|
||||
}
|
||||
|
||||
// Existing event was found. Initialize form values with values from
|
||||
// event object.
|
||||
$all_day_event = $event->is_allday() ? 'checked' : '';
|
||||
$instant_event = $event->is_instant() ? 'checked' : '';
|
||||
|
||||
$start = $event->get( 'start' );
|
||||
$end = $event->get( 'end' );
|
||||
$timezone_name = $event->get( 'timezone_name' );
|
||||
|
||||
$multi_day = $event->is_multiday();
|
||||
|
||||
$show_map = $event->get( 'show_map' );
|
||||
$google_map = $show_map ? 'checked="checked"' : '';
|
||||
|
||||
$show_coordinates = $event->get( 'show_coordinates' );
|
||||
$coordinates = $show_coordinates ? 'checked="checked"' : '';
|
||||
$longitude = (float)$event->get( 'longitude', 0 );
|
||||
$latitude = (float)$event->get( 'latitude', 0 );
|
||||
// There is a known bug in Wordpress (https://core.trac.wordpress.org/ticket/15158) that saves 0 to the DB instead of null.
|
||||
// We handle a special case here to avoid having the fields with a value of 0 when the user never inputted any coordinates
|
||||
if ( ! $show_coordinates ) {
|
||||
$longitude = '';
|
||||
$latitude = '';
|
||||
}
|
||||
|
||||
$venue = $event->get( 'venue' );
|
||||
$country = $event->get( 'country' );
|
||||
$address = $event->get( 'address' );
|
||||
$city = $event->get( 'city' );
|
||||
$province = $event->get( 'province' );
|
||||
$postal_code = $event->get( 'postal_code' );
|
||||
$contact_name = $event->get( 'contact_name' );
|
||||
$contact_phone = $event->get( 'contact_phone' );
|
||||
$contact_email = $event->get( 'contact_email' );
|
||||
$contact_url = $event->get( 'contact_url' );
|
||||
$cost = $event->get( 'cost' );
|
||||
$ticket_url = $event->get( 'ticket_url' );
|
||||
$rrule = $event->get( 'recurrence_rules' );
|
||||
$exrule = $event->get( 'exception_rules' );
|
||||
$exdate = $event->get( 'exception_dates' );
|
||||
$repeating_event = ! empty( $rrule );
|
||||
$exclude_event = ! empty( $exrule );
|
||||
|
||||
$is_free = '';
|
||||
$free = $event->is_free();
|
||||
if ( ! empty( $free ) ) {
|
||||
$is_free = 'checked="checked" ';
|
||||
$cost = '';
|
||||
}
|
||||
|
||||
if ( $repeating_event ) {
|
||||
$rrule_text = ucfirst(
|
||||
$this->_registry->get( 'recurrence.rule' )
|
||||
->rrule_to_text( $rrule )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $exclude_event ) {
|
||||
$exrule_text = ucfirst(
|
||||
$this->_registry->get( 'recurrence.rule' )
|
||||
->rrule_to_text( $exrule )
|
||||
);
|
||||
}
|
||||
} catch ( Ai1ec_Event_Not_Found_Exception $excpt ) {
|
||||
// Event does not exist.
|
||||
// Leave form fields undefined (= zero-length strings)
|
||||
$event = null;
|
||||
}
|
||||
|
||||
// Time zone; display if set.
|
||||
$timezone = '';
|
||||
$timezone_string = null;
|
||||
$date_timezone = $this->_registry->get( 'date.timezone' );
|
||||
|
||||
if (
|
||||
! empty( $timezone_name ) &&
|
||||
$local_name = $date_timezone->get_name( $timezone_name )
|
||||
) {
|
||||
$timezone_string = $local_name;
|
||||
}
|
||||
if ( null === $timezone_string ) {
|
||||
$timezone_string = $date_timezone->get_default_timezone();
|
||||
}
|
||||
|
||||
if ( $timezone_string ) {
|
||||
$timezone = $this->_registry->get( 'date.system' )
|
||||
->get_gmt_offset_expr( $timezone_string );
|
||||
}
|
||||
|
||||
if ( empty( $timezone_name ) ) {
|
||||
/**
|
||||
* Actual Olsen timezone name is used when value is to be directly
|
||||
* exposed to user in some mean. It's possible to use named const.
|
||||
* `'sys.default'` only when passing value to date.time library.
|
||||
*/
|
||||
$timezone_name = $date_timezone->get_default_timezone();
|
||||
}
|
||||
|
||||
// This will store each of the accordion tabs' markup, and passed as an
|
||||
// argument to the final view.
|
||||
$boxes = array();
|
||||
$parent_event_id = null;
|
||||
if ( $event ) {
|
||||
$parent_event_id = $this->_registry->get( 'model.event.parent' )
|
||||
->event_parent( $event->get( 'post_id' ) );
|
||||
}
|
||||
// ===============================
|
||||
// = Display event time and date =
|
||||
// ===============================
|
||||
$args = array(
|
||||
'all_day_event' => $all_day_event,
|
||||
'instant_event' => $instant_event,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'repeating_event' => $repeating_event,
|
||||
'rrule' => $rrule,
|
||||
'rrule_text' => $rrule_text,
|
||||
'exclude_event' => $exclude_event,
|
||||
'exrule' => $exrule,
|
||||
'exrule_text' => $exrule_text,
|
||||
'timezone' => $timezone,
|
||||
'timezone_string' => $timezone_string,
|
||||
'timezone_name' => $timezone_name,
|
||||
'exdate' => $exdate,
|
||||
'parent_event_id' => $parent_event_id,
|
||||
'instance_id' => $instance_id,
|
||||
'timezones_list' => $timezones_list,
|
||||
);
|
||||
|
||||
$boxes[] = $theme_loader
|
||||
->get_file( 'box_time_and_date.php', $args, true )
|
||||
->get_content();
|
||||
|
||||
// =================================================
|
||||
// = Display event location details and Google map =
|
||||
// =================================================
|
||||
$args = array(
|
||||
'select_venue' => apply_filters( 'ai1ec_admin_pre_venue_html', '' ),
|
||||
'save_venue' => apply_filters( 'ai1ec_admin_post_venue_html', '' ),
|
||||
'venue' => $venue,
|
||||
'country' => $country,
|
||||
'address' => $address,
|
||||
'city' => $city,
|
||||
'province' => $province,
|
||||
'postal_code' => $postal_code,
|
||||
'google_map' => $google_map,
|
||||
'show_map' => $show_map,
|
||||
'show_coordinates' => $show_coordinates,
|
||||
'longitude' => $longitude,
|
||||
'latitude' => $latitude,
|
||||
'coordinates' => $coordinates,
|
||||
);
|
||||
$boxes[] = $theme_loader
|
||||
->get_file( 'box_event_location.php', $args, true )
|
||||
->get_content();
|
||||
|
||||
// ===================================
|
||||
// = Display event ticketing options =
|
||||
// ===================================
|
||||
if ( $event ) {
|
||||
$cost_type = get_post_meta(
|
||||
$event->get( 'post_id' ),
|
||||
'_ai1ec_cost_type',
|
||||
true
|
||||
);
|
||||
if ( ! $cost_type ) {
|
||||
if ( $ticket_url || $cost ) {
|
||||
$cost_type = 'external';
|
||||
} else {
|
||||
$cost_type = 'free';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
$api_reg = $this->_registry->get( 'model.api.api-registration' );
|
||||
$ticketing = $api_reg->is_signed() && $api_reg->is_ticket_available() && $api_reg->is_ticket_enabled();
|
||||
$message = $api->get_sign_message();
|
||||
$ticket_error = null;
|
||||
$ticket_event_imported = false;
|
||||
$tickets = array( null );
|
||||
$tax_options = null;
|
||||
|
||||
if ( ! $api_reg->is_ticket_available() ) {
|
||||
$message = __(
|
||||
'Ticketing is currently not available for this website. Please, try again later.',
|
||||
AI1EC_PLUGIN_NAME
|
||||
);
|
||||
} else if ( ! $api_reg->is_ticket_enabled() ) {
|
||||
$message = __(
|
||||
'Timely Ticketing saves time & money. Create ticketing/registration right here and now. You do not pay any ticketing fees (other than regular PayPal transaction costs). Create as many ticketing/registration as you\'d like.<br /><br />Ticketing feature is not enabled for this website. Please sign up for Ticketing plan <a href="https://time.ly/tickets-existing-users/" target="_blank">here</a>.',
|
||||
AI1EC_PLUGIN_NAME
|
||||
);
|
||||
}
|
||||
|
||||
if ( $event ) {
|
||||
$is_ticket_event = ! is_null( $api->get_api_event_id( $event->get( 'post_id' ) ) );
|
||||
$ticket_event_account = $api->get_api_event_account( $event->get( 'post_id' ) );
|
||||
$ticket_event_imported = $api->is_ticket_event_imported( $event->get( 'post_id' ) );
|
||||
if ( $ticketing || $ticket_event_imported ) {
|
||||
if ( 'tickets' === $cost_type ) {
|
||||
if ( $ticket_event_imported ) {
|
||||
$response = json_decode( $api->get_ticket_types( $event->get( 'post_id' ) ) );
|
||||
if ( isset( $response->data ) && 0 < count( $response->data ) ) {
|
||||
$tickets = array_merge( $tickets, $response->data );
|
||||
}
|
||||
if ( isset( $response->error ) ) {
|
||||
$ticket_error = $response->error;
|
||||
}
|
||||
} else {
|
||||
$response = $api->get_event( $event->get( 'post_id' ) );
|
||||
if ( isset( $response->data ) && 0 < count( $response->data ) ) {
|
||||
$tickets = array_merge( $tickets, $response->data->ticket_types );
|
||||
$tax_options = $response->data->tax_options;
|
||||
}
|
||||
if ( isset( $response->error ) ) {
|
||||
$ticket_error = $response->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
$uid = $event->get_uid();
|
||||
} else {
|
||||
$uid = $empty_event->get_uid();
|
||||
}
|
||||
$uid = $event->get_uid();
|
||||
} else {
|
||||
$is_ticket_event = false;
|
||||
$ticket_event_account = '';
|
||||
$uid = $empty_event->get_uid();
|
||||
}
|
||||
|
||||
if ( $ticketing ) {
|
||||
if ( $event ) {
|
||||
$ticket_currency = $api->get_api_event_currency( $event->get( 'post_id' ) );
|
||||
if ( $api->is_ticket_event_from_another_account( $event->get( 'post_id' ) ) ) {
|
||||
$ticket_error = sprintf(
|
||||
__( 'This Event was created using a different account %s. Changes are not allowed.', AI1EC_PLUGIN_NAME ),
|
||||
$api->get_api_event_account( $event->get( 'post_id' ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( ! isset( $ticket_currency ) || is_null( $ticket_currency ) ) {
|
||||
//for new ticket events get the currency from the payments settings
|
||||
$payments_settings = $api->get_payment_settings();
|
||||
if ( null !== $payments_settings ) {
|
||||
$ticket_currency = $payments_settings['currency'];
|
||||
} else {
|
||||
$ticket_currency = 'USD';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ticket_currency = '';
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'cost' => $cost,
|
||||
'cost_type' => $cost_type,
|
||||
'ticket_url' => $ticket_url,
|
||||
'event' => $empty_event,
|
||||
'uid' => $uid,
|
||||
'tickets' => $tickets,
|
||||
'ticketing' => $ticketing,
|
||||
'valid_payout_details' => $api->has_payment_settings(),
|
||||
'tickets_message' => $message,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'tickets_loading_error' => $ticket_error,
|
||||
'ticket_event_imported' => $ticket_event_imported,
|
||||
'is_free' => $is_free,
|
||||
'ticket_currency' => $ticket_currency,
|
||||
'is_ticket_event' => $is_ticket_event,
|
||||
'ticket_event_account' => $ticket_event_account,
|
||||
'tax_options' => $tax_options
|
||||
);
|
||||
|
||||
$boxes[] = $theme_loader
|
||||
->get_file( 'box_event_cost.php', $args, true )
|
||||
->get_content();
|
||||
|
||||
|
||||
|
||||
// =========================================
|
||||
// = Display organizer contact information =
|
||||
// =========================================
|
||||
$submitter_html = null;
|
||||
if ( $event ) {
|
||||
$submitter_info = $event->get_submitter_info();
|
||||
if ( null !== $submitter_info ) {
|
||||
if ( 1 === $submitter_info['is_organizer'] ) {
|
||||
$submitter_html = Ai1ec_I18n::__( '<span class="ai1ec-info-text">The event was submitted by this Organizer.</span>' );
|
||||
} else if ( isset( $submitter_info['email'] ) ||
|
||||
isset( $submitter_info['name'] ) ) {
|
||||
$submitted_by = '';
|
||||
if ( false === ai1ec_is_blank ( $submitter_info['name'] ) ) {
|
||||
$submitted_by = sprintf( '<strong>%s</strong>', htmlspecialchars( $submitter_info['name'] ) );
|
||||
}
|
||||
if ( false === ai1ec_is_blank( $submitter_info['email'] ) ) {
|
||||
if ( '' !== $submitted_by ) {
|
||||
$submitted_by .= Ai1ec_I18n::__( ', email: ' );
|
||||
}
|
||||
$submitted_by .= sprintf( '<a href="mailto:%s" target="_top">%s</a>', $submitter_info['email'], $submitter_info['email'] ) ;
|
||||
}
|
||||
$submitter_html = sprintf( Ai1ec_I18n::__( '<span class="ai1ec-info-text">The event was submitted by %s.</span>' ),
|
||||
$submitted_by
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$args = array(
|
||||
'contact_name' => $contact_name,
|
||||
'contact_phone' => $contact_phone,
|
||||
'contact_email' => $contact_email,
|
||||
'contact_url' => $contact_url,
|
||||
'event' => $empty_event,
|
||||
'submitter_html' => $submitter_html
|
||||
);
|
||||
$boxes[] = $theme_loader
|
||||
->get_file( 'box_event_contact.php', $args, true )
|
||||
->get_content();
|
||||
|
||||
// ==========================
|
||||
// = Parent/Child relations =
|
||||
// ==========================
|
||||
if ( $event ) {
|
||||
$parent = $this->_registry->get( 'model.event.parent' )
|
||||
->get_parent_event( $event->get( 'post_id' ) );
|
||||
if ( $parent ) {
|
||||
try {
|
||||
$parent = $this->_registry->get( 'model.event', $parent );
|
||||
} catch ( Ai1ec_Event_Not_Found_Exception $exception ) { // ignore
|
||||
$parent = null;
|
||||
}
|
||||
}
|
||||
if ( $parent ) {
|
||||
$children = $this->_registry->get( 'model.event.parent' )
|
||||
->get_child_event_objects( $event->get( 'post_id' ) );
|
||||
$args = compact( 'parent', 'children' );
|
||||
$args['registry'] = $this->_registry;
|
||||
|
||||
$boxes[] = $theme_loader->get_file(
|
||||
'box_event_children.php',
|
||||
$args,
|
||||
true
|
||||
)->get_content();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$boxes = apply_filters( 'ai1ec_add_new_event_boxes', $boxes, $event );
|
||||
// Display the final view of the meta box.
|
||||
$args = array(
|
||||
'boxes' => $boxes,
|
||||
);
|
||||
|
||||
if ( $this->_is_post_event( $post ) ) {
|
||||
// ======================
|
||||
// = Display Box Review =
|
||||
// ======================
|
||||
$review = $this->_registry->get( 'model.review' );
|
||||
$review_content = $review->get_content( $theme_loader );
|
||||
|
||||
if ( false === ai1ec_is_blank( $review_content ) ) {
|
||||
$args['review_box'] = $review_content;
|
||||
}
|
||||
}
|
||||
|
||||
echo $theme_loader
|
||||
->get_file( 'add_new_event_meta_box.php', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Banner Image meta box to the Add/Edit Event.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function banner_meta_box_view( $post ) {
|
||||
$banner_image_meta = get_post_meta( $post->ID, 'ai1ec_banner_image' );
|
||||
$theme_loader = $this->_registry->get( 'theme.loader' );
|
||||
$args = array(
|
||||
'src' => $banner_image_meta && $banner_image_meta[0]
|
||||
? $banner_image_meta[0] : false,
|
||||
'set_text' => Ai1ec_I18n::__( 'Set banner image' ),
|
||||
'remove_text' => Ai1ec_I18n::__( 'Remove banner image' ),
|
||||
|
||||
);
|
||||
echo $theme_loader
|
||||
->get_file( 'banner-image.twig', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* disable_autosave method
|
||||
*
|
||||
* Callback to disable autosave script
|
||||
*
|
||||
* @param array $input List of scripts registered
|
||||
*
|
||||
* @return array Modified scripts list
|
||||
*/
|
||||
public function disable_autosave( array $input ) {
|
||||
wp_deregister_script( 'autosave' );
|
||||
$autosave_key = array_search( 'autosave', $input );
|
||||
if ( false === $autosave_key || ! is_scalar( $autosave_key ) ) {
|
||||
unset( $input[$autosave_key] );
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders Bootstrap inline alert.
|
||||
*
|
||||
* @param WP_Post $post Post object.
|
||||
*
|
||||
* @return void Method does not return.
|
||||
*/
|
||||
public function event_inline_alert( $post ) {
|
||||
if ( $this->_is_post_event( $post ) ) {
|
||||
$theme_loader = $this->_registry->get( 'theme.loader' );
|
||||
echo $theme_loader->get_file( 'box_inline_warning.php', null, true )
|
||||
->get_content();
|
||||
}
|
||||
}
|
||||
|
||||
private function _is_post_event( $post ) {
|
||||
return isset( $post->post_type ) && AI1EC_POST_TYPE === $post->post_type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The Calendar Add-ons page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.1
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Add_Ons extends Ai1ec_View_Admin_Abstract {
|
||||
/**
|
||||
* Adds page to the menu.
|
||||
*
|
||||
* @wp_hook admin_menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_page() {
|
||||
// =======================
|
||||
// = Calendar Add Ons Page =
|
||||
// =======================
|
||||
add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
Ai1ec_I18n::__( 'Add-ons' ),
|
||||
Ai1ec_I18n::__( 'Add-ons' ),
|
||||
'manage_ai1ec_feeds',
|
||||
AI1EC_PLUGIN_NAME . '-add-ons',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Display Add Ons list page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display_page() {
|
||||
wp_enqueue_style(
|
||||
'ai1ec_addons.css',
|
||||
AI1EC_ADMIN_THEME_CSS_URL . 'addons.css',
|
||||
array(),
|
||||
AI1EC_VERSION
|
||||
);
|
||||
$content = get_site_transient( 'ai1ec_timely_addons' );
|
||||
$is_error = false;
|
||||
if (
|
||||
false === $content ||
|
||||
(
|
||||
defined( 'AI1EC_DEBUG' ) &&
|
||||
AI1EC_DEBUG
|
||||
)
|
||||
) {
|
||||
$is_error = true;
|
||||
$feed = wp_remote_get( AI1EC_TIMELY_ADDONS_URI );
|
||||
if ( ! is_wp_error( $feed ) ) {
|
||||
$content = json_decode( wp_remote_retrieve_body( $feed ) );
|
||||
if ( null !== $content ) {
|
||||
set_site_transient( 'ai1ec_timely_addons', $content, 3600 );
|
||||
$is_error = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_registry->get( 'theme.loader' )->get_file(
|
||||
'add-ons-list/page.twig',
|
||||
array(
|
||||
'labels' => array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Add-ons for All In One Event Calendar'
|
||||
),
|
||||
'button_title' => Ai1ec_I18n::__(
|
||||
'Browse All Add-ons'
|
||||
),
|
||||
'paragraph_content' => Ai1ec_I18n::__(
|
||||
'These add-ons extend the functionality of the All-in-One Event Calendar.'
|
||||
),
|
||||
'error' => Ai1ec_I18n::__(
|
||||
'There was an error retrieving the extensions list from the server. Please try again later.'
|
||||
),
|
||||
),
|
||||
'content' => $content,
|
||||
'is_error' => $is_error,
|
||||
),
|
||||
true
|
||||
)->render();
|
||||
}
|
||||
|
||||
public function add_meta_box() {
|
||||
}
|
||||
|
||||
public function display_meta_box( $object, $box ) {
|
||||
}
|
||||
|
||||
public function handle_post() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
|
||||
class Ai1ec_View_Admin_All_Events extends Ai1ec_Base {
|
||||
|
||||
/**
|
||||
* change_columns function
|
||||
*
|
||||
* Adds Event date/time column to our custom post type
|
||||
* and renames Date column to Post Date
|
||||
*
|
||||
* @param array $columns Existing columns
|
||||
*
|
||||
* @return array Updated columns array
|
||||
*/
|
||||
public function change_columns( array $columns = array() ) {
|
||||
$columns['author'] = __( 'Author', AI1EC_PLUGIN_NAME );
|
||||
$columns['date'] = __( 'Post Date', AI1EC_PLUGIN_NAME );
|
||||
$columns['ai1ec_event_date'] = __( 'Event date/time', AI1EC_PLUGIN_NAME );
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
if ( $api->is_signed() ) {
|
||||
$columns['tickets'] = __( 'Ticket Types', AI1EC_PLUGIN_NAME );
|
||||
}
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* orderby function
|
||||
*
|
||||
* Orders events by event date
|
||||
*
|
||||
* @param string $orderby Orderby sql
|
||||
* @param object $wp_query
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function orderby( $orderby, $wp_query ) {
|
||||
|
||||
$db = $this->_registry->get( 'dbi.dbi' );
|
||||
$aco = $this->_registry->get( 'acl.aco' );
|
||||
|
||||
if( true === $aco->is_all_events_page() ) {
|
||||
$wp_query->query = wp_parse_args( $wp_query->query );
|
||||
$table_name = $db->get_table_name( 'ai1ec_events' );
|
||||
$posts = $db->get_table_name( 'posts' );
|
||||
if( isset( $wp_query->query['orderby'] ) && 'ai1ec_event_date' === @$wp_query->query['orderby'] ) {
|
||||
$orderby = "(SELECT start FROM {$table_name} WHERE post_id = {$posts}.ID) " . $wp_query->get('order');
|
||||
} else if( empty( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] === 'menu_order title' ) {
|
||||
$orderby = "(SELECT start FROM {$table_name} WHERE post_id = {$posts}.ID) " . 'desc';
|
||||
}
|
||||
}
|
||||
return $orderby;
|
||||
}
|
||||
|
||||
/**
|
||||
* custom_columns function
|
||||
*
|
||||
* Adds content for custom columns
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
if ( 'ai1ec_event_date' === $column ) {
|
||||
try {
|
||||
$event = $this->_registry->get( 'model.event', $post_id );
|
||||
$time = $this->_registry->get( 'view.event.time' );
|
||||
echo $time->get_timespan_html( $event );
|
||||
} catch ( Exception $e ) {
|
||||
// event wasn't found, output empty string
|
||||
echo '';
|
||||
}
|
||||
} else if ( 'tickets' === $column ) {
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
if ( $api->is_ticket_event_imported( $post_id ) ) {
|
||||
echo '';
|
||||
} else {
|
||||
try {
|
||||
$event = $this->_registry->get( 'model.event', $post_id );
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
$api_event_id = $api->get_api_event_id( $post_id );
|
||||
if ( $api_event_id ) {
|
||||
echo '<a href="#" class="ai1ec-has-tickets" data-post-id="'
|
||||
. $post_id . '">'
|
||||
. __( 'Ticketing Details', AI1EC_PLUGIN_NAME ) . '</a>';
|
||||
}
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
// event wasn't found, output empty string
|
||||
echo '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sortable_columns function
|
||||
*
|
||||
* Enable sorting of columns
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function sortable_columns( $columns ) {
|
||||
$columns['ai1ec_event_date'] = 'ai1ec_event_date';
|
||||
$columns['author'] = 'author';
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* taxonomy_filter_restrict_manage_posts function
|
||||
*
|
||||
* Adds filter dropdowns for event categories and event tags.
|
||||
* Adds filter dropdowns for event authors.
|
||||
*
|
||||
* @uses wp_dropdown_users To create a dropdown with current user selected.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function taxonomy_filter_restrict_manage_posts() {
|
||||
global $typenow;
|
||||
|
||||
// =============================================
|
||||
// = add the dropdowns only on the events page =
|
||||
// =============================================
|
||||
if( $typenow === AI1EC_POST_TYPE ) {
|
||||
$filters = get_object_taxonomies( $typenow );
|
||||
foreach( $filters as $tax_slug ) {
|
||||
$tax_obj = get_taxonomy( $tax_slug );
|
||||
wp_dropdown_categories( array(
|
||||
'show_option_all' => __( 'Show All ', AI1EC_PLUGIN_NAME ) . $tax_obj->label,
|
||||
'taxonomy' => $tax_slug,
|
||||
'name' => $tax_obj->name,
|
||||
'orderby' => 'name',
|
||||
'selected' => isset( $_GET[$tax_slug] ) ? $_GET[$tax_slug] : '',
|
||||
'hierarchical' => $tax_obj->hierarchical,
|
||||
'show_count' => true,
|
||||
'hide_if_empty' => true,
|
||||
'value_field' => 'slug',
|
||||
));
|
||||
}
|
||||
$args = array(
|
||||
'name' => 'author',
|
||||
'show_option_all' => __( 'Show All Authors', AI1EC_PLUGIN_NAME ),
|
||||
);
|
||||
if ( isset( $_GET['user'] ) ) {
|
||||
$args['selected'] = (int)$_GET['user'];
|
||||
}
|
||||
wp_dropdown_users($args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* taxonomy_filter_post_type_request function
|
||||
*
|
||||
* Adds filtering of events list by event tags and event categories
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function taxonomy_filter_post_type_request( $query ) {
|
||||
global $pagenow, $typenow;
|
||||
if( 'edit.php' === $pagenow ) {
|
||||
$filters = get_object_taxonomies( $typenow );
|
||||
foreach( $filters as $tax_slug ) {
|
||||
$var = &$query->query_vars[$tax_slug];
|
||||
if( isset( $var ) ) {
|
||||
$term = null;
|
||||
|
||||
if( is_numeric( $var ) ) {
|
||||
$term = get_term_by( 'id', $var, $tax_slug );
|
||||
} else {
|
||||
$term = get_term_by( 'slug', $var, $tax_slug );
|
||||
}
|
||||
|
||||
if( isset( $term->slug ) ) {
|
||||
$var = $term->slug;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ===========================
|
||||
// = Order by Event date ASC =
|
||||
// ===========================
|
||||
if( 'ai1ec_event' === $typenow ) {
|
||||
if ( ! array_key_exists( 'orderby', $query->query_vars ) ) {
|
||||
$query->query_vars['orderby'] = 'ai1ec_event_date';
|
||||
$query->query_vars['order'] = 'desc';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS and templates files needed for ticketing.
|
||||
*/
|
||||
public function add_ticketing_styling() {
|
||||
// Add CSS
|
||||
$this->_registry->get( 'css.admin' )->admin_enqueue_scripts(
|
||||
'ai1ec_event_page_all-in-one-event-calendar-settings'
|
||||
);
|
||||
$this->_registry->get( 'css.admin' )->process_enqueue(
|
||||
array(
|
||||
array( 'style', 'ticketing.css', ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ticket details by Event id.
|
||||
*/
|
||||
public function show_ticket_details() {
|
||||
$post_id = $_POST['ai1ec_event_id'];
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
if ( $api->is_ticket_event_from_another_account( $post_id ) ) {
|
||||
$tickets = json_encode(
|
||||
array( 'data' => array(), 'error' =>
|
||||
sprintf(
|
||||
__( 'This Event was created using a different account %s. Changes are not allowed.', AI1EC_PLUGIN_NAME ),
|
||||
$api->get_api_event_account( $post_id )
|
||||
)
|
||||
) );
|
||||
} else {
|
||||
$tickets = $api->get_ticket_types( $post_id );
|
||||
}
|
||||
echo $tickets;
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attendees list.
|
||||
*/
|
||||
public function show_attendees() {
|
||||
$post_id = $_POST['ai1ec_event_id'];
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
$tickets = $api->get_tickets( $post_id );
|
||||
echo $tickets;
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* count_future_events function
|
||||
*
|
||||
* @return Count future events
|
||||
**/
|
||||
public function count_future_events( $user_id = null ) {
|
||||
if ( is_admin() ) {
|
||||
$settings = $this->_registry->get( 'model.settings' );
|
||||
$current_time = $this->_registry->get( 'date.time' );
|
||||
$current_time->set_timezone( $settings->get( 'timezone_string' ) );
|
||||
$current_time = $current_time->format_to_gmt();
|
||||
$user_id = get_current_user_id();
|
||||
$where = get_posts_by_author_sql( AI1EC_POST_TYPE, true, $user_id );
|
||||
$db = $this->_registry->get( 'dbi.dbi' );
|
||||
$posts = $db->get_table_name( 'posts' );
|
||||
$table_name = $db->get_table_name( 'ai1ec_events' );
|
||||
$sql = "SELECT COUNT(*) FROM $table_name INNER JOIN $posts on $table_name.post_id = {$posts}.ID"
|
||||
. " $where AND $table_name.start > $current_time"; //future event
|
||||
return $db->get_var( $sql );
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The Calendar Feeds page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Calendar_Feeds extends Ai1ec_View_Admin_Abstract {
|
||||
|
||||
/**
|
||||
* Adds page to the menu.
|
||||
*
|
||||
* @wp_hook admin_menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_page() {
|
||||
// =======================
|
||||
// = Calendar Feeds Page =
|
||||
// =======================
|
||||
$calendar_feeds = add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
Ai1ec_I18n::__( 'Import Feeds' ),
|
||||
Ai1ec_I18n::__( 'Import Feeds' ),
|
||||
'manage_ai1ec_feeds',
|
||||
AI1EC_PLUGIN_NAME . '-feeds',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
$this->_registry->get( 'model.settings' )
|
||||
->set( 'feeds_page', $calendar_feeds );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds metabox to the page.
|
||||
*
|
||||
* @wp_hook admin_init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_meta_box() {
|
||||
// Add the 'ICS Import Settings' meta box.
|
||||
add_meta_box(
|
||||
'ai1ec-feeds',
|
||||
Ai1ec_I18n::_x( 'Feed Subscriptions', 'meta box' ),
|
||||
array( $this, 'display_meta_box' ),
|
||||
$this->_registry->get( 'model.settings' )->get( 'feeds_page' ),
|
||||
'left',
|
||||
'default'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display this plugin's feeds page in the admin.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display_page() {
|
||||
$settings = $this->_registry->get( 'model.settings' );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$args = array(
|
||||
'title' => __(
|
||||
'All-in-One Event Calendar: Import Feeds',
|
||||
AI1EC_PLUGIN_NAME
|
||||
),
|
||||
'settings_page' => $settings->get( 'feeds_page' ),
|
||||
'calendar_settings' => false,
|
||||
);
|
||||
$file = $loader->get_file( 'feeds_settings.php', $args, true );
|
||||
wp_enqueue_style(
|
||||
'ai1ec_samples.css',
|
||||
AI1EC_ADMIN_THEME_CSS_URL . 'samples.css',
|
||||
array(),
|
||||
AI1EC_VERSION
|
||||
);
|
||||
$file->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the contents of the Calendar Feeds meta box.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display_meta_box( $object, $box ) {
|
||||
// register the calendar feeds page.
|
||||
$calendar_feeds = $this->_registry->get( 'controller.calendar-feeds' );
|
||||
$feeds = array();
|
||||
|
||||
array_push( $feeds, $this->_registry->get( 'calendar-feed.import' ) );
|
||||
// Check for user subscription - Discover events
|
||||
if ($this->_api_registration->has_subscription_active( 'discover-events' ) ) {
|
||||
array_push( $feeds, $this->_registry->get( 'calendar-feed.suggested' ) );
|
||||
}
|
||||
|
||||
// Add ICS
|
||||
array_push( $feeds, $this->_registry->get( 'calendar-feed.ics' ) );
|
||||
|
||||
$feeds = apply_filters( 'ai1ec_calendar_feeds', $feeds );
|
||||
foreach ( $feeds as $feed ) {
|
||||
$calendar_feeds->add_plugin( $feed );
|
||||
}
|
||||
$calendar_feeds->handle_feeds_page_post();
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$file = $loader->get_file(
|
||||
'box_feeds.php',
|
||||
array( 'calendar_feeds' => $calendar_feeds ),
|
||||
true
|
||||
);
|
||||
$file->render();
|
||||
}
|
||||
|
||||
public function handle_post() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Event category admin view snippets renderer.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View.Admin
|
||||
*/
|
||||
class Ai1ec_View_Admin_EventCategory extends Ai1ec_Base {
|
||||
|
||||
/**
|
||||
* Inserts Color element at index 2 of columns array
|
||||
*
|
||||
* @param array $columns Array with event_category columns
|
||||
*
|
||||
* @return array Array with event_category columns where Color is inserted
|
||||
* at index 2
|
||||
*/
|
||||
public function manage_event_categories_columns( $columns ) {
|
||||
wp_enqueue_media();
|
||||
$this->_registry->get( 'css.admin' )
|
||||
->process_enqueue( array(
|
||||
array( 'style', 'bootstrap.min.css' )
|
||||
) );
|
||||
return array_splice( $columns, 0, 3 ) + // get only first element
|
||||
// insert at index 2
|
||||
array( 'cat_color' => __( 'Color', AI1EC_PLUGIN_NAME ) ) +
|
||||
// insert at index 3
|
||||
array( 'cat_image' => __( 'Image', AI1EC_PLUGIN_NAME ) ) +
|
||||
// insert rest of elements at the back
|
||||
array_splice( $columns, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color or image of the event category.
|
||||
*
|
||||
* That will be displayed on event category lists page in the backend.
|
||||
*
|
||||
* @param $not_set
|
||||
* @param $column_name
|
||||
* @param $term_id
|
||||
* @internal param array $columns Array with event_category columns
|
||||
*
|
||||
* @return array Array with event_category columns where Color is inserted
|
||||
* at index 2
|
||||
*/
|
||||
public function manage_events_categories_custom_column(
|
||||
$not_set,
|
||||
$column_name,
|
||||
$term_id
|
||||
) {
|
||||
switch ( $column_name ) {
|
||||
case 'cat_color':
|
||||
return $this->_registry->get( 'view.event.taxonomy' )
|
||||
->get_category_color_square( $term_id );
|
||||
case 'cat_image':
|
||||
return $this->_registry->get( 'view.event.taxonomy' )
|
||||
->get_category_image_square( $term_id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to process event categories creation
|
||||
*
|
||||
* @param $term_id
|
||||
*
|
||||
* @return void Method does not return.
|
||||
*/
|
||||
public function created_events_categories( $term_id ) {
|
||||
$this->edited_events_categories( $term_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback method, triggered when `event_categories' are being edited.
|
||||
*
|
||||
* @param int $term_id ID of term (category) being edited.
|
||||
*
|
||||
* @return void Method does not return.
|
||||
*/
|
||||
public function edited_events_categories( $term_id ) {
|
||||
if ( isset( $_POST['_inline_edit'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tag_color_value = '';
|
||||
if ( ! empty( $_POST['tag-color-value'] ) ) {
|
||||
$tag_color_value = (string)$_POST['tag-color-value'];
|
||||
}
|
||||
$tag_image_value = '';
|
||||
if ( ! empty( $_POST['ai1ec_category_image_url'] ) ) {
|
||||
$tag_image_value = (string)$_POST['ai1ec_category_image_url'];
|
||||
}
|
||||
if ( isset( $_POST['ai1ec_category_image_url_remove'] ) ) {
|
||||
$tag_image_value = null;
|
||||
}
|
||||
|
||||
$db = $this->_registry->get( 'dbi.dbi' );
|
||||
$table_name = $db->get_table_name( 'ai1ec_event_category_meta' );
|
||||
$term = $db->get_row( $db->prepare(
|
||||
'SELECT term_id FROM ' . $table_name .
|
||||
' WHERE term_id = %d',
|
||||
$term_id
|
||||
) );
|
||||
|
||||
if ( null === $term ) { // term does not exist, create it
|
||||
$db->insert(
|
||||
$table_name,
|
||||
array(
|
||||
'term_id' => $term_id,
|
||||
'term_color' => $tag_color_value,
|
||||
'term_image' => $tag_image_value,
|
||||
),
|
||||
array(
|
||||
'%d',
|
||||
'%s',
|
||||
'%s',
|
||||
)
|
||||
);
|
||||
} else { // term exist, update it
|
||||
$db->update(
|
||||
$table_name,
|
||||
array(
|
||||
'term_color' => $tag_color_value,
|
||||
'term_image' => $tag_image_value
|
||||
),
|
||||
array( 'term_id' => $term_id ),
|
||||
array( '%s', '%s' ),
|
||||
array( '%d' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function show_color( $term = null ) {
|
||||
|
||||
$taxonomy = $this->_registry->get( 'model.taxonomy' );
|
||||
$color = '';
|
||||
if ( null !== $term ) {
|
||||
$color = $taxonomy->get_category_color( $term->term_id );
|
||||
}
|
||||
|
||||
$style = '';
|
||||
$clr = '';
|
||||
|
||||
if ( $color ) {
|
||||
$style = 'style="background-color: ' . $color . '"';
|
||||
$clr = $color;
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'style' => $style,
|
||||
'color' => $clr,
|
||||
'label' => Ai1ec_I18n::__( 'Category Color' ),
|
||||
'description' => Ai1ec_I18n::__(
|
||||
'Events in this category will be identified by this color'
|
||||
),
|
||||
'edit' => true,
|
||||
);
|
||||
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$loader->get_file(
|
||||
'setting/categories-color-picker.twig',
|
||||
$args,
|
||||
true
|
||||
)->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit category form
|
||||
*
|
||||
* @param $term
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function events_categories_edit_form_fields( $term ) {
|
||||
$this->show_color( $term );
|
||||
$taxonomy = $this->_registry->get( 'model.taxonomy' );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$image = $taxonomy->get_category_image( $term->term_id );
|
||||
|
||||
$style = 'style="display:none"';
|
||||
|
||||
if ( null !== $image ) {
|
||||
$style = '';
|
||||
}
|
||||
|
||||
// Category image
|
||||
$args = array(
|
||||
'image_src' => $image,
|
||||
'image_style' => $style,
|
||||
'section_name' => __( 'Category Image', AI1EC_PLUGIN_NAME ),
|
||||
'label' => __( 'Add Image', AI1EC_PLUGIN_NAME ),
|
||||
'remove_label' => __( 'Remove Image', AI1EC_PLUGIN_NAME ),
|
||||
'description' => __(
|
||||
'Assign an optional image to the category. Recommended size: square, minimum 400×400 pixels.',
|
||||
AI1EC_PLUGIN_NAME
|
||||
),
|
||||
'edit' => true,
|
||||
);
|
||||
|
||||
$loader->get_file(
|
||||
'setting/categories-image.twig',
|
||||
$args,
|
||||
true
|
||||
)->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add category form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function events_categories_add_form_fields() {
|
||||
|
||||
$this->show_color();
|
||||
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
// Category image
|
||||
$args = array(
|
||||
'image_src' => '',
|
||||
'image_style' => 'style="display:none"',
|
||||
'section_name' => __( 'Category Image', AI1EC_PLUGIN_NAME ),
|
||||
'label' => __( 'Add Image', AI1EC_PLUGIN_NAME),
|
||||
'description' => __( 'Assign an optional image to the category. Recommended size: square, minimum 400×400 pixels.', AI1EC_PLUGIN_NAME ),
|
||||
'edit' => false,
|
||||
);
|
||||
|
||||
$file = $loader->get_file(
|
||||
'setting/categories-image.twig',
|
||||
$args,
|
||||
true
|
||||
);
|
||||
|
||||
$file->render();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,670 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The get repeat box snippet.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Admin_Get_repeat_Box extends Ai1ec_Base {
|
||||
/**
|
||||
* get_repeat_box function
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
public function get_repeat_box() {
|
||||
$time_system = $this->_registry->get( 'date.system' );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$repeat = (int) $_REQUEST["repeat"];
|
||||
$repeat = $repeat == 1 ? 1 : 0;
|
||||
$post_id = (int) $_REQUEST["post_id"];
|
||||
$count = 100;
|
||||
$end = 0;
|
||||
$until = $time_system->current_time( true );
|
||||
|
||||
// try getting the event
|
||||
try {
|
||||
$event = $this->_registry->get( 'model.event', $post_id );
|
||||
$rule = '';
|
||||
|
||||
if ( $repeat ) {
|
||||
$rule = $event->get( 'recurrence_rules' )
|
||||
? $event->get( 'recurrence_rules' )
|
||||
: '';
|
||||
} else {
|
||||
$rule = $event->get( 'exception_rules' ) ?
|
||||
$event->get( 'exception_rules' )
|
||||
: '';
|
||||
}
|
||||
|
||||
$rule = $this->_registry->get( 'recurrence.rule' )->filter_rule( $rule );
|
||||
|
||||
$rc = new SG_iCal_Recurrence(
|
||||
new SG_iCal_Line( 'RRULE:' . $rule )
|
||||
);
|
||||
|
||||
if ( $until = $rc->getUntil() ) {
|
||||
$until = ( is_numeric( $until ) )
|
||||
? $until
|
||||
: strtotime( $until );
|
||||
$end = 2;
|
||||
} elseif ( $count = $rc->getCount() ) {
|
||||
$count = ( is_numeric( $count ) ) ? $count : 100;
|
||||
$end = 1;
|
||||
}
|
||||
} catch( Ai1ec_Event_Not_Found_Exception $e ) {
|
||||
$rule = '';
|
||||
$rc = new SG_iCal_Recurrence(
|
||||
new SG_iCal_Line( 'RRULE:' )
|
||||
);
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'row_daily' => $this->row_daily(
|
||||
false,
|
||||
$rc->getInterval() ? $rc->getInterval() : 1
|
||||
),
|
||||
'row_weekly' => $this->row_weekly(
|
||||
false,
|
||||
$rc->getInterval() ? $rc->getInterval() : 1,
|
||||
is_array( $rc->getByDay() ) ? $rc->getByDay() : array()
|
||||
),
|
||||
'row_monthly' => $this->row_monthly(
|
||||
false,
|
||||
$rc->getInterval() ? $rc->getInterval() : 1,
|
||||
! $this->_is_monthday_empty( $rc ),
|
||||
$rc->getByMonthDay() ? $rc->getByMonthDay() : array(),
|
||||
$rc->getByDay() ? $rc->getByDay() : array()
|
||||
),
|
||||
'row_yearly' => $this->row_yearly(
|
||||
false,
|
||||
$rc->getInterval() ? $rc->getInterval() : 1,
|
||||
is_array( $rc->getByMonth() ) ? $rc->getByMonth() : array()
|
||||
),
|
||||
'row_custom' => $this->row_custom(
|
||||
false,
|
||||
$this->get_date_array_from_rule( $rule )
|
||||
),
|
||||
'count' => $this->create_count_input(
|
||||
'ai1ec_count',
|
||||
$count
|
||||
) . Ai1ec_I18n::__( 'times' ),
|
||||
'end' => $this->create_end_dropdown( $end ),
|
||||
'until' => $until,
|
||||
'repeat' => $repeat,
|
||||
'ending_type' => $end,
|
||||
'selected_tab' => $rc->getFreq()
|
||||
? strtolower( $rc->getFreq() )
|
||||
: 'custom',
|
||||
);
|
||||
$output = array(
|
||||
'error' => false,
|
||||
'message' => $loader->get_file(
|
||||
'box_repeat.php',
|
||||
$args,
|
||||
true
|
||||
)->get_content(),
|
||||
'repeat' => $repeat,
|
||||
);
|
||||
$json_strategy = $this->_registry->get( 'http.response.render.strategy.json' );
|
||||
$json_strategy->render( array( 'data' => $output ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* get_weekday_by_id function
|
||||
*
|
||||
* Returns weekday name in English
|
||||
*
|
||||
* @param int $day_id Day ID
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
public function get_weekday_by_id( $day_id, $by_value = false ) {
|
||||
// do not translate this !!!
|
||||
$week_days = array(
|
||||
0 => 'SU',
|
||||
1 => 'MO',
|
||||
2 => 'TU',
|
||||
3 => 'WE',
|
||||
4 => 'TH',
|
||||
5 => 'FR',
|
||||
6 => 'SA',
|
||||
);
|
||||
|
||||
if ( $by_value ) {
|
||||
while ( $_name = current( $week_days ) ) {
|
||||
if ( $_name == $day_id ) {
|
||||
return key( $week_days );
|
||||
}
|
||||
next( $week_days );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return $week_days[$day_id];
|
||||
}
|
||||
|
||||
/**
|
||||
* convert_rrule_to_text method
|
||||
*
|
||||
* Convert a `recurrence rule' to text to display it on screen
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function convert_rrule_to_text() {
|
||||
$error = false;
|
||||
$message = '';
|
||||
// check to see if RRULE is set
|
||||
if ( isset( $_REQUEST['rrule'] ) ) {
|
||||
// check to see if rrule is empty
|
||||
if ( empty( $_REQUEST['rrule'] ) ) {
|
||||
$error = true;
|
||||
$message = Ai1ec_I18n::__(
|
||||
'Recurrence rule cannot be empty.'
|
||||
);
|
||||
} else {
|
||||
//list( $rule, $value ) = explode( '=', $_REQUEST['rrule'], 2 );
|
||||
//if ( in_array( array(), $rule ) ) {
|
||||
// $message = $this->_registry->get( 'recurrence.date' );
|
||||
//
|
||||
//} else {
|
||||
$rrule = $this->_registry->get( 'recurrence.rule' );
|
||||
// convert rrule to text
|
||||
$message = ucfirst(
|
||||
$rrule->rrule_to_text( $_REQUEST['rrule'] )
|
||||
);
|
||||
//}
|
||||
}
|
||||
} else {
|
||||
$error = true;
|
||||
$message = Ai1ec_I18n::__(
|
||||
'Recurrence rule was not provided.'
|
||||
);
|
||||
}
|
||||
$output = array(
|
||||
'error' => $error,
|
||||
'message' => get_magic_quotes_gpc()
|
||||
? stripslashes( $message )
|
||||
: $message,
|
||||
);
|
||||
|
||||
$json_strategy = $this->_registry->get( 'http.response.render.strategy.json' );
|
||||
$json_strategy->render( array( 'data' => $output ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* create_end_dropdown function
|
||||
*
|
||||
* Outputs the dropdown list for the recurrence end option.
|
||||
*
|
||||
* @param int $selected The index of the selected option, if any
|
||||
* @return void
|
||||
**/
|
||||
protected function create_end_dropdown( $selected = NULL ) {
|
||||
ob_start();
|
||||
|
||||
$options = array(
|
||||
0 => Ai1ec_I18n::__( 'Never' ),
|
||||
1 => Ai1ec_I18n::__( 'After' ),
|
||||
2 => Ai1ec_I18n::__( 'On date' ),
|
||||
);
|
||||
|
||||
?>
|
||||
<select name="ai1ec_end" id="ai1ec_end">
|
||||
<?php foreach( $options as $key => $val ): ?>
|
||||
<option value="<?php echo $key ?>"
|
||||
<?php if( $key === $selected ) echo 'selected="selected"' ?>>
|
||||
<?php echo $val ?>
|
||||
</option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<?php
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* row_daily function
|
||||
*
|
||||
* Returns daily selector
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
protected function row_daily( $visible = false, $selected = 1 ) {
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$args = array(
|
||||
'visible' => $visible,
|
||||
'count' => $this->create_count_input(
|
||||
'ai1ec_daily_count',
|
||||
$selected,
|
||||
365
|
||||
) . Ai1ec_I18n::__( 'day(s)' ),
|
||||
);
|
||||
return $loader->get_file( 'row_daily.php', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* row_custom function
|
||||
*
|
||||
* Returns custom dates selector
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
protected function row_custom( $visible = false, $dates = array() ) {
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$args = array(
|
||||
'visible' => $visible,
|
||||
'selected_dates' => implode( ',', $dates )
|
||||
);
|
||||
return $loader->get_file( 'row_custom.php', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and returns "End after X times" input
|
||||
*
|
||||
* @param Integer|NULL $count Initial value of range input
|
||||
*
|
||||
* @return String Repeat dropdown
|
||||
*/
|
||||
protected function create_count_input( $name, $count = 100, $max = 365 ) {
|
||||
ob_start();
|
||||
|
||||
if ( ! $count ) {
|
||||
$count = 100;
|
||||
}
|
||||
?>
|
||||
<input type="range" name="<?php echo $name ?>" id="<?php echo $name ?>"
|
||||
min="1" max="<?php echo $max ?>"
|
||||
<?php if ( $count ) echo 'value="' . $count . '"' ?> />
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* row_weekly function
|
||||
*
|
||||
* Returns weekly selector
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
protected function row_weekly(
|
||||
$visible = false,
|
||||
$count = 1,
|
||||
array $selected = array()
|
||||
) {
|
||||
global $wp_locale;
|
||||
$start_of_week = $this->_registry->get( 'model.option' )
|
||||
->get( 'start_of_week', 1 );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$options = array();
|
||||
// get days from start_of_week until the last day
|
||||
for ( $i = $start_of_week; $i <= 6; ++$i ) {
|
||||
$options[$this->get_weekday_by_id( $i )] = $wp_locale
|
||||
->weekday_initial[$wp_locale->weekday[$i]];
|
||||
}
|
||||
|
||||
// get days from 0 until start_of_week
|
||||
if ( $start_of_week > 0 ) {
|
||||
for ( $i = 0; $i < $start_of_week; $i++ ) {
|
||||
$options[$this->get_weekday_by_id( $i )] = $wp_locale
|
||||
->weekday_initial[$wp_locale->weekday[$i]];
|
||||
}
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'visible' => $visible,
|
||||
'count' => $this->create_count_input(
|
||||
'ai1ec_weekly_count',
|
||||
$count,
|
||||
52
|
||||
) . Ai1ec_I18n::__( 'week(s)' ),
|
||||
'week_days' => $this->create_list_element(
|
||||
'ai1ec_weekly_date_select',
|
||||
$options,
|
||||
$selected
|
||||
)
|
||||
);
|
||||
return $loader->get_file( 'row_weekly.php', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a grid of weekday, day, or month selection buttons.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function create_list_element(
|
||||
$name,
|
||||
array $options = array(),
|
||||
array $selected = array()
|
||||
) {
|
||||
ob_start();
|
||||
?>
|
||||
<div class="ai1ec-btn-group-grid" id="<?php echo $name; ?>">
|
||||
<?php foreach ( $options as $key => $val ) : ?>
|
||||
<div class="ai1ec-pull-left">
|
||||
<a class="ai1ec-btn ai1ec-btn-default ai1ec-btn-block
|
||||
<?php echo in_array( $key, $selected ) ? 'ai1ec-active' : ''; ?>">
|
||||
<?php echo $val; ?>
|
||||
</a>
|
||||
<input type="hidden" name="<?php echo $name . '_' . $key; ?>"
|
||||
value="<?php echo $key; ?>">
|
||||
</div class="ai1ec-pull-left">
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<input type="hidden" name="<?php echo $name; ?>"
|
||||
value="<?php echo implode( ',', $selected ) ?>">
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* row_monthly function
|
||||
*
|
||||
* Returns monthly selector
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
protected function row_monthly(
|
||||
$visible = false,
|
||||
$count = 1,
|
||||
$bymonthday = true,
|
||||
$month = array(),
|
||||
$day = array()
|
||||
) {
|
||||
global $wp_locale;
|
||||
$start_of_week = $this->_registry->get( 'model.option' )
|
||||
->get( 'start_of_week', 1 );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$options_wd = array();
|
||||
// get days from start_of_week until the last day
|
||||
for ( $i = $start_of_week; $i <= 6; ++$i ) {
|
||||
$options_wd[$this->get_weekday_by_id( $i )] = $wp_locale
|
||||
->weekday[$i];
|
||||
}
|
||||
|
||||
// get days from 0 until start_of_week
|
||||
if ( $start_of_week > 0 ) {
|
||||
for ( $i = 0; $i < $start_of_week; $i++ ) {
|
||||
$options_wd[$this->get_weekday_by_id( $i )] = $wp_locale
|
||||
->weekday[$i];
|
||||
}
|
||||
}
|
||||
|
||||
// get options like 1st/2nd/3rd for "day number"
|
||||
$options_dn = array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5 );
|
||||
foreach ( $options_dn as $_dn ) {
|
||||
$options_dn[$_dn] = $this->_registry->get(
|
||||
'date.time',
|
||||
strtotime( $_dn . '-01-1998 12:00:00' )
|
||||
)->format_i18n( 'jS' );
|
||||
}
|
||||
$options_dn['-1'] = Ai1ec_I18n::__( 'last' );
|
||||
|
||||
$byday_checked = $bymonthday ? '' : 'checked';
|
||||
$byday_expanded = $bymonthday ? 'ai1ec-collapse' : 'ai1ec-in';
|
||||
$bymonthday_checked = $bymonthday ? 'checked' : '';
|
||||
$bymonthday_expanded = $bymonthday ? 'ai1ec-in' : 'ai1ec-collapse';
|
||||
|
||||
$args = array(
|
||||
'visible' => $visible,
|
||||
'count' => $this->create_count_input(
|
||||
'ai1ec_monthly_count',
|
||||
$count,
|
||||
12
|
||||
) . Ai1ec_I18n::__( 'month(s)' ),
|
||||
'month' => $this->create_monthly_date_select(
|
||||
$month
|
||||
),
|
||||
'day_nums' => $this->create_select_element(
|
||||
'ai1ec_monthly_byday_num',
|
||||
$options_dn,
|
||||
$this->_get_day_number_from_byday( $day )
|
||||
),
|
||||
'week_days' => $this->create_select_element(
|
||||
'ai1ec_monthly_byday_weekday',
|
||||
$options_wd,
|
||||
$this->_get_day_shortname_from_byday( $day )
|
||||
),
|
||||
'bymonthday_checked' => $bymonthday_checked,
|
||||
'byday_checked' => $byday_checked,
|
||||
'bymonthday_expanded' => $bymonthday_expanded,
|
||||
'byday_expanded' => $byday_expanded,
|
||||
);
|
||||
return $loader->get_file( 'row_monthly.php', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates selector for dates in monthly repeat tab.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function create_monthly_date_select( $selected = array() ) {
|
||||
$options = array();
|
||||
for ( $i = 1; $i <= 31; ++$i ) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
return $this->create_list_element(
|
||||
'ai1ec_montly_date_select',
|
||||
$options,
|
||||
$selected
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create_on_the_select function
|
||||
*
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
protected function create_on_the_select(
|
||||
$f_selected = false,
|
||||
$s_selected = false
|
||||
) {
|
||||
$ret = '';
|
||||
|
||||
$first_options = array(
|
||||
'0' => Ai1ec_I18n::__( 'first' ),
|
||||
'1' => Ai1ec_I18n::__( 'second' ),
|
||||
'2' => Ai1ec_I18n::__( 'third' ),
|
||||
'3' => Ai1ec_I18n::__( 'fourth' ),
|
||||
'4' => '------',
|
||||
'5' => Ai1ec_I18n::__( 'last' )
|
||||
);
|
||||
$ret = $this->create_select_element(
|
||||
'ai1ec_monthly_each_select',
|
||||
$first_options,
|
||||
$f_selected,
|
||||
array( 4 )
|
||||
);
|
||||
|
||||
$second_options = array(
|
||||
'0' => Ai1ec_I18n::__( 'Sunday' ),
|
||||
'1' => Ai1ec_I18n::__( 'Monday' ),
|
||||
'2' => Ai1ec_I18n::__( 'Tuesday' ),
|
||||
'3' => Ai1ec_I18n::__( 'Wednesday' ),
|
||||
'4' => Ai1ec_I18n::__( 'Thursday' ),
|
||||
'5' => Ai1ec_I18n::__( 'Friday' ),
|
||||
'6' => Ai1ec_I18n::__( 'Saturday' ),
|
||||
'7' => '--------',
|
||||
'8' => Ai1ec_I18n::__( 'day' ),
|
||||
'9' => Ai1ec_I18n::__( 'weekday' ),
|
||||
'10' => Ai1ec_I18n::__( 'weekend day' )
|
||||
);
|
||||
|
||||
return $ret . $this->create_select_element(
|
||||
'ai1ec_monthly_on_the_select',
|
||||
$second_options,
|
||||
$s_selected,
|
||||
array( 7 )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create_select_element function
|
||||
*
|
||||
* Render HTML <select> element
|
||||
*
|
||||
* @param string $name Name of element to be rendered
|
||||
* @param array $options Select <option> values as key=>value pairs
|
||||
* @param string $selected Key to be marked as selected [optional=false]
|
||||
* @param array $disabled_keys List of options to disable [optional=array]
|
||||
*
|
||||
* @return string Rendered <select> HTML element
|
||||
**/
|
||||
protected function create_select_element(
|
||||
$name,
|
||||
array $options = array(),
|
||||
$selected = false,
|
||||
array $disabled_keys = array()
|
||||
) {
|
||||
ob_start();
|
||||
?>
|
||||
<select name="<?php echo $name ?>" id="<?php echo $name ?>">
|
||||
<?php foreach( $options as $key => $val ): ?>
|
||||
<option value="<?php echo $key ?>"
|
||||
<?php echo $key === $selected ? 'selected="selected"' : '' ?>
|
||||
<?php echo in_array( $key, $disabled_keys ) ? 'disabled' : '' ?>>
|
||||
<?php echo $val ?>
|
||||
</option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* row_yearly function
|
||||
*
|
||||
* Returns yearly selector
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
protected function row_yearly(
|
||||
$visible = false,
|
||||
$count = 1,
|
||||
$year = array(),
|
||||
$first = false,
|
||||
$second = false
|
||||
) {
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$args = array(
|
||||
'visible' => $visible,
|
||||
'count' => $this->create_count_input(
|
||||
'ai1ec_yearly_count',
|
||||
$count,
|
||||
10
|
||||
) . Ai1ec_I18n::__( 'year(s)' ),
|
||||
'year' => $this->create_yearly_date_select( $year ),
|
||||
'on_the_select' => $this->create_on_the_select(
|
||||
$first,
|
||||
$second
|
||||
),
|
||||
);
|
||||
return $loader->get_file( 'row_yearly.php', $args, true )
|
||||
->get_content();
|
||||
}
|
||||
|
||||
/**
|
||||
* create_yearly_date_select function
|
||||
*
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
protected function create_yearly_date_select( $selected = array() ) {
|
||||
global $wp_locale;
|
||||
$options = array();
|
||||
for ( $i = 1; $i <= 12; ++$i ) {
|
||||
$options[$i] = $wp_locale->month_abbrev[
|
||||
$wp_locale->month[sprintf( '%02d', $i )]
|
||||
];
|
||||
}
|
||||
return $this->create_list_element(
|
||||
'ai1ec_yearly_date_select',
|
||||
$options,
|
||||
$selected
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts recurrence rule to array of string of dates.
|
||||
*
|
||||
* @param string $rule RUle.
|
||||
*
|
||||
* @return array Array of dates or empty array.
|
||||
* @throws Ai1ec_Bootstrap_Exception
|
||||
*/
|
||||
protected function get_date_array_from_rule( $rule ) {
|
||||
if (
|
||||
'RDATE' !== substr( $rule, 0, 5 ) &&
|
||||
'EXDATE' !== substr( $rule, 0, 6 )
|
||||
) {
|
||||
return array();
|
||||
}
|
||||
$line = new SG_iCal_Line( 'RRULE:' . $rule );
|
||||
$dates = $line->getDataAsArray();
|
||||
$dates_as_strings = array();
|
||||
foreach ( $dates as $date ) {
|
||||
$date = str_replace( array( 'RDATE=', 'EXDATE=' ), '', $date );
|
||||
$date = $this->_registry->get( 'date.time', $date )->set_preferred_timezone( 'UTC' );
|
||||
$dates_as_strings[] = $date->format( 'm/d/Y' );
|
||||
}
|
||||
return $dates_as_strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether recurrence rule has non null ByMonthDay.
|
||||
*
|
||||
* @param SG_iCal_Recurrence $rc iCal class.
|
||||
*
|
||||
* @return bool True or false.
|
||||
*/
|
||||
protected function _is_monthday_empty( SG_iCal_Recurrence $rc ) {
|
||||
return false === $rc->getByMonthDay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns day number from by day array.
|
||||
*
|
||||
* @param array $day
|
||||
*
|
||||
* @return bool|int Day of false if empty array.
|
||||
*/
|
||||
protected function _get_day_number_from_byday( array $day ) {
|
||||
return isset( $day[0] ) ? (int) $day[0] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string part from "ByDay" recurrence rule.
|
||||
*
|
||||
* @param array $day Element to parse.
|
||||
*
|
||||
* @return bool|string False if empty or not matched, otherwise short day
|
||||
* name.
|
||||
*/
|
||||
protected function _get_day_shortname_from_byday( $day ) {
|
||||
if ( empty( $day ) ) {
|
||||
return false;
|
||||
}
|
||||
$value = $day[0];
|
||||
if ( preg_match('/[-]?\d([A-Z]+)/', $value, $matches ) ) {
|
||||
return $matches[1];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The get tax options box.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.4
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Admin_Get_Tax_Box extends Ai1ec_Base {
|
||||
/**
|
||||
* get_tax_box function
|
||||
*
|
||||
* @return string
|
||||
**/
|
||||
public function get_tax_box() {
|
||||
$api = $this->_registry->get( 'model.api.api-ticketing' );
|
||||
$post_id = $_POST['ai1ec_event_id'];
|
||||
$modal = $api->get_tax_options_modal( $post_id );
|
||||
$output = array(
|
||||
'error' => $modal->error,
|
||||
'message' => $modal->data
|
||||
);
|
||||
$json_strategy = $this->_registry->get( 'http.response.render.strategy.json' );
|
||||
$json_strategy->render( array( 'data' => $output ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Admin-side navigation elements rendering.
|
||||
*
|
||||
* @author Time.ly Network, Inc.
|
||||
* @since 2.0
|
||||
* @package Ai1EC
|
||||
* @subpackage Ai1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Admin_Navigation extends Ai1ec_Base {
|
||||
|
||||
/**
|
||||
* Adds a link to Settings page in plugin list page.
|
||||
*
|
||||
* @param array $links List of available links.
|
||||
*
|
||||
* @return array Modified links list.
|
||||
*/
|
||||
public function plugin_action_links( $links ) {
|
||||
$settings_link = sprintf(
|
||||
Ai1ec_I18n::__( '<a href="%s">Settings</a>' ),
|
||||
ai1ec_admin_url( AI1EC_SETTINGS_BASE_URL )
|
||||
);
|
||||
array_unshift( $links, $settings_link );
|
||||
if ( current_user_can( 'activate_plugins' ) ) {
|
||||
$updates_link = sprintf(
|
||||
Ai1ec_I18n::__( '<a href="%s">Check for updates</a>' ),
|
||||
ai1ec_admin_url( AI1EC_FORCE_UPDATES_URL )
|
||||
);
|
||||
array_push( $links, $updates_link );
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The page to manage taxonomies.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Organize extends Ai1ec_Base {
|
||||
|
||||
/**
|
||||
* @var array The taxonomies for events
|
||||
*/
|
||||
protected $_taxonomies = array();
|
||||
|
||||
/**
|
||||
* Register actions to draw the headers
|
||||
*/
|
||||
public function add_taxonomy_actions() {
|
||||
$taxonomies = get_object_taxonomies( AI1EC_POST_TYPE, 'object' );
|
||||
$dispatcher = $this->_registry->get( 'event.dispatcher' );
|
||||
$taxonomy_metadata = array(
|
||||
'events_categories' => array(
|
||||
'icon' => 'ai1ec-fa ai1ec-fa-folder-open'
|
||||
),
|
||||
'events_tags' => array(
|
||||
'icon' => 'ai1ec-fa ai1ec-fa-tags'
|
||||
)
|
||||
);
|
||||
$taxonomy_metadata = apply_filters(
|
||||
'ai1ec_add_custom_groups',
|
||||
$taxonomy_metadata
|
||||
);
|
||||
do_action( 'ai1ec_taxonomy_management_css' );
|
||||
foreach ( $taxonomies as $taxonomy => $data ) {
|
||||
if ( true === $data->public ) {
|
||||
$active_taxonomy =
|
||||
isset( $_GET['taxonomy'] ) &&
|
||||
$taxonomy === $_GET['taxonomy'];
|
||||
$edit_url = $edit_label = '';
|
||||
if ( isset( $taxonomy_metadata[$taxonomy]['url'] ) ) {
|
||||
$edit_url = $taxonomy_metadata[$taxonomy]['url'];
|
||||
$edit_label = $taxonomy_metadata[$taxonomy]['edit_label'];
|
||||
}
|
||||
$this->_taxonomies[] = array(
|
||||
'taxonomy_name' => $taxonomy,
|
||||
'url' => add_query_arg(
|
||||
array(
|
||||
'post_type' => AI1EC_POST_TYPE,
|
||||
'taxonomy' => $taxonomy
|
||||
),
|
||||
admin_url( 'edit-tags.php' )
|
||||
),
|
||||
'name' => $data->labels->name,
|
||||
'active' => $active_taxonomy,
|
||||
'icon' => isset( $taxonomy_metadata[$taxonomy] ) ?
|
||||
$taxonomy_metadata[$taxonomy]['icon'] :
|
||||
'',
|
||||
'edit_url' => $edit_url,
|
||||
'edit_label' => $edit_label,
|
||||
);
|
||||
|
||||
if ( $active_taxonomy ) {
|
||||
$dispatcher->register_action(
|
||||
$taxonomy . '_pre_add_form',
|
||||
array( 'view.admin.organize', 'render_header' )
|
||||
);
|
||||
$dispatcher->register_action(
|
||||
$taxonomy . '_pre_edit_form',
|
||||
array( 'view.admin.organize', 'render_header' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render tabbed header to manage taxonomies.
|
||||
*/
|
||||
public function render_header() {
|
||||
echo $this->get_header();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and return tabbed header to manage taxonomies.
|
||||
*
|
||||
* @return string HTML markup for tabbed header
|
||||
*/
|
||||
public function get_header() {
|
||||
return $this->_registry->get( 'theme.loader' )->get_file(
|
||||
'organize/header.twig',
|
||||
array(
|
||||
'taxonomies' => apply_filters(
|
||||
'ai1ec_custom_taxonomies',
|
||||
$this->_taxonomies
|
||||
),
|
||||
'text_title' => Ai1ec_I18n::__( 'Organize Events' ),
|
||||
),
|
||||
true
|
||||
)->get_content();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The Calendar Samples page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.1
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Samples extends Ai1ec_View_Admin_Abstract {
|
||||
/**
|
||||
* Adds page to the menu.
|
||||
*
|
||||
* @wp_hook admin_menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_page() {
|
||||
// =======================
|
||||
// = Calendar Add Ons Page =
|
||||
// =======================
|
||||
}
|
||||
/**
|
||||
* Display Add Ons list page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display_page() {
|
||||
wp_enqueue_style(
|
||||
'ai1ec_samples.css',
|
||||
AI1EC_ADMIN_THEME_CSS_URL . 'samples.css',
|
||||
array(),
|
||||
AI1EC_VERSION
|
||||
);
|
||||
|
||||
$this->_registry->get( 'theme.loader' )->get_file(
|
||||
'samples.twig',
|
||||
array(),
|
||||
true
|
||||
)->render();
|
||||
}
|
||||
|
||||
public function add_meta_box() {
|
||||
}
|
||||
|
||||
public function display_meta_box( $object, $box ) {
|
||||
}
|
||||
|
||||
public function handle_post() {
|
||||
}
|
||||
|
||||
}
|
||||
349
wp-content/plugins/all-in-one-event-calendar/app/view/admin/settings.php
Executable file
349
wp-content/plugins/all-in-one-event-calendar/app/view/admin/settings.php
Executable file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The Settings page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Admin_Settings extends Ai1ec_View_Admin_Abstract {
|
||||
|
||||
/**
|
||||
* @var string The nonce action
|
||||
*/
|
||||
CONST NONCE_ACTION = 'ai1ec_settings_save';
|
||||
|
||||
/**
|
||||
* @var string The nonce name
|
||||
*/
|
||||
CONST NONCE_NAME = 'ai1ec_settings_nonce';
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Abstract::display_page()
|
||||
*/
|
||||
public function display_page() {
|
||||
$settings = $this->_registry->get( 'model.settings' );
|
||||
$args = array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'All-in-One Event Calendar: Settings'
|
||||
),
|
||||
'nonce' => array(
|
||||
'action' => self::NONCE_ACTION,
|
||||
'name' => self::NONCE_NAME,
|
||||
'referrer' => false,
|
||||
),
|
||||
'metabox' => array(
|
||||
'screen' => $settings->get( 'settings_page' ),
|
||||
'action' => 'left',
|
||||
'object' => null
|
||||
),
|
||||
'support' => array(
|
||||
'screen' => $settings->get( 'settings_page' ),
|
||||
'action' => 'right',
|
||||
'object' => null
|
||||
),
|
||||
'action' =>
|
||||
ai1ec_admin_url(
|
||||
'?controller=front&action=ai1ec_save_settings&plugin=' .
|
||||
AI1EC_PLUGIN_NAME
|
||||
),
|
||||
);
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$file = $loader->get_file( 'setting/page.twig', $args, true );
|
||||
$file->render();
|
||||
if ( apply_filters( 'ai1ec_robots_install', true ) ) {
|
||||
$this->_registry->get( 'robots.helper' )->install();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Abstract::add_page()
|
||||
*/
|
||||
public function add_page() {
|
||||
$settings_page = add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
Ai1ec_I18n::__( 'Settings' ),
|
||||
Ai1ec_I18n::__( 'Settings' ),
|
||||
'manage_ai1ec_options',
|
||||
AI1EC_PLUGIN_NAME . '-settings',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
$this->_registry->get( 'model.settings' )
|
||||
->set( 'settings_page', $settings_page );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds metabox to the page.
|
||||
*
|
||||
* @wp_hook admin_init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_meta_box() {
|
||||
// Add the 'General Settings' meta box.
|
||||
add_meta_box(
|
||||
'ai1ec-general-settings',
|
||||
Ai1ec_I18n::_x( 'General Settings', 'meta box' ),
|
||||
array( $this, 'display_meta_box' ),
|
||||
$this->_registry->get( 'model.settings' )->get( 'settings_page' ),
|
||||
'left',
|
||||
'default'
|
||||
);
|
||||
// Add the 'Timely' meta box.
|
||||
add_meta_box(
|
||||
'ai1ec-support',
|
||||
Ai1ec_I18n::_x( 'Timely', 'meta box', AI1EC_PLUGIN_NAME ),
|
||||
array( $this, 'support_meta_box' ),
|
||||
$this->_registry->get( 'model.settings' )->get( 'settings_page' ),
|
||||
'right',
|
||||
'default'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Timely blog meta box
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param mixed $box
|
||||
*/
|
||||
public function support_meta_box( $object, $box ) {
|
||||
$newsItems = $this->_registry->get( 'news.feed' )->import_feed();
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$file = $loader->get_file(
|
||||
'box_support.php',
|
||||
array(
|
||||
'news' => $newsItems,
|
||||
),
|
||||
true
|
||||
);
|
||||
$file->render();
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Abstract::handle_post()
|
||||
*/
|
||||
public function handle_post() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the meta box for the settings page.
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param mixed $box
|
||||
*/
|
||||
public function display_meta_box( $object, $box ) {
|
||||
$tabs = array(
|
||||
'viewing-events' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Viewing Events' ),
|
||||
),
|
||||
'editing-events' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Adding/Editing Events' ),
|
||||
),
|
||||
'advanced' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Advanced' ),
|
||||
'items' => array(
|
||||
'advanced' => Ai1ec_I18n::__( 'Advanced Settings' ),
|
||||
'embedded-views' => Ai1ec_I18n::__( 'Shortcodes' ),
|
||||
'email' => Ai1ec_I18n::__( 'Email Templates' ),
|
||||
'apis' => Ai1ec_I18n::__( 'External Services' ),
|
||||
'cache' => Ai1ec_I18n::__( 'Cache Report' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// let other extensions add tabs.
|
||||
$tabs = apply_filters( 'ai1ec_add_setting_tabs', $tabs );
|
||||
$settings = $this->_registry->get( 'model.settings' );
|
||||
$plugin_settings = $settings->get_options();
|
||||
$tabs = $this->_get_tabs_to_show( $plugin_settings, $tabs );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$api = $this->_registry->get( 'model.api.api-registration' );
|
||||
$signup_available = $api->is_api_sign_up_available();
|
||||
$signed_to_api = $api->is_signed();
|
||||
$ticketing_message = $api->get_sign_message();
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$account = $api->get_current_account();
|
||||
$signup_args = array(
|
||||
'api_signed' => $signed_to_api,
|
||||
'signup_available' => $signup_available,
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Please, Sign In to Timely Network.'
|
||||
),
|
||||
'nonce' => array(
|
||||
'action' => 'ai1ec_api_ticketing_signup',
|
||||
'name' => 'ai1ec_api_ticketing_nonce',
|
||||
'referrer' => false,
|
||||
),
|
||||
'api_action' =>
|
||||
'?controller=front&action=ai1ec_api_ticketing_signup&plugin=' .
|
||||
AI1EC_PLUGIN_NAME,
|
||||
'required_text' => Ai1ec_I18n::__( 'This field is required.' ),
|
||||
'register_text' => Ai1ec_I18n::__( 'Register' ),
|
||||
'sign_in_text' => Ai1ec_I18n::__( 'Sign in' ),
|
||||
'signed_in_text' => Ai1ec_I18n::__(
|
||||
'You are signed in to <b>Timely Network</b> as ' . $account
|
||||
),
|
||||
'sign_out_text' => Ai1ec_I18n::__( 'Sign out' ),
|
||||
'can_sign_out' => apply_filters( 'ai1ec_api_can_sign_out', true ),
|
||||
'full_name_text' => Ai1ec_I18n::__( 'Full Name:' ),
|
||||
'hide_form_text' => Ai1ec_I18n::__( 'Hide form' ),
|
||||
'show_form_text' => Ai1ec_I18n::__( 'Show form' ),
|
||||
'email_text' => Ai1ec_I18n::__( 'Email:' ),
|
||||
'password_text' => Ai1ec_I18n::__( 'Password:' ),
|
||||
'confirm_password_text' => Ai1ec_I18n::__( 'Confirm Password:' ),
|
||||
'phone_number_text' => Ai1ec_I18n::__( 'Phone Number:' ),
|
||||
'terms_text' => Ai1ec_I18n::__(
|
||||
'I confirm that I have read, understand and agree with the <a href="https://time.ly/tos">terms of service</a>.'
|
||||
),
|
||||
'sign_out_warning' => Ai1ec_I18n::__(
|
||||
'<h4>Attention Required:</h4>If you choose to sign-out of the API Timely Network this will close all the created tickets and remove user access to them. In this case, on the event page, users will see the status “Event closed”.'
|
||||
),
|
||||
'sign_out_cancel' => Ai1ec_I18n::__( 'Cancel' ),
|
||||
'sign_out_confirm' => Ai1ec_I18n::__( 'Sign Out' ),
|
||||
'sign_up_button_text' => Ai1ec_I18n::__( 'Sign Up' ),
|
||||
'sign_in_button_text' => Ai1ec_I18n::__( 'Sign In' ),
|
||||
'calendar_type_text' => Ai1ec_I18n::__( 'Calendar Type:' ),
|
||||
'calendar_types' => array(
|
||||
'tourism' => Ai1ec_I18n::__( 'Tourism' ),
|
||||
'media' => Ai1ec_I18n::__( 'Media' ),
|
||||
'community_hubs' => Ai1ec_I18n::__( 'Community Hubs' ),
|
||||
'education' => Ai1ec_I18n::__( 'Education' ),
|
||||
'venue_business' => Ai1ec_I18n::__( 'Venue/Business' ),
|
||||
'artist_performer' => Ai1ec_I18n::__( 'Artist/Performer' ),
|
||||
'church_spiritual' => Ai1ec_I18n::__( 'Church/Spiritual' ),
|
||||
'association_group' => Ai1ec_I18n::__( 'Association/Group' ),
|
||||
'other' => Ai1ec_I18n::__( 'Other' )
|
||||
),
|
||||
);
|
||||
$loader->get_file( 'setting/api-signup.twig', $signup_args, true )->render();
|
||||
|
||||
|
||||
$args = array(
|
||||
'tabs' => $tabs,
|
||||
'content_class' => 'ai1ec-form-horizontal',
|
||||
'submit' => array(
|
||||
'id' => 'ai1ec_save_settings',
|
||||
'value' => '<i class="ai1ec-fa ai1ec-fa-save ai1ec-fa-fw"></i> ' .
|
||||
Ai1ec_I18n::__( 'Save Settings' ),
|
||||
'args' => array(
|
||||
'class' => 'ai1ec-btn ai1ec-btn-primary ai1ec-btn-lg',
|
||||
),
|
||||
),
|
||||
'pre_tabs_markup' => sprintf(
|
||||
'<div class="ai1ec-gzip-causes-js-failure">' .
|
||||
Ai1ec_I18n::__(
|
||||
'If the form below is not working please follow <a href="%s">this link</a>.'
|
||||
) .
|
||||
'</div>',
|
||||
wp_nonce_url(
|
||||
add_query_arg( 'ai1ec_disable_gzip_compression', '1' ),
|
||||
'ai1ec_disable_gzip_compression'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
$file = $loader->get_file( 'setting/bootstrap_tabs.twig', $args, true );
|
||||
$file->render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on the plugin options, decides what tabs to render.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param array $plugin_settings
|
||||
* @param array $tabs
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _get_tabs_to_show( array $plugin_settings, array $tabs ) {
|
||||
$index = 0;
|
||||
$renderer = $this->_registry->get( 'html.element.setting-renderer' );
|
||||
foreach ( $plugin_settings as $id => $setting ) {
|
||||
// if the setting is shown
|
||||
if ( isset ( $setting['renderer'] ) ) {
|
||||
$tab_to_use = isset( $setting['renderer']['item'] ) ?
|
||||
$setting['renderer']['item'] :
|
||||
$setting['renderer']['tab'];
|
||||
// check if it's the first one
|
||||
if (
|
||||
! isset ( $tabs[$tab_to_use]['elements'] )
|
||||
) {
|
||||
$tabs[$tab_to_use]['elements'] = array();
|
||||
}
|
||||
$setting['id'] = $id;
|
||||
// render the settings
|
||||
$weight = 10;
|
||||
if ( isset( $setting['renderer']['weight'] ) ) {
|
||||
$weight = (int)$setting['renderer']['weight'];
|
||||
}
|
||||
// NOTICE: do NOT change order of two first
|
||||
// elements {weight,index}, otherwise sorting will fail.
|
||||
$tabs[$tab_to_use]['elements'][] = array(
|
||||
'weight' => $weight,
|
||||
'index' => ++$index,
|
||||
'html' => $renderer->render( $setting ),
|
||||
);
|
||||
// if the settings has an item tab, set the item as active.
|
||||
if ( isset( $setting['renderer']['item'] ) ) {
|
||||
if ( ! isset( $tabs[$setting['renderer']['tab']]['items_active'][$setting['renderer']['item']] ) ) {
|
||||
$tabs[$setting['renderer']['tab']]['items_active'][$setting['renderer']['item']] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabs_to_display = array();
|
||||
// now let's see what tabs to display.
|
||||
foreach ( $tabs as $name => $tab ) {
|
||||
// sort by weights
|
||||
if ( isset( $tab['elements'] ) ) {
|
||||
asort( $tab['elements'] );
|
||||
}
|
||||
// if a tab has more than one item.
|
||||
if ( isset( $tab['items'] ) ) {
|
||||
// if no item is active, nothing is shown
|
||||
if ( empty( $tab['items_active'] ) ) {
|
||||
continue;
|
||||
}
|
||||
// if only one item is active, do not use the dropdown
|
||||
if ( count( $tab['items_active'] ) === 0 ) {
|
||||
$name = key($tab['items_active']);
|
||||
$tab['name'] = $tab['items'][$name];
|
||||
unset ( $tab['items'] );
|
||||
} else {
|
||||
// check active items for the dropdown
|
||||
foreach ( $tab['items'] as $item => $longname ) {
|
||||
if ( ! isset( $tab['items_active'][$item] ) ) {
|
||||
unset( $tab['items'][$item] );
|
||||
}
|
||||
}
|
||||
}
|
||||
// lets make a check to avoid overriding tabs
|
||||
if ( ! isset( $tabs_to_display[$name] ) ) {
|
||||
$tabs_to_display[$name] = $tab;
|
||||
} else {
|
||||
$tabs_to_display[$name]['elements'] = $tab['elements'];
|
||||
}
|
||||
|
||||
} else {
|
||||
// no items, just check for any element to display.
|
||||
if ( isset( $tab['elements'] ) ) {
|
||||
// lets make a check to avoid overriding tabs
|
||||
if ( ! isset( $tabs_to_display[$name] ) ) {
|
||||
$tabs_to_display[$name] = $tab;
|
||||
} else {
|
||||
$tabs_to_display[$name]['elements'] = $tab['elements'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tabs_to_display;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The Theme options page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Theme_Options extends Ai1ec_View_Admin_Abstract {
|
||||
|
||||
/**
|
||||
* @var string The nonce action
|
||||
*/
|
||||
const NONCE_ACTION = 'ai1ec_theme_options_save';
|
||||
|
||||
/**
|
||||
* @var string The nonce name
|
||||
*/
|
||||
const NONCE_NAME = 'ai1ec_theme_options_nonce';
|
||||
|
||||
/**
|
||||
* @var string The id/name of the submit button.
|
||||
*/
|
||||
const SUBMIT_ID = 'ai1ec_save_themes_options';
|
||||
|
||||
/**
|
||||
* @var string The id/name of the Reset button.
|
||||
*/
|
||||
const RESET_ID = 'ai1ec_reset_themes_options';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $meta_box_id;
|
||||
|
||||
/**
|
||||
* Adds the page to the correct menu.
|
||||
*/
|
||||
public function add_page() {
|
||||
$theme_options_page = add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
Ai1ec_I18n::__( 'Theme Options' ),
|
||||
Ai1ec_I18n::__( 'Theme Options' ),
|
||||
'manage_ai1ec_options',
|
||||
AI1EC_PLUGIN_NAME . '-edit-css',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
$settings = $this->_registry->get( 'model.settings' );
|
||||
if ( false !== $settings->get( 'less_variables_page' ) ) {
|
||||
// Make copy of Theme Options page at its old location.
|
||||
$submenu['themes.php'][] = array(
|
||||
Ai1ec_I18n::__( 'Calendar Theme Options' ),
|
||||
'manage_ai1ec_options',
|
||||
AI1EC_THEME_OPTIONS_BASE_URL,
|
||||
);
|
||||
};
|
||||
$settings->set( 'less_variables_page', $theme_options_page );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta box for page.
|
||||
*
|
||||
* @wp_hook admin_init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_meta_box() {
|
||||
// Add the 'General Settings' meta box.
|
||||
add_meta_box(
|
||||
'ai1ec-less-variables-tabs',
|
||||
Ai1ec_I18n::_x( 'Calendar Theme Options', 'meta box' ),
|
||||
array( $this, 'display_meta_box' ),
|
||||
$this->_registry->get( 'model.settings' )
|
||||
->get( 'less_variables_page' ),
|
||||
'left',
|
||||
'default'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page html
|
||||
*/
|
||||
public function display_page() {
|
||||
|
||||
$settings = $this->_registry->get( 'model.settings' );
|
||||
|
||||
$args = array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Calendar Theme Options'
|
||||
),
|
||||
'nonce' => array(
|
||||
'action' => self::NONCE_ACTION,
|
||||
'name' => self::NONCE_NAME,
|
||||
'referrer' => false,
|
||||
),
|
||||
'metabox' => array(
|
||||
'screen' => $settings->get( 'themes_option_page' ),
|
||||
'action' => 'left',
|
||||
'object' => null
|
||||
),
|
||||
'action' =>
|
||||
'?controller=front&action=ai1ec_save_theme_options&plugin=' . AI1EC_PLUGIN_NAME
|
||||
);
|
||||
|
||||
$frontend = $this->_registry->get( 'css.frontend' );
|
||||
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$file = $loader->get_file( 'theme-options/page.twig', $args, true );
|
||||
|
||||
return $file->render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the meta box for the settings page.
|
||||
*
|
||||
* @param mixed $object
|
||||
* @param mixed $box
|
||||
*/
|
||||
public function display_meta_box( $object, $box ) {
|
||||
|
||||
$tabs = array(
|
||||
'general' => array(
|
||||
'name' => Ai1ec_I18n::__( 'General' ),
|
||||
),
|
||||
'table' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Tables' ),
|
||||
),
|
||||
'buttons' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Buttons' ),
|
||||
),
|
||||
'forms' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Forms' ),
|
||||
),
|
||||
'calendar' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Calendar general' ),
|
||||
),
|
||||
'month' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Month/week/day view' ),
|
||||
),
|
||||
'agenda' => array(
|
||||
'name' => Ai1ec_I18n::__( 'Agenda view' ),
|
||||
),
|
||||
);
|
||||
|
||||
$tabs = apply_filters( 'ai1ec_less_variables_tabs', $tabs );
|
||||
|
||||
$less_variables = $this->_registry
|
||||
->get( 'less.lessphp' )->get_saved_variables();
|
||||
$tabs = $this->_get_tabs_to_show( $less_variables, $tabs );
|
||||
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$args = array(
|
||||
'stacked' => true,
|
||||
'content_class' => 'ai1ec-form-horizontal',
|
||||
'tabs' => $tabs,
|
||||
'submit' => array(
|
||||
'id' => self::SUBMIT_ID,
|
||||
'value' => '<i class="ai1ec-fa ai1ec-fa-save ai1ec-fa-fw"></i> ' .
|
||||
Ai1ec_I18n::__( 'Save Options' ),
|
||||
'args' => array(
|
||||
'class' => 'ai1ec-btn ai1ec-btn-primary ai1ec-btn-lg',
|
||||
),
|
||||
),
|
||||
'reset' => array(
|
||||
'id' => self::RESET_ID,
|
||||
'value' => '<i class="ai1ec-fa ai1ec-fa-undo ai1ec-fa-fw"></i> ' .
|
||||
Ai1ec_I18n::__( 'Reset to Defaults' ),
|
||||
'args' => array(
|
||||
'class' => 'ai1ec-btn ai1ec-btn-danger ai1ec-btn-lg',
|
||||
),
|
||||
),
|
||||
);
|
||||
$file = $loader->get_file( 'theme-options/bootstrap_tabs.twig', $args, true );
|
||||
$file->render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the theme options tabs
|
||||
*
|
||||
* @param array $less_variables
|
||||
* @param array $tabs list of tabs
|
||||
*
|
||||
* @return array the array of tabs to display
|
||||
*/
|
||||
protected function _get_tabs_to_show( array $less_variables, array $tabs) {
|
||||
|
||||
// Inizialize the array of tabs that will be added to the layout
|
||||
$bootstrap_tabs_to_add = array();
|
||||
|
||||
foreach( $tabs as $id => $tab ){
|
||||
$tab['elements'] = array();
|
||||
$bootstrap_tabs_to_add[$id] = $tab;
|
||||
}
|
||||
foreach ( $less_variables as $variable_id => $variable_attributes ) {
|
||||
$variable_attributes['id'] = $variable_id;
|
||||
$renderable = $this->_registry->get(
|
||||
'less.variable.' . $variable_attributes['type'],
|
||||
$variable_attributes
|
||||
);
|
||||
$bootstrap_tabs_to_add[$variable_attributes['tab']]['elements'][] = array(
|
||||
'html' => $renderable->render()
|
||||
);
|
||||
}
|
||||
return $bootstrap_tabs_to_add;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle post, likely to be deprecated to use commands.
|
||||
*/
|
||||
public function handle_post() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The Theme selection page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.0
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Admin_Theme_Switching extends Ai1ec_View_Admin_Abstract {
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Abstract::display_page()
|
||||
*/
|
||||
public function display_page() {
|
||||
global $ct;
|
||||
// defaults
|
||||
$activated = isset( $_GET['activated'] ) ? true : false;
|
||||
$deleted = false;
|
||||
|
||||
$_list_table = $this->_registry->get( 'theme.list' );
|
||||
$_list_table->prepare_items();
|
||||
|
||||
$args = array(
|
||||
'activated' => $activated,
|
||||
'deleted' => $deleted,
|
||||
'ct' => $ct,
|
||||
'wp_list_table' => $_list_table,
|
||||
'page_title' => Ai1ec_I18n::__(
|
||||
'All-in-One Event Calendar: Themes'
|
||||
),
|
||||
);
|
||||
|
||||
add_thickbox();
|
||||
wp_enqueue_script( 'theme-preview' );
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
|
||||
$file = $loader->get_file( 'themes.php', $args, true );
|
||||
return $file->render();
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Abstract::add_page()
|
||||
*/
|
||||
public function add_page() {
|
||||
global $submenu;
|
||||
// ===============
|
||||
// = Themes Page =
|
||||
// ===============
|
||||
$themes_page = add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
Ai1ec_I18n::__( 'Calendar Themes' ),
|
||||
Ai1ec_I18n::__( 'Calendar Themes' ),
|
||||
'switch_ai1ec_themes',
|
||||
AI1EC_PLUGIN_NAME . '-themes',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
}
|
||||
|
||||
public function add_meta_box() {
|
||||
}
|
||||
|
||||
public function handle_post() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tickets page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.4
|
||||
*
|
||||
* @package AI1EC
|
||||
* @subpackage AI1EC.View
|
||||
*/
|
||||
class Ai1ec_View_Tickets extends Ai1ec_View_Admin_Abstract {
|
||||
|
||||
/**
|
||||
* @var string The nonce action
|
||||
*/
|
||||
const NONCE_ACTION = 'ai1ec_api_ticketing_signup';
|
||||
|
||||
/**
|
||||
* @var string The nonce name
|
||||
*/
|
||||
const NONCE_NAME = 'ai1ec_api_ticketing_nonce';
|
||||
|
||||
/**
|
||||
* @var string The id/name of the submit button.
|
||||
*/
|
||||
const SUBMIT_ID = 'ai1ec_api_ticketing_signup';
|
||||
|
||||
/**
|
||||
* Adds the page to the correct menu.
|
||||
*/
|
||||
public function add_page() {
|
||||
add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
__( 'Ticketing', AI1EC_PLUGIN_NAME ),
|
||||
__( 'Ticketing', AI1EC_PLUGIN_NAME ),
|
||||
'manage_ai1ec_feeds',
|
||||
AI1EC_PLUGIN_NAME . '-tickets',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add meta box for page.
|
||||
*
|
||||
* @wp_hook admin_init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_meta_box() {}
|
||||
|
||||
/**
|
||||
* Display the page html
|
||||
*/
|
||||
public function display_page() {
|
||||
|
||||
$signed_to_api = $this->_api_registration->is_signed();
|
||||
$signup_available = $this->_api_registration->is_api_sign_up_available();
|
||||
$ticketing_available = $this->_api_registration->is_ticket_available();
|
||||
$ticketing_enabled = $this->_api_registration->has_subscription_active( Ai1ec_Api_Features::CODE_TICKETING );
|
||||
$ticketing_message = $this->_api_registration->get_sign_message();
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
wp_enqueue_style(
|
||||
'ai1ec_samples.css',
|
||||
AI1EC_ADMIN_THEME_CSS_URL . 'samples.css',
|
||||
array(),
|
||||
AI1EC_VERSION
|
||||
);
|
||||
|
||||
if ( ! $signed_to_api ) {
|
||||
|
||||
if ( false === ai1ec_is_blank( $ticketing_message ) ) {
|
||||
$this->_api_registration->clear_sign_message();
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Timely Ticketing'
|
||||
),
|
||||
'sign_up_text' => 'Please, <a href="edit.php?post_type=ai1ec_event&page=all-in-one-event-calendar-settings">Sign Up for a Timely Network account</a> to use Ticketing.',
|
||||
'signup_form' => Ai1ec_I18n::__( 'You need to sign up for a Timely Network account in order to use Ticketing.<br /><br />' ) .
|
||||
(
|
||||
$signup_available
|
||||
? Ai1ec_I18n::__( '<a href="edit.php?post_type=ai1ec_event&page=all-in-one-event-calendar-settings" class="ai1ec-btn ai1ec-btn-primary ai1ec-btn-lg">Sign In to Timely Network</a>' )
|
||||
: Ai1ec_I18n::__( '<b>Signing up for a Timely Network account is currently unavailable. Please, try again later.</b>' )
|
||||
),
|
||||
'show_info' => true
|
||||
|
||||
);
|
||||
$file = $loader->get_file( 'ticketing/signup.twig', $args, true );
|
||||
} elseif ( ! $ticketing_available ) {
|
||||
$args = array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Timely Ticketing'
|
||||
),
|
||||
'sign_up_text' => '',
|
||||
'signup_form' => 'Ticketing is currently not available for this website. Please, try again later.',
|
||||
'show_info' => true
|
||||
|
||||
);
|
||||
$file = $loader->get_file( 'ticketing/signup.twig', $args, true );
|
||||
} elseif ( ! $ticketing_enabled ) {
|
||||
$args = array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Timely Ticketing'
|
||||
),
|
||||
'sign_up_text' => '',
|
||||
'signup_form' => '',
|
||||
'show_info' => true
|
||||
);
|
||||
$file = $loader->get_file( 'ticketing/signup.twig', $args, true );
|
||||
} else {
|
||||
$response = $this->_api_registration->get_payment_preferences();
|
||||
$purchases = $this->_api_registration->get_purchases();
|
||||
$args = array(
|
||||
'title' => Ai1ec_I18n::__(
|
||||
'Timely Ticketing'
|
||||
),
|
||||
'settings_text' => Ai1ec_I18n::__( 'Settings' ),
|
||||
'sales_text' => Ai1ec_I18n::__( 'Sales' ),
|
||||
'select_payment_text' => Ai1ec_I18n::__( 'Please provide your PayPal details.' ),
|
||||
'cheque_text' => Ai1ec_I18n::__( 'Cheque' ),
|
||||
'paypal_text' => Ai1ec_I18n::__( 'PayPal' ),
|
||||
'currency_text' => Ai1ec_I18n::__( 'Preferred currency for tickets:' ),
|
||||
'required_text' => Ai1ec_I18n::__( 'This field is required.' ),
|
||||
'save_changes_text' => Ai1ec_I18n::__( 'Save Changes' ),
|
||||
'date_text' => Ai1ec_I18n::__( 'Date' ),
|
||||
'event_text' => Ai1ec_I18n::__( 'Event' ),
|
||||
'purchaser_text' => Ai1ec_I18n::__( 'Purchaser' ),
|
||||
'tickets_text' => Ai1ec_I18n::__( 'Tickets' ),
|
||||
'email_text' => Ai1ec_I18n::__( 'Email' ),
|
||||
'status_text' => Ai1ec_I18n::__( 'Status' ),
|
||||
'total_text' => Ai1ec_I18n::__( 'Total' ),
|
||||
'sign_out_button_text' => Ai1ec_I18n::__( 'Sign Out' ),
|
||||
'payment_method' => $response->payment_method,
|
||||
'paypal_email' => $response->paypal_email,
|
||||
'first_name' => $response->first_name,
|
||||
'last_name' => $response->last_name,
|
||||
'currency' => $response->currency,
|
||||
'nonce' => array(
|
||||
'action' => self::NONCE_ACTION,
|
||||
'name' => self::NONCE_NAME,
|
||||
'referrer' => false,
|
||||
),
|
||||
'action' =>
|
||||
'?controller=front&action=ai1ec_api_ticketing_signup&plugin=' .
|
||||
AI1EC_PLUGIN_NAME,
|
||||
'purchases' => $purchases,
|
||||
'paypal_currencies' => array (
|
||||
array( 'description' => Ai1ec_I18n::__( 'United States Dollar' ), 'code' => 'USD' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Canadian Dollar' ), 'code' => 'CAD' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Australian Dollar' ), 'code' => 'AUD' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Brazilian Real' ), 'code' => 'BRL', 'note' => Ai1ec_I18n::__( 'Note: This currency is supported as a payment currency and a currency balance for in-country PayPal accounts only.' ) ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Czech Koruna' ), 'code' => 'CZK' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Danish Krone' ), 'code' => 'DKK' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Euro' ), 'code' => 'EUR' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Hong Kong Dollar' ), 'code' => 'HKD' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Hungarian Forint' ), 'code' => 'HUF', 'note' => Ai1ec_I18n::__( 'Note: Decimal amounts are not supported for this currency. Passing a decimal amount will throw an error.' ) ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Israeli New Sheqel' ), 'code' => 'ILS' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Japanese Yen' ), 'code' => 'JPY', 'note' => Ai1ec_I18n::__( 'Note: This currency does not support decimals. Passing a decimal amount will throw an error. 1,000,000' ) ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Malaysian Ringgit' ), 'code' => 'MYR', 'note' => Ai1ec_I18n::__( 'Note: This currency is supported as a payment currency and a currency balance for in-country PayPal accounts only.' ) ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Mexican Peso' ), 'code' => 'MXN' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Norwegian Krone' ), 'code' => 'NOK' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'New Zealand Dollar' ), 'code' => 'NZD' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Philippine Peso' ), 'code' => 'PHP' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Polish Zloty' ), 'code' => 'PLN' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Pound Sterling' ), 'code' => 'GBP' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Russian Ruble' ), 'code' => 'RUB', 'note' => Ai1ec_I18n::__( 'For in-border payments (payments made within Russia), the Russian Ruble is the only accepted currency. If you use another currency for in-border payments, the transaction will fail' ) ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Singapore Dollar' ), 'code' => 'SGD' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Swedish Krona' ), 'code' => 'SEK' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Swiss Franc' ), 'code' => 'CHF' ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Taiwan New Dollar' ), 'code' => 'TWD', 'note' => Ai1ec_I18n::__( 'Note: Decimal amounts are not supported for this currency. Passing a decimal amount will throw an error.' ) ),
|
||||
array( 'description' => Ai1ec_I18n::__( 'Thai Baht' ), 'code' => 'THB' ),
|
||||
)
|
||||
);
|
||||
$file = $loader->get_file( 'ticketing/manage.twig', $args, true );
|
||||
}
|
||||
|
||||
$this->_registry->get( 'css.admin' )->admin_enqueue_scripts(
|
||||
'ai1ec_event_page_all-in-one-event-calendar-settings'
|
||||
);
|
||||
$this->_registry->get( 'css.admin' )->process_enqueue(
|
||||
array(
|
||||
array( 'style', 'ticketing.css', ),
|
||||
)
|
||||
);
|
||||
if ( isset( $_POST['ai1ec_save_settings'] ) ) {
|
||||
$response = $this->_api_registration->save_payment_preferences();
|
||||
|
||||
// this redirect makes sure that the error messages appear on the screen
|
||||
if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
|
||||
header( "Location: " . $_SERVER['HTTP_REFERER'] );
|
||||
}
|
||||
}
|
||||
return $file->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle post, likely to be deprecated to use commands.
|
||||
*/
|
||||
public function handle_post(){}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The SuperWidget creator page.
|
||||
*
|
||||
* @author Time.ly Network Inc.
|
||||
* @since 2.1
|
||||
*
|
||||
* @package AI1ECSW
|
||||
* @subpackage AI1ECSW.View
|
||||
*/
|
||||
class Ai1ec_View_Widget_Creator extends Ai1ec_View_Admin_Abstract {
|
||||
|
||||
/**
|
||||
* Adds page to the menu.
|
||||
*
|
||||
* @wp_hook admin_menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_page() {
|
||||
add_submenu_page(
|
||||
AI1EC_ADMIN_BASE_URL,
|
||||
__( 'Widget Creator', AI1EC_PLUGIN_NAME ),
|
||||
__( 'Widget Creator', AI1EC_PLUGIN_NAME ),
|
||||
'manage_ai1ec_feeds',
|
||||
AI1EC_PLUGIN_NAME . '-widget-creator',
|
||||
array( $this, 'display_page' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display this plugin's feeds page in the admin.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display_page() {
|
||||
$this->_registry->get( 'css.admin' )->admin_enqueue_scripts(
|
||||
'ai1ec_event_page_all-in-one-event-calendar-settings'
|
||||
);
|
||||
$this->_registry->get( 'css.admin' )->process_enqueue(
|
||||
array(
|
||||
array( 'style', 'super-widget.css', ),
|
||||
)
|
||||
);
|
||||
$args = array(
|
||||
'title' => __(
|
||||
'Widget Creator',
|
||||
AI1EC_PLUGIN_NAME
|
||||
),
|
||||
'metabox' => array(
|
||||
'screen' => 'ai1ec-super-widget',
|
||||
'action' => 'left',
|
||||
'object' => null
|
||||
),
|
||||
);
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$file = $loader->get_file( 'widget-creator/page.twig', $args, true );
|
||||
$file->render();
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Settings::handle_post()
|
||||
*/
|
||||
public function handle_post() {
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Settings::add_meta_box()
|
||||
*/
|
||||
public function add_meta_box() {
|
||||
add_meta_box(
|
||||
'ai1ec-widget-creator',
|
||||
_x( 'Widget Creator', 'meta box', AI1EC_PLUGIN_NAME ),
|
||||
array( $this, 'display_meta_box' ),
|
||||
'ai1ec-super-widget',
|
||||
'left',
|
||||
'default'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the settings
|
||||
*
|
||||
* @param array $settings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_html_from_settings( array $settings ) {
|
||||
$named_elements = array();
|
||||
foreach ( $settings as $id => $setting ) {
|
||||
$named_elements[$id] = $this->_registry->get(
|
||||
'html.element.setting.' . $setting['renderer']['class'],
|
||||
array(
|
||||
'id' => $id,
|
||||
'value' => $setting['value'],
|
||||
'renderer' => $setting['renderer'],
|
||||
)
|
||||
)->render();
|
||||
}
|
||||
return $named_elements;
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
* @see Ai1ec_View_Admin_Settings::display_meta_box()
|
||||
*/
|
||||
public function display_meta_box( $object, $box ) {
|
||||
$widgets = $this->_registry->get( 'controller.javascript-widget' )
|
||||
->get_widgets();
|
||||
// this is just for the Super Widget which doesn't fully implement Ai1ec_Embeddable
|
||||
$widgets = apply_filters( 'ai1ec_widget_creators_widgets', $widgets );
|
||||
$tabs = array();
|
||||
foreach ( $widgets as $widget_id => $widget_class ) {
|
||||
$widget = $this->_registry->get( $widget_class );
|
||||
$tabs[$widget_id] = array(
|
||||
'name' => $widget->get_name(),
|
||||
'icon' => $widget->get_icon(),
|
||||
'requirements' => $widget->check_requirements(),
|
||||
'elements' => $this->get_html_from_settings(
|
||||
$widget->get_configurable_for_widget_creation()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$loader = $this->_registry->get( 'theme.loader' );
|
||||
$file = $loader->get_file(
|
||||
'widget-creator/super-widget-contents.twig',
|
||||
array(
|
||||
'tabs' => $tabs,
|
||||
'siteurl' => trailingslashit( preg_replace( '/^.*?:/', '', ai1ec_get_site_url() ) ),
|
||||
'text_common_info' => Ai1ec_I18n::__( 'Use this tool to generate code snippets you can add to <strong>an external website</strong> to embed new calendars and widgets.' ),
|
||||
'text_alert' => Ai1ec_I18n::__( '<h4>Attention!</h4><p>These widgets are designed to be embedded in <strong>external sites only</strong> and may cause conflicts if used within the same WordPress site.</p>' ),
|
||||
'text_alternatives' => sprintf(
|
||||
Ai1ec_I18n::__( '<p>Use <a href="%s"><strong>Appearance</strong> > <strong>Widgets</strong></a> to add event widgets to your WordPress site as you would any other widget, or use <a href="%s" target="_blank">shortcodes</a> to embed the full calendar.</strong></p>' ),
|
||||
admin_url( 'widgets.php' ),
|
||||
'https://time.ly/document/user-guide/using-calendar/display-multiple-calendars-site/'
|
||||
),
|
||||
'display_alert' => apply_filters( 'ai1ec_display_widget_creator_warning', true ),
|
||||
'text_preview' => Ai1ec_I18n::__( 'Preview:' ),
|
||||
'text_paste' => Ai1ec_I18n::__( 'Paste this code onto your site:' ),
|
||||
'text_updated_code' => Ai1ec_I18n::__( 'This code will update to reflect changes made to the settings. Changing settings will not affect previously embedded widgets.' ),
|
||||
),
|
||||
true
|
||||
);
|
||||
$file->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user