コード例 #1
0
 /**
  * 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));
 }
コード例 #2
0
 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.'));
 }
コード例 #3
0
 /**
  * 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));
 }
コード例 #4
0
    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);
    }
コード例 #5
0
 public static function unhide_prices()
 {
     $post = filter_input_array(INPUT_POST, FILTER_SANITIZE_ENCODED);
     $response = array();
     $nonce = $post['nonce'];
     if (isset($post['admin'])) {
         $nonceTitle = 'bpt-admin-nonce';
     } else {
         $nonceTitle = 'bpt-event-list-nonce';
     }
     Utilities::check_nonce($nonce, $nonceTitle);
     if (Utilities::is_user_an_admin()) {
         $hidden_prices = get_option('_bpt_hidden_prices');
         if (!$hidden_prices) {
             $response['error'] = 'No hidden prices';
         }
         $prices = $post['prices'];
         $response['prices'] = $prices;
         foreach ($prices as $price) {
             $id = $price['priceId'];
             unset($hidden_prices[$id]);
         }
         $response['hiddenPrices'] = $hidden_prices;
         $update_option = update_option('_bpt_hidden_prices', $hidden_prices);
         if ($update_option) {
             $response['success'] = 'Price is now visible.';
             $response['priceID'] = $price['priceId'];
         } else {
             $response['error'] = 'Could not unhide price.';
             $response['priceID'] = $price['priceId'];
         }
     } else {
         $response = array('error' => 'Not authorized.');
     }
     wp_send_json($response);
 }