Пример #1
0
 function update($new_instance, $old_instance)
 {
     global $bwp_rc;
     $use_settings = isset($new_instance['use_settings']) ? true : false;
     $instances = $bwp_rc->get_instances();
     if (isset($new_instance['instance'])) {
         $new_instance['instance'] = $bwp_rc->format_instance_name($new_instance['instance']);
     }
     if (true == $use_settings) {
         $the_instance = 'bwp_rc_instance_' . str_replace(' ', '_', $new_instance['instance']);
         if (!empty($instances[$the_instance])) {
             $instance = $instances[$the_instance];
         } else {
             $instance = wp_parse_args((array) $new_instance, $bwp_rc->get_default_parameters());
             $instance['separate'] = isset($new_instance['separate']) ? true : false;
             $instance['ajax'] = isset($new_instance['ajax']) ? true : false;
         }
     } else {
         $instance = wp_parse_args((array) $new_instance, $bwp_rc->get_default_parameters());
         $instance['separate'] = isset($new_instance['separate']) ? true : false;
         $instance['ajax'] = isset($new_instance['ajax']) ? true : false;
     }
     $instance['post_id'] = trim($instance['post_id']);
     $instance['limit'] = (int) $instance['limit'];
     $instance['tb_limit'] = (int) $instance['tb_limit'];
     $instance['grouped'] = (int) $instance['grouped'];
     $tb_limit = empty($instance['tb_limit']) && !empty($bwp_rc->options['input_tbs']) ? $bwp_rc->options['input_tbs'] : $instance['tb_limit'];
     $instance['separate'] = !empty($tb_limit) && $instance['separate'] == true ? true : false;
     $instance['title'] = strip_tags($new_instance['title']);
     $instance['instance'] = strip_tags($new_instance['instance']);
     if (empty($instance['instance'])) {
         $instance['instance'] = BWP_RC_LIST;
     }
     bwp_get_recent_comments($instance, false, true);
     return $instance;
 }
Пример #2
0
 function handle_ajax_request()
 {
     $actions = array('older', 'newer');
     // What to do
     if (empty($_GET['bwp_rc_action']) || !in_array($_GET['bwp_rc_action'], $actions)) {
         die(-1);
     }
     $action = $_GET['bwp_rc_action'];
     // Instance name
     if (!empty($_GET['bwp_rc_instance'])) {
         $instance = $this->format_instance_name($_GET['bwp_rc_instance']);
     } else {
         $instance = '';
     }
     // Current page
     if (!empty($_GET['bwp_rc_paged'])) {
         $paged = (int) preg_replace('/[^0-9]+/i', '', $_GET['bwp_rc_paged']);
     }
     // Limit
     if (!empty($_GET['bwp_rc_paged_limit'])) {
         $paged_limit = (int) preg_replace('/[^0-9]+/i', '', $_GET['bwp_rc_paged_limit']);
     }
     // Paged template
     if (!empty($_GET['bwp_rc_paged_template'])) {
         $paged_template = true;
     } else {
         $paged_template = false;
     }
     // Invalidated requests
     if (empty($paged) || empty($paged_limit)) {
         die(-1);
     }
     // Paged
     if ('newer' == $action) {
         $paged = $paged <= 1 ? 1 : $paged - 1;
     } else {
         $paged = $paged + 1;
     }
     // Response with comments
     @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
     @header('X-Content-Type-Options: nosniff');
     bwp_get_recent_comments(array('instance' => $instance, 'paged' => $paged, 'paged_limit' => $paged_limit, 'paged_template' => $paged_template), true, true);
     die;
 }