<commit_before><?php
function pitaya_rest_social_nav() {
  $options = get_option('pitaya_options');
  $socials = pitaya_setting_fields();
  $socials = $socials['social_links'];
  $array   = [];
  foreach($options as $key => $value) {
    if($value && in_array($key, $socials)) {
      $social_name = preg_replace('#[ -]+#', '-', strtolower($key));
      $social_link = $value;
      $array[$social_name] = $social_link;
    }
  }
  return $array;
}


add_action( 'rest_api_init', function () {
	register_rest_route( 'pitaya/v1', '/socials', array(
		'methods' => 'GET',
		'callback' => 'pitaya_rest_social_nav',
	));
});<commit_msg>cleaned up code<commit_after><?php
/* ==========================================================================
  Pitaya API Routes and Functions.
  ========================================================================== */

/*
|--------------------------------------------------------------------------
| Pitaya Social navigation in rest format.
|--------------------------------------------------------------------------
|
| You can request the below with https://your-website.com/wp-json/pitaya/v1/socials
| And you will get a list of social links that have data.
*/

function pitaya_rest_social_nav() {
  $options = get_option('pitaya_options');
  $socials = pitaya_setting_fields();
  $socials = $socials['social_links'];
  $array   = [];
  foreach($options as $key => $value) {
    if($value && in_array($key, $socials)) {
      $social_name = preg_replace('#[ -]+#', '-', strtolower($key));
      $social_link = $value;
      $array[$social_name] = $social_link;
    }
  }
  return $array;
}

add_action( 'rest_api_init', function () {
	register_rest_route( 'pitaya/v1', '/socials', array(
		'methods' => 'GET',
		'callback' => 'pitaya_rest_social_nav',
	));
});
{'fraction_non_alphanumeric': 0.3185595567867036, 'fraction_numerical': 0.0016620498614958448, 'mean_word_length': 3.085972850678733, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1171189', 'n_tokens_mistral': 567, 'n_tokens_neox': 550, 'n_words': 106}