Support » Plugin: LearnPress - WordPress LMS Plugin » Does not follow WP template hierarchy

  • This big plugin and does not even follow WordPress template hierarchy. All contents are displayed using page.php template. What???

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Ken Nguyen

    (@kendy73)

    Hi Nilambar Sharma,

    I think there is a misunderstanding here. All those LearnPress templates are located in folder /learnpress/templates/. Almost plugins do the same (WooCommerce, bbPress, BuddyPress…).

    I am pretty sure that the issue came out from your current WordPress time, somehow (a conflict maybe) it process LearnPress templates via page.php.

    I really hope you can continue the discussion so we can find a solution for that.

    Regards,

    Ken

    I dont think there is misunderstanding. Like you said yourself, using page.php for rendering everything is the biggest flaw. This means single-*.php and archive-*.php does not work. And also is_single() and is_tax() does not work as expected.
    Yes, plugin provides template overriding but it should not hijack the template hierarchy.

    Plugin Author Ken Nguyen

    (@kendy73)

    Hi Nilambar,

    I didn’t fully get your point before.

    Those LP templates didn’t use page.php.

    And single-*.php and archive-*.php still working fine.

    Can you please check again?

    Regards,

    Ken

    Inside code it hacks default wp_query objects and modify things like this $wp_query->is_category=false directly, it’s wrong in so many ways. You never ever should change the value of $wp_query->is_category, it should be controlled by WordPress itself. It conflicts with other Breadcrumb plugins. Here’s the whole code from LearnPress plugin:

    if ( is_post_type_archive( LP_COURSE_CPT ) || LEARNPRESS_IS_CATEGORY ) {
    	$wp_query->is_page    = false;
    	$wp_query->is_archive = true;
    	// Fixed issue with Yoast Seo plugin
    	$wp_query->is_category = learn_press_is_course_category();
    	$wp_query->is_tax      = learn_press_is_course_tax();
    	$wp_query->is_single   = false;
    } else {
    	$wp_query->found_posts          = 1;
    	$wp_query->is_single            = true;
    	$wp_query->is_preview           = false;
    	$wp_query->is_archive           = false;
    	$wp_query->is_date              = false;
    	$wp_query->is_year              = false;
    	$wp_query->is_month             = false;
    	$wp_query->is_day               = false;
    	$wp_query->is_time              = false;
    	$wp_query->is_author            = false;
    	$wp_query->is_category          = false;
    	$wp_query->is_tag               = false;
    	$wp_query->is_tax               = false;
    	$wp_query->is_search            = false;
    	$wp_query->is_feed              = false;
    	$wp_query->is_comment_feed      = false;
    	$wp_query->is_trackback         = false;
    	$wp_query->is_home              = false;
    	$wp_query->is_404               = false;
    	$wp_query->is_comments_popup    = false;
    	$wp_query->is_paged             = false;
    	$wp_query->is_admin             = false;
    	$wp_query->is_attachment        = false;
    	$wp_query->is_singular          = false;
    	$wp_query->is_posts_page        = false;
    	$wp_query->is_post_type_archive = false;
    }

    Hope you fix this

    Plugin Author Ken Nguyen

    (@kendy73)

    Hi Md Kowsar Hossain,

    Thanks you for your feedback. We will improve this in a next update.

    Regards,

    Ken

    Hi Ken,

    A few more things:

    1. In javascript file there’s $(document).ready inside of another $(document).ready, this is another weird thing which I’ve never seen before. Here’s from LearnPress code:

    $(document).ready(function () {
        $(document).ready(function () {
            new LP_Course({});
    
            $(this).on('submit', 'form[name="course-external-link"]', function () {
                var redirect = $(this).attr('action');
                if (redirect) {
                    window.location.href = redirect;
                    return false;
                }
            })
        });
    });

    2. It sort of true that it follows weird template hierarchy structure, for example Single Lesson page is generated on top of single Course page using absolute positioning and higher z-index value(that way single course is invisible and single lesson is visible), while it could be a separate template. It should be restructured in next big release(maybe on v4.0)

    Plugin Author Ken Nguyen

    (@kendy73)

    Hi Md Kowsar Hossain,

    I let the team know and we will make those necessary updates.

    Thank you.

    Regards,

    Ken

    Another bug that occurred after the recent updates.

    It bloats the options table by creating a lot extra rows(50000+ in my website!). As a result my wp_options table size becomes 35+ MB!

    Here’s a screenshot: http://prntscr.com/j49fsr

    I guess many other users don’t even know about this issue since there’s no way to find it out unless you look into the database. I’m optimizing the database now and it becomes a nightmare. You should work on that too as priority basis.

    2. It sort of true that it follows weird template hierarchy structure, for example Single Lesson page is generated on top of single Course page using absolute positioning and higher z-index value(that way single course is invisible and single lesson is visible), while it could be a separate template. It should be restructured in next big release(maybe on v4.0)

    @kendy73, the template based on z-index is also making some issue when viewing on Safari, as reported here.
    I agree with @kowsar89 that will be better to load everything on a separate template

    • This reply was modified 6 months, 2 weeks ago by  fabio.grasso.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Does not follow WP template hierarchy’ is closed to new replies.