Example #1
0
 /**
  *
  * filter $_POST meta data options and prepare to save in db
  *
  * @param array  $options array with meta data to filter
  * @param string $prefix
  *
  * @return array
  */
 public static function getPostOption(array $options, $prefix = null)
 {
     if (!\is_null($prefix)) {
         $prefix = '_' . $prefix . '_';
     }
     $option = array();
     foreach ($options as $key => $value) {
         $result = array();
         if (\preg_match('/^' . THEME_OPTION_PREFIX . $prefix . '/', $key, $result)) {
             $index = \preg_replace('/^' . THEME_OPTION_PREFIX . '_/', '', $key);
             // Sanitize the user input.
             $option[$index] = String::sanitize_text_field($value);
         }
     }
     return $option;
 }