Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
"choctawnationofoklahoma",
"classmap",
"cpts",
"kses",
"Linktree",
"macrosbysara",
"pmpro",
"remoteip",
"trackbacks",
"wght",
"wpcf"
"wpcf",
"wpdb"
],
"css.format.spaceAroundSelectorSeparator": true,
"editor.codeActionsOnSave": {
Expand Down
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
wp_die( 'Autoloader not found. Please run composer install.' );
}
$theme = new Theme_Init();
add_action( 'after_setup_theme', array( $theme, 'bootstrap_theme' ) );
add_action( 'after_setup_theme', array( $theme, 'bootstrap_theme' ) );
34 changes: 31 additions & 3 deletions inc/plugins/class-pmpro-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace MacrosBySara\Plugins;

use stdClass;
use WP_Query;

/**
Expand All @@ -30,12 +31,12 @@ class PMPro_Handler {
/**
* Constructor
*
* @param int[] $consistency_club_levels An array of PMPro membership levels that grant access to the content.
* @param string $cc_post_type_slug The slug of the custom post type to lock
* @param int[] $consistency_club_levels An array of PMPro membership levels that grant access to the content.
*/
public function __construct( array $consistency_club_levels = array(), string $cc_post_type_slug ) {
$this->consistency_club_levels = array_map( 'strval', $consistency_club_levels );
public function __construct( string $cc_post_type_slug, array $consistency_club_levels = array() ) {
$this->cc_post_type_slug = $cc_post_type_slug;
$this->consistency_club_levels = array_map( 'strval', $consistency_club_levels );
}

/**
Expand Down Expand Up @@ -106,4 +107,31 @@ public function lock_down_queries( WP_Query $query ): void {
}
}
}

/**
* Edit visible member action links to prevent cancellation for certain levels.
*
* @param array $links The original action links.
* @param string $level The membership level ID.
*/
public function edit_membership_action_links( array $links, $level ): array {
$one_time_payment_levels = array( '3', '5' );
if ( in_array( $level, $one_time_payment_levels, true ) ) {
if ( isset( $links['renew'] ) ) {
unset( $links['renew'] );
}
}
$user_id = get_current_user_id();
if ( empty( $user_id ) ) {
return $links;
}
// if ( mbs_user_can_cancel( $user_id ) ) {
// return $links;
// }
$links['commitment'] = '<span>You signed a 3-month contract. If you need to cancel, you can discuss this with us directly.</span>';
if ( isset( $links['cancel'] ) ) {
unset( $links['cancel'] );
}
return $links;
}
}
3 changes: 2 additions & 1 deletion inc/theme/class-plugin-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ private function handle_pmpro() {
return;
}
$consistency_club_levels = array( 2, 3, 4, 5 ); // Define your PMPro membership levels here
$pmpro_handler = new PMPro_Handler( $consistency_club_levels, 'cc-post' );
$pmpro_handler = new PMPro_Handler( 'cc-post', $consistency_club_levels );
$pmpro_handler->lock_down_cpt();
add_filter( 'pmpro_member_action_links', array( $pmpro_handler, 'edit_membership_action_links' ), 10, 2 );
}
}
2 changes: 1 addition & 1 deletion inc/theme/navwalkers/class-navwalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,4 @@ protected function get_the_attributes(): string {
$attributes['class'] .= ' nav-link';
return $this->build_atts( $attributes );
}
}
}
Loading
Loading