PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Code improvements: double title attribute, insert ID

  1. Just some tips / improvements... in version 1.2.3 of the PayPal Add-On:

    paypal.php on line 370:

    <span class="edit">
    <a title="<?php _e("Edit", "gravityformspaypal")?>" href="admin.php?page=gf_paypal&view=edit&id=<?php echo $setting["id"] ?>" title="<?php _e("Edit", "gravityformspaypal") ?>"><?php _e("Edit", "gravityformspaypal") ?></a>
    |
    </span>
    <a title="<?php _e("View Stats", "gravityformspaypal")?>" href="admin.php?page=gf_paypal&view=stats&id=<?php echo $setting["id"] ?>" title="<?php _e("View Stats", "gravityformspaypal") ?>"><?php _e("Stats", "gravityformspaypal") ?></a>
    |
    </span>
    <a title="<?php _e("View Entries", "gravityformspaypal")?>" href="admin.php?page=gf_entries&view=entries&id=<?php echo $setting["form_id"] ?>" title="<?php _e("View Entries", "gravityformspaypal") ?>"><?php _e("Entries", "gravityformspaypal") ?></a>
    |
    </span>
    <span class="edit">
    <a title="<?php _e("Delete", "gravityformspaypal") ?>" href="javascript: if(confirm('<?php _e("Delete this feed? ", "gravityformspaypal") ?> <?php _e("\'Cancel\' to stop, \'OK\' to delete.", "gravityformspaypal") ?>')){ DeleteSetting(<?php echo $setting["id"] ?>);}"><?php _e("Delete", "gravityformspaypal")?></a>
    </span>

    The "title" attribute is often specified twice. There is missing an opening "span" tag just before the "View Entries" link. I think the <span> element wrapped around the "Delete" link should be classifcied as "trash", and the <span> around the "View Entries" link as "view".

    data.php on line 169:

    $id = $wpdb->get_var("SELECT LAST_INSERT_ID()");

    Why don't you use the code:

    $id = $wpdb->insert_id;

    http://codex.wordpress.org/Function_Reference/wpdb_Class#INSERT_rows

    I guess these improvements also apply to other Add-Ons.

    Posted 13 years ago on Wednesday June 29, 2011 | Permalink