Forum Replies Created
-
AuthorPosts
-
egnsh98MemberStill having some trouble, OOP is still new to me. I am trying to call a Class method from outside my main plugin class. My
get_user()call works fine inside of my “Main” class, but when trying to call it from outside,NULLis returned. Here is what I have done so far, I have included only the code I thought was relevant to the problem and have put comments where necessary.<?php class Main { protected $user = null; public function __construct() { // Init and admin init action hooks } public function init() { // Check for piklist plugin // Enqeue admin styles and scripts // Action hook on authenticate function } public function authenticate() { $this->set_user( "John Smith" ); } public function set_user( $new_user ) { $this->user = $new_user; } public function get_user() { return $this->user; } } /* ------------------------------------------------ * Code from /parts/settings/twitter.php * ------------------------------------------------*/ $instance = Main::get_instance(); $user = $instance->get_user(); var_dump ( $user ); // Hidden field gets the username and registers it as a setting in the database piklist('field', array( 'type' => 'hidden' ,'field' => 'user_name' ,'value' => $user )); ?>
egnsh98MemberThank you that seemed to do the trick! How would I go about passing data from my main class, to a PHP file within /parts/. It is not in the same class so I can’t use “$this” and I don’t to use super globals.
-
AuthorPosts