gde_get_profiles

Get profile data.

Description

(array) gde_get_profiles( (string) $ident = '', (constant) $include_id = true, (bool) $include_desc = false ); 

Returns (array)

Array of profiles with their data, or a specific profile

Parameters (3)

0. $ident — Optional. (string) => ''
The ident.
1. $include_id — Optional. (constant) => true
The include id.
2. $include_desc — Optional. (bool) => false
The include desc.

Usage

  1. if ( !function_exists( 'gde_get_profiles' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/functions.php'; 
  3.  
  4. // The ident. 
  5. $ident = ''; 
  6.  
  7. // The include id. 
  8. $include_id = true; 
  9.  
  10. // The include desc. 
  11. $include_desc = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = gde_get_profiles($ident, $include_id, $include_desc); 
  15.  

Defined (1)

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

/functions.php  
  1. function gde_get_profiles( $ident = '', $include_id = true, $include_desc = false ) { 
  2. global $wpdb; 
  3. $table = $wpdb->prefix . 'gde_profiles'; 
  4.  
  5. if ( empty( $ident ) ) { 
  6. $where = "WHERE 1 = 1 ORDER BY profile_id ASC"; 
  7. } elseif ( ! is_numeric( $ident ) ) { 
  8. $where = "WHERE profile_name = '$ident'"; 
  9. } else { 
  10. $where = "WHERE profile_id = $ident"; 
  11.  
  12. $profiles = $wpdb->get_results( "SELECT * FROM $table $where", ARRAY_A ); 
  13.  
  14. if ( ! is_array( $profiles ) ) { 
  15. gde_dx_log("Requested profile $ident not found"); 
  16. return false; 
  17. } elseif ( ! empty( $ident ) ) { 
  18. // return specific profile data 
  19. if ( isset( $profiles[0] ) ) { 
  20. $data = unserialize($profiles[0]['profile_data']); 
  21. if ( $include_id ) { 
  22. $data['profile_id'] = $profiles[0]['profile_id']; 
  23. if ( $include_desc ) { 
  24. $data['profile_desc'] = $profiles[0]['profile_desc']; 
  25.  
  26. $profiles = $data; 
  27. } else { 
  28. gde_dx_log("Requested profile $ident doesn't exist"); 
  29. return false; 
  30.  
  31. return $profiles;