• Resolved dameer.dj

    (@dameerdj)


    Hi,
    so far I have had something like this in my custom Pods Template:

    {@ID,kka_get_pods}

    …which worked just fine. “kka_get_pods” is the function in my theme’s “functions.php” and returns a chunk of HTML.

    However, I had to move “kka_get_pods” function to the plugin due to the fact that certain things belong to plugin territory. Anyhow…

    The question is: how do I call/access my function that is now part of the plugin?

    I’ve tried:

    {@ID,My_Plugin::kka_get_pods}

    …but it doesn’t seem to work.

    My function is public and declared inside the class. Somewhat standard thing.

    class My_Plugin {
    
    	private static $instance;
    	
    	public static function get_instance() {
    		
    		if( ! self::$instance ) {
    			
    			self::$instance = new self();
    			self::$instance->init();
    			
    		}
    		
    		return self::$instance;
    		
    	}
    	
    	public function init() {
    
    		// nothing to init yet
    		
    	}
    
    	public function kka_get_pods() {
    		
    		// code
    
    	}
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @dameerdj ,

    My_Plugin::kka_get_pods is a static call so you need to declare your function as static: public static function kka_get_pods().
    I’m actually uncertain whether this will work at all but since static calls work relatively similar to regular functions I think it might!

    Regards, Jory

    Thread Starter dameer.dj

    (@dameerdj)

    Forgot to mention that I already tried to declare it as a static function and it didn’t work as well.

    Is there any workaround to the problem? I mean, you are Pods developer, there must be something.

    Thanks for any hint in advance!

    Plugin Author Jory Hogeveen

    (@keraweb)

    I found a bottleneck in the code. It validates through function_exists and in your case it’s not a function.

    A workaround for now is to create a function within your plugin that calls the class method.

    I’ve made a PR on GitHub to discuss this topic with a possible solution.
    https://github.com/pods-framework/pods/pull/5437

    I’ll close this topic here in favor of GitHub. Thanks for your report!

    Cheers, Jory

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    We’ve merged this PR into our next maintenance release going out this month. Thanks for your understanding here @dameerdj

    Thread Starter dameer.dj

    (@dameerdj)

    That’s awesome, thanks a lot guys!!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Pods Template function callback’ is closed to new replies.