function bps_display_form($form, $template = '', $location = '') { if (!function_exists('bp_has_profile')) { printf('<p class="bps_error">' . __('%s: The BuddyPress Extended Profiles component is not active.', 'bp-profile-search') . '</p>', '<strong>BP Profile Search ' . BPS_VERSION . '</strong>'); return false; } $meta = bps_meta($form); if (empty($meta['field_name'])) { printf('<p class="bps_error">' . __('%s: Form %d was not found, or has no fields.', 'bp-profile-search') . '</p>', '<strong>BP Profile Search ' . BPS_VERSION . '</strong>', $form); return false; } $version = BPS_VERSION; if (empty($template)) { $template = bps_default_template(); } bps_set_request_data($form, $location); echo "\n<!-- BP Profile Search {$version} {$form} {$template} {$location} -->\n"; $found = bp_get_template_part($template); if (!$found) { printf('<p class="bps_error">' . __('%s: The form template "%s" was not found.', 'bp-profile-search') . '</p>', '<strong>BP Profile Search ' . BPS_VERSION . '</strong>', $template); } echo "\n<!-- BP Profile Search {$version} {$form} {$template} {$location} - end -->\n"; return true; }
function bps_meta($form) { static $options; if (isset($options[$form])) { return $options[$form]; } $default = array(); $default['field_name'] = array(); $default['field_label'] = array(); $default['field_desc'] = array(); $default['field_range'] = array(); $default['directory'] = 'No'; $default['template'] = bps_default_template(); $default['header'] = __('<h4>Advanced Search</h4>', 'bps'); $default['toggle'] = 'Enabled'; $default['button'] = __('Hide/Show Form', 'bps'); $default['method'] = 'POST'; $default['action'] = 0; $default['searchmode'] = 'LIKE'; if (get_post_status($form) == 'publish') { $meta = get_post_meta($form); } $options[$form] = isset($meta['bps_options']) ? unserialize($meta['bps_options'][0]) : $default; return $options[$form]; }