/** * Outputs the body of the widget * * @param array $args Widget args * @param array $instance Widget instance * @param array $settings Widget settings * @return void (Text is echoed.) */ function widget_body($args, $instance, $settings) { extract($args); extract($settings); // Bail early if no field was specified if (empty($field)) { return; } if (0 === $post_id) { $post_id = 'current'; } // Determine, based on inputs given, which template tag to use. if (!empty($post_id)) { if ('current' == $post_id) { echo c2c_get_current_custom($field, $before, $after, $none, $between, $before_last); } elseif ($random) { echo c2c_get_random_post_custom($post_id, $field, $limit, $before, $after, $none, $between, $before_last); } else { echo c2c_get_post_custom($post_id, $field, $before, $after, $none, $between, $before_last); } } else { if ($random) { echo c2c_get_random_custom($field, $before, $after, $none, $limit, $between, $before_last); } else { echo c2c_get_recent_custom($field, $before, $after, $none, $between, $before_last, $limit); } } }
function shortcode($atts, $content = null) { $defaults = array(); foreach ($this->widget_handler->config as $opt => $values) { $defaults[$opt] = $values['default']; } $atts2 = shortcode_atts($defaults, $atts); foreach (array_keys($this->widget_handler->config) as $key) { ${$key} = $atts2[$key]; } $ret = ''; if ($post_id && !$this_post) { if ('current' == $post_id) { $ret = c2c_get_current_custom($field, $before, $after, $none, $between, $before_last); } elseif ($random) { $ret = c2c_get_random_post_custom($post_id, $field, $limit, $before, $after, $none, $between, $before_last); } else { $ret = c2c_get_post_custom($post_id, $field, $before, $after, $none, $between, $before_last); } } else { if ($this_post) { $ret = c2c_get_custom($field, $before, $after, $none, $between, $before_last); } elseif ($random) { $ret = c2c_get_random_custom($field, $before, $after, $none); } else { $ret = c2c_get_recent_custom($field, $before, $after, $none, $between, $before_last, $limit); } } return $ret; }