/** * Register the product custom post type * * @author Jonathan Davis * @since 1.3 * * @return void **/ public function products() { WPShoppObject::register('ShoppProduct', ShoppPages()->baseslug()); }
private static function taxquery($sql) { $tablename = WPShoppObject::tablename(ShoppProduct::$table); $sql = str_replace($tablename . '.', 'p.', $sql); $sql = ltrim($sql, ' AND '); return $sql; }
/** * Sets the status of a set of products * * @author Jonathan Davis * @since 1.2 * * @param array $ids Set of product IDs to update * @param string $status The status to set: publish, draft, trash * @return boolean **/ static function publishset(array $ids, $status) { if (empty($ids) || !is_array($ids)) { return false; } $settings = array('publish', 'draft', 'trash'); if (!in_array($status, $settings)) { return false; } $table = WPShoppObject::tablename(self::$table); $time = current_time('timestamp'); $post_date_gmt = sDB::mkdatetime($time + get_option('gmt_offset') * 3600); $post_date = sDB::mkdatetime($time); sDB::query("UPDATE {$table} SET post_status='{$status}', post_date='{$post_date}', post_date_gmt='{$post_date_gmt}', post_modified='{$post_date}', post_modified_gmt='{$post_date_gmt}' WHERE ID in (" . join(',', $ids) . ")"); foreach ($ids as $id) { // Recount taxonomy counts #2968 $Post = get_post($id); switch ($status) { case 'trash': do_action('wp_trash_post', $id); break; default: do_action('save_post', $id, $Post); break; } if (function_exists('clean_post_cache')) { clean_post_cache($id); } wp_transition_post_status($status, $Product->status, $Post); } return true; }
/** * Sets the status of a set of products * * @author Jonathan Davis * @since 1.2 * * @param array $ids Set of product IDs to update * @param string $status The status to set: publish, draft, trash * @return boolean **/ static function publishset(array $ids, $status) { if (empty($ids) || !is_array($ids)) { return false; } $settings = array('publish', 'draft', 'trash'); if (!in_array($status, $settings)) { return false; } $table = WPShoppObject::tablename(self::$table); $time = current_time('timestamp'); $post_date_gmt = sDB::mkdatetime($time + get_option('gmt_offset') * 3600); $post_date = sDB::mkdatetime($time); sDB::query("UPDATE {$table} SET post_status='{$status}', post_date='{$post_date}', post_date_gmt='{$post_date_gmt}', post_modified='{$post_date}', post_modified_gmt='{$post_date_gmt}' WHERE ID in (" . join(',', $ids) . ")"); foreach ($ids as $id) { // Recount taxonomy counts #2968 $laststatus = get_post_status($id); $Post = new StdClass(); $Post->ID = $id; $Post->post_type = ShoppProduct::$posttype; wp_transition_post_status($status, $laststatus, $Post); } return true; }