public function getWidgetsBufferAsArray($strSidebarID, $arrSidebarsWidgets, $arrShowOnlys, $arrOmits, $bRemoveIDAttributes) { // since 1.1.1, moved from the core class in 1.1.2 global $wp_registered_sidebars, $wp_registered_widgets; // Variables $arrWidgetBuffer = array(); // stores the returning widget buffer outputs, one key for one widget. $arrSidebarInfo = isset($wp_registered_sidebars[$strSidebarID]) ? $wp_registered_sidebars[$strSidebarID] : array(); /* $arrSidebarInfo contains the following keys ( the values are as an example ): [name] => Responsive Column Widgets [id] => responsive_column_widgets [description] => The default widget box of Responsive Column Widgets. [class] => [before_widget] => <aside id="%1$s" class="%2$s"><div class="widget"> [after_widget] => </div></aside> [before_title] => <h3 class="widget-title"> [after_title] => </h3> */ $numWidgetOrder = 0; // for the omit parameter $bShowOnly = count($arrShowOnlys) > 0 ? True : False; // if showonly is set, render only the specified widget id. $this->arrIsPluginWidgetBoxWidget = array(); // Objects $oReplace = new ResponsiveColumnWidgets_HTMLElementReplacer(); foreach ((array) $arrSidebarsWidgets[$strSidebarID] as $strWidgetID) { if (!isset($wp_registered_widgets[$strWidgetID])) { continue; } if (in_array(++$numWidgetOrder, $arrOmits)) { continue; } // if the omit ids match, skip if ($bShowOnly && !in_array($numWidgetOrder, $arrShowOnlys)) { continue; } // if the show-only orders match, skip, $arrParams = array_merge(array(array_merge($arrSidebarInfo, array('widget_id' => $strWidgetID, 'widget_name' => $wp_registered_widgets[$strWidgetID]['name']))), (array) $wp_registered_widgets[$strWidgetID]['params']); // Substitute HTML id and class attributes into before_widget $strClassName = ''; foreach ((array) $wp_registered_widgets[$strWidgetID]['classname'] as $cn) { if (is_string($cn)) { $strClassName .= '_' . $cn; } elseif (is_object($cn)) { $strClassName .= '_' . get_class($cn); } } $strClassName = ltrim($strClassName, '_'); $arrParams[0]['before_widget'] = sprintf($arrParams[0]['before_widget'], '', $strClassName); // the second parameter is for the backward compatibility. // $arrParams[0]['before_widget'] = sprintf( $arrParams[0]['before_widget'], $strWidgetID, $strClassName ); $arrParams = apply_filters('dynamic_sidebar_params', $arrParams); $vCallback = $wp_registered_widgets[$strWidgetID]['callback']; do_action('dynamic_sidebar', $wp_registered_widgets[$strWidgetID]); // since 1.1.3 - stores an array to check if the widget is the plugin widget-box widget that is added in v1.1.3. // This will store true/false ( boolean ) in the array with the index that is same as the array storing the buffer. // This flag array will be passed to a filter so that it can be captured from other places. $this->arrIsPluginWidgetBoxWidget[] = isset($arrParams[0]['widget_id']) && preg_match('/^responsive_column_widget_box-\\d+/', $arrParams[0]['widget_id']); ob_start(); if (is_callable($vCallback)) { call_user_func_array($vCallback, $arrParams); // will echo the widget. $arrWidgetBuffer[] = $bRemoveIDAttributes ? $oReplace->RemoveIDAttributes(ob_get_contents()) : ob_get_contents(); // deletes the ID attributes here. } ob_end_clean(); } // end of foreach() return $arrWidgetBuffer; }