Beispiel #1
0
function cp_custom_fields()
{
    global $options_new_field, $wpdb, $current_user;
    $current_user = wp_get_current_user();
    ?>

	<!-- show/hide the dropdown field values tr -->
	<script type="text/javascript">
	/* <![CDATA[ */
		jQuery(document).ready(function() {
			jQuery("#mainform").validate({errorClass: "invalid"});
		});

		function show(o){
			if(o){switch(o.value){
				case 'drop-down': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break;
				case 'radio': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break;
				case 'checkbox': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break;
				case 'text box': jQuery('#field_min_length_row').show(); jQuery('#field_values_row').hide(); break;
				default: jQuery('#field_values_row').hide(); jQuery('#field_min_length_row').hide();
			}}
		}

		//show/hide immediately on document load
		jQuery(document).ready(function() {
			show(jQuery('#field_type').get(0));
		});

		//hide unwanted options for cp_currency field
		jQuery(document).ready(function() {
			var field_name = jQuery('#field_name').val();
			if(field_name == 'cp_currency'){
				jQuery("#field_type option[value='text box']").attr("disabled", "disabled");
				jQuery("#field_type option[value='text area']").attr("disabled", "disabled");
				jQuery("#field_type option[value='checkbox']").attr("disabled", "disabled");
			}
		});
	/* ]]> */
	</script>

	<?php 
    // check to prevent php "notice: undefined index" msg when php strict warnings is on
    if (isset($_GET['action'])) {
        $theswitch = $_GET['action'];
    } else {
        $theswitch = '';
    }
    switch ($theswitch) {
        case 'addfield':
            ?>

			<div class="wrap">
				<div class="icon32" id="icon-themes"><br /></div>
				<h2><?php 
            _e('New Custom Field', APP_TD);
            ?>
</h2>

				<?php 
            cp_admin_info_box();
            ?>

				<?php 
            // check and make sure the form was submitted
            if (isset($_POST['submitted'])) {
                $_POST['field_search'] = '';
                // we aren't using this field so set it to blank for now to prevent notice
                $data = array('field_name' => appthemes_clean(cp_make_custom_name($_POST['field_label'])), 'field_label' => appthemes_clean($_POST['field_label']), 'field_desc' => appthemes_clean($_POST['field_desc']), 'field_tooltip' => esc_attr(appthemes_clean($_POST['field_tooltip'])), 'field_type' => appthemes_clean($_POST['field_type']), 'field_values' => appthemes_clean($_POST['field_values']), 'field_search' => appthemes_clean($_POST['field_search']), 'field_owner' => appthemes_clean($_POST['field_owner']), 'field_created' => current_time('mysql'), 'field_modified' => current_time('mysql'));
                $insert = $wpdb->insert($wpdb->cp_ad_fields, $data);
                if ($insert) {
                    ?>

						<p style="text-align:center;padding-top:50px;font-size:22px;"><?php 
                    _e('Creating your field.....', APP_TD);
                    ?>
<br /><br /><img src="<?php 
                    bloginfo('template_directory');
                    ?>
/images/loader.gif" alt="" /></p>
						<meta http-equiv="refresh" content="0; URL=?page=fields">

					<?php 
                }
                die;
            } else {
                ?>

            <form method="post" id="mainform" action="">

                <?php 
                cp_admin_fields($options_new_field);
                ?>

                <p class="submit"><input class="btn button-primary" name="save" type="submit" value="<?php 
                _e('Create New Field', APP_TD);
                ?>
" />&nbsp;&nbsp;&nbsp;
                    <input name="cancel" type="button" onClick="location.href='?page=fields'" value="<?php 
                _e('Cancel', APP_TD);
                ?>
" /></p>
                <input name="submitted" type="hidden" value="yes" />
                <input name="field_owner" type="hidden" value="<?php 
                echo $current_user->user_login;
                ?>
" />

            </form>

        <?php 
            }
            ?>

        </div><!-- end wrap -->

    <?php 
            break;
        case 'editfield':
            ?>

			<div class="wrap">
				<div class="icon32" id="icon-themes"><br /></div>
				<h2><?php 
            _e('Edit Custom Field', APP_TD);
            ?>
</h2>

				<?php 
            cp_admin_info_box();
            ?>

				<?php 
            if (isset($_POST['submitted']) && $_POST['submitted'] == 'yes') {
                $data = array('field_name' => appthemes_clean($_POST['field_name']), 'field_label' => appthemes_clean($_POST['field_label']), 'field_desc' => appthemes_clean($_POST['field_desc']), 'field_tooltip' => esc_attr(appthemes_clean($_POST['field_tooltip'])), 'field_type' => appthemes_clean($_POST['field_type']), 'field_values' => appthemes_clean($_POST['field_values']), 'field_min_length' => appthemes_clean($_POST['field_min_length']), 'field_owner' => appthemes_clean($_POST['field_owner']), 'field_modified' => current_time('mysql'));
                $wpdb->update($wpdb->cp_ad_fields, $data, array('field_id' => $_GET['id']));
                ?>

					<p style="text-align:center;padding-top:50px;font-size:22px;">
						<?php 
                _e('Saving your changes.....', APP_TD);
                ?>
<br /><br />
						<img src="<?php 
                bloginfo('template_directory');
                ?>
/images/loader.gif" alt="" />
					</p>
					<meta http-equiv="refresh" content="0; URL=?page=fields">

				<?php 
            } else {
                ?>


            <form method="post" id="mainform" action="">

            <?php 
                cp_admin_db_fields($options_new_field, 'cp_ad_fields', 'field_id');
                ?>

                <p class="submit">
                    <input class="btn button-primary" name="save" type="submit" value="<?php 
                _e('Save changes', APP_TD);
                ?>
" />&nbsp;&nbsp;&nbsp;
                    <input name="cancel" type="button" onClick="location.href='?page=fields'" value="<?php 
                _e('Cancel', APP_TD);
                ?>
" />
                    <input name="submitted" type="hidden" value="yes" />
                    <input name="field_owner" type="hidden" value="<?php 
                echo $current_user->user_login;
                ?>
" />
                </p>

            </form>

        <?php 
            }
            ?>

        </div><!-- end wrap -->

    <?php 
            break;
        case 'delete':
            // check and make sure this fields perms allow deletion
            $sql = $wpdb->prepare("SELECT field_perm FROM {$wpdb->cp_ad_fields} WHERE field_id = %d LIMIT 1", $_GET['id']);
            $results = $wpdb->get_row($sql);
            // if it's not greater than zero, then delete it
            if (!$results->field_perm > 0) {
                $delete = $wpdb->prepare("DELETE FROM {$wpdb->cp_ad_fields} WHERE field_id = %d", $_GET['id']);
                $wpdb->query($delete);
            }
            ?>
        <p style="text-align:center;padding-top:50px;font-size:22px;"><?php 
            _e('Deleting custom field.....', APP_TD);
            ?>
<br /><br /><img src="<?php 
            bloginfo('template_directory');
            ?>
/images/loader.gif" alt="" /></p>
        <meta http-equiv="refresh" content="0; URL=?page=fields">

    <?php 
            break;
            // cp_custom_fields() show the table of all custom fields
        // cp_custom_fields() show the table of all custom fields
        default:
            $sql = "SELECT field_id, field_name, field_label, field_desc, field_tooltip, field_type, field_perm, field_owner, field_modified " . "FROM {$wpdb->cp_ad_fields} " . "ORDER BY field_name desc";
            $results = $wpdb->get_results($sql);
            ?>

        <div class="wrap">
        <div class="icon32" id="icon-tools"><br /></div>
        <h2><?php 
            _e('Custom Fields', APP_TD);
            ?>
&nbsp;<a class="button add-new-h2" href="?page=fields&amp;action=addfield"><?php 
            _e('Add New', APP_TD);
            ?>
</a></h2>

        <?php 
            cp_admin_info_box();
            ?>

        <p class="admin-msg"><?php 
            _e('Custom fields allow you to customize your ad submission forms and collect more information. Each custom field needs to be added to a form layout in order to be visible on your website. You can create unlimited custom fields and each one can be used across multiple form layouts. It is highly recommended to NOT delete a custom field once it is being used on your ads because it could cause ad editing problems for your customers.', APP_TD);
            ?>
</p>

        <table id="tblspacer" class="widefat fixed">

            <thead>
                <tr>
                    <th scope="col" style="width:35px;">&nbsp;</th>
                    <th scope="col"><?php 
            _e('Name', APP_TD);
            ?>
</th>
                    <th scope="col" style="width:100px;"><?php 
            _e('Type', APP_TD);
            ?>
</th>
                    <th scope="col"><?php 
            _e('Description', APP_TD);
            ?>
</th>
                    <th scope="col" style="width:150px;"><?php 
            _e('Modified', APP_TD);
            ?>
</th>
                    <th scope="col" style="text-align:center;width:100px;"><?php 
            _e('Actions', APP_TD);
            ?>
</th>
                </tr>
            </thead>

            <?php 
            if ($results) {
                ?>

                <tbody id="list">

                  <?php 
                $rowclass = '';
                $i = 1;
                foreach ($results as $result) {
                    $rowclass = 'even' == $rowclass ? 'alt' : 'even';
                    ?>

                    <tr class="<?php 
                    echo $rowclass;
                    ?>
">
                        <td style="padding-left:10px;"><?php 
                    echo $i;
                    ?>
.</td>
                        <td><a href="?page=fields&amp;action=editfield&amp;id=<?php 
                    echo $result->field_id;
                    ?>
"><strong><?php 
                    echo esc_html(translate($result->field_label, APP_TD));
                    ?>
</strong></a></td>
                        <td><?php 
                    echo $result->field_type;
                    ?>
</td>
                        <td><?php 
                    echo esc_html(translate($result->field_desc, APP_TD));
                    ?>
</td>
                        <td><?php 
                    echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->field_modified);
                    ?>
 <?php 
                    _e('by', APP_TD);
                    ?>
 <?php 
                    echo $result->field_owner;
                    ?>
</td>
                        <td style="text-align:center">

                            <?php 
                    // show the correct edit options based on perms
                    switch ($result->field_perm) {
                        case '1':
                            // core fields no editing
                            ?>

                                    <a href="?page=fields&amp;action=editfield&amp;id=<?php 
                            echo $result->field_id;
                            ?>
"><img src="<?php 
                            bloginfo('template_directory');
                            ?>
/images/edit.png" alt="" /></a>&nbsp;&nbsp;&nbsp;
                                    <img src="<?php 
                            bloginfo('template_directory');
                            ?>
/images/cross-grey.png" alt="" />

                                <?php 
                            break;
                        case '2':
                            // core fields some editing
                            ?>

                                    <a href="?page=fields&amp;action=editfield&amp;id=<?php 
                            echo $result->field_id;
                            ?>
"><img src="<?php 
                            bloginfo('template_directory');
                            ?>
/images/edit.png" alt="" /></a>&nbsp;&nbsp;&nbsp;
                                    <img src="<?php 
                            bloginfo('template_directory');
                            ?>
/images/cross-grey.png" alt="" />

                                <?php 
                            break;
                        default:
                            // regular fields full editing
                            // don't change these two lines to plain html/php. Get t_else error msg
                            echo '<a href="?page=fields&amp;action=editfield&amp;id=' . $result->field_id . '"><img src="' . get_bloginfo('template_directory') . '/images/edit.png" alt="" /></a>&nbsp;&nbsp;&nbsp;';
                            echo '<a onclick="return confirmBeforeDelete();" href="?page=fields&amp;action=delete&amp;id=' . $result->field_id . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="" /></a>';
                    }
                    // endswitch
                    ?>

                        </td>
                    </tr>

                <?php 
                    $i++;
                }
                //end foreach;
                //} // mystery bracket which makes it work
                ?>

              </tbody>

            <?php 
            } else {
                ?>

                <tr>
                    <td colspan="5"><?php 
                _e('No custom fields found. This usually means your install script did not run correctly. Go back and try reactivating the theme again.', APP_TD);
                ?>
</td>
                </tr>

            <?php 
            }
            // end $results
            ?>

        </table>

        </div><!-- end wrap -->

    <?php 
    }
    // endswitch
    ?>



    <script type="text/javascript">
        /* <![CDATA[ */
            function confirmBeforeDelete() { return confirm("<?php 
    _e('WARNING: Deleting this field will prevent any existing ads currently using this field from displaying the field value. Deleting fields is NOT recommended unless you do not have any existing ads using this field. Are you sure you want to delete this field?? (This cannot be undone)', APP_TD);
    ?>
"); }
        /* ]]> */
    </script>

<?php 
}
function cp_custom_fields()
{
    global $options_new_field, $wpdb, $current_user;
    $current_user = wp_get_current_user();
    ?>

    <!-- show/hide the dropdown field values tr -->
    <script type="text/javascript">
		/* <![CDATA[ */
			jQuery(document).ready(function() {
				jQuery("#mainform").validate({errorClass: "invalid"});
			});

			function show(o){
				if(o){switch(o.value){
					case 'drop-down': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break;
					case 'radio': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break;
					case 'checkbox': jQuery('#field_values_row').show(); jQuery('#field_min_length_row').hide(); break;
					case 'text box': jQuery('#field_min_length_row').show(); jQuery('#field_values_row').hide(); break;
					default: jQuery('#field_values_row').hide();jQuery('#field_min_length_row').hide();
				}}
			}

			//show/hide immediately on document load
			jQuery(document).ready(function() {
				show(jQuery('#field_type').get(0));
			});

			//hide unwanted options for cp_currency field
			jQuery(document).ready(function() {
				var field_name = jQuery('#field_name').val();
				if(field_name == 'cp_currency'){
					jQuery("#field_type option[value='text box']").attr("disabled","disabled");
					jQuery("#field_type option[value='text area']").attr("disabled","disabled");
					jQuery("#field_type option[value='checkbox']").attr("disabled","disabled");
				}
			});
		/* ]]> */
    </script>

    <?php 
    // check to prevent php "notice: undefined index" msg when php strict warnings is on
    if (isset($_GET['action'])) {
        $theswitch = $_GET['action'];
    } else {
        $theswitch = '';
    }
    switch ($theswitch) {
        // Adds a new AV form filed to DB
        case 'addfield':
            ?>

        <div class="wrap">
            <div class="icon32" id="icon-themes"><br /></div>
            <h2><?php 
            _e('New Custom Field', 'appthemes');
            ?>
</h2>

            <?php 
            cp_admin_info_box();
            ?>

        <?php 
            // check and make sure the form was submitted
            if (isset($_POST['submitted'])) {
                $_POST['field_search'] = '';
                // we aren't using this field so set it to blank for now to prevent notice
                $insert = "INSERT INTO {$wpdb->cp_ad_fields} ( field_name, field_label, field_desc, field_tooltip, field_type, field_values, field_search, field_owner, field_max_value, field_min_value, field_created, field_modified ) VALUES ( '" . $wpdb->escape(appthemes_clean(cp_make_custom_name($_POST['field_label']))) . "','" . $wpdb->escape(appthemes_clean($_POST['field_label'])) . "','" . $wpdb->escape(appthemes_clean($_POST['field_desc'])) . "','" . $wpdb->escape(esc_attr(appthemes_clean($_POST['field_tooltip']))) . "','" . $wpdb->escape(appthemes_clean($_POST['field_type'])) . "','" . $wpdb->escape(appthemes_clean($_POST['field_values'])) . "','" . $wpdb->escape(appthemes_clean($_POST['field_search'])) . "','" . $wpdb->escape(appthemes_clean($_POST['field_owner'])) . "','" . $wpdb->escape(appthemes_clean($_POST['field_max_value'])) . "','" . $wpdb->escape(appthemes_clean($_POST['field_min_value'])) . "','" . current_time('mysql') . "','" . current_time('mysql') . "' )";
                $results = $wpdb->query($insert);
                if ($results) {
                    //$lastid = $wpdb->insert_id;
                    //echo $lastid;
                    ?>

                <p style="text-align:center;padding-top:50px;font-size:22px;"><?php 
                    _e('Creating your field.....', 'appthemes');
                    ?>
<br /><br /><img src="<?php 
                    echo bloginfo('template_directory');
                    ?>
/images/loader.gif" alt="" /></p>
                <meta http-equiv="refresh" content="0; URL=?page=fields">

            <?php 
                }
                die;
            } else {
                ?>

            <form method="post" id="mainform" action="">

                <?php 
                cp_admin_fields($options_new_field);
                ?>

                <p class="submit"><input class="btn button-primary" name="save" type="submit" value="<?php 
                _e('Create New Field', 'appthemes');
                ?>
" />&nbsp;&nbsp;&nbsp;
                    <input name="cancel" type="button" onClick="location.href='?page=fields'" value="<?php 
                _e('Cancel', 'appthemes');
                ?>
" /></p>
                <input name="submitted" type="hidden" value="yes" />
                <input name="field_owner" type="hidden" value="<?php 
                echo $current_user->user_login;
                ?>
" />

            </form>

        <?php 
            }
            ?>

        </div><!-- end wrap -->

    <?php 
            break;
            // Updates an existing AV form filed from DB
        // Updates an existing AV form filed from DB
        case 'editfield':
            ?>

        <div class="wrap">
            <div class="icon32" id="icon-themes"><br /></div>
            <h2>Genel Alanlari Duzenle</h2>

            <?php 
            cp_admin_info_box();
            ?>

        <?php 
            if (isset($_POST['submitted']) && $_POST['submitted'] == 'yes') {
                // @todo Change to Update
                $update = $wpdb->prepare("UPDATE {$wpdb->cp_ad_fields} SET" . " field_name = %s," . " field_label = %s," . " field_desc = %s," . " field_tooltip = %s," . " field_type = %s," . " field_values = %s," . " field_min_length = %s," . " field_owner = %s," . " field_max_value = %s," . " field_min_value = %s," . " field_modified = %s" . " WHERE field_id = %s", appthemes_clean($_POST['field_name']), appthemes_clean($_POST['field_label']), appthemes_clean($_POST['field_desc']), esc_attr(appthemes_clean($_POST['field_tooltip'])), appthemes_clean($_POST['field_type']), appthemes_clean($_POST['field_values']), appthemes_clean($_POST['field_min_length']), appthemes_clean($_POST['field_owner']), appthemes_clean($_POST['field_max_value']), appthemes_clean($_POST['field_min_value']), current_time('mysql'), $_GET['id']);
                $results = $wpdb->query($update);
                ?>

            <p style="text-align:center;padding-top:50px;font-size:22px;">

                <?php 
                _e('Saving your changes.....', 'appthemes');
                ?>
<br /><br />
                <img src="<?php 
                echo bloginfo('template_directory');
                ?>
/images/loader.gif" alt="" />

            </p>

            <meta http-equiv="refresh" content="0; URL=?page=fields">

        <?php 
            } else {
                ?>


            <form method="post" id="mainform" action="">

            <?php 
                cp_admin_db_fields($options_new_field, 'cp_ad_fields', 'field_id');
                ?>

                <p class="submit">
                    <input class="btn button-primary" name="save" type="submit" value="Degisiklikleri Kaydet" />&nbsp;&nbsp;&nbsp;
                    <input name="cancel" type="button" onClick="location.href='?page=fields'" value="Degisiklikleri iptal et" />
                    <input name="submitted" type="hidden" value="yes" />
                    <input name="field_owner" type="hidden" value="<?php 
                echo $current_user->user_login;
                ?>
" />
                </p>

            </form>

        <?php 
            }
            ?>

        </div><!-- end wrap -->

    <?php 
            break;
            // Deletes an existing AV form filed from DB
        // Deletes an existing AV form filed from DB
        case 'delete':
            // check and make sure this fields perms allow deletion
            $sql = "SELECT field_perm " . "FROM {$wpdb->cp_ad_fields} " . "WHERE field_id = '" . $_GET['id'] . "' LIMIT 1";
            $results = $wpdb->get_row($sql);
            // if it's not greater than zero, then delete it
            if (!$results->field_perm > 0) {
                $delete = "DELETE FROM {$wpdb->cp_ad_fields} WHERE field_id = '" . $_GET['id'] . "'";
                $wpdb->query($delete);
            }
            ?>
        <p style="text-align:center;padding-top:50px;font-size:22px;"><?php 
            _e('Deleting custom field.....', 'appthemes');
            ?>
<br /><br /><img src="<?php 
            echo bloginfo('template_directory');
            ?>
/images/loader.gif" alt="" /></p>
        <meta http-equiv="refresh" content="0; URL=?page=fields">

    <?php 
            break;
            // cp_custom_fields() show the table of all custom fields
        // cp_custom_fields() show the table of all custom fields
        default:
            $sql = "SELECT field_id, field_name, field_label, field_desc, field_tooltip, field_type, field_perm, field_owner, field_modified " . "FROM {$wpdb->cp_ad_fields} " . "ORDER BY field_name desc";
            $results = $wpdb->get_results($sql);
            ?>

        <div class="wrap">
        <div class="icon32" id="icon-tools"><br /></div>
        <h2>Genel Alanlar&nbsp;<a class="button add-new-h2" href="?page=fields&amp;action=addfield">Yeni Alan Ekle</a></h2>

        <?php 
            cp_admin_info_box();
            ?>

        <p class="admin-msg"><?php 
            _e('Genel Alanlar Erisim Engeli Formlarinda kullanicilarin doldurduklari Erisim Engellerine bagli alanlari olusturmaktadir. Asagidaki tabloda tum Erisim Engeli Alanlari listelenmektedir. Yeni bir alan ekleyebilir ve var olan alanlari degistirebilirsiniz.', 'appthemes');
            ?>
</p>

        <table id="tblspacer" class="widefat fixed">

            <thead>
                <tr>
                    <th scope="col" style="width:35px;">&nbsp;</th>
                    <th scope="col"><?php 
            _e('Alan Ismi', 'appthemes');
            ?>
</th>
                    <th scope="col" style="width:100px;"><?php 
            _e('Alan Tipi', 'appthemes');
            ?>
</th>
                    <th scope="col"><?php 
            _e('Alan Aciklamasi', 'appthemes');
            ?>
</th>
                    <th scope="col" style="width:150px;"><?php 
            _e('Degistiren', 'appthemes');
            ?>
</th>
                    <th scope="col" style="text-align:center;width:100px;"><?php 
            _e('Aksiyonlar', 'appthemes');
            ?>
</th>
                </tr>
            </thead>

            <?php 
            if ($results) {
                ?>

                <tbody id="list">

                  <?php 
                $rowclass = '';
                $i = 1;
                foreach ($results as $result) {
                    $rowclass = 'even' == $rowclass ? 'alt' : 'even';
                    ?>

                    <tr class="<?php 
                    echo $rowclass;
                    ?>
">
                        <td style="padding-left:10px;"><?php 
                    echo $i;
                    ?>
.</td>
                        <td><a href="?page=fields&amp;action=editfield&amp;id=<?php 
                    echo $result->field_id;
                    ?>
"><strong><?php 
                    echo esc_html(translate($result->field_label, 'appthemes'));
                    ?>
</strong></a></td>
                        <td><?php 
                    echo $result->field_type;
                    ?>
</td>
                        <td><?php 
                    echo esc_html(translate($result->field_desc, 'appthemes'));
                    ?>
</td>
                        <td><?php 
                    echo mysql2date(get_option('date_format') . ' ' . get_option('time_format'), $result->field_modified);
                    ?>
 <?php 
                    _e('by', 'appthemes');
                    ?>
 <?php 
                    echo $result->field_owner;
                    ?>
</td>
                        <td style="text-align:center">

                            <?php 
                    // show the correct edit options based on perms
                    switch ($result->field_perm) {
                        case '1':
                            // core fields no editing
                            ?>

                                    <a href="?page=fields&amp;action=editfield&amp;id=<?php 
                            echo $result->field_id;
                            ?>
"><img src="<?php 
                            echo bloginfo('template_directory');
                            ?>
/images/edit.png" alt="" /></a>&nbsp;&nbsp;&nbsp;
                                    <img src="<?php 
                            echo bloginfo('template_directory');
                            ?>
/images/cross-grey.png" alt="" />

                                <?php 
                            break;
                        case '2':
                            // core fields some editing
                            ?>

                                    <a href="?page=fields&amp;action=editfield&amp;id=<?php 
                            echo $result->field_id;
                            ?>
"><img src="<?php 
                            echo bloginfo('template_directory');
                            ?>
/images/edit.png" alt="" /></a>&nbsp;&nbsp;&nbsp;
                                    <img src="<?php 
                            echo bloginfo('template_directory');
                            ?>
/images/cross-grey.png" alt="" />

                                <?php 
                            break;
                        default:
                            // regular fields full editing
                            // don't change these two lines to plain html/php. Get t_else error msg
                            echo '<a href="?page=fields&amp;action=editfield&amp;id=' . $result->field_id . '"><img src="' . get_bloginfo('template_directory') . '/images/edit.png" alt="" /></a>&nbsp;&nbsp;&nbsp;';
                            echo '<a onclick="return confirmBeforeDelete();" href="?page=fields&amp;action=delete&amp;id=' . $result->field_id . '"><img src="' . get_bloginfo('template_directory') . '/images/cross.png" alt="" /></a>';
                    }
                    // endswitch
                    ?>

                        </td>
                    </tr>

                <?php 
                    $i++;
                }
                //end foreach;
                //} // mystery bracket which makes it work
                ?>

              </tbody>

            <?php 
            } else {
                ?>

                <tr>
                    <td colspan="5"><?php 
                _e('No custom fields found. This usually means your install script did not run correctly. Go back and try reactivating the theme again.', 'appthemes');
                ?>
</td>
                </tr>

            <?php 
            }
            // end $results
            ?>

        </table>

        </div><!-- end wrap -->

    <?php 
    }
    // endswitch
    ?>



    <script type="text/javascript">
        /* <![CDATA[ */
            function confirmBeforeDelete() { return confirm("<?php 
    _e('WARNING: Deleting this field will prevent any existing ads currently using this field from displaying the field value. Deleting fields is NOT recommended unless you do not have any existing ads using this field. Are you sure you want to delete this field?? (This cannot be undone)', 'appthemes');
    ?>
"); }
        /* ]]> */
    </script>

<?php 
}