array( * array('type' => 'text', 'name' => 'name', 'label' => 'Nom', 'required' => true), * array('type' => 'email', 'name' => 'email', 'label' => 'Email', 'required' => true), * array('type' => 'textarea', 'name' => 'message', 'label' => 'Message', 'required' => true), * array('type' => 'submit', 'name' => 'submit', 'label' => 'Send'), * ), * )); * * @param string $form_id Unique form identifier * @param array $config Form configuration array */ function adpf_register_form($form_id, $config) { add_filter('adpf_form_config_' . $form_id, function() use ($config) { return $config; }); } /** * Get form configuration * * @param string $form_id Form ID * @return array|false Form configuration or false */ function adpf_get_form_config($form_id) { return apply_filters('adpf_form_config_' . $form_id, false); } /** * Lighten a hex color by mixing it toward white by the given percentage. * * @param string $hex Hex color (with or without leading #). * @param int $percent 0–100. Higher = closer to white. * @return string Lightened hex color with leading #. */ function adpf_lighten_color($hex, $percent = 20) { $hex = ltrim($hex, '#'); if (strlen($hex) === 3) { $hex = str_repeat($hex[0], 2) . str_repeat($hex[1], 2) . str_repeat($hex[2], 2); } if (strlen($hex) !== 6) { return '#' . $hex; } $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); $r = (int) min(255, round($r + (255 - $r) * $percent / 100)); $g = (int) min(255, round($g + (255 - $g) * $percent / 100)); $b = (int) min(255, round($b + (255 - $b) * $percent / 100)); return sprintf('#%02x%02x%02x', $r, $g, $b); } /** * Get the upgrade URL for the Pro version * * @return string URL to the Pro version page */ function adpf_get_upgrade_url() { if (function_exists('adpf_fs_integration')) { $upgrade_url = adpf_fs_integration()->get_upgrade_url(); if (!empty($upgrade_url)) { return $upgrade_url; } } return admin_url('admin.php?page=ad-pro-forms-menu-pricing'); }