<?php

function travel_blogz_sanitize_checkbox( $input ) {
    if ( true === $input ) {
        return 1;
     } else {
        return 0;
     }
}
function travel_blogz_sanitize_url( $url ) {
  return esc_url_raw( $url );
}


if (!function_exists('travel_blogz_get_categories_select')):
    function travel_blogz_get_categories_select()
    {
        $travel_blogz_categories = get_categories();
        $results = [];

        if (!empty($travel_blogz_categories)):
            $results[''] = __('Select Category', 'travel-blogz');
            foreach ($travel_blogz_categories as $result) {
                $results[$result->slug] = $result->name;
            }
        endif;
        return $results;
    }
endif;

function travel_blogz_sanitize_select($input, $setting)
{
    $input = sanitize_key($input);

    $choices = $setting->manager->get_control($setting->id)->choices;

    return array_key_exists($input, $choices) ? $input : $setting->default;
}
