svg_gnerator = $svg_generator; } /** * Get bank icon html. * * @param int $bank_id Bank id. * @param string $bank_name Bank name. * @param string $text Bank description. * @param string $cc_id CC id data. * @param string $class Additional class. * @param string $onclick On click JavaScript code. * @param bool $with_input Generate additional form. * @return string */ public function get_bank_html( $bank_id, $bank_name, $text = '', $cc_id = '', $class = '', $onclick = '', $with_input = false ) { $bank_id = sanitize_text_field( $bank_id ); $bank_name = sanitize_text_field( $bank_name ); $text = sanitize_text_field( $text ); $cc_id = sanitize_text_field( $cc_id ); $class = sanitize_text_field( $class ); $onclick = sanitize_text_field( $onclick ); $with_input = sanitize_text_field( $with_input ); $css = $this->get_logo_css( $bank_id, true ); return '' . ( empty( $cc_id ) ? '' : '' ) . '
' . $bank_name . '
' . ( $with_input ? "" : '' ) . '
'; } /** * Get pay now html due to lack of proper template machine. * * @param int $bank_id The id of a bank. * @param string $bank_name The name of a bank. * * @return string */ public function get_pay_now_html( $bank_id = 266, $bank_name = '' ) { $css = $this->get_logo_css( $bank_id, true ); $logo = sprintf( '', $css ); $text = sprintf( '
%s
', $bank_name ); return sprintf( '
%s%s
', $bank_id, 'payments-extra-promoted extra-promoted-box text-center', $logo, $text ); } /** * Get logo CSS. * * @param int $bank_id The id of a bank. * @param bool $mobile True if a mobile icon is requested. * @return string */ private function get_logo_css( $bank_id, $mobile ) { $bg_image = $this->svg_gnerator->get_icon( $bank_id, $mobile ); if ( $bg_image ) { $css = "background-image: url('$bg_image')"; } else { $css = ''; } return $css; } }