Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter djhowden

    (@djhowden)

    you beautiful people 🙂 thank you thank you lol I would have stared at the screen all day if it were not for that 🙂 makes sense too when I think about it. Thanks

    Thread Starter djhowden

    (@djhowden)

    path or url? sorry I missed that. Im not sure which one? I thought it was ok but if the url is a http request it can be outside wordpress and so… outside scope hmmm will test tomorrow and let you know

    Thread Starter djhowden

    (@djhowden)

    OK I managed to get both working (class and procedural) and both same result WP not declared and yet the page appears. Maybe last resort… reboot lol not laughing but sniggering. I have reinstalled etc and running out of options other than do I need the option page? lol get away

    Thread Starter djhowden

    (@djhowden)

    Hi 🙂 yes I want the url for the file to include into the admin page, which works and the page does indeed load and I can write HTML and PHP and it still works, however when I want to use a core function of wordpress the functions are not defined which means my page has lost scope (i think thats what you say)

    I got on with some other stuff but am planning to run it outside the class I’m using (Loader) but like I say the code works and the page appears and will print HTML and work with PHP but not wordpress lol not really laughing

    Thread Starter djhowden

    (@djhowden)

    me too which is why I’m baffled 🙂 I’ll take it out of the class and load it procedural and see if it works.
    The bootstrap is a simple set of classes to organise code for plugins in a professional way. It took me a couple of days to work it out but it’s fairly simple and logical and other than this page and sub menu pages (its the same for them too) it’s been a great way to build a plugin in an OOP way 🙂 thanks for your thoughts and help, maybe someone else has come across this and they can help. It’s not common so not WordPress

    hmmmmm it’s a head scratcher

    Thread Starter djhowden

    (@djhowden)

    I tried to edit it and lost the code lol here is my original message

    Thanks for that because it works so it must be my code.

    I’ve created the code in a class and am calling it from a class loader (I’m using Bootstrap Plugin)

    public function pwg_admin_page(){
    add_menu_page(
    __(‘PWG Admin’, ‘pwg’), //page title
    ‘PWG Options’, // menu title
    ‘manage_options’, //capabilities
    ‘pwg_admin’, //menu slug
    [$this , ‘pwg_show_admin_page’], //function
    ‘dashicons-filter’,
    ‘5.0’ //menu position
    );
    }

    which will call this

    public function pwg_show_admin_page(){
    include plugin_dir_url( __FILE__ ) . ‘partials/pwg-admin-display.php’;
    }

    and is added as an action from the loader class

    $this->loader->add_action( ‘admin_menu’, $plugin_admin, ‘pwg_admin_page’);

    and error is

    Fatal error: Call to undefined function bloginfo() in C:\xampp\htdocs\wordpress\wp-content\plugins\pwg\admin\partials\pwg-admin-display.php on line 20

    and the HTML on line 20 is

    <h1>General Settings</h1>
    <?php bloginfo(‘name’); ?>

    As I say the page will load without error with HTML and PHP but I have not got the WP class or I am out of it’s scope (not sure how you say it) so WordPress is processing it and Query Monitor says it was called within the admin_menu hook and reports no errors.

    It is baffling and is there something I have missed because I’m using classes?

    Thread Starter djhowden

    (@djhowden)

    Thank you 🙂 thats fixed it

    Totally Appreciated 🙂

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