Unexpected add action function in WP plugin

It’s not entirely clear in the tutorial, but the add_action() call should be outside the class. class My_gCal_Widget extends WP_Widget { public function __construct() { parent:: __construct( ‘my_gcal_widget’, ‘My_gCal_Widget’, array( ‘classname’ => ‘my-gcal-widget’, ‘description’ => ‘Shows events from a calendar’ ) ); } public function widget($args, $instance) { } } add_action(‘widgets_init’, function() { register_widget(‘My_gCal_Widget’); });

WordPress can’t use ZipArchive

I successfully created zip file in root folder of WordPress using following code: $files = array(__DIR__.’/test.jpg’, __DIR__.’/screenshot.png’); $zipname=”images.zip”; $zip = new ZipArchive; $zip->open($zipname, ZipArchive::CREATE) or die(‘ cant open ‘); foreach ($files as $file) { if( $zip->addFile($file)){ echo “<br>$file Added To Zip Sucessfully”; }else { echo “<br>Can not add $file file”; } } $zip->close(); if(file_exists($zipname)){ echo … Read more