user_id = intval( $params['user_id'] ); } else { $this->user_id = get_current_user_id(); } if ( $this->user_id === 0 ) { $this->user_id = null; } else { $user = get_user_by( 'id', $this->user_id ); if ( $user === false || $user->ID === 0 ) { $this->user_id = null; } } // order if ( isset( $params['order'] ) ) { $this->order = intval( $params['order'] ); } } /** * Outputs the dashboard section's template. */ public function render() { if ( !$this->require_user_id || $this->user_id !== null ) { Affiliates_Templates::include_template( $this->template, array( 'section' => $this ) ); } } /** * {@inheritDoc} * @see I_Affiliates_Dashboard_Section::get_url_parameters() */ public function get_url_parameters() { return $this->url_parameters; } /** * Returns the user ID related to this instance. * * @return int or null */ public function get_user_id() { return $this->user_id; } /** * {@inheritDoc} * @see I_Affiliates_Dashboard_Section::get_affiliate_id() */ public function get_affiliate_id() { $affiliate_id = null; if ( $this->user_id !== null ) { if ( affiliates_user_is_affiliate( $this->get_user_id() ) ) { $affiliate_ids = affiliates_get_user_affiliate( $this->get_user_id() ); $affiliate_id = array_shift( $affiliate_ids ); } } return $affiliate_id; } }