/** * Main shortocde function. * * @since 1.0.0 * @param array $atts Shortcode attributes. * @return string */ public function shortcode($atts) { $atts = shortcode_atts(array('descr' => '', 'url' => '', 'project_button' => ''), $atts, 'tf_track_project'); if (!$atts['url']) { return; } $handler = tf_track_kickstarter_handle($atts['url']); $data = $handler->get_data(); $template = tf_track_kickstarter_tools()->locate_template('default.php'); $url = esc_url($atts['url']); $descr = !empty($atts['descr']) ? $atts['descr'] : ''; $project_button = !empty($atts['project_button']) ? $atts['project_button'] : ''; ob_start(); if ($data && $template) { include $template; } return ob_get_clean(); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { if (empty($instance['url'])) { return; } $widget_header = tf_track_kickstarter_tools()->locate_template('widget-header.php'); if ($widget_header) { include $widget_header; } $handler = tf_track_kickstarter_handle($instance['url']); $data = $handler->get_data(); $widget_template = tf_track_kickstarter_tools()->locate_template('default.php'); $url = esc_url($instance['url']); $descr = !empty($instance['descr']) ? $instance['descr'] : ''; $project_button = !empty($instance['project_button']) ? $instance['project_button'] : ''; if ($data && $widget_template) { include $widget_template; } $widget_footer = tf_track_kickstarter_tools()->locate_template('widget-footer.php'); if ($widget_footer) { include $widget_footer; } }
?> </span> <span class="tf-tracker-label"><?php _e('goal', 'track-kickstarter-project'); ?> </span> </div> <?php } ?> <?php if (!empty($data['end_time'])) { ?> <div class="tf-tracker-item tf-end-time"> <span class="tf-tracker-value"><?php echo tf_track_kickstarter_tools()->time_diff(current_time('timestamp'), strtotime($data['end_time']), 'd'); ?> </span> <span class="tf-tracker-label"><?php _e('days left', 'track-kickstarter-project'); ?> </span> </div> <?php } ?> <?php if (!empty($project_button)) { ?> <div class="tf-tracker-action"> <a href="<?php