function sa_load_predefined_items_addon() { if (class_exists('SI_Item')) { return; } require_once 'inc/Item.php'; require_once 'inc/Predefined_Items.php'; SI_Item::init(); Predefined_Items::init(); }
public static function migrate_terms_to_items() { $update = get_option(self::UPDATED, false); if ($update) { return; } // Get all the terms $item_types = get_terms(array(SI_Estimate::LINE_ITEM_TAXONOMY), array('hide_empty' => false, 'fields' => 'all')); // convert to item PT foreach ($item_types as $item_type) { $args = array('name' => $item_type->name, 'description' => $item_type->description, 'product' => false, 'qty' => 1, 'rate' => 100, 'percentage' => 0); SI_Item::new_item($args); wp_delete_term($item_type->term_id, SI_Estimate::LINE_ITEM_TAXONOMY); } update_option(self::UPDATED, time()); }
public static function get_items_and_products() { $items = array(); // multi-dimensional array of products and tasks $args = array('orderby' => 'modified', 'post_type' => SI_Item::POST_TYPE, 'posts_per_page' => -1, 'fields' => 'ids'); $item_ids = get_posts($args); foreach ($item_ids as $item_id) { $item = SI_Item::get_instance($item_id); $items[$item->get_type()][$item_id] = array('id' => $item_id, 'type' => $item->get_type(), 'qty' => $item->get_default_qty(), 'rate' => $item->get_default_rate(), 'percentage' => $item->get_default_percentage(), 'sku' => $item->get_default_sku(), 'title' => $item->get_title(), 'content' => $item->get_content()); } return apply_filters('si_items_and_products', $items); }