| 1 |
<?php |
| 2 |
/** |
| 3 |
* The public-facing functionality of the module. |
| 4 |
* |
| 5 |
* @link https://codesupply.co |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Powerkit |
| 9 |
* @subpackage Modules/public |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* The public-facing functionality of the module. |
| 14 |
*/ |
| 15 |
class Powerkit_Headers_Footers_Public extends Powerkit_Module_Public { |
| 16 |
|
| 17 |
/** |
| 18 |
* Initialize |
| 19 |
*/ |
| 20 |
public function initialize() { |
| 21 |
add_action( 'wp_head', array( $this, 'header' ) ); |
| 22 |
add_action( 'wp_footer', array( $this, 'footer' ) ); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Outputs script / CSS to the frontend header. |
| 27 |
*/ |
| 28 |
public function header() { |
| 29 |
$this->output( 'powerkit_insert_header_code' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Outputs script / CSS to the frontend footer. |
| 34 |
*/ |
| 35 |
public function footer() { |
| 36 |
$this->output( 'powerkit_insert_footer_code' ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Outputs the given setting, if conditions are met. |
| 41 |
* |
| 42 |
* @param string $setting Setting Name. |
| 43 |
*/ |
| 44 |
public function output( $setting ) { |
| 45 |
// Ignore admin, feed, robots or trackbacks. |
| 46 |
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) { |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
// Get code. |
| 51 |
$code = get_option( $setting ); |
| 52 |
|
| 53 |
// Output. |
| 54 |
echo (string) $code; // XSS. |
| 55 |
} |
| 56 |
} |
| 57 |
|