Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documenting some hooks inline #54

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions adminpages/affiliates.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@
</tbody>
</table>

<?php do_action("pmpro_affiliate_after_settings"); ?>
<?php
/**
* Action to add additional fields to the affiliate edit form.
*/
do_action("pmpro_affiliate_after_settings");
?>

<p class="submit topborder">
<input name="edit" type="hidden" value="<?php if(!empty($edit)) echo esc_attr( $edit ); ?>" />
Expand Down Expand Up @@ -381,7 +386,12 @@
<th><?php esc_html_e( 'Conversion %', 'pmpro-affiliates' ); ?></th>
<th><?php esc_html_e( 'Commission Earned', 'pmpro-affiliate' ); ?></th>
<th><?php esc_html_e( 'Revenue Contributed', 'pmpro-affiliates' ); ?></th>
<?php do_action( "pmpro_affiliate_extra_cols_header" ); ?>
<?php
/**
* Action to add additional columns to the affiliates table.
*/
do_action( "pmpro_affiliate_extra_cols_header" );
?>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -463,7 +473,15 @@
<td>
<?php echo pmpro_formatPrice( $earnings ); ?>
</td>
<?php do_action( "pmpro_affiliate_extra_cols_body", $affiliate, $earnings ); ?>
<?php
/**
* Action to populate additional columns in the affiliates table.
*
* @param object $affiliate The affiliate object
* @param float $earnings The earnings for the affiliate
*/
do_action( "pmpro_affiliate_extra_cols_body", $affiliate, $earnings );
?>
</tr>
<?php } ?>
</tbody>
Expand Down
15 changes: 15 additions & 0 deletions adminpages/report-csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
'total',
);

/**
* Filter the headings for the CSV export.
*
* @param array $headings The headings for the CSV export.
*
* @return array The modified headings.
*/
$headings = apply_filters( 'pmpro_affiliate_list_csv_extra_columns', $headings ); // Add to the string.

echo implode( ',', $headings ) . "\n";
Expand All @@ -84,6 +91,14 @@
pmpro_enclose( $order->total ),
);

/**
* Filter the data for the CSV export.
*
* @param array $pmpro_affiliate_report_data The data for the CSV export.
* @param object $order The order object.
* @param object $level The membership level object.
* @return array The modified data.
*/
$pmpro_affiliate_report_data = apply_filters( 'pmpro_affiliate_list_csv_extra_column_data', $pmpro_affiliate_report_data, $order, $level );

echo implode( ',', $pmpro_affiliate_report_data ) . "\n";
Expand Down
16 changes: 14 additions & 2 deletions adminpages/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@
<th><?php esc_html_e( 'Commission Earned', 'pmpro-affiliates' ); ?></th>
<th><?php esc_html_e( 'Order Total', 'pmpro-affiliates' ); ?></th>
<th><?php esc_html_e( 'Status', 'pmpro-affiliates' ); ?></th>
<?php do_action( "pmpro_affiliate_report_extra_cols_header" ); ?>
<?php
/**
* Action to add additional columns to the affiliates report table.
*/
do_action( "pmpro_affiliate_report_extra_cols_header" );
?>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -156,7 +161,14 @@
<td><?php echo pmpro_formatPrice( $order->total * $order->commissionrate ); ?></td>
<td><?php echo pmpro_formatPrice( $order->total ); ?></td>
<td><?php echo '<span class="pmpro_affiliate_paid_status" id="order_' . esc_attr( $order->order_id ) . '">' . $affiliate_paid . '</span>'; // We escape the $affiliate_paid before outputting further up.?></td>
<?php do_action( "pmpro_affiliate_report_extra_cols_body", $order ); ?>
<?php
/**
* Action to populate additional columns in the affiliates report table.
*
* @param object $order The order object.
*/
do_action( "pmpro_affiliate_report_extra_cols_body", $order );
?>
</tr>
<?php
}
Expand Down
8 changes: 8 additions & 0 deletions pmpro-affiliates.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ function pmpro_affiliates_generate_affiliate_after_checkout( $user_id, $morder )
$pmpro_create_affiliate_level = get_option( 'pmpro_create_affiliate_level_' . $pmpro_level->id );
$code = pmpro_affiliates_getNewCode();
if ( ! empty( $pmpro_create_affiliate_level ) ) {
/**
* Filter the number of days to set the cookie for the affiliate.
*
* @param int $days The number of days to set the cookie for the affiliate.
* @param int $user_id The user ID.
* @param object $pmpro_level The membership level object.
* @return int The number of days to set the cookie for the affiliate.
*/
$days = intval( apply_filters( 'pmproaf_default_cookie_duration', 30, $user_id, $pmpro_level ) );
$sqlQuery = "INSERT INTO $wpdb->pmpro_affiliates (code, name, affiliateuser, trackingcode, cookiedays, enabled) VALUES('" . esc_sql( $code ) . "', '" . esc_sql( $user->display_name ) . "', '" . esc_sql( $user->user_login ) . "', '', $days, '1')";
$wpdb->query( $sqlQuery );
Expand Down