wpcf7_captchac_options

The Contact Form 7 wpcf7 captchac options function.

Description

wpcf7_captchac_options( $options ); 

Parameters (1)

0. $options
The options.

Usage

  1. if ( !function_exists( 'wpcf7_captchac_options' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/modules/really-simple-captcha.php'; 
  3.  
  4. // The options. 
  5. $options = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpcf7_captchac_options($options); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/really-simple-captcha.php  
  1. function wpcf7_captchac_options( $options ) { 
  2. if ( ! is_array( $options ) ) 
  3. return array(); 
  4.  
  5. $op = array(); 
  6. $image_size_array = preg_grep( '%^size:[smlSML]$%', $options ); 
  7.  
  8. if ( $image_size = array_shift( $image_size_array ) ) { 
  9. preg_match( '%^size:([smlSML])$%', $image_size, $is_matches ); 
  10. switch ( strtolower( $is_matches[1] ) ) { 
  11. case 's': 
  12. $op['img_size'] = array( 60, 20 ); 
  13. $op['base'] = array( 6, 15 ); 
  14. $op['font_size'] = 11; 
  15. $op['font_char_width'] = 13; 
  16. break; 
  17. case 'l': 
  18. $op['img_size'] = array( 84, 28 ); 
  19. $op['base'] = array( 6, 20 ); 
  20. $op['font_size'] = 17; 
  21. $op['font_char_width'] = 19; 
  22. break; 
  23. case 'm': 
  24. default: 
  25. $op['img_size'] = array( 72, 24 ); 
  26. $op['base'] = array( 6, 18 ); 
  27. $op['font_size'] = 14; 
  28. $op['font_char_width'] = 15; 
  29.  
  30. $fg_color_array = preg_grep( '%^fg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $options ); 
  31. if ( $fg_color = array_shift( $fg_color_array ) ) { 
  32. preg_match( '%^fg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $fg_color, $fc_matches ); 
  33. if ( 3 == strlen( $fc_matches[1] ) ) { 
  34. $r = substr( $fc_matches[1], 0, 1 ); 
  35. $g = substr( $fc_matches[1], 1, 1 ); 
  36. $b = substr( $fc_matches[1], 2, 1 ); 
  37. $op['fg'] = array( hexdec( $r . $r ), hexdec( $g . $g ), hexdec( $b . $b ) ); 
  38. } elseif ( 6 == strlen( $fc_matches[1] ) ) { 
  39. $r = substr( $fc_matches[1], 0, 2 ); 
  40. $g = substr( $fc_matches[1], 2, 2 ); 
  41. $b = substr( $fc_matches[1], 4, 2 ); 
  42. $op['fg'] = array( hexdec( $r ), hexdec( $g ), hexdec( $b ) ); 
  43.  
  44. $bg_color_array = preg_grep( '%^bg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $options ); 
  45. if ( $bg_color = array_shift( $bg_color_array ) ) { 
  46. preg_match( '%^bg:#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$%', $bg_color, $bc_matches ); 
  47. if ( 3 == strlen( $bc_matches[1] ) ) { 
  48. $r = substr( $bc_matches[1], 0, 1 ); 
  49. $g = substr( $bc_matches[1], 1, 1 ); 
  50. $b = substr( $bc_matches[1], 2, 1 ); 
  51. $op['bg'] = array( hexdec( $r . $r ), hexdec( $g . $g ), hexdec( $b . $b ) ); 
  52. } elseif ( 6 == strlen( $bc_matches[1] ) ) { 
  53. $r = substr( $bc_matches[1], 0, 2 ); 
  54. $g = substr( $bc_matches[1], 2, 2 ); 
  55. $b = substr( $bc_matches[1], 4, 2 ); 
  56. $op['bg'] = array( hexdec( $r ), hexdec( $g ), hexdec( $b ) ); 
  57.  
  58. return $op;