Month: June 2021

  • LearnPress Lesson Template Changes : Part 2

    LearnPress Lesson Template Changes : Part 2

    This is the new and updated version of my article here: LearnPress Lesson Template Changes

    I got to admit, it is quite simpler in terms of files than before.
    Turns out it is now possible to edit with only CSS and make our Header and Footer show in current implementation of LearnPress plugin.

    WordPress Version : 5.7.2
    Theme Twenty Twenty-One : 1.3
    LearnPress Version : 4.0.7

    Quick Start

    Here, is the fast answer you need and keep on moving.

    /*Learn Press Lesson Template Design Changes*/
    html {
        overflow: visible !important;
    }
    
    #popup-course {
        position: relative !important;
        flex-wrap: wrap;
    }
    
    #popup-course > div {
        position: relative;
        flex-basis: 100%;
    }
    
    #popup-course #popup-header {
        position: absolute !important;
    }
    
    #popup-course #popup-content {
        flex-basis: calc(100% - 475px) !important;
    }
    
    #popup-course #popup-footer {
        position: absolute !important;
    }

    Contain the width

    Now if the lesson content area is full width, and you want it contained, like the header and footer, we need to do more. Not necessarily important, but could be helpful to someone.

    Lets contain the main section

    main#main {
        max-width: var(--responsive--alignwide-width); // this is the max-width you want your container to be e.g.1170px
        margin: 0 auto;
        border: 1px solid;
    }
    

    Lets make the curriculum sidebar smaller around 300px.

    #popup-course #popup-sidebar {
        flex: 0 0 300px !important;
    }
    #popup-course #popup-sidebar .course-curriculum {
        width: 300px !important;
    }
    

    After that compensate the “300px” width to lesson’s header, footer, toggle collapse arrow

    #popup-course #popup-header,
    #popup-course #popup-footer,
    #popup-course #sidebar-toggle {
        left: 300px !important;
    }
    

    And finally adjust toggled case

    body.lp-sidebar-toggle__close #popup-course #popup-sidebar {
        flex: 0 0 0 !important;
    }
    
    body.lp-sidebar-toggle__close #popup-course>#sidebar-toggle,
    body.lp-sidebar-toggle__close #popup-course #popup-header,
    body.lp-sidebar-toggle__close #popup-course #popup-footer {
        left: 0 !important;
    }
    

    P.S. For responsive, you’re on your own. 🙂

  • Yith WooCommerce Subscriptions : List all the active subscribers

    Yith WooCommerce Subscriptions : List all the active subscribers

    In order to do a custom listing of active subscriptions in Yith WooCommerce Subscription plugin, here is the code you can write:
    Assuming your WordPress database table prefix is the default: “wp_”

    
    function list_all_subscriptions() {
    
    	global $wpdb;
    
    	$query= "";
    	$query .= "SELECT wp_posts.* FROM wp_posts ";
    	$query .= "INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) ";
    	$query .= "WHERE 1=1 ";
    	$query .= "AND wp_posts.post_type = 'ywsbs_subscription' ";
    	$query .= "GROUP BY wp_posts.ID ";
    	$query .= "ORDER BY ID DESC";
    
    	$subscribers = $wpdb->get_results( $query );
    }
    

    Hell, if you want to move one step further and list only active members, then you can throw “AND” condition in the query itself, like below;

    
    function list_all_subscriptions() {
    
    	global $wpdb;
    
    	$query= "";
    	$query .= "SELECT wp_posts.* FROM wp_posts ";
    	$query .= "INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) ";
    	$query .= "WHERE 1=1 ";
    	$query .= "AND wp_posts.post_type = 'ywsbs_subscription' ";
    	$query .= "AND ( wp_postmeta.meta_key = 'status' AND wp_postmeta.meta_value = 'active' ) "; 
            // will filters only active members
    	$query .= "GROUP BY wp_posts.ID ";
    	$query .= "ORDER BY ID DESC";
    
    	$subscribers = $wpdb->get_results( $query );
    }
    

    You can do the pagination as well now.

    Final Note: There is a file /plugins/yith-woocommerce-subscription/includes/admin/class.ywsbs-subscriptions-list-table.php, look or find the function prepare_items() , this is where I derived above query from.