function Action_config() { // Security check check_admin_referer(c_al2fb_nonce_action, c_al2fb_nonce_name); // Get current user global $user_ID; get_currentuserinfo(); // Default values $consts = get_defined_constants(true); foreach ($consts['user'] as $name => $value) { if (strpos($value, 'al2fb_') === 0 && $value != c_al2fb_meta_trailer && $value != c_al2fb_meta_fb_comments_trailer) { if (isset($_POST[$value]) && is_string(sanitize_text_field($_POST[$value]))) { $_POST[$value] = trim(sanitize_text_field($_POST[$value])); } else { if (empty($_POST[$value])) { $_POST[$value] = null; } } } } if (empty($_POST[c_al2fb_meta_picture_type])) { $_POST[c_al2fb_meta_picture_type] = 'post'; } // Prevent losing selected page if (!self::Is_authorized($user_ID) || !WPAL2Int::Check_multiple() && get_user_meta($user_ID, c_al2fb_meta_use_groups, true) && get_user_meta($user_ID, c_al2fb_meta_group, true)) { $_POST[c_al2fb_meta_page] = get_user_meta($user_ID, c_al2fb_meta_page, true); $_POST[c_al2fb_meta_page_extra] = get_user_meta($user_ID, c_al2fb_meta_page_extra, true); } // Prevent losing selected group if (!self::Is_authorized($user_ID) || !get_user_meta($user_ID, c_al2fb_meta_use_groups, true)) { $_POST[c_al2fb_meta_group] = get_user_meta($user_ID, c_al2fb_meta_group, true); $_POST[c_al2fb_meta_group_extra] = get_user_meta($user_ID, c_al2fb_meta_group_extra, true); } // Prevent losing selected friends if (!self::Is_authorized($user_ID)) { $_POST[c_al2fb_meta_friend_extra] = get_user_meta($user_ID, c_al2fb_meta_friend_extra, true); } // App ID or secret changed if (get_user_meta($user_ID, c_al2fb_meta_client_id, true) != sanitize_text_field($_POST[c_al2fb_meta_client_id]) || get_user_meta($user_ID, c_al2fb_meta_app_secret, true) != sanitize_text_field($_POST[c_al2fb_meta_app_secret])) { delete_user_meta($user_ID, c_al2fb_meta_access_token); WPAL2Int::Clear_fb_pages_cache($user_ID); WPAL2Int::Clear_fb_groups_cache($user_ID); WPAL2Int::Clear_fb_friends_cache($user_ID); } // Like or send button enabled if (!get_user_meta($user_ID, c_al2fb_meta_post_like_button, true) && !empty($_POST[c_al2fb_meta_post_like_button]) || !get_user_meta($user_ID, c_al2fb_meta_post_send_button, true) && !empty($_POST[c_al2fb_meta_post_send_button])) { $_POST[c_al2fb_meta_open_graph] = true; } // Update user options update_user_meta($user_ID, c_al2fb_meta_client_id, sanitize_text_field($_POST[c_al2fb_meta_client_id])); update_user_meta($user_ID, c_al2fb_meta_app_secret, sanitize_text_field($_POST[c_al2fb_meta_app_secret])); update_user_meta($user_ID, c_al2fb_meta_picture_type, sanitize_text_field($_POST[c_al2fb_meta_picture_type])); update_user_meta($user_ID, c_al2fb_meta_picture, sanitize_text_field($_POST[c_al2fb_meta_picture])); update_user_meta($user_ID, c_al2fb_meta_picture_default, sanitize_text_field($_POST[c_al2fb_meta_picture_default])); update_user_meta($user_ID, c_al2fb_meta_picture_size, sanitize_text_field($_POST[c_al2fb_meta_picture_size])); update_user_meta($user_ID, c_al2fb_meta_icon, sanitize_text_field($_POST[c_al2fb_meta_icon])); update_user_meta($user_ID, c_al2fb_meta_page, sanitize_text_field($_POST[c_al2fb_meta_page])); update_user_meta($user_ID, c_al2fb_meta_page_extra, sanitize_text_field($_POST[c_al2fb_meta_page_extra])); update_user_meta($user_ID, c_al2fb_meta_use_groups, sanitize_text_field($_POST[c_al2fb_meta_use_groups])); update_user_meta($user_ID, c_al2fb_meta_group, sanitize_text_field($_POST[c_al2fb_meta_group])); update_user_meta($user_ID, c_al2fb_meta_group_extra, sanitize_text_field($_POST[c_al2fb_meta_group_extra])); update_user_meta($user_ID, c_al2fb_meta_friend_extra, sanitize_text_field($_POST[c_al2fb_meta_friend_extra])); update_user_meta($user_ID, c_al2fb_meta_caption, sanitize_text_field($_POST[c_al2fb_meta_caption])); update_user_meta($user_ID, c_al2fb_meta_msg, sanitize_text_field($_POST[c_al2fb_meta_msg])); update_user_meta($user_ID, c_al2fb_meta_auto_excerpt, sanitize_text_field($_POST[c_al2fb_meta_auto_excerpt])); update_user_meta($user_ID, c_al2fb_meta_shortlink, sanitize_text_field($_POST[c_al2fb_meta_shortlink])); update_user_meta($user_ID, c_al2fb_meta_privacy, sanitize_text_field($_POST[c_al2fb_meta_privacy])); update_user_meta($user_ID, c_al2fb_meta_some_friends, sanitize_text_field($_POST[c_al2fb_meta_some_friends])); update_user_meta($user_ID, c_al2fb_meta_add_new_page, sanitize_text_field($_POST[c_al2fb_meta_add_new_page])); update_user_meta($user_ID, c_al2fb_meta_show_permalink, sanitize_text_field($_POST[c_al2fb_meta_show_permalink])); update_user_meta($user_ID, c_al2fb_meta_social_noexcerpt, sanitize_text_field($_POST[c_al2fb_meta_social_noexcerpt])); update_user_meta($user_ID, c_al2fb_meta_trailer, sanitize_text_field($_POST[c_al2fb_meta_trailer])); update_user_meta($user_ID, c_al2fb_meta_hyperlink, sanitize_text_field($_POST[c_al2fb_meta_hyperlink])); update_user_meta($user_ID, c_al2fb_meta_fb_comments, sanitize_text_field($_POST[c_al2fb_meta_fb_comments])); update_user_meta($user_ID, c_al2fb_meta_fb_comments_trailer, sanitize_text_field($_POST[c_al2fb_meta_fb_comments_trailer])); update_user_meta($user_ID, c_al2fb_meta_fb_comments_postback, sanitize_text_field($_POST[c_al2fb_meta_fb_comments_postback])); update_user_meta($user_ID, c_al2fb_meta_fb_comments_only, sanitize_text_field($_POST[c_al2fb_meta_fb_comments_only])); update_user_meta($user_ID, c_al2fb_meta_fb_comments_copy, sanitize_text_field($_POST[c_al2fb_meta_fb_comments_copy])); update_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, sanitize_text_field($_POST[c_al2fb_meta_fb_comments_nolink])); update_user_meta($user_ID, c_al2fb_meta_fb_likes, sanitize_text_field($_POST[c_al2fb_meta_fb_likes])); update_user_meta($user_ID, c_al2fb_meta_post_likers, sanitize_text_field($_POST[c_al2fb_meta_post_likers])); update_user_meta($user_ID, c_al2fb_meta_post_like_button, sanitize_text_field($_POST[c_al2fb_meta_post_like_button])); update_user_meta($user_ID, c_al2fb_meta_like_nohome, sanitize_text_field($_POST[c_al2fb_meta_like_nohome])); update_user_meta($user_ID, c_al2fb_meta_like_noposts, sanitize_text_field($_POST[c_al2fb_meta_like_noposts])); update_user_meta($user_ID, c_al2fb_meta_like_nopages, sanitize_text_field($_POST[c_al2fb_meta_like_nopages])); update_user_meta($user_ID, c_al2fb_meta_like_noarchives, sanitize_text_field($_POST[c_al2fb_meta_like_noarchives])); update_user_meta($user_ID, c_al2fb_meta_like_nocategories, sanitize_text_field($_POST[c_al2fb_meta_like_nocategories])); update_user_meta($user_ID, c_al2fb_meta_like_layout, sanitize_text_field($_POST[c_al2fb_meta_like_layout])); update_user_meta($user_ID, c_al2fb_meta_like_faces, sanitize_text_field($_POST[c_al2fb_meta_like_faces])); update_user_meta($user_ID, c_al2fb_meta_like_width, sanitize_text_field($_POST[c_al2fb_meta_like_width])); update_user_meta($user_ID, c_al2fb_meta_like_action, sanitize_text_field($_POST[c_al2fb_meta_like_action])); update_user_meta($user_ID, c_al2fb_meta_like_font, sanitize_text_field($_POST[c_al2fb_meta_like_font])); update_user_meta($user_ID, c_al2fb_meta_like_colorscheme, sanitize_text_field($_POST[c_al2fb_meta_like_colorscheme])); update_user_meta($user_ID, c_al2fb_meta_like_link, sanitize_text_field($_POST[c_al2fb_meta_like_link])); update_user_meta($user_ID, c_al2fb_meta_like_top, sanitize_text_field($_POST[c_al2fb_meta_like_top])); update_user_meta($user_ID, c_al2fb_meta_post_send_button, sanitize_text_field($_POST[c_al2fb_meta_post_send_button])); update_user_meta($user_ID, c_al2fb_meta_post_combine_buttons, sanitize_text_field($_POST[c_al2fb_meta_post_combine_buttons])); update_user_meta($user_ID, c_al2fb_meta_like_share, sanitize_text_field($_POST[c_al2fb_meta_like_share])); update_user_meta($user_ID, c_al2fb_meta_like_box_width, sanitize_text_field($_POST[c_al2fb_meta_like_box_width])); update_user_meta($user_ID, c_al2fb_meta_like_box_height, sanitize_text_field($_POST[c_al2fb_meta_like_box_height])); update_user_meta($user_ID, c_al2fb_meta_like_box_border, sanitize_text_field($_POST[c_al2fb_meta_like_box_border])); update_user_meta($user_ID, c_al2fb_meta_like_box_noheader, sanitize_text_field($_POST[c_al2fb_meta_like_box_noheader])); update_user_meta($user_ID, c_al2fb_meta_like_box_nostream, sanitize_text_field($_POST[c_al2fb_meta_like_box_nostream])); update_user_meta($user_ID, c_al2fb_meta_subscribe_layout, sanitize_text_field($_POST[c_al2fb_meta_subscribe_layout])); update_user_meta($user_ID, c_al2fb_meta_subscribe_width, sanitize_text_field($_POST[c_al2fb_meta_subscribe_width])); update_user_meta($user_ID, c_al2fb_meta_comments_posts, sanitize_text_field($_POST[c_al2fb_meta_comments_posts])); update_user_meta($user_ID, c_al2fb_meta_comments_width, sanitize_text_field($_POST[c_al2fb_meta_comments_width])); update_user_meta($user_ID, c_al2fb_meta_comments_auto, sanitize_text_field($_POST[c_al2fb_meta_comments_auto])); update_user_meta($user_ID, c_al2fb_meta_pile_size, sanitize_text_field($_POST[c_al2fb_meta_pile_size])); update_user_meta($user_ID, c_al2fb_meta_pile_width, sanitize_text_field($_POST[c_al2fb_meta_pile_width])); update_user_meta($user_ID, c_al2fb_meta_pile_rows, sanitize_text_field($_POST[c_al2fb_meta_pile_rows])); update_user_meta($user_ID, c_al2fb_meta_reg_width, sanitize_text_field($_POST[c_al2fb_meta_reg_width])); update_user_meta($user_ID, c_al2fb_meta_login_width, sanitize_text_field($_POST[c_al2fb_meta_login_width])); update_user_meta($user_ID, c_al2fb_meta_reg_success, sanitize_text_field($_POST[c_al2fb_meta_reg_success])); update_user_meta($user_ID, c_al2fb_meta_login_regurl, sanitize_text_field($_POST[c_al2fb_meta_login_regurl])); update_user_meta($user_ID, c_al2fb_meta_login_redir, sanitize_text_field($_POST[c_al2fb_meta_login_redir])); update_user_meta($user_ID, c_al2fb_meta_login_html, sanitize_text_field($_POST[c_al2fb_meta_login_html])); update_user_meta($user_ID, c_al2fb_meta_act_width, sanitize_text_field($_POST[c_al2fb_meta_act_width])); update_user_meta($user_ID, c_al2fb_meta_act_height, sanitize_text_field($_POST[c_al2fb_meta_act_height])); update_user_meta($user_ID, c_al2fb_meta_act_header, sanitize_text_field($_POST[c_al2fb_meta_act_header])); update_user_meta($user_ID, c_al2fb_meta_act_recommend, sanitize_text_field($_POST[c_al2fb_meta_act_recommend])); update_user_meta($user_ID, c_al2fb_meta_open_graph, sanitize_text_field($_POST[c_al2fb_meta_open_graph])); update_user_meta($user_ID, c_al2fb_meta_open_graph_type, sanitize_text_field($_POST[c_al2fb_meta_open_graph_type])); update_user_meta($user_ID, c_al2fb_meta_open_graph_admins, sanitize_text_field($_POST[c_al2fb_meta_open_graph_admins])); update_user_meta($user_ID, c_al2fb_meta_exclude_default, sanitize_text_field($_POST[c_al2fb_meta_exclude_default])); update_user_meta($user_ID, c_al2fb_meta_exclude_default_video, sanitize_text_field($_POST[c_al2fb_meta_exclude_default_video])); update_user_meta($user_ID, c_al2fb_meta_not_post_list, sanitize_text_field($_POST[c_al2fb_meta_not_post_list])); update_user_meta($user_ID, c_al2fb_meta_fb_encoding, sanitize_text_field($_POST[c_al2fb_meta_fb_encoding])); update_user_meta($user_ID, c_al2fb_meta_fb_locale, sanitize_text_field($_POST[c_al2fb_meta_fb_locale])); update_user_meta($user_ID, c_al2fb_meta_param_name, sanitize_text_field($_POST[c_al2fb_meta_param_name])); update_user_meta($user_ID, c_al2fb_meta_param_value, sanitize_text_field($_POST[c_al2fb_meta_param_value])); update_user_meta($user_ID, c_al2fb_meta_donated, sanitize_text_field($_POST[c_al2fb_meta_donated])); if (isset($_REQUEST['debug'])) { if (empty($_POST[c_al2fb_meta_access_token])) { $_POST[c_al2fb_meta_access_token] = null; } $_POST[c_al2fb_meta_access_token] = trim(sanitize_text_field($_POST[c_al2fb_meta_access_token])); update_user_meta($user_ID, c_al2fb_meta_access_token, sanitize_text_field($_POST[c_al2fb_meta_access_token])); update_user_meta($user_ID, c_al2fb_meta_token_time, date('c')); } // Update admin options if (current_user_can('manage_options')) { if (empty($_POST[c_al2fb_option_app_share])) { $_POST[c_al2fb_option_app_share] = null; } else { $_POST[c_al2fb_option_app_share] = (int) $user_ID; } if (is_multisite()) { update_site_option(c_al2fb_option_app_share, $_POST[c_al2fb_option_app_share]); } else { update_option(c_al2fb_option_app_share, $_POST[c_al2fb_option_app_share]); } update_option(c_al2fb_option_timeout, sanitize_text_field($_POST[c_al2fb_option_timeout])); update_option(c_al2fb_option_nonotice, sanitize_text_field($_POST[c_al2fb_option_nonotice])); update_option(c_al2fb_option_min_cap, sanitize_text_field($_POST[c_al2fb_option_min_cap])); update_option(c_al2fb_option_no_post_submit, sanitize_text_field($_POST[c_al2fb_option_no_post_submit])); update_option(c_al2fb_option_min_cap_comment, sanitize_text_field($_POST[c_al2fb_option_min_cap_comment])); update_option(c_al2fb_option_msg_refresh, sanitize_text_field($_POST[c_al2fb_option_msg_refresh])); update_option(c_al2fb_option_msg_maxage, sanitize_text_field($_POST[c_al2fb_option_msg_maxage])); update_option(c_al2fb_option_cron_enabled, sanitize_text_field($_POST[c_al2fb_option_cron_enabled])); update_option(c_al2fb_option_max_descr, sanitize_text_field($_POST[c_al2fb_option_max_descr])); update_option(c_al2fb_option_max_text, sanitize_text_field($_POST[c_al2fb_option_max_text])); update_option(c_al2fb_option_max_comment, sanitize_text_field($_POST[c_al2fb_option_max_comment])); update_option(c_al2fb_option_exclude_custom, sanitize_text_field($_POST[c_al2fb_option_exclude_custom])); update_option(c_al2fb_option_exclude_type, sanitize_text_field($_POST[c_al2fb_option_exclude_type])); update_option(c_al2fb_option_exclude_cat, sanitize_text_field($_POST[c_al2fb_option_exclude_cat])); update_option(c_al2fb_option_exclude_tag, sanitize_text_field($_POST[c_al2fb_option_exclude_tag])); update_option(c_al2fb_option_exclude_author, sanitize_text_field($_POST[c_al2fb_option_exclude_author])); update_option(c_al2fb_option_metabox_type, sanitize_text_field($_POST[c_al2fb_option_metabox_type])); update_option(c_al2fb_option_noverifypeer, sanitize_text_field($_POST[c_al2fb_option_noverifypeer])); update_option(c_al2fb_option_use_cacerts, sanitize_text_field($_POST[c_al2fb_option_use_cacerts])); update_option(c_al2fb_option_shortcode_widget, sanitize_text_field($_POST[c_al2fb_option_shortcode_widget])); update_option(c_al2fb_option_noshortcode, sanitize_text_field($_POST[c_al2fb_option_noshortcode])); update_option(c_al2fb_option_nofilter, sanitize_text_field($_POST[c_al2fb_option_nofilter])); update_option(c_al2fb_option_nofilter_comments, sanitize_text_field($_POST[c_al2fb_option_nofilter_comments])); update_option(c_al2fb_option_use_ssp, sanitize_text_field($_POST[c_al2fb_option_use_ssp])); update_option(c_al2fb_option_ssp_info, sanitize_text_field($_POST[c_al2fb_option_ssp_info])); update_option(c_al2fb_option_filter_prio, sanitize_text_field($_POST[c_al2fb_option_filter_prio])); update_option(c_al2fb_option_noasync, sanitize_text_field($_POST[c_al2fb_option_noasync])); update_option(c_al2fb_option_noscript, sanitize_text_field($_POST[c_al2fb_option_noscript])); update_option(c_al2fb_option_uselinks, sanitize_text_field($_POST[c_al2fb_option_uselinks])); update_option(c_al2fb_option_notoken_refresh, sanitize_text_field($_POST[c_al2fb_option_notoken_refresh])); update_option(c_al2fb_option_clean, sanitize_text_field($_POST[c_al2fb_option_clean])); update_option(c_al2fb_option_css, sanitize_text_field($_POST[c_al2fb_option_css])); update_option(c_al2fb_option_login_add_links, sanitize_text_field($_POST[c_al2fb_option_login_add_links])); if (isset($_REQUEST['debug'])) { update_option(c_al2fb_option_siteurl, sanitize_text_field($_POST[c_al2fb_option_siteurl])); update_option(c_al2fb_option_nocurl, sanitize_text_field($_POST[c_al2fb_option_nocurl])); update_option(c_al2fb_option_use_pp, sanitize_text_field($_POST[c_al2fb_option_use_pp])); update_option(c_al2fb_option_debug, sanitize_text_field($_POST[c_al2fb_option_debug])); } } // Show result echo '<div id="message" class="updated fade al2fb_notice"><p>' . __('Settings updated', c_al2fb_text_domain) . '</p></div>'; // Clear all errors if ($_POST[c_al2fb_meta_clear_errors]) { $query = array('meta_key' => c_al2fb_meta_error, 'posts_per_page' => -1); if (!get_site_option(c_al2fb_option_app_share)) { $query['author'] = $user_ID; } $posts = new WP_Query($query); while ($posts->have_posts()) { $posts->next_post(); delete_post_meta($posts->post->ID, c_al2fb_meta_error); } } }