public function show_upcoming_events() { ?> <div class="show-upcoming-dates-calendar-wrapper"> <input id="show-upcoming-dates-calendar-true" name="_bpt_show_upcoming_events_calendar" <?php esc_attr_e(Utilities::is_selected('true', '_bpt_show_upcoming_events_calendar', 'checked')); ?> value="true" type="radio" /> <label for="show-upcoming-events-calendar-true">Yes</label> <input id="show-upcoming-events-calendar-false" name="_bpt_show_upcoming_events_calendar" <?php esc_attr_e(Utilities::is_selected('false', '_bpt_show_upcoming_events_calendar', 'checked')); ?> value="false" type="radio" /> <label for="show-upcoming-events-calendar-false">No</label> <div class="<?php esc_attr_e(plugin::get_menu_slug()); ?> _help"> <span>?</span> <div> <p> If you would like to show upcoming events in the calendar, select yes. </p> </div> </div> </div> <?php }
/** * Returns an array of a specific producers events formatted for the CLNDR. * @param string $client_id The Client ID of the producer you wish * to get the events of. * @param boolean $dates Get prices? Default is false. * @param boolean $prices Get Prices? Default is false. * @return json The JSON string of the event Data. */ public static function get_events() { $get = filter_input_array(INPUT_GET, FILTER_SANITIZE_ENCODED); $nonce = $get['nonce']; $widget_instance = $get['widgetID']; Utilities::check_nonce($nonce, 'bpt-calendar-widget-nonce'); if (isset($get['clientID'])) { $client_id = $get['clientID']; } else { $client_id = get_option('_bpt_client_id'); } if (!$client_id) { wp_send_json(array('success' => false, 'error' => 'No client ID.')); } if (!$widget_instance) { wp_send_json(array('success' => false, 'error' => 'No widget ID.')); } if (!Utilities::cache_enabled()) { $events = new Api(); wp_send_json($events->get_events($client_id)); } if (get_transient('_bpt_calendar_events_' . $widget_instance) === false && Utilities::cache_enabled()) { $events = new Api(); set_transient('_bpt_calendar_events_' . $widget_instance, $events->get_events($client_id), Utilities::cache_time()); } wp_send_json(get_transient('_bpt_calendar_events_' . $widget_instance)); }
/** * Simple Get Account Call for testing that the settings are correct. * $dev_id and $client_id must be passed to the function. */ public function test_account($dev_id, $client_id) { $account_info = new \BrownPaperTickets\APIv2\AccountInfo($dev_id); $event_list = new \BrownPaperTickets\APIv2\EventInfo($dev_id); $response = array('account' => $account_info->getAccount($client_id), 'events' => $event_list->getEvents($client_id)); $response['events'] = Utilities::remove_bad_events($response['events']); return $response; }
public static function add_prices() { Utilities::check_nonce($_REQUEST['nonce'], self::$nonce_title); if (!isset($_POST['prices'])) { wp_send_json(array('success' => false, 'message' => 'No prices were sent.')); } if (Utilities::set_session_var('prices', $_POST['prices'])) { wp_send_json(array('success' => true, 'message' => 'Prices updated.', 'prices' => Utilities::get_session_var('prices'))); } wp_send_json(array('success' => false, 'message' => 'Unable to add prices.')); }
public function get_events($client_id = null, $event_id = null) { if (!$client_id) { $client_id = $this->client_id; } if (!$event_id) { $event_id = null; } /** * Get Event List Setting Options * */ $show_dates = get_option('_bpt_show_dates'); $show_prices = get_option('_bpt_show_prices'); $show_past_dates = get_option('_bpt_show_past_dates'); $show_sold_out_dates = get_option('_bpt_show_sold_out_dates'); $show_sold_out_prices = get_option('_bpt_show_sold_out_prices'); $event_info = new \BrownPaperTickets\APIv2\EventInfo($this->dev_id); if ($event_id) { $client_id = null; $event_id = explode(' ', $event_id); $events = array(); foreach ($event_id as $id) { $events[] = $event_info->getEvents($client_id, $id, $show_dates, $show_prices); } foreach ($events as $event) { $event_list[] = $event[0]; } } if (!$event_id) { $event_list = $event_info->getEvents($client_id, $event_id, $show_dates, $show_prices); } if (isset($event_list['error'])) { $event_list; } $event_list = Utilities::remove_bad_events($event_list); $event_list = Utilities::sort_prices($event_list); if ($show_dates === 'true') { $remove_past = true; if ($show_past_dates === 'false') { $remove_past = false; } $event_list = Utilities::remove_bad_dates($event_list, true, $remove_past); } if ($show_prices === 'true' && $show_sold_out_prices === 'false') { $event_list = Utilities::remove_bad_prices($event_list); } return $event_list; }
/** * Account Test Setup */ public static function test_account() { $post = filter_input_array(INPUT_POST, FILTER_SANITIZE_ENCODED); Utilities::check_nonce($post['nonce'], 'bpt-admin-nonce'); $dev_id = isset($post['devID']) ? htmlentities($post['devID']) : false; $client_id = isset($post['clientID']) ? htmlentities($post['clientID']) : false; if (!$dev_id) { wp_send_json(array('success' => false, 'error' => 'No developer ID.')); } if (!$client_id) { wp_send_json(array('success' => false, 'error' => 'No client ID.')); } $account = new Api(); wp_send_json($account->test_account($dev_id, $client_id)); }
public static function get_all_options() { $get = filter_input_array(INPUT_GET, FILTER_SANITIZE_ENCODED); Utilities::check_nonce($get['nonce'], self::$nonce_title); global $wpdb; $options = $wpdb->get_results('SELECT * FROM `wp_options` WHERE `option_name` LIKE \'%_bpt_%\'', OBJECT); $results = array(); foreach ($options as &$option) { $option_name = str_replace('_bpt_', '', $option->option_name); $results[$option_name] = $option->option_value; } wp_send_json($results); }
<?php namespace BrownPaperTickets\Modules; use BrownPaperTickets\BptWordpress as Utilities; require_once Utilities::plugin_root_dir() . 'lib/BptAPI/vendor/autoload.php'; class ModuleApi { protected $dev_id; protected $client_id; public function __construct() { $this->dev_id = get_option('_bpt_dev_id'); $this->client_id = get_option('_bpt_client_id'); } }
/** * Filter Hidden Prices * @param mixed $events Either a json string or an array of events. * @return array The modified/filtered array. */ private static function filter_hidden_prices($events) { if (is_string($events)) { $events = json_decode($events, true); } $hidden_prices = get_option('_bpt_hidden_prices'); if ($hidden_prices) { // If the user is an admin, we'll just add a property "hidden" to the // price. if (Utilities::is_user_an_admin()) { foreach ($events as &$event) { foreach ($event['dates'] as &$date) { foreach ($date['prices'] as &$price) { if (array_key_exists($price['id'], $hidden_prices)) { $price['hidden'] = true; } } } } } else { // If the user is not an admin, we'll remove that price. foreach ($events as &$event) { foreach ($event['dates'] as &$date) { $i = 0; foreach ($date['prices'] as &$price) { if (array_key_exists($price['id'], $hidden_prices)) { unset($date['prices'][$i]); } $i++; } $date['prices'] = array_values($date['prices']); } } } } return $events; }
<?php namespace BrownPaperTickets\Modules\Calendar; use BrownPaperTickets\BptWordpress as Utilities; require_once Utilities::plugin_root_dir() . 'src/modules/bpt-module-api.php'; class Api extends \BrownPaperTickets\Modules\ModuleApi { /** * Returns an array of a specific producers events formatted for the CLNDR. * @param string $client_id The Client ID of the producer you wish * to get the events of. * @param boolean $dates Get prices? Default is false. * @param boolean $prices Get Prices? Default is false. * @return json The JSON string of the event Data. */ public function get_events($client_id = null, $dates = true, $prices = false) { $dev_id = get_option('_bpt_dev_id'); if (!$this->dev_id) { return array('success' => false, 'error' => 'Unable to fetch events.'); } if (isset($_POST['clientID']) && $_POST['clientID'] !== '') { $client_id = $_POST['clientID']; } $events = new \BrownPaperTickets\APIv2\EventInfo($this->dev_id); $events = $events->getEvents($client_id, null, $dates, $prices); $clndr_format = array(); foreach ($events as $event) { if ($event['live']) { foreach ($event['dates'] as $date) {
esc_attr_e($currency); ?> ')}} w/service fee)</small> {{/value}} {{ /.includeFee }} </td> <td> <select class="bpt-price-qty" name="price_{{ id }}" data-price-id="{{ id }}"> {{{ getQuantityOptions( . ) }}} <option value="0" selected="true">0</option> </select> </td> </tr> <?php if (Utilities::is_user_an_admin()) { ?> <tr class="bpt-admin-option"> <td colspan="3"> <!-- <h5>Price Options</h5> --> <span> <label for="bpt-price-hidden-{{ id }}" class="bpt-admin-option bpt-price-hidden">Display Price</label> <select id="bpt-price-hidden-{{ id }}" on-change="togglePriceVisibility" class="bpt-admin-option bpt-price-hidden" data-price-id="{{ id }}" data-price-name="{{ name }}"> <option {{ ^hidden }}selected{{ /hidden }} value="true">Yes</option> <option {{ #hidden }}selected{{ /hidden }}value="false">No</option> </select> </span> <span> <label class="bpt-admin-option bpt-price-max-quantity" for="bpt-price-max-quantity-{{ id }}">Set Max Quantity</label> <input id="bpt-price-max-quantity-{{ id }}" type="text" value="{{ .maxQuantity }}" class="bpt-admin-option bpt-price-max-quantity" on-change="setPriceMaxQuantity" placeholder="20"> </span>
public function include_service_fee() { ?> <div class="include-service-fee-wrapper"> <input id="include-service-fee-true" name="_bpt_include_service_fee" <?php esc_attr_e(Utils::is_selected('true', '_bpt_include_service_fee', 'checked')); ?> value="true" type="radio" /> <label for="include-service-fee-true">Yes</label> <input id="include-service-fee-true" name="_bpt_include_service_fee" <?php esc_attr_e(Utils::is_selected('false', '_bpt_include_service_fee', 'checked')); ?> value="false" type="radio" /> <label for="include-service-fee-true">No</label> <div class="<?php esc_attr_e(BPTPlugin::get_menu_slug()); ?> _help"> <span>?</span> <div> <p> If you would like to include the Brown Paper Tickets service fees in your price total, select true. </p> </div> </div> <p class="bpt-help">This will override any individual price's service fee setting.</p> </div> <?php }
<?php namespace BrownPaperTickets\Modules; require_once plugin_dir_path(__FILE__) . '../bpt-module-class.php'; require_once plugin_dir_path(__FILE__) . '/purchase-inputs.php'; require_once plugin_dir_path(__FILE__) . '/purchase-ajax.php'; require_once \BrownPaperTickets\BptWordpress::plugin_root_dir() . 'lib/BptAPI/vendor/autoload.php'; use BrownPaperTickets\APIv2\ManageCart; use BrownPaperTickets\APIv2\CartInfo; class Purchase extends Module { public function register_settings() { register_setting(self::$menu_slug, self::$setting_prefix . 'purchase_settings'); } public function register_sections() { $section_title = 'Purchase Settings'; $section_suffix = '_purchase'; $inputs = new Purchase\Inputs(); add_settings_section($section_title, $section_title, array($inputs, 'section'), self::$menu_slug . $section_suffix); add_settings_field(self::$setting_prefix . 'enable_sales', 'Enable Sales', array($inputs, 'enable_sales'), self::$menu_slug . $section_suffix, $section_title); } public function load_public_js($hook) { global $post; $options = get_option('_bpt_purchase_settings'); $sales_enabled = isset($options['enable_sales']) ? $options['enable_sales'] : false; $require_all_info = isset($options['require_all_info']) ? $options['require_all_info'] : false; if (is_a($post, 'WP_Post') && (has_shortcode($post->post_content, 'list-events') || has_shortcode($post->post_content, 'list_events')) && $sales_enabled) {