retesere20

add-widgets-sample

Jun 6th, 2021
22
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // add_action( 'widgets_init', [$this,'addWidgets'] );
  3. public function addWidgets() {
  4. $optval=get_option('optname_widgets', my_sample_array_widgets);
  5. $additional_array = !empty($GLOBALS['MyWidgetss']) ? $GLOBALS['MyWidgetss'] : array();
  6. $widgets= array_merge( explode(',',$optval), $additional_array );
  7. if (!empty($widgets) ) {
  8. foreach ($widgets as $value){
  9. register_sidebar( array('name' => $value ,'id' => strtolower($value), 'before_widget'=>'<div class="sideb_clas '.$value.'">','after_widget'=>'</div>','before_title'=>'<h2 class="sideb_around">','after_title'=>'</h2>') );
  10. }
  11. }
  12. }
  13.  
RAW Paste Data