Add delete button to the dashboard with alert window
Hi everyone!
Note : Before editing the file make sure you have a duplicate
First is first, I recommend using a child theme
part 1 and
part 2 tutorials, so you well not lose you changes.
1. If you are using a child theme copy ( tpl-dashboard.php ) file from parent theme ( classipress ) to child theme (classipress-child) as showing in the image blow
If not just open ( tpl-dashboard.php ) file in your favorite code editor.
copy-dashboard.jpg
3. We have 2 pates of code to inserted
1 -
First part - Build button elements ( text button, action when button clicked, etc ... )
Code:
//building delete button elements
$deltext ='Delete Ad';// Button text
$delaction = 'trash';// Button action, in this case we want to delete ad listing
// when the button clicked window pops up showing message confirmation
$delonclick ='javascript:if(!confirm(\'Are you sure you want to delete this ad ?\')) return false;';
Insert the code above, at
line 147 blow code
Code:
$postaction = 'pause';
code-part-1.jpg
2 -
Second part - Inserting the actual button
Insert the code blow at
line 258
code-part-2.jpg
Code:
//delete button
<a href="<?php echo CP_DASHBOARD_URL; ?>?aid=<?php the_id(); ?>&action=<?php echo $delaction; ?>" onclick="<?php echo $delonclick; ?>" ><?php echo $deltext; ?></a>
The result should be like this
Delete Button
delet-button.jpg
Window alert
ad-deletion-alert.jpg