PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.15.0
GiveWP – Donation Plugin and Fundraising Platform v3.15.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
← All changes | src/Framework/Blocks/BlockCollection.php +9 -0 3.14.23.15.0 View file →
@@ -208,11 +208,20 @@
208 208 $this->blocks[] = $block;
209 209 return $this;
210 210 }
211 211
212 + /**
213 + * @since 3.15.0 returns the block collection if block does not exist.
214 + * @since 3.0.0
215 + */
212 216 public function remove($blockName) {
213 217 $blockCollection = $this->findByNameRecursive($blockName, 0, 'parent');
214 218 $innerBlocks = $blockCollection->blocks;
219 +
220 + if(!$innerBlocks){
221 + return $this;
222 + }
223 +
215 224 $blockIndex = array_search($blockName, array_column($innerBlocks, 'name'));
216 225 array_splice($innerBlocks, $blockIndex, 1);
217 226 $blockCollection->blocks = $innerBlocks;
218 227 return $this;