/**
 * Filter a single pin :
 * Remove the "pinner" key if the pinner is the current logged user
 * @param array $raw_pin
 * @return type
 */
function pin_raw_data_remove_self_pinner($raw_pin)
{
    if (!isset($raw_pin['pinner'])) {
        return $raw_pin;
    }
    $user_datas = pinim_tool_page()->get_session_data('user_datas');
    if ($raw_pin['pinner']['username'] != $user_datas['username']) {
        return $raw_pin;
    }
    unset($raw_pin['pinner']);
    return $raw_pin;
}
 function enqueue_scripts_styles($hook)
 {
     $screen = get_current_screen();
     if ($screen->id != pinim_tool_page()->options_page) {
         return;
     }
     wp_enqueue_script('pinim', $this->plugin_url . '_inc/js/pinim.js', array('jquery'), $this->version);
     wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', false, '4.3.0');
     wp_enqueue_style('pinim', $this->plugin_url . '_inc/css/pinim.css', false, $this->version);
     //localize vars
     $localize_vars = array();
     $localize_vars['ajaxurl'] = admin_url('admin-ajax.php');
     $localize_vars['update_warning'] = __('Updating a pin will override it.  Continue ?', 'pinim');
     wp_localize_script('pinim', 'pinimL10n', $localize_vars);
 }
 /**
  * Get an associative array ( id => link ) with the list
  * of views available on this table.
  *
  * @since 3.1.0
  * @access protected
  *
  * @return array
  */
 protected function get_views()
 {
     $link_args = array('step' => 2, 'board_ids' => implode(',', (array) pinim_tool_page()->get_requested_boards_ids()));
     $link_args = array_filter($link_args);
     $link_processed_args = $link_args;
     $link_processed_args['pins_filter'] = 'processed';
     $link_pending_args = $link_args;
     $link_pending_args['pins_filter'] = 'pending';
     $link_processed_classes = array();
     $link_pending_classes = array();
     $processed_count = pinim_tool_page()->get_pins_count_processed();
     $pending_count = pinim_tool_page()->get_pins_count_pending();
     switch (pinim_tool_page()->get_screen_pins_filter()) {
         case 'pending':
             $link_pending_classes[] = 'current';
             break;
         case 'processed':
             $link_processed_classes[] = 'current';
             break;
     }
     $link_processed = sprintf(__('<a href="%1$s"%2$s>%3$s <span class="count">(<span class="imported-count">%4$s</span>)</span></a>'), pinim_get_tool_page_url($link_processed_args), pinim_get_classes($link_processed_classes), __('Processed', 'pinim'), $processed_count);
     $link_pending = sprintf(__('<a href="%1$s"%2$s>%3$s <span class="count">(<span class="imported-count">%4$s</span>)</span></a>'), pinim_get_tool_page_url($link_pending_args), pinim_get_classes($link_pending_classes), __('Pending', 'pinim'), $pending_count);
     return array('pending' => $link_pending, 'processed' => $link_processed);
 }
 /**
  * Get an associative array ( id => link ) with the list
  * of views available on this table.
  *
  * @since 3.1.0
  * @access protected
  *
  * @return array
  */
 protected function get_views()
 {
     $boards_data = pinim_tool_page()->get_session_data('user_boards');
     $link_args = array('step' => 1);
     $link_pending_args = $link_args;
     $link_pending_args['boards_filter'] = 'pending';
     $link_pending_classes = array();
     $pending_count = pinim_tool_page()->get_boards_count_pending();
     $link_completed_args = $link_args;
     $link_completed_args['boards_filter'] = 'completed';
     $link_completed_classes = array();
     $completed_count = pinim_tool_page()->get_boards_count_completed();
     $link_waiting_args = $link_args;
     $link_waiting_args['boards_filter'] = 'waiting';
     $link_waiting_classes = array();
     $waiting_count = pinim_tool_page()->get_boards_count_waiting();
     //
     switch (pinim_tool_page()->get_screen_boards_filter()) {
         case 'pending':
             $link_pending_classes[] = 'current';
             break;
         case 'waiting':
             $link_waiting_classes[] = 'current';
             break;
         case 'completed':
             $link_completed_classes[] = 'current';
             break;
     }
     $link_waiting = sprintf(__('<a href="%1$s"%2$s>%3$s <span class="count">(<span class="imported-count">%4$s</span>)</span></a>'), pinim_get_tool_page_url($link_waiting_args), pinim_get_classes($link_waiting_classes), __('Needs cache refresh', 'pinim'), $waiting_count);
     $link_pending = sprintf(__('<a href="%1$s"%2$s>%3$s <span class="count">(<span class="imported-count">%4$s</span>)</span></a>'), pinim_get_tool_page_url($link_pending_args), pinim_get_classes($link_pending_classes), __('Pending', 'pinim'), $pending_count);
     $link_completed = sprintf(__('<a href="%1$s"%2$s>%3$s <span class="count">(<span class="imported-count">%4$s</span>)</span></a>'), pinim_get_tool_page_url($link_completed_args), pinim_get_classes($link_completed_classes), __('Completed', 'pinim'), $completed_count);
     return array('waiting' => $link_waiting, 'pending' => $link_pending, 'completed' => $link_completed);
 }
 function get_pins_count_processed()
 {
     $count = 0;
     $pins = $this->get_requested_pins();
     foreach ((array) $pins as $pin) {
         if (in_array($pin->pin_id, pinim_tool_page()->existing_pin_ids)) {
             $count++;
         }
     }
     return $count;
 }