Example #1
0
function get_antennas_details()
{
    //get all antenna users
    $users = get_antenna_users();
    //count the number of user
    $nb = count($users);
    if ($nb === 1) {
        //if only 1 user, we assume that it's the admin user so $user->ID = 1
        $categ_admin = get_cat_if_user(1);
        $antenna = get_cat_slug($categ_admin);
        $options = get_option('iftheme_theme_options_' . $antenna, iftheme_get_default_theme_options());
        //cf. theme-options.php for keys of the option array
        //adding useful infos to $options
        $options['aid'] = $categ_admin;
        $options['slug'] = $antenna;
    } else {
        //more than 1 user
        foreach ($users as $k => $o) {
            $categ = get_cat_if_user($o->ID);
            //$categ = function_exists('icl_object_id') ? icl_object_id($categ, 'category', TRUE) : $categ;
            $antenna = get_cat_slug($categ) ? get_cat_slug($categ) : __('You must assign a category to this user : '******'iftheme') . $o->display_name;
            $options[$categ] = get_option('iftheme_theme_options_' . $antenna, iftheme_get_default_theme_options());
            //cf. theme-options.php for keys of the option array
            //unset country options for non admin user
            //@todo: posibility to have multiple admin. Maybe check user's roles more then his ID
            if ($o->ID != 1) {
                unset($options[$categ]['bg_frame_country']);
                unset($options[$categ]['background_img_country']);
                unset($options[$categ]['theme_home_categ_country']);
            }
            //adding useful infos to $options
            $options[$categ]['aid'] = !$categ ? null : $categ;
            $options[$categ]['slug'] = $antenna;
        }
    }
    return $options;
}
Example #2
0
/**
 * Sanitize and validate form input. Accepts an array, return a sanitized array.
 *
 * @see iftheme_theme_options_init()
 * @todo set up Reset Options action
 */
function iftheme_theme_options_validate($input)
{
    $output = $defaults = iftheme_get_default_theme_options();
    // Background frame must be in our array of background frame options
    if (isset($input['bg_frame']) && array_key_exists($input['bg_frame'], iftheme_bg_frames())) {
        $output['bg_frame'] = $input['bg_frame'];
    }
    // Background frame must be in our array of background frame options
    if (isset($input['bg_frame_country']) && array_key_exists($input['bg_frame_country'], iftheme_bg_frames())) {
        $output['bg_frame_country'] = $input['bg_frame_country'];
    }
    // Home categories
    if (isset($input['theme_home_categ']) && is_array($input['theme_home_categ'])) {
        $output['theme_home_categ'][] = $input['theme_home_categ'];
    }
    //nb of events homepage
    if (isset($input['theme_home_nb_events']) && strlen($input['theme_home_nb_events'])) {
        $output['theme_home_nb_events'] = $input['theme_home_nb_events'];
    }
    // Country Home categories
    if (isset($input['theme_home_categ_country']) && is_array($input['theme_home_categ_country'])) {
        $output['theme_home_categ_country'][] = $input['theme_home_categ_country'];
    }
    //nb of events country's homepage
    if (isset($input['theme_home_nb_events_country']) && strlen($input['theme_home_nb_events_country'])) {
        $output['theme_home_nb_events_country'] = $input['theme_home_nb_events_country'];
    }
    // Background image
    if (isset($input['background_img'])) {
        $output['background_img'] = $input['background_img'];
    }
    // Country Background image
    if (isset($input['background_img_country'])) {
        $output['background_img_country'] = $input['background_img_country'];
    }
    //header page menu
    $output['theme_options_setting_hmenupage'] = isset($input['theme_options_setting_hmenupage']) ? $input['theme_options_setting_hmenupage'] : 0;
    //wysija embedded sub. form
    $output['theme_options_setting_wysija_embed'] = isset($input['theme_options_setting_wysija_embed']) ? $input['theme_options_setting_wysija_embed'] : 0;
    //Under construction Landing page
    if (isset($input['theme_options_setting_underconstruction'])) {
        $output['theme_options_setting_underconstruction'] = $input['theme_options_setting_underconstruction'];
    }
    //d($_POST);
    //d($input);
    //SOCIAL NETWORKS
    if (isset($input['theme_options_setting_facebook'])) {
        $output['theme_options_setting_facebook'] = $input['theme_options_setting_facebook'];
    }
    if (isset($input['theme_options_setting_twitter'])) {
        $output['theme_options_setting_twitter'] = $input['theme_options_setting_twitter'];
    }
    if (isset($input['theme_options_setting_googleplus'])) {
        $output['theme_options_setting_googleplus'] = $input['theme_options_setting_googleplus'];
    }
    if (isset($input['theme_options_setting_iftv'])) {
        $output['theme_options_setting_iftv'] = $input['theme_options_setting_iftv'];
    }
    if (isset($input['theme_options_setting_youtube'])) {
        $output['theme_options_setting_youtube'] = $input['theme_options_setting_youtube'];
    }
    if (isset($input['theme_options_setting_instagram'])) {
        $output['theme_options_setting_instagram'] = $input['theme_options_setting_instagram'];
    }
    return apply_filters('iftheme_theme_options_validate', $output, $input, $defaults);
}