/** * Constructor magic method. * Private because this class should not be called on its own. */ public function __construct($args = array()) { parent::__construct(); $this->labels = $this->get_labels(); $this->item = new WPIMItem(); $this->set_query_args($args); $this->set_single(); $this->use_currency_formats = array('price', 'amount', 'inventory_price', 'inventory_amount'); $this->use_currency_formats = apply_filters('wpim_use_currency_formats', $this->use_currency_formats); $this->use_date_formats = array('date_updated', 'date_added', 'inventory_date_updated', 'inventory_date_added'); $this->use_date_formats = apply_filters('wpim_use_date_formats', $this->use_date_formats); }
public static function activate($data, $key) { // data to send in our API request if (!$data) { $item_name = self::REG_ITEM_NAME; $item_key = 'core'; } else { $item_name = $data->item_name; $item_key = $data->key; } $api_params = array('edd_action' => 'activate_license', 'license' => $key, 'item_name' => urlencode($item_name), 'url' => home_url()); $response = wp_remote_post(self::API_URL, array('timeout' => 15, 'sslverify' => FALSE, 'body' => $api_params)); if (is_wp_error($response)) { // Try again with post $response = wp_remote_get(add_query_arg($api_params, self::API_URL), array('timeout' => 15, 'sslverify' => FALSE)); if (is_wp_error($response)) { echo '<div class="error"><p>' . WPIMCore::__('When attempting to activate license, could not reach license site.') . '</p></div>'; return FALSE; } } if (!$response) { echo '<div class="error"><p>' . WPIMCore::__('When attempting to activate license, no response was received.') . '</p></div>'; } else { if (wp_remote_retrieve_response_code($response) != 200) { echo '<div class="error"><p>' . sprintf(WPIMCore::__('When attempting to activate license, a response code of %d was returned.'), wp_remote_retrieve_response_code($response)) . '</p>'; echo '<p><strong>Debugging Information: Please provide the information below to support.</strong></p>'; var_dump($response); echo '</div>'; } else { $response = json_decode(wp_remote_retrieve_body($response)); if ($response->license != 'valid') { echo '<div class="error"><p>' . sprintf(WPIMCore::__('The license entered for %s is invalid.'), $item_name) . '</p></div>'; $key = array('key' => '', 'expires' => NULL, 'valid' => FALSE); } else { echo '<div class="updated"><p>' . sprintf(WPIMCore::__('Congratulations! The %s license entered is valid.'), $item_name); if ($item_key != 'core') { echo ' <a href="' . admin_url('admin.php?page=manage_settings') . '">' . sprintf(WPIMCore::__('(Click to refresh if %s is not visible.)'), $item_name) . '</a>'; } echo '</p></div>'; $key = array('key' => $key, 'expires' => strtotime($response->expires), 'valid' => TRUE); } } $all_reg_info = WPIMCore::get_reg_info(); $all_reg_info[$item_key] = $key; update_option('wpim_license', $all_reg_info); } }
echo wpinventory_label_class($field); ?> "><?php wpinventory_the_label($field); ?> </th> <?php } } ?> </tr> </thead> <tbody> <?php while (wpinventory_have_items()) { wpinventory_the_item(); wpinventory_get_template_part('single-loop-category', 'table'); } ?> </tbody> </table> <?php echo wpinventory_pagination(); } else { ?> <p class="wpinventory_warning"><?php WPIMCore::_e('No Inventory Items'); ?> </p> <?php }
/** * Constructor magic method. * Private because this class should not be called on its own. */ public function __construct() { parent::__construct(); self::$template = new WPIMTemplate(); }
public static function prep_sort($default = NULL, $default_dir = NULL) { self::$sortby = self::request('sortby', $default); self::$sortdir = self::request('sortdir', $default_dir); }
function wpinventory_get_filter_criteria($args = array()) { $WPIMLoop = wpinventory_get_wpim(); $query_args = $WPIMLoop->get_query_args(); if (!empty($args) && is_string($args) && stripos($args, "&") != FALSE) { $args = explode('&', $args); } // Override. If the shortcode contains a category id, do not show if (!empty($query_args['category_id']) && !WPIMCore::request('inventory_category_id')) { $args['categories'] = FALSE; } $default = array("search" => TRUE, "sort" => TRUE, "sort_label" => $WPIMLoop->__("Sort By"), "categories" => TRUE, "button" => $WPIMLoop->__("Search"), "search_label" => $WPIMLoop->__("Search For"), "caller" => ""); $args = wp_parse_args($args, $default); if (empty($query_args['sort_by'])) { $query_args['sort_by'] = 'inventory_name'; } $args['inventory_search'] = $WPIMLoop->request("inventory_search"); $args['inventory_sort_by'] = $WPIMLoop->request("inventory_sort_by", $query_args['order']); $args['inventory_category_id'] = $WPIMLoop->request("inventory_category_id", $query_args['category_id']); return $args; }
function form($instance) { $default = array('title' => WPIMCore::__('Latest Items'), 'page_id' => '', 'category_id' => '', 'number' => '4'); $instance = wp_parse_args((array) $instance, $default); $WPIMCategories = new WPIMCategory(); $categories = $WPIMCategories->get_all(array('order' => 'sort_order')); $categories_array = array('' => WPIMCore::__('Show All')); foreach ($categories as $cat) { $categories_array[$cat->category_id] = $cat->category_name; } $category_select = WPIMCore::dropdown_array($this->get_field_name('category_id'), $instance['category_id'], $categories_array); echo '<p><label for="' . $this->get_field_name('title') . '">' . WPIMCore::__('Widget Title') . '</label> <input type="text" class="widefat" name="' . $this->get_field_name('title') . '" value="' . $instance['title'] . '" /></p>'; echo '<p><label for="' . $this->get_field_name('number') . '">' . WPIMCore::__('Number of Items') . '</label> <input type="text" class="small-text" name="' . $this->get_field_name('number') . '" value="' . $instance['number'] . '" /></p>'; echo '<p><label for="' . $this->get_field_name('page_id') . '">' . WPIMCore::__('Links to Page') . '</label> ' . wp_dropdown_pages('echo=0&name=' . $this->get_field_name('page_id') . '&selected=' . $instance['page_id'] . '&show_option_none=' . WPIMCore::__('Select...')) . '</p>'; echo '<p><label for="' . $this->get_field_name('category_id') . '">' . WPIMCore::__('Category') . '</label> ' . $category_select . '</p>'; }