$wpdb */ function bpml_admin_save_settings_submit() { if (current_user_can('manage_options') && wp_verify_nonce(isset($_POST['_wpnonce']), 'bpml_save_options') && isset($_POST['bpml'])) { if (isset($_POST['bpml_clear_google_cache'])) { bpml_activities_clear_cache('all', 'bpml_google_translation'); bpml_store_admin_notice('settings_saved', '

Cache cleared

'); } else if (isset($_POST['bpml_clear_all_activity_data'])) { bpml_activities_clear_all_data(); bpml_store_admin_notice('settings_saved', '

Activities data cleared

'); } else if (isset($_POST['bpml_admin_clear_activity_translations_single'])) { bpml_admin_clear_activity_translations_single(key($_POST['bpml_admin_clear_activity_translations_single'])); bpml_store_admin_notice('settings_saved', '

Activity data cleared

'); } else if (isset($_POST['bpml_admin_clear_activity_data_single'])) { bpml_admin_clear_activity_data_single(key($_POST['bpml_admin_clear_activity_data_single'])); bpml_store_admin_notice('settings_saved', '

Activity data cleared

'); } else if (isset($_POST['bpml_reset_options'])) { bpml_save_settings(bpml_default_settings()); bpml_store_admin_notice('settings_saved', '

Settings set to default

'); } else { bpml_admin_save_settings_submit_recursive(&$_POST['bpml']); bpml_save_settings($_POST['bpml']); do_action('bpml_settings_saved', $_POST['bpml']); bpml_store_admin_notice('settings_saved', '

Settings saved

'); } wp_redirect(admin_url('options-general.php?page=bpml')); exit; } } /** * Sets POST values. * * @param $array */ function bpml_admin_save_settings_submit_recursive(&$array) { foreach ($array as $key => &$value) { if (is_array($value)) { bpml_admin_save_settings_submit_recursive(&$value); } else if ($value == '0' || $value == '1' || $value == '-1') { $value = intval($value); } } } /** * Renders admin page. * * @global $bpml */ function bpml_admin_page() { bpml_delete_setting('admin_notices'); global $bpml; echo '

BuddyPress Multilingual

'; echo '
'; wp_nonce_field('bpml_save_options'); echo '

General

'; echo 'Enable debugging (visible on frontend for admin only)
'; echo '  '; echo ''; echo '

'; do_action('bpml_settings_form_before'); echo '

Activities

'; echo 'Filter activity entries per language
Default: No (activities are all displayed and optionally translated)
'; echo '  '; echo ''; echo '

'; echo ''; echo '

'; echo 'Show activity language assign dropdown for admin
'; echo '  '; echo ''; echo '

'; echo 'Display activity updates without language in:
'; echo '  '; echo '  '; echo ''; echo '

'; echo 'Auto-assing default language to activities without language data
'; echo '  '; echo ''; echo '

'; echo 'Enable Google Translation for titles and content
will not be used if filtering is enabled
'; echo '  '; echo '  '; echo ''; echo '  '; echo '

'; echo '
'; echo 'Collected activities:
'; echo 'Soon as some activity is registered on site it will be displayed here.

'; echo 'Set all for translation | '; echo 'Clear all

'; ksort($bpml['collected_activities']); foreach ($bpml['collected_activities'] as $type => $activity) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; do_action('bpml_settings_form_collected_activities', $type, $activity); echo '
' . $type . '
'; echo '
'; echo '
'; } echo '
'; do_action('bpml_settings_form_after'); echo '

'; echo ' '; echo '
'; echo '
'; } /** * Clears cached translation by activity type. * * @global $wpdb * @param $type */ function bpml_admin_clear_activity_translations_single($type) { global $wpdb; $results = $wpdb->get_results("SELECT id from {$wpdb->prefix}bp_activity WHERE type='" . $type . "'"); foreach ($results as $key => $result) { bpml_activities_clear_cache($result->id, 'bpml_google_translation'); } } /** * Clears cached data by activity type. * * @global $wpdb * @param $type */ function bpml_admin_clear_activity_data_single($type) { global $wpdb; $results = $wpdb->get_results("SELECT id FROM {$wpdb->prefix}bp_activity WHERE type='" . $type . "'"); foreach ($results as $key => $result) { bpml_activities_clear_cache($result->id, 'bpml_google_translation'); bpml_activities_clear_cache($result->id, 'bpml_lang'); bpml_activities_clear_cache($result->id, 'bpml_lang_recorded'); bpml_activities_clear_cache($result->id, 'bpml_lang_orphan'); } } /** * Admin form hook. * * @global $bpml * @return */ function bpml_profiles_admin_form() { global $bpml; echo '

Profile fields

'; echo '  
'; echo '  
'; echo '

'; echo 'Select fields that can be translated:'; // get fields $groups = BP_XProfile_Group::get(array( 'fetch_fields' => true )); if (empty($groups)) { echo 'No profile fields.'; return FALSE; } foreach ($groups as $group) { if (empty($group->fields)) { echo 'No fields in this group'; continue; } echo '

' . $group->name . '

'; foreach ($group->fields as $field) { $checked = isset($bpml['profiles']['fields'][$field->id]) ? ' checked="checked"' : ''; echo '  '; } } echo '


Translate field titles
'; $checked = isset($bpml['profiles']['translate_fields_title']) ? ' checked="checked"' : ''; echo '  '; echo '

'; echo '

'; }