Support » Plugin: Simple Membership Menu » Plugin works great once fixed

  • Once I replace add_swpm_fields with:

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    function add_swpm_fields( $id, $item, $depth, $args ) {
    
                    //// Logged levels
                    $levels = $this->get_membership_levels();
    
                    $item_groups = get_post_meta( $item->ID, self::META_KEY_NAME, true );
    
                    ?>
                        <p class="description description-wide menu-item-actions">
                            Membership groups permitted :
                            <?php foreach($levels as $level)
                            {
                                $key = self::META_KEY_NAME.'-'.$level->id;
                                $name  = sprintf( '%s[%s]', $key, $item->ID );
    			    // Handle the case where there is no array because it is a new menu item that has been added.
    			    // In this case checkall of the member levels since it is more likely to be included than not.
    			    if ( is_array( $item_groups ) ) {
    				$checked = in_array($level->id, $item_groups) || (count($item_groups) == 0 && $level->id == self::NOT_LOGGED_IN_LEVEL_ID) ? "checked" : "";
    			    } else {
    				$checked = "checked";
                                }
    
    			    // If the class menu-item-title is used then this is perceived to be a menu item that can be moved and will cause the
    			    // Under link to include all of the member leves. Not good.
                                ?>
                                <label class="swpm-menu-item-title" style="padding-top:8px;padding-bottom:8px;">
                                   <?php printf(
                                     '<input type="checkbox" class="menu-item-checkbox" name="%3$s" value="%1$s" %4$s> %2$s',
                                     $level->id,
                                     $level->alias,
                                     $name,
                                     $checked); ?>
                                </label>
                            <?php } ?>
                        </p>
                    <?php
                }

    it works well.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this review.