/** * widget() * * This is the main function that initializes the SRP rendering process. * * @author Luca Grandicelli <*****@*****.**> * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @access public * @param array $args The option values args. * @param array $instance The current widget instance. * @return boolean true */ function widget($args, $instance) { // Checking Visualization Filter. if (SpecialRecentPostsFree::visualization_check($instance, 'widget')) { // Extracting arguments. extract($args, EXTR_SKIP); // Printing pre-widget stuff. echo $before_widget; // Checking for 'Use default Wordpress HTML layout for widget title' option value. if (isset($instance['widget_title_show_default_wp']) && 'yes' == $instance['widget_title_show_default_wp']) { // Checking that this option exists. if (isset($instance['widget_title_hide'])) { // Fetching widget title. $widget_title = apply_filters('widget_title', $instance['widget_title']); // Checking for "widget title hide" option. if ('yes' != $instance['widget_title_hide']) { // Printing default Widget Title HTML layout. echo $before_title . $widget_title . $after_title; } } } // Creating an instance of the Special Recent Posts Class. $srp = new SpecialRecentPostsFree($instance, $this->id); // Checking that the $srp is a valid SRP class object. if (is_object($srp)) { // Displaying posts. $srp->display_posts(true, 'print'); } // Printing after widget stuff. echo $after_widget; } // Returning true. return true; }
/** * srp_shortcode() * * This function handles the shortcodes generated by SRP. * * @author Luca Grandicelli <*****@*****.**> * @copyright (C) 2011-2014 Luca Grandicelli * @package special-recent-posts-free * @version 2.0.4 * @global array $srp_default_widget_values The default SRP widget presets. * @param array $atts The plugin shortcodes attributes. * @return boolean/string It could be a boolean true or the generated HTML posts layout. */ function srp_shortcode($atts) { // Including default widget presets. global $srp_default_widget_values; // Checking Visualization Filter. if (SpecialRecentPostsFree::visualization_check($srp_default_widget_values, 'shortcode')) { // If shortcode comes without parameters, make $atts a valid array. if (!is_array($atts)) { // Initializing $atts as an empty array. $atts = array(); } // Combining default widget presets with available shortcode attributes. extract(shortcode_atts($srp_default_widget_values, $atts)); // Creating an instance of the SRP class with widget args passed in manual mode. $srp = new SpecialRecentPostsFree($atts); // Displaying posts. return $srp->display_posts(NULL, 'return'); } // Nothing happened. Returning true anyway. return true; }