• Hi! i just purchased GD bbPress Toolbox and would like to add an avatar to its ‘New Post’ widget… the author said its possible but im not a coder so i dont know where to start… posted the php file below and would really appreciate any help…

    thanks!

    <?php
    
    if (!defined('ABSPATH')) exit;
    
    class d4pbbpWidget_newposts extends d4pLib_Widget {
        private $replies = array();
    
        public $widget_base = 'd4p_bbw_newposts';
        public $widget_domain = 'd4pbbw_widgets';
        public $cache_prefix = 'd4pbbw';
    
        public $cache_active = true;
    
        public $defaults = array(
            'title' => 'New Posts',
            '_display' => 'all',
            '_hook' => '',
            '_cached' => 0,
            '_tab' => 'global',
            '_class' => '',
            'period' => 'last_day',
            'scope' => 'topic,reply',
            'display_date' => 'yes',
            'display_author' => 'no',
            'limit' => 10,
            'before' => '',
            'after' => ''
        );
    
        function __construct($id_base = false, $name = '', $widget_options = array(), $control_options = array()) {
            $this->widget_description = __("New topics or topics with new replies.", "gd-bbpress-toolbox");
            $this->widget_name = 'GD bbPress Toolbox: '.__("New Posts", "gd-bbpress-toolbox");
    
            parent::__construct($this->widget_base, $this->widget_name, array(), array('width' => 500));
        }
    
        function form($instance) {
            $instance = wp_parse_args((array)$instance, $this->get_defaults());
    
            $_tabs = array(
                'global' => array('name' => __("Global", "gd-bbpress-toolbox"), 'include' => array('shared-global', 'shared-display', 'shared-cache')),
                'content' => array('name' => __("Content", "gd-bbpress-toolbox"), 'include' => array('newposts-content')),
                'extra' => array('name' => __("Extra", "gd-bbpress-toolbox"), 'include' => array('shared-wrapper'))
            );
    
            include(GDBBX_PATH.'forms/widgets/shared-loader.php');
        }
    
        function update($new_instance, $old_instance) {
            $instance = $old_instance;
    
            $instance['title'] = strip_tags(stripslashes($new_instance['title']));
            $instance['_display'] = strip_tags(stripslashes($new_instance['_display']));
            $instance['_cached'] = intval(strip_tags(stripslashes($new_instance['_cached'])));
            $instance['_class'] = strip_tags(stripslashes($new_instance['_class']));
            $instance['_tab'] = strip_tags(stripslashes($new_instance['_tab']));
            $instance['_hook'] = sanitize_key($new_instance['_hook']);
    
            $instance['period'] = strip_tags(stripslashes($new_instance['period']));
            $instance['scope'] = strip_tags(stripslashes($new_instance['scope']));
            $instance['limit'] = intval(strip_tags(stripslashes($new_instance['limit'])));
            $instance['display_date'] = strip_tags(stripslashes($new_instance['display_date']));
            $instance['display_author'] = strip_tags(stripslashes($new_instance['display_author']));
    
            if (current_user_can('unfiltered_html')) {
                $instance['before'] = $new_instance['before'];
                $instance['after'] = $new_instance['after'];
            } else {
                $instance['before'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['before'])));
                $instance['after'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['after'])));
            }
    
            return $instance;
        }
    
        function results($instance) {
            $instance = wp_parse_args((array)$instance, $this->get_defaults());
    
            $month = 0;
            $days = 0;
            $years = 0;
            $hours = 1;
    
            $scope = $instance['scope'];
    
            switch ($instance['period']) {
                case 'last_hour':
                    $hours = 2;
                    break;
                default:
                case 'last_day':
                    $days = 1;
                    break;
                case 'last_week':
                    $days = 7;
                    break;
                case 'last_fortnight':
                    $days = 14;
                    break;
                case 'last_month':
                    $month = 1;
                    break;
                case 'last_3months':
                    $month = 3;
                    break;
                case 'last_6months':
                    $month = 6;
                    break;
                case 'last_year':
                    $years = 1;
                    break;
            }
    
            $timestamp = mktime(date('H') - $hours, 0, 0, date('n') - $month, date('j') - $days, date('Y') - $years);
    
            switch ($scope) {
                case 'topic,reply':
                    return gdbbx_get_new_posts($timestamp, 0, $instance['limit']);
                case 'topic':
                    return gdbbx_get_new_posts_topics($timestamp, 0, $instance['limit']);
                case 'reply':
                    return gdbbx_get_new_posts_replies($timestamp, 0, $instance['limit']);
            }
        }
    
        function render($results, $instance) {
            $instance = wp_parse_args((array)$instance, $this->get_defaults());
    
            gdbbx_widget_render_header($instance, 'bbf-newposts');
    
            if (empty($results)) {
                echo '<span class="bbf-no-topics">'.__("No topics found", "gd-bbpress-toolbox").'</span>';
            } else {
                echo '<ul>'.D4P_EOL;
    
                $show_date = isset($instance['display_date']) && $instance['display_date'] == 'yes';
                $show_author = isset($instance['display_author']) && $instance['display_author'] == 'yes';
                $path = gdbbx_get_template_part('gdbbx-widget-newposts.php');
    
                foreach ($results as $post) {
                    include($path);
                }
    
                echo '</ul>'.D4P_EOL;
            }
    
            gdbbx_widget_render_footer($instance);
        }
    }
    
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • If you purchased a product from them they should be supplying you with the necessary assistance and or code on how to achieve this. If they don’t provide support then I would re-consider who your giving your money too.

    As a plugin developer myself, most of my value comes into play with the level of support that I provide to my premium users. Hopefully they feel the same!

    Evan

    Thread Starter wafadul

    (@wafadul)

    already asked him but he said he doesn’t do that…

    anybody, please…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add avatar in New Post widget’ is closed to new replies.