OK Full Code:
<?php
//check to see whether the user is an admin or not.
if (is_admin()) {
function wpsc_display_products_seo(){
global $wpdb;
$productList = $wpdb->get_results("SELECT * FROM " . WPSC_TABLE_PRODUCT_LIST . " ORDER BY name ASC");
echo get_admin_page_parent();
$path="admin.php?page=wpsc_product_seo_details";
$url = admin_url($path);
?>
<h2><?php _e('Products List','wpsc'); ?></h2>
<p>Below is a list of products. Select a product to edit it's SEO properties.</p>
<table>
<tr>
<td></td>
<td>Product Name</td>
<td>Meta Title</td>
<td>Meta Description</td>
<td>Edit</td>
</tr>
</table>
<table>
<?php if($productList) : ?>
<?php foreach($productList as $product) : ?>
<?php $meta = getProductMeta($product->id); ?>
<tr style="background:#fff;">
<td width="200"><?php echo $product->name; ?></td>
<td width="300"><?php getVal($meta, 'meta_title'); ?></td>
<td width="200"><?php getVal($meta, 'meta_description'); ?></td>
<td width="200"><?php getVal($meta, 'meta_keywords'); ?></td>
<td width="200"><a href="https://wordpress.stackexchange.com/questions/4677/<?php echo $url; ?>">Edit</a></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</table>
<?php
}
function wpsc_product_seo_details()
{
echo "<h2>Hello</h2>";
}
function getProductMeta($id)
{
global $wpdb;
$meta = $wpdb->get_results("SELECT * FROM " . WPSC_TABLE_PRODUCT_META . " WHERE product_id = $id");
if($meta)
{
return $meta;
} else {
return null;
}
}
function getVal($RS, $key)
{
if($RS)
{
if (property_exists($RS, $key))
{
return $RS->$key;
}
}
return null;
}
function wpsc_add_seo_admin_pages($page_hooks, $base_page) {
$page_hooks[] = add_submenu_page($base_page, __('SEO For Products','wpsc'), __('SEO For Products','wpsc'), 7, 'wpsc-module-seo', 'wpsc_display_products_seo');
return $page_hooks;
}
add_filter('wpsc_additional_pages', 'wpsc_add_seo_admin_pages',10, 2);
}
?>
OLD POST
Hi Guys,
I am currently writing a plugin for my client in wordpress. The issue I am having is when a user clicks on edit to change a record I am not sure how to create the admin link to do this.
i.e.
<a href="https://wordpress.stackexchange.com/questions/4677/<?php echo get_bloginfo("url'); ?>/wp-admin/admin.php?page=wpsc_product_seo_details">Edit</a>
function wpsc_product_seo_details()
{
echo "<h2>Hello</h2>";
}
I know my markup for the tag is probably wrong but I was just testing. Do I need to register a hook to do this.