/** * Register widget * * @param string $class_name Widget class name. * * @return bool * @throws Exception If could not locate widget file or it's not readable. */ function wi_register_widget($class_name) { // Load widget class if it was not loaded yet if (false === class_exists($class_name)) { $filename = strtolower(str_replace(array('WI_Widget_', '_'), array('', '-'), $class_name)); $filepath = wi_plugin_path(sprintf('widgets/%1$s/class-widget-%1$s.php', $filename)); if (false === file_exists($filepath) || false === is_readable($filepath)) { throw new Exception(sprintf('Could not load "%s" widget! File "%s" is not readable or does not exist!', $class_name, $filepath)); } require_once $filepath; } // Register widget register_widget($class_name); return true; }
* @license GPL-3.0+ * @copyright 2016 Template Monster */ global $post; $posts = get_posts(array('orderby' => 'date', 'order' => 'ASC', 'numberposts' => 5)); $item_count = 1; $special_class = 'small'; $image_size = $this->instance['image_sizes']['small']; if (0 < sizeof($posts)) { ?> <div class="tm_fpblock tm_fpblock-layout-1"> <?php foreach ($posts as $post) { setup_postdata($post); if (true === has_post_thumbnail()) { require wi_plugin_path('widgets/featured-posts-block/views/public/layout-loop.php'); $item_count = $item_count + 1; if (3 === $item_count) { $special_class = 'large'; $image_size = $this->instance['image_sizes']['large']; } else { $special_class = 'small'; $image_size = $this->instance['image_sizes']['small']; } } wp_reset_postdata(); } ?> </div> <?php }
<?php print $args['before_widget']; } ?> <?php if (isset($args['before_title'])) { ?> <?php print $args['before_title']; } ?> <div class="tm_fpblock__wrapper"> <?php require wi_plugin_path(sprintf('widgets/featured-posts-block/views/public/%s.php', $this->instance['layout_view'])); ?> </div> <?php if (isset($args['after_title'])) { ?> <?php print $args['after_title']; } ?> <?php if (isset($args['after_widget'])) { ?> <?php
/** * Outputs the settings update form. * * @param array $instance Current settings. * * @return string|void */ public function form($instance) { $this->_apply_instance($instance); require wi_plugin_path('widgets/featured-posts-block/views/admin/form.php'); return; }