Skip to content

Commit

Permalink
Merge pull request #3070 from kimcoleman/body-class-style-chosen
Browse files Browse the repository at this point in the history
Now adding the chosen style variation to the <body> tag so themes and child themes can target based on which variation is chosen
  • Loading branch information
dparker1005 authored Jul 17, 2024
2 parents 545ef79 + 53bba49 commit a432a5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion adminpages/designsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
</div>
<div id="pmpro_style_variation_item-high-contrast" class="pmpro_style_variation_item">
<label for="style_high_contrast">
<input name="style_variation" id="style_high_contrast" type="radio" value="high_contrast" class="tog" <?php checked( 'high_contrast', $pmpro_style_variation ); ?>>
<input name="style_variation" id="style_high_contrast" type="radio" value="variation_high_contrast" class="tog" <?php checked( 'variation_high_contrast', $pmpro_style_variation ); ?>>
<span class="pmpro_style_variation_item-name"><?php esc_html_e( 'High Contrast', 'paid-memberships-pro' ); ?></span>
<?php pmpro_style_variation_item_preview_html(); ?>
<p class="description"><?php esc_html_e( 'Crisp borders and high contrast colors.', 'paid-memberships-pro' ); ?></p>
Expand Down
File renamed without changes.
23 changes: 15 additions & 8 deletions includes/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,26 @@ function pmpro_print_root_color_values() {
}
add_action( 'wp_head', 'pmpro_print_root_color_values' );

/*
Add PMPro page names to the BODY class.
*/
function pmpro_body_class($classes)
{
/**
* Add PMPro CSS selectors to the BODY class.
*
* @param array $classes An array of body classes.
*/
function pmpro_body_class( $classes ) {
global $pmpro_body_classes;

if(is_array($pmpro_body_classes))
$classes = array_merge($pmpro_body_classes, $classes);
// Add PMPro classes based on the site's selected style variation.
$pmpro_style_variation = get_option( 'pmpro_style_variation', 'variation_1' );
! empty( $pmpro_style_variation ) ? array_unshift( $classes, 'pmpro-' . esc_attr( $pmpro_style_variation ) ) : '';

// Add PMPro classes based on the current page.
if ( is_array($pmpro_body_classes ) ) {
$classes = array_merge( $pmpro_body_classes, $classes );
}

return $classes;
}
add_filter("body_class", "pmpro_body_class");
add_filter( 'body_class', 'pmpro_body_class' );

//add membership level to current user object
function pmpro_set_current_user()
Expand Down

0 comments on commit a432a5b

Please sign in to comment.