You are here

function honeypot_create_css in Honeypot 7

Create CSS file to hide the Honeypot field.

Parameters

string $element_name: The honeypot element class name (e.g. 'url').

5 calls to honeypot_create_css()
HoneypotCssTestCase::testHoneypotCssRegeneration in ./honeypot.test
Test CSS file regeneration.
honeypot_admin_form_submit in ./honeypot.admin.inc
Honeypot admin form submit callback.
honeypot_cron in ./honeypot.module
Implements hook_cron().
honeypot_install in ./honeypot.install
Implements hook_install().
honeypot_update_7004 in ./honeypot.install
Create Honeypot CSS file.

File

./honeypot.module, line 515
Honeypot module, for deterring spam bots from completing Drupal forms.

Code

function honeypot_create_css($element_name) {
  $path = honeypot_file_default_scheme() . '://honeypot';
  if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
    drupal_set_message(t('Unable to create Honeypot CSS directory, %path. Check the permissions on your files directory.', array(
      '%path' => file_uri_target($path),
    )), 'error');
  }
  else {
    $filename = $path . '/honeypot.css';
    $data = '.' . $element_name . '-textfield { display: none !important; }';
    file_unmanaged_save_data($data, $filename, FILE_EXISTS_REPLACE);
  }
}