WC_PS_PostMeta_Data

"Copyright 2012 A3 Revolution Web Design" This software is distributed under the terms of GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007.

Defined (1)

The class is defined in the following location(s).

/classes/data/class-wc-ps-postmeta-data.php  
  1. class WC_PS_PostMeta_Data 
  2. public function install_database() { 
  3. global $wpdb; 
  4. $collate = ''; 
  5. if ( $wpdb->has_cap( 'collation' ) ) { 
  6. if( ! empty($wpdb->charset ) ) $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; 
  7. if( ! empty($wpdb->collate ) ) $collate .= " COLLATE $wpdb->collate"; 
  8.  
  9. require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 
  10.  
  11. $table_ps_postmeta = $wpdb->prefix. "ps_postmeta"; 
  12.  
  13. if ($wpdb->get_var("SHOW TABLES LIKE '$table_ps_postmeta'") != $table_ps_postmeta) { 
  14. $sql = "CREATE TABLE IF NOT EXISTS `{$table_ps_postmeta}` ( 
  15. meta_id bigint(20) NOT NULL auto_increment,  
  16. ps_post_id bigint(20) NOT NULL,  
  17. meta_key varchar(255) NULL,  
  18. meta_value longtext NULL,  
  19. PRIMARY KEY (meta_id),  
  20. KEY ps_post_id (ps_post_id),  
  21. KEY meta_key (meta_key) 
  22. ) $collate; "; 
  23.  
  24. $wpdb->query($sql); 
  25.  
  26.  
  27. /** 
  28. * Predictive Search Post Meta Table - set table name 
  29. * @return void 
  30. */ 
  31. public function set_table_wpdbfix() { 
  32. global $wpdb; 
  33. $meta_name = 'ps_postmeta'; 
  34.  
  35. $wpdb->ps_postmeta = $wpdb->prefix . $meta_name; 
  36.  
  37. $wpdb->tables[] = 'ps_postmeta'; 
  38.  
  39. /** 
  40. * Get Predictive Search Array Items Exclude by Out of Stock 
  41. */ 
  42. public function get_array_products_out_of_stock() { 
  43. global $wpdb; 
  44. return $wpdb->get_col( $wpdb->prepare( "SELECT ps_post_id FROM {$wpdb->ps_postmeta} AS ppm WHERE ppm.meta_key= %s AND ppm.meta_value = %s ", '_stock_status', 'outofstock' ) ); 
  45.  
  46. /** 
  47. * Add Predictive Search Post Meta 
  48. */ 
  49. public function add_item_meta( $object_id, $meta_key, $meta_value, $unique = true ) { 
  50. return add_metadata( 'ps_post', $object_id, $meta_key, $meta_value, $unique ); 
  51.  
  52. /** 
  53. * Update Predictive Search Post Meta 
  54. */ 
  55. public function update_item_meta( $object_id, $meta_key, $meta_value, $prev_value = '' ) { 
  56. return update_metadata( 'ps_post', $object_id, $meta_key, $meta_value, $prev_value ); 
  57.  
  58. /** 
  59. * Get Predictive Search Post Meta 
  60. */ 
  61. public function get_item_meta( $object_id, $meta_key, $single = true ) { 
  62. return get_metadata( 'ps_post', $object_id, $meta_key, $single ); 
  63.  
  64. /** 
  65. * Delete Predictive Search Post Meta 
  66. */ 
  67. public function delete_item_meta( $object_id, $meta_key, $meta_value = '', $delete_all = false ) { 
  68. return delete_metadata( 'ps_post', $object_id, $meta_key, $meta_value, $delete_all ); 
  69.  
  70. /** 
  71. * Delete Predictive Search Post Metas 
  72. */ 
  73. public function delete_item_metas( $object_id ) { 
  74. global $wpdb; 
  75. return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->ps_postmeta} WHERE ps_post_id = %d ", $object_id ) ); 
  76.  
  77. /** 
  78. * Empty Predictive Search Post Metas 
  79. */ 
  80. public function empty_table() { 
  81. global $wpdb; 
  82. return $wpdb->query( "TRUNCATE {$wpdb->ps_postmeta}" );