WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Does this php include look ok?

[Resolved] Does this php include look ok?

  • I would like to add a dashboard widget and need to include/ require (whatever is better) a php file from my root. I combined a couple of things together that I found on different websites and it works, but I don’t know php very well so just checking to see if there is a better way to write it especially if it causes problems with security/performance.

    function andym_dashboard_widget_1() {
    	wp_add_dashboard_widget(
                     'andym_dashboard_app_widget',         // Widget slug.
                     'Test Widget',                               // Title.
                     'andym_dashboard_widget_1_function'   // Display function.
        );
    }
    add_action( 'wp_dashboard_setup', 'andym_dashboard_widget_1' );
    function andym_dashboard_widget_1_function() {
     $path = $_SERVER['DOCUMENT_ROOT'];
       $path .= "/myfolder/myfile.php";
       include_once($path);
    }

    Thanks in advance

  • The topic ‘[Resolved] Does this php include look ok?’ is closed to new replies.