• Resolved kskerp

    (@kskerp)


    I edited the code inside: namaste-lms/controllers/shortcodes.php

    It now displays lesson requirements for non-completed lessons inside a course page. It works great; however when I try to save the changes in a new php file and use the command require() I am having some problems.

    I am trying to save the changes in a separate php file (kevin-changes.php) which is being saved to:
    (NAMASTE_PATH. “/views/kevin-changes.php”)

    When I call require(NAMASTE_PATH.”/views/kevin-changes.php”) from inside “namaste-lms/controllers/shortcodes.php”

    The code executes like it should; however, there is code being displayed above the text on the course page. Does anyone know what causes this to occur? I am not sure if nested require() commands are causing the extraneous code to be displayed on the course page or what exactly.

    http://ww.wp.xz.cn/plugins/namaste-lms/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Bob

    (@prasunsen)

    Shortcodes shouldn’t output anything (which is essentially what require does). They should instead return contents.
    You can use something like the code below to solve this:

    ob_start();
    require(…..);
    $content = ob_get_contents();
    ob_end_clean();
    return $content;

    Also as you have done the customization right in the plugin instead of by using the API, you will lose it if you ever upgrade the plugin.

    Thread Starter kskerp

    (@kskerp)

    Thanks!! wrapping it with the output buffering is what I needed.

    As for losing it with when the plugin updates –

    Won’t the plugin self update when a new one is released?

    I am going to look at using the API. Is it difficult? I am new to wordpress and not sure exactly what can be done using what.

    Plugin Author Bob

    (@prasunsen)

    The plugin updates from the WP admin panel. It’s semi-automated, means that you will be notified when there is a new release and you’ll need to click a button to apply.
    If you do this, your customization will be lost.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem with require( );’ is closed to new replies.