get( $name, $default ); } /** * @tested * @since 3.0.2 */ public function get( $name, $default='' ) { return isset( $_GET[ $name ] ) ? $_GET[ $name ] : $default; } /** * @tested * @since 3.0.2 */ public function post_param( $name, $default='' ) { _deprecated_function( __FUNCTION__, '3.2.3', 'post( $name, $default )' ); return $this->post( $name, $default ); } /** * @since 3.3 */ public function all_request_params() { return $_REQUEST; } /** * @tested * @since 3.0.2 */ public function post( $name, $default='' ) { return isset( $_POST[ $name ] ) ? $_POST[ $name ] : $default; } /** * @tested * @since 3.0.2 */ public function get_query_var( $name, $default='' ) { $value = get_query_var( $name ); return strlen( $value ) === 0 ? $default : $value; } /** * @tested * @since 3.0.2 */ public function get_category_id() { $category_id = $this->param( 'category_id', 0 ); if ( empty( $category_id ) ) { return intval( $this->get_query_var( 'cid' ) ); } else { return intval( $category_id ); } } /** * @tested * @since 3.0.2 */ public function get_ad_id() { return $this->get_current_listing_id(); } /** * @since 3.6.4 */ public function get_current_listing_id() { $listing_id = $this->param( 'adid' ); $listing_id = empty( $listing_id ) ? $this->param( 'id' ) : $listing_id; $listing_id = empty( $listing_id ) ? $this->get_query_var( 'id' ) : $listing_id; return apply_filters( 'awpcp-current-listing-id', intval( $listing_id ) ); } /** * @since 3.3 */ public function get_current_user() { return wp_get_current_user(); } public function is_bot() { if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) { return false; } $regexp = '/' . implode( '|', self::$bot_user_agents_keywords ) . '/'; return (bool) preg_match( $regexp, strtolower( $_SERVER['HTTP_USER_AGENT'] ) ); } }