Example #1
0
function cp_admin_fields($options)
{
    global $cp_options;
    ?>

	<div id="tabs-wrap">

<?php 
    // first generate the page tabs
    $counter = 0;
    echo '<ul class="tabs">' . "\n";
    foreach ($options as $value) {
        if (in_array('tab', $value)) {
            echo '<li><a href="#' . $value['type'] . $counter . '">' . $value['tabname'] . '</a></li>' . "\n";
            $counter++;
        }
    }
    echo '</ul>' . "\n\n";
    // now loop through all the options
    $counter = 0;
    $table_width = $cp_options->table_width;
    foreach ($options as $value) {
        if (empty($value['tip'])) {
            $tooltip = '';
        } else {
            $tooltip = html("img", array('class' => 'tip-icon', 'title' => __('Help', APP_TD), 'src' => appthemes_framework_image('help.png')));
            $tooltip .= html("div class='tip-content'", $value['tip']);
        }
        switch ($value['type']) {
            case 'tab':
                echo '<div id="' . $value['type'] . $counter . '">' . "\n\n";
                echo '<table class="widefat fixed" style="width:' . $table_width . '; margin-bottom:20px;">' . "\n\n";
                break;
            case 'notab':
                echo '<table class="widefat fixed" style="width:' . $table_width . '; margin-bottom:20px;">' . "\n\n";
                break;
            case 'title':
                ?>
				<thead>
					<tr>
						<th scope="col" width="200px"><?php 
                echo esc_html($value['name']);
                ?>
</th>
						<th class="tip">&nbsp;</th>
						<th scope="col"><?php 
                if (isset($value['desc'])) {
                    echo $value['desc'];
                }
                ?>
&nbsp;</th>
					</tr>
				</thead>
		<?php 
                break;
            case 'text':
                // don't show the meta name field used by WP. This is automatically created by CP.
                if ($value['id'] == 'field_name') {
                    break;
                }
                $args = array('name' => $value['id'], 'id' => $value['id'], 'type' => $value['type'], 'class' => array(), 'style' => $value['css'], 'value' => get_option($value['id']) ? get_option($value['id']) : $value['std']);
                if (!empty($value['req'])) {
                    $args['class'][] = 'required';
                }
                if (!empty($value['altclass'])) {
                    $args['class'][] = $value['altclass'];
                }
                $args['class'] = implode(' ', $args['class']);
                if (!empty($value['min'])) {
                    $args['minlength'] = $value['min'];
                }
                ?>
				<tr <?php 
                if ($value['vis'] == '0') {
                    ?>
id="<?php 
                    if (!empty($value['visid'])) {
                        echo $value['visid'];
                    } else {
                        echo 'field_values';
                    }
                    ?>
" style="display:none;"<?php 
                } else {
                    ?>
id="<?php 
                    echo $value['id'];
                    ?>
_row"<?php 
                }
                ?>
>
					<td class="titledesc"><?php 
                echo esc_html($value['name']);
                ?>
:</td>
					<td class="tip"><?php 
                echo $tooltip;
                ?>
</td>
					<td class="forminp"><?php 
                echo html('input', $args);
                ?>
<br /><small><?php 
                echo $value['desc'];
                ?>
</small></td>
				</tr>
		<?php 
                break;
            case 'select':
                ?>
				<tr id="<?php 
                echo $value['id'];
                ?>
_row">
					<td class="titledesc"><?php 
                echo esc_html($value['name']);
                ?>
:</td>
					<td class="tip"><?php 
                echo $tooltip;
                ?>
</td>
					<td class="forminp">
						<select <?php 
                if (!empty($value['js'])) {
                    echo $value['js'];
                }
                ?>
 name="<?php 
                echo $value['id'];
                ?>
" id="<?php 
                echo $value['id'];
                ?>
" style="<?php 
                echo $value['css'];
                ?>
"<?php 
                if ($value['req']) {
                    ?>
 class="required"<?php 
                }
                ?>
>
						<?php 
                foreach ($value['options'] as $key => $val) {
                    ?>
							<option value="<?php 
                    echo $key;
                    ?>
" <?php 
                    selected(get_option($value['id']) == $key);
                    ?>
><?php 
                    echo $val;
                    ?>
</option>
						<?php 
                }
                ?>
						</select>
						<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
					</td>
				</tr>
		<?php 
                break;
            case 'checkbox':
                ?>
				<tr id="<?php 
                echo $value['id'];
                ?>
_row">
					<td class="titledesc"><?php 
                echo esc_html($value['name']);
                ?>
:</td>
					<td class="tip"><?php 
                echo $tooltip;
                ?>
</td>
					<td class="forminp">
						<input type="checkbox" name="<?php 
                echo $value['id'];
                ?>
" id="<?php 
                echo $value['id'];
                ?>
" value="true" style="<?php 
                echo $value['css'];
                ?>
" <?php 
                checked(get_option($value['id']));
                ?>
 />
						<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
					</td>
				</tr>
		<?php 
                break;
            case 'textarea':
                ?>
				<tr id="<?php 
                echo $value['id'];
                ?>
_row"<?php 
                if ($value['id'] == 'field_values') {
                    ?>
 style="display: none;" <?php 
                }
                ?>
>
					<td class="titledesc"><?php 
                echo esc_html($value['name']);
                ?>
:</td>
					<td class="tip"><?php 
                echo $tooltip;
                ?>
</td>
					<td class="forminp">
						<textarea name="<?php 
                echo $value['id'];
                ?>
" id="<?php 
                echo $value['id'];
                ?>
" style="<?php 
                echo $value['css'];
                ?>
" <?php 
                if ($value['req']) {
                    ?>
 class="required" <?php 
                }
                if ($value['min']) {
                    ?>
 minlength="<?php 
                    echo $value['min'];
                    ?>
"<?php 
                }
                ?>
><?php 
                if (get_option($value['id'])) {
                    echo stripslashes(get_option($value['id']));
                } else {
                    echo $value['std'];
                }
                ?>
</textarea>
						<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
					</td>
				</tr>
		<?php 
                break;
            case 'cat_checklist':
                ?>
				<tr id="<?php 
                echo $value['id'];
                ?>
_row">
					<td class="titledesc"><?php 
                echo esc_html($value['name']);
                ?>
:</td>
					<td class="tip"><?php 
                echo $tooltip;
                ?>
</td>
					<td class="forminp">
						<div id="form-categorydiv">
							<div class="tabs-panel" id="categories-all" style="<?php 
                echo $value['css'];
                ?>
">
								<ul class="list:category categorychecklist form-no-clear" id="categorychecklist">
									<?php 
                $catcheck = cp_category_checklist(0, cp_exclude_cats());
                ?>
									<?php 
                if ($catcheck) {
                    echo $catcheck;
                } else {
                    wp_die('<p style="color:red;">' . __('All your categories are currently being used. You must remove at least one category from another form layout before you can continue.', APP_TD) . '</p>');
                }
                ?>
								</ul>
							</div>
							<a href="#" class="checkall"><?php 
                _e('check all', APP_TD);
                ?>
</a>
						</div>
						<br /><small><?php 
                echo $value['desc'];
                ?>
</small>
					</td>
				</tr>
		<?php 
                break;
            case 'logo':
                ?>
				<tr id="<?php 
                echo $value['id'];
                ?>
_row">
					<td class="titledesc"><?php 
                echo esc_html($value['name']);
                ?>
</td>
					<td class="tip">&nbsp;</td>
					<td class="forminp">&nbsp;</td>
				</tr>
		<?php 
                break;
            case 'tabend':
                echo '</table>' . "\n\n";
                echo '</div> <!-- #tab' . $counter . ' -->' . "\n\n";
                $counter++;
                break;
            case 'notabend':
                echo '</table>' . "\n\n";
                break;
        }
        // end switch
    }
    // end foreach
    ?>

	</div> <!-- #tabs-wrap -->

<?php 
}
 public function table_row($field, $formdata = false)
 {
     if (empty($field['tip'])) {
         $tip = '';
     } else {
         $tip = html("img", array('class' => 'tip-icon', 'title' => __('Help', APP_TD), 'src' => appthemes_framework_image('help.png')));
         $tip .= html("div class='tip-content'", $field['tip']);
     }
     if (isset($field['desc'])) {
         $field['desc'] = html('span class="description"', $field['desc']);
     }
     return html("tr", html("th scope='row'", $field['title']), html("td class='tip'", $tip), html("td", scbForms::input($field, $this->options->get())));
 }
Example #3
0
 protected function box_icon($name)
 {
     return html('img', array('class' => 'box-icon', 'src' => appthemes_framework_image($name)));
 }