protected function FetchItems($arrURLs, $numItems = 1)
 {
     // since 1.1.4
     $strURLID = md5(serialize(is_string($arrURLs) ? array($arrURLs) : $arrURLs));
     if (!isset($this->arrFeedItems[$strURLID])) {
         $this->arrFeedItems[$strURLID] = (array) get_transient('RCWUserAds_' . $strURLID);
         unset($this->arrFeedItems[$strURLID][0]);
         // casting array causes the 0 key,
     }
     // If it's out of stock, fill the array by fetching the feed.
     if (count($this->arrFeedItems[$strURLID]) < $numItems) {
         $oReplace = new ResponsiveColumnWidgets_HTMLElementReplacer($this->strCharSet);
         // When an array of urls is passed to the Simple Pie's set_feed_url() method, the memory usage increases largely.
         // So fetch the feeds one by one per url and store the output into an array.
         foreach ($arrURLs as $strURL) {
             $oFeed = $this->GetFeedObj($strURL, $numItems * 20);
             // multiplied by X to store items more than enough for next calls.
             foreach ($oFeed->get_items() as $item) {
                 // foreach ( $oFeed->get_items( 0, $numItems * 3 ) as $item ) does not change the memory usage
                 $this->arrFeedItems[$strURLID][] = $oReplace->Perform($item->get_content());
             }
             // For PHP below 5.3 to release the memory.
             $oFeed->__destruct();
             // Do what PHP should be doing on it's own.
             unset($oFeed);
         }
         unset($oReplace);
         // This life span should be little longer than the feed cache life span, which is 1700.
         set_transient('RCWUserAds_' . $strURLID, $this->arrFeedItems[$strURLID], 1800);
         // 30 minutes
     }
     $strOut = '';
     shuffle($this->arrFeedItems[$strURLID]);
     for ($i = 1; $i <= $numItems; $i++) {
         $strOut .= array_pop($this->arrFeedItems[$strURLID]);
     }
     return $strOut;
 }
 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;
 }