Example #1
0
function custom_contact_get_form()
{
    $fields = custom_contact_get_field_defs();
    $html = '<div class="custom_contact_form">' . "\n";
    foreach ($fields as $field) {
        if ($field->required == 1) {
            $required_subclass = '_required';
        } else {
            $required_subclass = '';
        }
        $html .= '<div class="custom_contact_row">' . "\n";
        if ($field->input_type != CC_CHECKBOX_FIELD) {
            $html .= '<div class="custom_contact_label' . $required_subclass . '">';
            $html .= xyooj_unesc_quote($field->label);
            $html .= '</div><!-- label -->';
        }
        $html .= '<div class="custom_contact_data">';
        if ($field->input_type == CC_TEXT_FIELD) {
            $html .= '<input type="text" id="field_' . $field->id . '" name="field_' . $field->id . '" />';
        } else {
            if ($field->input_type == CC_TEXTAREA_FIELD) {
                $html .= '<textarea id="field_' . $field->id . '" name="field_' . $field->id . '" rows="3" cols="50"></textarea>';
            } else {
                if ($field->input_type == CC_CHECKBOX_FIELD) {
                    $html .= '<input type="checkbox" value="Yes" id="field_' . $field->id . '" name="field_' . $field->id . '" />';
                } else {
                    if ($field->input_type == CC_SELECT_FIELD) {
                        $html .= '<select id="field_' . $field->id . '" name="field_' . $field->id . '" >';
                        $options = explode(',', xyooj_unesc_quote($field->options));
                        foreach ($options as $option) {
                            $html .= '<option value="' . $option . '">' . $option . '</option>';
                        }
                        $html .= '</select>';
                    }
                }
            }
        }
        $html .= '</div><!-- data -->';
        if ($field->input_type == CC_CHECKBOX_FIELD) {
            $html .= '<div class="custom_contact_label' . $required_subclass . '">';
            $html .= xyooj_unesc_quote($field->label);
            $html .= '</div><!-- label -->';
        }
        $html .= "\n</div><!-- row --><br/>\n";
    }
    $html .= '<div class="custom_contact_buttons"><input type="button" value="Senden" onclick="customContactEmail(); return false;"/></div>' . "\n";
    $html .= '</div><!-- form -->';
    return $html;
}
function custom_contact_build_admin_form()
{
    ?>
		<div class="wrap">
			<h2>Options</h2>
			<form name="doptions" method="post">
				<input type="hidden" name="action" value="update_options" />
				<fieldset name="new" class="options">
					<table summary="Field" class="editform" cellpadding="5" cellspacing="2" style="width:100%;vertical-align:top;">
						<tr>
							<th scope="row">Successs Response: </th>
							<td><input name="custom_contact_success_msg" max_length="64" value="<?php 
    echo get_option('custom_contact_success_msg');
    ?>
" size="40" class="code" type="text" />
							</td>
						</tr>
						<tr>
							<th scope="row">Email Subject: </th>
							<td><input name="custom_contact_email_subject" max_length="64" value="<?php 
    echo get_option('custom_contact_email_subject');
    ?>
" size="40" class="code" type="text" />
							</td>
						</tr>
						<tr>
							<th scope="row">Missing Required Field Message: </th>
							<td><input name="custom_contact_required_msg" max_length="64" value="<?php 
    echo get_option('custom_contact_required_msg');
    ?>
" size="40" class="code" type="text" />
							</td>
						</tr>
					</table>
				</fieldset>
				<div class="submit">
					<input type="submit" name="update_options" value="Update Options" title="Submit and saves changes" />
				</div>
			</form>
			<h2>Add Field</h2>
			<?php 
    custom_contact_build_field_form(null, "add");
    ?>
			<h2>Modify Fields</h2>
			<?php 
    $fields = custom_contact_get_field_defs();
    if ($fields != null) {
        foreach ($fields as $field) {
            custom_contact_build_field_form($field, "update");
        }
    }
    ?>
		</div>
<?php 
}
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
require_once '../../../wp-blog-header.php';
require_once 'custom-contact.php';
custom_contact_init();
header("Content-type: text/xml;");
$fields = custom_contact_get_field_defs();
$email_body = "";
foreach ($fields as $field) {
    $field_value = $_REQUEST['field_' . $field->id];
    if ($field->required == 1 && $field_value == null) {
        return_required_msg();
        return;
    }
    $email_body .= xyooj_unesc_quote($field->label) . ": " . $field_value . "\n";
}
$email_subject = get_option('custom_contact_email_subject');
wp_mail(get_settings('admin_email'), "{$email_subject}", $email_body);
return_success_msg();
function return_success_msg()
{
    $msg = get_option('custom_contact_success_msg');