Beispiel #1
0
 /**
  * (non-PHPdoc)
  * @see WP_Widget::widget()
  */
 function widget($args, $instance)
 {
     // https://codex.wordpress.org/Function_Reference/url_to_postid
     // FIXME may not work with attachments. See here: https://pippinsplugins.com/retrieve-attachment-id-from-image-url/
     $post_id = url_to_postid(MR_Utils::get_current_url());
     if ($post_id == 0 || $post_id == null) {
         return;
         // Nothing to do.
     }
     if (!apply_filters('mr_can_apply_widget', true, $post_id, $args, $instance)) {
         return;
         // do nothing
     }
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     $header = empty($instance['header']) ? 'h3' : $instance['header'];
     $before_title = '<' . $header . ' class="widget-title">';
     $after_title = '</' . $header . '>';
     $title = apply_filters('widget_title', $title);
     echo $before_widget;
     Multi_Rating_API::display_rating_form(array('class' => 'mr-widget', 'before_title' => $before_title, 'after_title' => $after_title, 'title' => $title, 'post_id' => $post_id));
     echo $after_widget;
 }