Last active
December 31, 2020 18:18
-
-
Save xnau/96d5b0a38ed9c78aeca74bd56426f7de to your computer and use it in GitHub Desktop.
Participants Database Default List Template with Edit Record Link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* template for participants list shortcode output with a record edit link | |
* | |
*/ | |
/* | |
* this is the name of the field that will hold the edit link | |
* | |
* you may need to change this if you are using a different field for the edit link | |
* | |
* make sure the "edit link" field is configured to show in the list | |
*/ | |
$link_field = 'edit_link'; | |
?> | |
<div class="wrap <?php echo $this->wrap_class ?>" id="<?php echo $this->list_anchor ?>"> | |
<?php | |
/* | |
* SEARCH/SORT FORM | |
* | |
* the search/sort form is only presented when enabled in the shortcode. | |
* | |
*/ | |
$this->show_search_sort_form(); | |
?> | |
<table class="wp-list-table widefat fixed pages list-container" > | |
<?php | |
// print the count if enabled in the shortcode | |
$this->print_list_count($wrap_tag = false); | |
?> | |
<?php if ( $record_count > 0 ) : // print only if there are records to show ?> | |
<thead> | |
<tr> | |
<?php $this->print_header_row( '<th class="%2$s" scope="col">%1$s</th>' ); ?> | |
</tr> | |
</thead> | |
<tbody> | |
<?php while ( $this->have_records() ) : $this->the_record(); // each record is one row ?> | |
<?php $record = new PDb_Template($this); ?> | |
<tr> | |
<?php while( $this->have_fields() ) : $this->the_field(); // each field is one cell ?> | |
<td class="<?php echo $this->field->name() ?>-field"> | |
<?php | |
/* | |
* put the edit link URL into the link property of the field | |
*/ | |
if ( $this->field->name() === $link_field ) { | |
$this->field->link = $record->get_edit_link(); | |
} | |
$this->field->print_value(); | |
?> | |
</td> | |
<?php endwhile; // each field ?> | |
</tr> | |
<?php endwhile; // each record ?> | |
</tbody> | |
<?php else : // if there are no records ?> | |
<tbody> | |
<tr> | |
<td><?php if ($this->is_search_result) echo Participants_Db::$plugin_options['no_records_message'] ?></td> | |
</tr> | |
</tbody> | |
<?php endif; // $record_count > 0 ?> | |
</table> | |
<?php | |
/* | |
* this shortcut function presents a pagination control with default layout | |
*/ | |
$this->show_pagination_control(); | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment