Skip to content

Commit

Permalink
Use plugin relative path/url instead of hardcoded folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Apr 22, 2020
1 parent 5091072 commit 6e3bd58
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 244 deletions.
72 changes: 36 additions & 36 deletions admin/artists.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,76 @@
function gigpress_artists() {

global $wpdb;

if(isset($_POST['gpaction']) && $_POST['gpaction'] == "add") {
require_once('handlers.php');
$result = gigpress_add_artist();
$result = gigpress_add_artist();
}

if(isset($_POST['gpaction']) && $_POST['gpaction'] == "update") {
require_once('handlers.php');
$result = gigpress_update_artist();
}

if(isset($_GET['gpaction']) && $_GET['gpaction'] == "delete") {
require_once('handlers.php');
gigpress_delete_artist();
gigpress_delete_artist();
}

if(isset($_GET['gpaction']) && $_GET['gpaction'] == "import-tours") {
require_once('handlers.php');
gigpress_map_tours_to_artists();
gigpress_map_tours_to_artists();
}
$url_args = (isset($_GET['gp-page'])) ? '&gp-page=' . sanitize_text_field($_GET['gp-page']) : '';

$url_args = (isset($_GET['gp-page'])) ? '&gp-page=' . sanitize_text_field($_GET['gp-page']) : '';

?>

<div class="wrap gigpress gp-artists">

<h1><?php _e("Artists", "gigpress"); ?></h1>
<h1><?php _e("Artists", "gigpress"); ?></h1>

<?php
if(isset($_GET['gpaction']) && $_GET['gpaction'] == "edit" || isset($result) && isset($result['editing']) ) {

$artist_id = (isset($_REQUEST['artist_id'])) ? $wpdb->prepare('%d', $_REQUEST['artist_id']) : '';

$artist = $wpdb->get_row("SELECT artist_name, artist_url FROM ". GIGPRESS_ARTISTS ." WHERE artist_id = ". $artist_id);
if($artist) {

$submit = '<span class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __("Update artist", "gigpress") . '" /></span> ' . __("or", "gigpress") . ' <a href="' . admin_url('admin.php?page=gigpress-artists' . $url_args) . '">' . __("cancel", "gigpress") . '</a>'; ?>

<h3><?php _e("Edit this artist", "gigpress"); ?></h3>

<form method="post" action="<?php echo admin_url("admin.php?page=gigpress-artists" . $url_args); ?>">
<input type="hidden" name="gpaction" value="update" />
<input type="hidden" name="artist_id" value="<?php echo $artist_id; ?>" />

<?php
} else {
?>
<div id="message" class="error fade"><p><?php _e("Sorry, but we had trouble loading that artist for editing.", "gigpress"); ?></p></div>

<div id="message" class="error fade"><p><?php _e("Sorry, but we had trouble loading that artist for editing.", "gigpress"); ?></p></div>

<h3><?php _e("Add an artist", "gigpress"); ?></h3>
<?php

<?php
}

} else {

$artist = array();
$submit = '<span class="submit"><input type="submit" name="Submit" class="button-primary" value="' . __("Add artist", "gigpress") . '" /></span>'; ?>

<h2><?php _e("Add an artist", "gigpress"); ?></h2>

<form method="post" action="<?php echo admin_url('admin.php?page=gigpress-artists' . $url_args); ?>">
<input type="hidden" name="gpaction" value="add" />
<input type="hidden" name="gpaction" value="add" />

<?php
}
wp_nonce_field('gigpress-action') ?>

<table class="form-table gp-table">
<tr>
<th scope="row"><label for="artist_name"><?php _e("Artist name", "gigpress"); ?>:</label></th>
Expand All @@ -91,13 +91,13 @@ function gigpress_artists() {
<td>
<?php echo $submit; ?>
</td>
</tr>
</tr>
</table>

</form>

<h2><?php _e("All artists", "gigpress"); ?></h2>

<div class="tablenav">
<div class="alignleft"><p><?php _e("Note that you cannot delete an artist while they have shows in the database.", "gigpress"); ?></p></div>
<?php
Expand All @@ -114,7 +114,7 @@ function gigpress_artists() {
*/
?>
</div>

<table class="widefat">
<thead>
<tr>
Expand All @@ -129,10 +129,10 @@ function gigpress_artists() {
<?php

if($artists) {

$i = 0;
foreach($artists as $artist) {

if($n = $wpdb->get_var("SELECT count(*) FROM ". GIGPRESS_SHOWS ." WHERE show_artist_id = ". $artist->artist_id . " AND show_status != 'deleted'")) {
$count = '<a href="' . admin_url('admin.php?page=gigpress-shows&amp;artist_id=' . $artist->artist_id) . '">' . $n . '</a>';
} else {
Expand All @@ -144,7 +144,7 @@ function gigpress_artists() {
// Print out our rows.
?>
<tr<?php echo $style; ?> id="artist_<?php echo $artist->artist_id; ?>">
<td class="gp-tiny"><img src="<?php echo plugins_url('gigpress/images/sort.png'); ?>" alt="" class="gp-sort-handle" /></td>
<td class="gp-tiny"><img src="<?php echo esc_url( GIGPRESS_PLUGIN_URL . 'images/sort.png' ); ?>" alt="" class="gp-sort-handle" /></td>
<td class="gp-tiny"><?php echo $artist->artist_id; ?></td>
<td><?php if(!empty($artist->artist_url)) echo '<a href="'.esc_url($artist->artist_url).'">'; echo wptexturize($artist->artist_name); if(!empty($artist->artist_url)) echo '</a>';?></td>
<td class="gp-centre"><?php echo $count; ?></td>
Expand Down Expand Up @@ -177,8 +177,8 @@ function gigpress_artists() {
<?php // echo $pagination['output']; ?>
</div>
<?php endif; ?>
<div id="artist-sort-update"></div>

<div id="artist-sort-update"></div>

</div>
<?php }
Loading

0 comments on commit 6e3bd58

Please sign in to comment.