first commit

This commit is contained in:
CHIEFSOFT\ameye
2023-11-30 13:20:54 -05:00
commit e9e5c0546c
5833 changed files with 1801865 additions and 0 deletions
@@ -0,0 +1,108 @@
<?php
/**
* The admin-specific functionality of the module.
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package Powerkit
* @subpackage Modules/Admin
*/
/**
* The admin-specific functionality of the module.
*/
class Powerkit_Headers_Footers_Admin extends Powerkit_Module_Admin {
/**
* Initialize
*/
public function initialize() {
add_action( 'admin_menu', array( $this, 'register_options_page' ) );
}
/**
* Register admin page
*
* @since 1.0.0
*/
public function register_options_page() {
add_options_page( esc_html__( 'Insert Headers & Footers', 'powerkit' ), esc_html__( 'Insert Headers & Footers', 'powerkit' ), 'manage_options', powerkit_get_page_slug( $this->slug ), array( $this, 'build_options_page' ) );
}
/**
* Build admin page
*
* @since 1.0.0
*/
public function build_options_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have sufficient rights to view this page.', 'powerkit' ) );
}
$this->save_options_page();
?>
<div class="wrap pk-wrap">
<h1><?php esc_html_e( 'Insert Headers & Footers', 'powerkit' ); ?></h1>
<div class="pk-settings">
<form method="post">
<table class="form-table">
<tbody>
<!-- Scripts in Header -->
<tr>
<th scope="row">
<label for="powerkit_insert_header_code">
<?php esc_html_e( 'Scripts in Header', 'powerkit' ); ?>
<p class="description"><?php esc_html_e( 'These scripts will be printed in the &lt;head&gt; section.', 'powerkit' ); ?></p>
</label>
</th>
<td><textarea style="width:100%" id="powerkit_insert_header_code" name="powerkit_insert_header_code" rows="8"><?php echo (string) get_option( 'powerkit_insert_header_code' ); // XSS. ?></textarea></td>
</tr>
<!-- Scripts in Footer -->
<tr>
<th scope="row">
<label for="powerkit_insert_footer_code">
<?php esc_html_e( 'Scripts in Footer', 'powerkit' ); ?>
<p class="description"><?php esc_html_e( 'These scripts will be printed above the &lt;/body&gt; tag.', 'powerkit' ); ?></p>
</label>
</th>
<td><textarea style="width:100%" id="powerkit_insert_footer_code" name="powerkit_insert_footer_code" rows="8"><?php echo (string) get_option( 'powerkit_insert_footer_code' ); // XSS. ?></textarea></td>
</tr>
</tbody>
</table>
<?php wp_nonce_field(); ?>
<p class="submit"><input class="button button-primary" name="save_settings" type="submit" value="<?php esc_html_e( 'Save changes', 'powerkit' ); ?>" /></p>
</form>
</div>
</div>
<?php
}
/**
* Settings save
*
* @since 1.0.0
*/
protected function save_options_page() {
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'] ) ) { // Input var ok; sanitization ok.
return;
}
if ( isset( $_POST['save_settings'] ) ) { // Input var ok.
if ( isset( $_POST['powerkit_insert_header_code'] ) ) { // Input var ok.
update_option( 'powerkit_insert_header_code', wp_unslash( $_POST['powerkit_insert_header_code'] ) ); // Input var ok. sanitization ok.
}
if ( isset( $_POST['powerkit_insert_footer_code'] ) ) { // Input var ok.
update_option( 'powerkit_insert_footer_code', wp_unslash( $_POST['powerkit_insert_footer_code'] ) ); // Input var ok. sanitization ok.
}
printf( '<div id="message" class="updated fade"><p><strong>%s</strong></p></div>', esc_html__( 'Settings saved.', 'powerkit' ) );
}
}
}
@@ -0,0 +1,51 @@
<?php
/**
* Headers Footers
*
* @package Powerkit
* @subpackage Modules
*/
if ( class_exists( 'Powerkit_Module' ) ) {
/**
* Init module
*/
class Powerkit_Headers_Footers extends Powerkit_Module {
/**
* Register module
*/
public function register() {
$this->name = esc_html__( 'Header and Footer Scripts', 'powerkit' );
$this->desc = esc_html__( 'You insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site header and footer.', 'powerkit' );
$this->slug = 'headers_footers';
$this->type = 'default';
$this->category = 'tools';
$this->priority = 140;
$this->public = false;
$this->enabled = false;
$this->links = array(
array(
'name' => esc_html__( 'View documentation', 'powerkit' ),
'url' => powerkit_get_setting( 'documentation' ) . '/headers-footers/',
'target' => '_blank',
),
);
}
/**
* Initialize module
*/
public function initialize() {
// Admin and public area.
require_once dirname( __FILE__ ) . '/admin/class-powerkit-headers-footers-admin.php';
require_once dirname( __FILE__ ) . '/public/class-powerkit-headers-footers-public.php';
new Powerkit_Headers_Footers_Admin( $this->slug );
new Powerkit_Headers_Footers_Public( $this->slug );
}
}
new Powerkit_Headers_Footers();
}
@@ -0,0 +1,56 @@
<?php
/**
* The public-facing functionality of the module.
*
* @link https://codesupply.co
* @since 1.0.0
*
* @package Powerkit
* @subpackage Modules/public
*/
/**
* The public-facing functionality of the module.
*/
class Powerkit_Headers_Footers_Public extends Powerkit_Module_Public {
/**
* Initialize
*/
public function initialize() {
add_action( 'wp_head', array( $this, 'header' ) );
add_action( 'wp_footer', array( $this, 'footer' ) );
}
/**
* Outputs script / CSS to the frontend header.
*/
public function header() {
$this->output( 'powerkit_insert_header_code' );
}
/**
* Outputs script / CSS to the frontend footer.
*/
public function footer() {
$this->output( 'powerkit_insert_footer_code' );
}
/**
* Outputs the given setting, if conditions are met.
*
* @param string $setting Setting Name.
*/
public function output( $setting ) {
// Ignore admin, feed, robots or trackbacks.
if ( is_admin() || is_feed() || is_robots() || is_trackback() ) {
return;
}
// Get code.
$code = get_option( $setting );
// Output.
echo (string) $code; // XSS.
}
}