function wppb_sanitize_inputs($input = '') { // Grab from POST if ('' == $input) { $input = $_POST; } // If no data loaded, then grab from database (presumably because on initial page load instead of loading via AJAX) if ('' == $input) { $input = get_option(WPPB_DESIGNER_SETTINGS); } // Processing entire POST to array with errors (replaced later with correct values - used for debugging purposes) foreach (wppb_ajax_option_get() as $option) { if (isset($input[$option])) { $wppb_design_settings[$option] = 'Sanitization error!'; } } // Sanitizing CSS if (isset($input['add_custom_css'])) { $wppb_design_settings['add_custom_css'] = pixopoint_validate_css($input['add_custom_css']); } // Sanitizing CSS // Sanitizing the added custom CSS (only one option for this so need for accessing from array) if (empty($wppb_design_settings['add_custom_css'])) { $wppb_design_settings['add_custom_css'] = ''; } if (isset($input['add_custom_css'])) { $wppb_design_settings['add_custom_css'] = pixopoint_validate_css($input['add_custom_css']); } // Sanitizing font size options foreach (wppb_fontsize_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if (is_numeric($input[$opt])) { if ($input[$opt] > 4 && $input[$opt] < 120) { $wppb_design_settings[$opt] = $input[$opt]; } else { $wppb_design_settings[$opt] = '12'; } } } // Sanitizing Font family options foreach (wppb_fontfamily_options() as $stuff => $opt) { // Loop through all variations foreach (wppb_font_family() as $variation) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Correcting escaped characters $input[$opt] = str_replace("\\'", "'", $input[$opt]); // Setting option if matches possible variation if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // If no variation selected, then default to helvetica if ('' == $input[$opt]) { $wppb_design_settings[$opt] = "'Helvetica Neue', Arial, Helvetica, 'Nimbus Sans L', sans-serif"; } } // Sanitizing colour options foreach (wppb_colour_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } $wppb_design_settings[$opt] = wppb_sanitize_hex_colour($input[$opt]); } // Sanitizing image options foreach (wppb_image_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } $image_location_initial = explode('/', $input[$opt]); $image_location_final[0] = sanitize_file_name($image_location_initial[0]); if (isset($image_location_initial[1])) { $image_location_final[1] = sanitize_file_name($image_location_initial[1]); } $wppb_design_settings[$opt] = implode('/', $image_location_final); if ('/' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = ''; } } // Sanitizing image tiling options foreach (wppb_imagetiling_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Loop through all variations foreach (wppb_imagetiling_variations() as $variation => $text) { if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // If no variation selected, then default to "repeat" if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'repeat'; } } // Sanitizing Small-caps options foreach (wppb_smallcaps_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Loop through all variations foreach (wppb_smallcaps_variations() as $variation => $text) { if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } // If no variation selected, then default to "repeat" if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'normal'; } } // Sanitizing font weight options foreach (wppb_fontweight_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if ('bold' == $input[$opt]) { $wppb_design_settings[$opt] = 'bold'; } elseif ('inherit' == $input[$opt]) { $wppb_design_settings[$opt] = 'inherit'; } else { $wppb_design_settings[$opt] = 'normal'; } } // Sanitizing text decoration options foreach (wppb_textdecoration_options() as $stuff => $opt) { // Loop through all variations foreach (wppb_textdecoration_variations() as $variation) { if (!isset($input[$opt])) { $input[$opt] = ''; } if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // Inherit variation is only present for some options if ($input[$opt] == 'inherit') { $wppb_design_settings[$opt] = $input[$opt]; } // If no variation selected, then default to "repeat" if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'none'; } } // Sanitizing big numbers options foreach (wppb_bignumbers_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if (is_numeric($input[$opt])) { if ($input[$opt] > -0.001 and $input[$opt] < 1600) { $wppb_design_settings[$opt] = $input[$opt]; } else { $wppb_design_settings[$opt] = '600'; } } } // Sanitizing little numbers options foreach (wppb_littlenumbers_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if (is_numeric($input[$opt])) { if ($input[$opt] > 0 and $input[$opt] < 100) { $wppb_design_settings[$opt] = $input[$opt]; } else { $wppb_design_settings[$opt] = '0'; } } } // Sanitizing shadow coordinate options foreach (wppb_shadow_coordinates_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if (is_numeric($input[$opt])) { if ($input[$opt] > -0.001 and $input[$opt] < 40) { $wppb_design_settings[$opt] = $input[$opt]; } else { $wppb_design_settings[$opt] = '0'; } } } // Sanitizing opacity options foreach (wppb_opacity_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if (is_numeric($input[$opt])) { if ($input[$opt] > 0 and $input[$opt] < 1.00001) { $wppb_design_settings[$opt] = $input[$opt]; } else { $wppb_design_settings[$opt] = '1'; } } } // Sanitizing display options foreach (wppb_display_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = 'none'; } if ($input[$opt] == 'on' || $input[$opt] == 'block') { $wppb_design_settings[$opt] = 'block'; } else { $wppb_design_settings[$opt] = 'none'; } } // Sanitizing centered options foreach (wppb_centered_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Loop through all variations foreach (wppb_alignment_variations() as $variation) { if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // If no variation selected, then default to "repeat" if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'none'; } } // Sanitizing alignment options foreach (wppb_alignment_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Loop through all variations foreach (wppb_alignment_variations() as $variation) { if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // If no variation selected, then default to "none" if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'none'; } } // Sanitizing Text transform options foreach (wppb_texttransform_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Loop through all variations foreach (wppb_texttransform_variations() as $variation) { if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // If no variation selected, then default to "none" if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'none'; } } // Sanitizing border type options foreach (wppb_bordertype_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Loop through all variations foreach (wppb_bordertype_variations() as $variation) { if ($input[$opt] == $variation) { $wppb_design_settings[$opt] = $input[$opt]; } } // If no variation selected, then default to "solid" if (!isset($wppb_design_settings[$opt])) { $wppb_design_settings[$opt] = ''; } if ('' == $wppb_design_settings[$opt]) { $wppb_design_settings[$opt] = 'solid'; } } // Sanitizing font style options foreach (wppb_fontstyle_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } if ('normal' == $input[$opt] || 'italic' == $input[$opt] || 'inherit' == $input[$opt]) { $wppb_design_settings[$opt] = $input[$opt]; } else { $wppb_design_settings[$opt] = 'normal'; } } // Sanitizing raw text options foreach (wppb_rawtext_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Allows some HTML, and converts quote marks to ensure they don't screw up quote marks in input fields $wppb_design_settings[$opt] = str_replace("'", '"', wp_kses($input[$opt], pixopoint_limited_html(), '')); } // Sanitizing raw text options foreach (wppb_rawhtml_options() as $stuff => $opt) { if (!isset($input[$opt])) { $input[$opt] = ''; } // Allows some HTML, and converts quote marks to ensure they don't screw up quote marks in input fields $wppb_design_settings[$opt] = wp_kses($input[$opt], pixopoint_allowed_html(), ''); } return $wppb_design_settings; }
/** * Displaying font families * @since 0.1 */ function wppb_fontfamily_selector($option, $wppb_design_settings, $title, $class = 'block fontfamily') { echo ' <div class="' . $class . '"><p><label>' . $title . '</label><select id="' . $option . '" name="' . $option . '">' . "\n"; $later = ''; // Setting variable foreach (wppb_font_family() as $opt => $font) { if ($font == $wppb_design_settings[$option]) { $initial = '<option style="font-family:' . $font . '" value="' . $font . '">' . $font . "</option>"; } else { $later .= '<option style="font-family:' . $font . '" value="' . $font . '">' . $font . "</option>"; } } echo $initial . $later; echo "</select></p></div>\n"; }