Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/widget//layout.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_action('widgets_init','bopea_widget_layouts');
function bopea_widget_layouts(){
register_widget("bopea_widget_add_layouts");
}
class bopea_widget_add_layouts extends WP_widget{
/*-----------------------------------------------------------------------------------*/
/* Widget Setup
/*-----------------------------------------------------------------------------------*/
public function __construct() {
$widget_ops = array( 'classname' => 'jl_cus_layouts_widget', 'description' => esc_html__( 'Add custom layouts' , 'bopea-function') );
parent::__construct('bopea_widget_add_layouts', esc_html__(' Custom layouts', 'bopea-function'), $widget_ops);
}
/*-----------------------------------------------------------------------------------*/
/* Display Widget
/*-----------------------------------------------------------------------------------*/
function widget($args,$instance){
extract($args);
$jllayout = isset($instance["jllayout"]) ? $instance["jllayout"] : "";
?>
<?php print $before_widget;?>
<div class="widget_jl_wrapper jl-cuslayouts-wrapper">
<div class="jl_cuslayouts_inner">
<?php if ( ! empty( $jllayout ) ) {
echo do_shortcode( '[jl_layout id="' . esc_attr($jllayout) . '"]' );
} ?>
</div>
<?php
print $after_widget;
print "</div>";
}
/*-----------------------------------------------------------------------------------*/
/* Update Widget
/*-----------------------------------------------------------------------------------*/
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['jllayout'] = $new_instance['jllayout'];
return $instance;
}
/*-----------------------------------------------------------------------------------*/
/* Widget Settings (Displays the widget settings controls on the widget panel)
/*-----------------------------------------------------------------------------------*/
function form( $instance ) {
?>
<?php
$jllayout = isset($instance['jllayout']) ? esc_attr($instance['jllayout']) : '';
?>
<p>
<span class="widefat">
<?php esc_html_e('Choose your layouts:', 'bopea-function');?>
</span>
<?php
$options = array();
$custom_layouts = get_posts( 'post_type="jl_layout"&numberposts=-1' );
if ( ! empty( $custom_layouts ) ) {
$options[''] = esc_html__( 'Default', 'bopea-function' );
foreach ( $custom_layouts as $add_layouts ) {
$options[ $add_layouts->ID ] = esc_html( $add_layouts->post_title );
}
}
?>
<select name="<?php echo $this->get_field_name('jllayout'); ?>" class="widefat" style="width:100%;">
<option><?php esc_html_e( 'Default', 'bopea-function' );?></option>
<?php
if ( ! empty( $custom_layouts ) ) {
foreach ( $custom_layouts as $add_layouts ) {?>
<option <?php if ( !empty($instance['jllayout']) ) { selected( $instance['jllayout'], $add_layouts->ID ); } ?> value="<?php echo $add_layouts->ID; ?>">
<?php esc_html_e( $add_layouts->post_title ) ?>
</option>
<?php }}?>
</select>
</p>
<?php
}
}
?>