Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Best way to wrap "get_component()"
#1
Information 
Hello all,

In my theme i must to define if get_component('component-xyz') return null value.
I implement this function. 

PHP Code:
/**
 * This return get_component() function in a string
 *
 * @param string $id - ID of the component
 * @return string
 */
function return_get_component($id)
{
    
ob_start();
    
get_component($id);
    
$html ob_get_clean();

    return 
$html;


In this mode i can check if component return empty value (simply using "if" statement).

Do you resolve this problem in other way?
Reply
#2
(2017-08-30, 01:11:42)tempUser Wrote: Do you resolve this problem in other way?

If your method works for you, then use it!

It is possible to test for existence of a component, for example see this wiki page, but your solution seems elegant.
--
Nick.
Reply




Users browsing this thread: 1 Guest(s)