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