| @@ 118-129 (lines=12) @@ | ||
| 115 | * @param mixed $context Data about the context in which the call is made. |
|
| 116 | * @return boolean Whether the shortcode is needed or not. |
|
| 117 | */ |
|
| 118 | protected function is_needed( $context = null ) {
|
|
| 119 | ||
| 120 | $is_needed = $this->hasConfigKey( 'is_needed' ) |
|
| 121 | ? $this->getConfigKey( 'is_needed' ) |
|
| 122 | : false; |
|
| 123 | ||
| 124 | if ( is_callable( $is_needed ) ) {
|
|
| 125 | return $is_needed( $context ); |
|
| 126 | } |
|
| 127 | ||
| 128 | return (bool) $is_needed; |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * Get the shortcode tag. |
|
| @@ 101-113 (lines=13) @@ | ||
| 98 | * @param mixed $context Data about the context in which the call is made. |
|
| 99 | * @return boolean Whether the shortcode UI is needed or not. |
|
| 100 | */ |
|
| 101 | protected function is_needed( $context = null ) { |
|
| 102 | ||
| 103 | $is_needed = $this->hasConfigKey( 'is_needed' ) |
|
| 104 | ? $this->getConfigKey( 'is_needed' ) |
|
| 105 | : false; |
|
| 106 | ||
| 107 | // Return true if a callable 'is_needed' evaluates to true. |
|
| 108 | if ( is_callable( $is_needed ) ) { |
|
| 109 | return $is_needed( $context ); |
|
| 110 | } |
|
| 111 | ||
| 112 | return (bool) $is_needed; |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||