__('Column', 'aqpb-l10n'), 'size' => 'span6', ); //create the widget parent::__construct('aq_column_block', $block_options); } //form header function before_form($instance) { extract($instance); $title = $title ? ' : '.$title.'' : ''; $resizable = $resizable ? '' : 'not-resizable'; echo '
  • ', '
    ', '
    ', '
    ', $name , $title, '
    ', '', 'Edit Block', '', '
    ', '
    ', '
    '; } function form($instance) { echo '

    ', __('Drag block items into this column box', 'aqpb-l10n'), '

    '; echo ''; } function form_callback($instance = array()) { $instance = is_array($instance) ? wp_parse_args($instance, $this->block_options) : $this->block_options; //insert the dynamic block_id & block_saving_id into the array $this->block_id = 'aq_block_' . $instance['number']; $instance['block_saving_id'] = 'aq_blocks[aq_block_'. $instance['number'] .']'; extract($instance); $col_order = $order; //column block header if(isset($template_id)) { echo '
  • ', '
    ', '

    ', __('Drag block items into this column box', 'aqpb-l10n'), '

    ', ''; } else { $this->before_form($instance); $this->form($instance); } //form footer $this->after_form($instance); } //form footer function after_form($instance) { extract($instance); $block_saving_id = 'aq_blocks[aq_block_'.$number.']'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
    ', '
  • '; } function block_callback($instance) { $instance = is_array($instance) ? wp_parse_args($instance, $this->block_options) : $this->block_options; extract($instance); $col_order = $order; $col_size = absint(preg_replace("/[^0-9]/", '', $size)); //column block header if(isset($template_id)) { $this->before_block($instance); //define vars $overgrid = 0; $span = 0; $first = false; //check if column has blocks inside it $blocks = aq_get_blocks($template_id); //outputs the blocks if($blocks) { foreach($blocks as $key => $child) { global $aq_registered_blocks; extract($child); if(class_exists($id_base)) { //get the block object $block = $aq_registered_blocks[$id_base]; //insert template_id into $child $child['template_id'] = $template_id; //display the block if($parent == $col_order) { $child_col_size = absint(preg_replace("/[^0-9]/", '', $size)); $overgrid = $span + $child_col_size; if($overgrid > $col_size || $span == $col_size || $span == 0) { $span = 0; $first = true; } if($first == true) { $child['first'] = true; } $block->block_callback($child); $span = $span + $child_col_size; $overgrid = 0; //reset $overgrid $first = false; //reset $first } } } } $this->after_block($instance); } else { //show nothing } } }