WC_PS_Exclude_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-exclude-data.php  
  1. class WC_PS_Exclude_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_exclude = $wpdb->prefix. "ps_exclude"; 
  12.  
  13. if ($wpdb->get_var("SHOW TABLES LIKE '$table_ps_exclude'") != $table_ps_exclude) { 
  14. $sql = "CREATE TABLE IF NOT EXISTS `{$table_ps_exclude}` ( 
  15. object_id bigint(20) NOT NULL,  
  16. object_type VARCHAR(20) NOT NULL DEFAULT 'post',  
  17. PRIMARY KEY (object_id, object_type),  
  18. KEY object_type (object_type) 
  19. ) $collate; "; 
  20.  
  21. $wpdb->query($sql); 
  22.  
  23.  
  24. /** 
  25. * Predictive Search Exclude Table - set table name 
  26. * @return void 
  27. */ 
  28. public function set_table_wpdbfix() { 
  29. global $wpdb; 
  30. $meta_name = 'ps_exclude'; 
  31.  
  32. $wpdb->ps_exclude = $wpdb->prefix . $meta_name; 
  33.  
  34. $wpdb->tables[] = 'ps_exclude'; 
  35.  
  36. /** 
  37. * Insert Predictive Search Exclude 
  38. */ 
  39. public function insert_item( $object_id, $object_type = 'post' ) { 
  40. global $wpdb; 
  41.  
  42. $value = $this->get_item( $object_id, $object_type ); 
  43. if ( NULL == $value ) { 
  44. return $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->ps_exclude} VALUES(%d, %s)", $object_id, stripslashes( $object_type ) ) ); 
  45. } else { 
  46. return false; 
  47.  
  48. /** 
  49. * Get Predictive Search Item Exclude 
  50. */ 
  51. public function get_item( $object_id, $object_type = 'post' ) { 
  52. global $wpdb; 
  53. return $wpdb->get_var( $wpdb->prepare( "SELECT object_id FROM {$wpdb->ps_exclude} WHERE object_id = %d AND object_type = %s LIMIT 0, 1 ", $object_id, stripslashes( $object_type ) ) ); 
  54.  
  55. /** 
  56. * Get Predictive Search Items Exclude 
  57. */ 
  58. public function get_items( $object_type = 'post' ) { 
  59. global $wpdb; 
  60. return $wpdb->get_results( $wpdb->prepare( "SELECT object_id FROM {$wpdb->ps_exclude} WHERE object_type = %s ", stripslashes( $object_type ) ) ); 
  61.  
  62. /** 
  63. * Get Predictive Search Array Items Exclude 
  64. */ 
  65. public function get_array_items( $object_type = 'post' ) { 
  66. global $wpdb; 
  67. return $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM {$wpdb->ps_exclude} WHERE object_type = %s ", stripslashes( $object_type ) ) ); 
  68.  
  69. /** 
  70. * Delete Predictive Search Item Exclude 
  71. */ 
  72. public function delete_item( $object_id, $object_type = 'post' ) { 
  73. global $wpdb; 
  74. return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->ps_exclude} WHERE object_id = %d AND object_type = %s ", $object_id, stripslashes( $object_type ) ) ); 
  75.  
  76. /** 
  77. * Delete Predictive Search Items Exclude 
  78. */ 
  79. public function delete_items( $object_type = 'post' ) { 
  80. global $wpdb; 
  81. return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->ps_exclude} WHERE object_type = %s ", stripslashes( $object_type ) ) ); 
  82.  
  83. /** 
  84. * Empty Predictive Search Posts 
  85. */ 
  86. public function empty_table() { 
  87. global $wpdb; 
  88. return $wpdb->query( "TRUNCATE {$wpdb->ps_exclude}" ); 
  89.