Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/inc//header-footer.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'jelly_header_footer_settings' ) ) {
class jelly_header_footer_settings {
protected static $instance = null;
public $page_slug, $page_title, $menu_title;
public $topic_ID;
static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
function __construct() {
$this->page_title = esc_html__( 'Custom Scripts', 'bopea-function' );
$this->menu_title = esc_html__( 'Custom Scripts', 'bopea-function' );
$this->page_slug = 'jelly-custom-script';
$this->topic_ID = 'jelly_bbp_topic';
add_action( 'admin_menu', [ $this, 'register_options_page' ] );
add_action( 'admin_init', [ $this, 'register_settings' ] );
}
public function register_options_page() {
add_submenu_page( 'jlwelcome.php', $this->page_title, $this->menu_title, 'manage_options', $this->page_slug, [
$this,
'page_options'
] );
}
public function page_options() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
} ?>
<div class="wrap jelly-bbp-settings">
<h1><?php esc_html_e( 'Custom Header and Footer Script', 'bopea-function' ) ?></h1>
<p><?php esc_html__( 'Support styles, layout and features for bbPress forum plugin.', 'bopea-function' ); ?></p>
<form action="options.php" method="post">
<?php
settings_fields( $this->topic_ID );
do_settings_sections( $this->topic_ID );
submit_button();
?>
</form>
</div>
<?php
}
public function register_settings() {
add_settings_section( $this->topic_ID, '', [ $this, 'jl_script_head_foot' ], $this->topic_ID );
register_setting( $this->topic_ID, 'jl_cus_head_code' );
register_setting( $this->topic_ID, 'jl_cus_foot_code' );
add_settings_field( 'jl-cus-head-code', esc_html__( 'Header Code', 'bopea-function' ), [
$this,
'input_textarea'
], $this->topic_ID, $this->topic_ID, [
'name' => 'jl_cus_head_code',
'value' => get_option( 'jl_cus_head_code', '' ),
'desc' => esc_html__( 'Will add to the <head> tag. Useful if you need to add additional codes such as CSS or JS.', 'bopea-function' )
] );
add_settings_field( 'jl-cus-foot-code', esc_html__( 'Footer Code', 'bopea-function' ), [
$this,
'input_textarea'
], $this->topic_ID, $this->topic_ID, [
'name' => 'jl_cus_foot_code',
'value' => get_option( 'jl_cus_foot_code', '' ),
'desc' => esc_html__( 'Will add to the footer before the closing </body> tag. Useful if you need to add Javascript.', 'bopea-function' )
] );
}
function jl_script_head_foot() {
echo '';
}
function on_off_dropdown( $args ) { ?>
<select name="<?php echo esc_attr( $args['name'] ); ?>">
<option value="1" <?php if ( ! empty( $args['selected'] ) ) {
echo 'selected';
} ?> ><?php esc_html_e( 'Enable', 'bopea-function' ); ?></option>
<option value="0" <?php if ( empty( $args['selected'] ) ) {
echo 'selected';
} ?> ><?php esc_html_e( '- Disable -', 'bopea-function' ); ?></option>
</select>
<p><?php if ( ! empty( $args['desc'] ) ) {
echo esc_html( $args['desc'] );
} ?></p>
<?php
}
function sidebar_dropdown( $args ) { ?>
<select name="<?php echo esc_attr( $args['name'] ); ?>">
<?php if ( ! empty( $args['has_default'] ) ) : ?>
<option value="_default" <?php if ( empty( $args['selected'] ) && '_default' == $args['selected'] ) {
echo 'selected';
} ?>><?php esc_html_e( '- Default -', 'bopea-function' ); ?></option>
<?php endif; ?>
<option value="0" <?php if ( empty( $args['selected'] ) ) {
echo 'selected';
} ?>><?php esc_html_e( 'Disable', 'bopea-function' ); ?></option>
<?php global $wp_registered_sidebars;
foreach ( $wp_registered_sidebars as $sidebar_id => $data ) {
if ( $args['selected'] === $sidebar_id ) {
$selected = 'selected';
} else {
$selected = '';
}
?>
<option value="<?php echo esc_attr( $sidebar_id ); ?>" <?php echo $selected ?> ><?php echo esc_html( $data['name'] ); ?></option>
<?php } ?>
</select>
<p><?php if ( ! empty( $args['desc'] ) ) {
echo esc_html( $args['desc'] );
} ?></p>
<?php
}
function input_text( $args ) { ?>
<input class="regular-text" type="text" name="<?php echo esc_attr( $args['name'] ); ?>" placeholder="<?php if ( ! empty( $args['placeholder'] ) ) {
echo esc_attr( $args['placeholder'] );
} ?>" value="<?php echo $args['value']; ?>">
<p><?php if ( ! empty( $args['desc'] ) ) {
echo esc_html( $args['desc'] );
} ?></p>
<?php
}
function input_textarea( $args ) { ?>
<textarea class="widefat" rows="7" cols="50" name="<?php echo esc_attr( $args['name'] ); ?>" placeholder="<?php if ( ! empty( $args['placeholder'] ) ) {
echo esc_attr( $args['placeholder'] );
} ?>"><?php echo $args['value']; ?></textarea>
<p><?php if ( ! empty( $args['desc'] ) ) {
echo esc_html( $args['desc'] );
} ?></p>
<?php
}
function topic_custom_field( $args ) {
$data = wp_parse_args(
$args['data'], [
'title' => '',
'private' => 0
]
)
?>
<p>
<label for="<?php echo esc_attr( $args['name'] . '-title' ); ?>"><?php echo esc_html__( 'Title:', 'bopea-function' ); ?>
<input type="text" name="<?php echo esc_attr( $args['name'] . '[title]' ); ?>" value="<?php echo $data['title']; ?>"></label>
</p>
<p>
<label for="<?php echo esc_attr( $args['name'] . '-private' ); ?>"><?php esc_html_e( 'is private field?', 'bopea-function' ); ?>
<select name="<?php echo esc_attr( $args['name'] . '[private]' ); ?>">
<option value="1" <?php if ( ! empty( $data['private'] ) ) {
echo 'selected';
} ?> ><?php esc_html_e( 'Enable', 'bopea-function' ); ?></option>
<option value="0" <?php if ( empty( $data['private'] ) ) {
echo 'selected';
} ?> ><?php esc_html_e( '- Disable -', 'bopea-function' ); ?></option>
</select></label></p>
<p><?php if ( ! empty( $args['desc'] ) ) {
echo esc_html( $args['desc'] );
} ?></p>
<?php
}
}
}