Get the yes/no response count
@param  int    $postId   Post
@param  string $type     Count or percent
@return array
430851
public static function getResponses($postId, $type = 'count')
    {
        $answers = array('no' => 0, 'yes' => 0);
        $modDate = get_the_modified_date('Y-m-d H:i:s', $postId);

        // Get answer posts
        $answerPosts = new \WP_Query(array(
            'posts_per_page' => -1,
            'post_type' => 'customer-feedback',
            'post_status' => array('publish', 'pending', 'draft'),
            'date_query' => array(
                array(
                    'after'  => $modDate,
                    'inclusive' => true
                ),
            ),
            'meta_query' => array(
                'relation' => 'AND',
                array(
                    'key' => 'customer_feedback_page_reference',
                    'value' => $postId,
                    'comare' => '='
                )
            )
        ));

        // Get answer meta
        foreach ($answerPosts->posts as $item) {
            $answers[get_post_meta($item->ID, 'customer_feedback_answer', true)]++;
        }

        arsort($answers);

        if ($type === 'percent') {
            $total = array_sum($answers);

            $answers = array_map(function ($item) use ($total) {
                if ($total === 0) {
                    return 0;
                }

                return ($item / $total) * 100;
            }, $answers);
        }

        return $answers;
    }
1030666
public function get_post_type($post_type){
    global $wpdb;

    $query = $wpdb->prepare( "SELECT * FROM ".MF_TABLE_POSTTYPES." WHERE type = %s", array( $post_type ) );

    $post_type = $wpdb->get_row( $query, ARRAY_A );
    if($post_type){
      $post_type_id = $post_type['id'];
      $post_type = unserialize($post_type['arguments']);
      $post_type['core']['id'] = $post_type_id;
      return $post_type;
    }
    return false;
  }
529821
private function getTypeByStatus($status)
    {
        if (isset($this->typeList[(int) $status])) {
            return $this->typeList[(int) $status];
        } else {
            return false;
        }
    }
802171
public function countByOrderId($orderId, $statusIds = array(), $comparator = "=")
    {
        return $this->getShippingRepository()->countByOrderId($orderId, $statusIds, $comparator);
    }
230484
public function list(string $msgId, int $index, int $begin, int $count, int $type = 0)
    {
        $params = [
            'msg_data_id' => $msgId,
            'index' => $index,
            'begin' => $begin,
            'count' => $count,
            'type' => $type,
        ];

        return $this->httpPostJson('cgi-bin/comment/list', $params);
    }
67199
public function countInstancesOfType($typeId)
    {
        try {
            return $this->innerGateway->countInstancesOfType($typeId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
686522
public function indexAction($postid)
    {
        $post = $this->getPost($postid);

        $entities = $post->getComments()->toArray();
        usort($entities, function (Comment $a, Comment $b) {
            return $a->getDateCreated() < $b->getDateCreated();
        });

        return array(
            'post'     => $post,
            'entities' => $entities,
        );
    }
69186
protected function get_post_id( $post = null ) {

		return is_a( 'WP_Post', $post ) ? $post->ID : ( is_numeric( $post ) ? absint( $post ) : get_queried_object_id() );

	}
741858
public function count($type='admin.web')
    {
        return $this->task->scopeQuery(function($query)use($type){
                return $query->whereUserId(user_id($type))
                            ->whereUserType(user_type($type));
            })->count();
    }
821597
public function voteNeutral($post_id)
    {
        $this->checkId($post_id);

        return $this->vote($post_id, self::VOTE_NEUTRAL);
    }
64232
public static function isChildPost($postOrPostId = null)
    {
        $post = self::getPost($postOrPostId);
        if (empty($post)) {
            return false;
        }

        return $post->post_parent > 0;
    }
923825
public function getAllComments(string $type, int $typeId)
    {
        $type = strtolower($type);

        if (('project' !== $type && 'task' !== $type) || ! $this->validateId($typeId)) {
            return false;
        }

        $query  = http_build_query([$type . '_id' => $typeId], null, '&', PHP_QUERY_RFC3986);
        $result = $this->get('comments?' . $query);

        $status = $result->getStatusCode();
        if (204 === $status) {
            return [];
        }
        if (200 === $status) {
            return json_decode($result->getBody()->getContents());
        }

        return false;
    }
51680
public static function get_post_type_date_archive_support( $post_type ) {
		if ( is_string( $post_type ) ) {
			$post_type = get_post_type_object( $post_type );
		}

		if ( ! empty( $post_type->cptp ) && isset( $post_type->cptp['date_archive'] ) ) {
			return ! ! $post_type->cptp['date_archive'];
		}

		return true;
	}
652062
public function getPermalinkAfter($postId, $post)
    {
        if (wp_is_post_revision($postId)) {
            return;
        }

        remove_action('save_post', array($this, 'getPermalinkAfter'), 10, 2);

        $this->permalinkAfter = get_permalink($this->postId);

        if ($post->post_status === 'trash') {
            $this->trashed = true;
        }

        if ($this->permalinkBefore && !empty($this->permalinkBefore)) {
            $this->detectChangedPermalink();
        }
    }
1339782
public function list(string $type, int $offset = 0, int $count = 20)
    {
        return Response::json($this->curl->post(self::LIST.$this->access_token, json_encode([
                    'type' => $type,
                    'offset' => $offset,
                    'count' => $count,
                ]
            )
        )
        );
    }
1156306
def query_by_postid(postid, limit=5):
        '''
        
        '''
        recs = TabPostHist.select().where(
            TabPostHist.post_id == postid
        ).order_by(
            TabPostHist.time_update.desc()
        ).limit(limit)
        return recs
284730
public function getById($typeId, array $queryParams = [])
    {
        $response = $this->api
            ->applications()
            ->scans()
            ->issues()
            ->origins()
            ->types()
            ->getById($typeId, $queryParams);

        return new TypeResponse($response);
    }