In general, the essence is as follows. I have a WP theme, a bulletin board. There you can publish ads, which can then be "highlighted" with color, raised above other ads and other promotion tools. To use these nishtyak, users must pay them. In the subject there are 20 built-in payment methods, but there is not one that would suit me. (All are designed for the market either in India or in England). Question: how to sew there another one, your payment method? I need to embed a button there.
Here is an example code for one of the payment methods. I have no boom boom in php, but if I were told how to remake this code for my needs, I think I could figure it out.
<?php if( !class_exists('Adifier_Bank') ){ class Adifier_Bank{ /* Add paypal options to the theme options */ static public function register_in_options( $sections ){ $sections[] = array( 'title' => esc_html__('Bank Transfer', 'adifier') , 'icon' => '', 'subsection'=> true, 'desc' => esc_html__('Configure Bank Transfer payment.', 'adifier'), 'fields' => array( array( 'id' => 'enable_bank', 'type' => 'select', 'options' => array( 'yes' => esc_html__( 'Yes', 'adifier' ), 'no' => esc_html__( 'No', 'adifier' ) ), 'title' => esc_html__('Enable Bank Transfer', 'adifier') , 'desc' => esc_html__('Enable or disable payment Bank Transfer', 'adifier'), 'default' => 'no' ), array( 'id' => 'bank_account_name', 'type' => 'text', 'title' => esc_html__('Bank Account Name', 'adifier'), 'compiler' => 'true', 'desc' => esc_html__('Input your bank account name.', 'adifier') ), array( 'id' => 'bank_name', 'type' => 'text', 'title' => esc_html__('Bank Name', 'adifier'), 'compiler' => 'true', 'desc' => esc_html__('Input your bank name.', 'adifier') ), array( 'id' => 'bank_account_number', 'type' => 'text', 'title' => esc_html__('Bank Account Number', 'adifier'), 'compiler' => 'true', 'desc' => esc_html__('Input your bank account number.', 'adifier') ), array( 'id' => 'bank_sort_number', 'type' => 'text', 'title' => esc_html__('Sort Number', 'adifier'), 'compiler' => 'true', 'desc' => esc_html__('Input your sort number.', 'adifier') ), array( 'id' => 'bank_iban_number', 'type' => 'text', 'title' => esc_html__('IBAN Code', 'adifier'), 'compiler' => 'true', 'desc' => esc_html__('Input your IBAN code.', 'adifier') ), array( 'id' => 'bank_bic_swift_number', 'type' => 'text', 'title' => esc_html__('BIC / Swift Code', 'adifier'), 'compiler' => 'true', 'desc' => esc_html__('Input your BIC / Swift code.', 'adifier') ), ) ); return $sections; } /* Check payment method */ static public function start_payment(){ if( self::is_enabled() ){ if( !empty( $_GET['screen'] ) && in_array( $_GET['screen'], array( 'ads', 'acc_pay' ) ) ){ add_action( 'wp_enqueue_scripts', 'Adifier_Bank::enqueue_scripts' ); add_action( 'adifier_payment_methods', 'Adifier_Bank::render' ); } add_action( 'adifier_refund_bank', 'Adifier_Bank::refund', 10, 2 ); add_filter( 'adifier_payments_dropdown', 'Adifier_Bank::select_dropdown' ); add_action( 'wp_ajax_bank_execute_payment', 'Adifier_Bank::execute_payment' ); add_action( 'adifier_manual_refund_list', 'Adifier_Bank::add_to_refund_list' ); } } static public function add_to_refund_list( $list ){ $list[] = 'bank'; return $list; } static public function select_dropdown( $dropdown ){ $dropdown['bank'] = esc_html__( 'Bank Transfer', 'adifier' ); return $dropdown; } /* Check if we can actually use paypal */ static public function is_enabled(){ $enable_bank = adifier_get_option( 'enable_bank' ); if( $enable_bank == 'yes' ){ return true; } else{ return false; } } /* Add required scripts and styles */ static public function enqueue_scripts(){ wp_enqueue_script('adifier-bank', get_theme_file_uri( '/js/payments/bank.js' ), array('jquery', 'adifier-purchase'), false, true); wp_enqueue_style( 'adifier-bank', get_theme_file_uri( '/css/payments/bank.css' ) ); } /* Add paypal t the list of the available payments in the frontend */ static public function render(){ ?> <li> <a href="javascript:void(0);" id="bank-button" > <img src="<?php echo esc_url( get_theme_file_uri( '/images/bank.png' ) ); ?>" alt="" width="148" height="42"> </a> </li> <?php } /* Execute refund */ static public function refund( $order, $order_transaction_id ){ Adifier_Order::mark_as_refunded( $order ); } /* Once user have confirmed payment we can execute it */ static public function execute_payment(){ $order = Adifier_Order::get_order(); $order_id = Adifier_Order::create_transient( $order ); if( !empty( $order['price'] ) ){ $result = Adifier_Order::create_order(array( 'order_payment_type' => 'bank', 'order_transaction_id' => '', 'order_id' => $order_id, 'order_paid' => 'no' )); $bank_account_name = adifier_get_option( 'bank_account_name' ); $bank_name = adifier_get_option( 'bank_name' ); $bank_account_number = adifier_get_option( 'bank_account_number' ); $bank_sort_number = adifier_get_option( 'bank_sort_number' ); $bank_iban_number = adifier_get_option( 'bank_iban_number' ); $bank_bic_swift_number = adifier_get_option( 'bank_bic_swift_number' ); ob_start(); ?> <p> <?php printf( esc_html__( 'Make your payment directly into our bank account. Please use %s as the payment reference. Your order won't be processed until the funds have cleared in our account.', 'adifier' ), '<strong>'.$order_id.'</strong>' ); ?> </p> <div class="bank-details-title"> <h5><?php esc_html_e( 'Our Bank Details', 'adifier' ) ?></h5> <?php echo $bank_account_name.' - '.$bank_name; ?> </div> <ul class="list-unstyled list-inline bank-details clearfix"> <li> <p class="small-bank-title"><?php esc_html_e( 'ACCOUNT NUMBER', 'adifier' ); ?></p> <strong><?php echo $bank_account_number ?></strong> </li> <li> <p class="small-bank-title"><?php esc_html_e( 'SORT CODE', 'adifier' ); ?></p> <strong><?php echo $bank_sort_number ?></strong> </li> <li> <p class="small-bank-title"><?php esc_html_e( 'IBAN', 'adifier' ); ?></p> <strong><?php echo $bank_iban_number ?></strong> </li> <li> <p class="small-bank-title"><?php esc_html_e( 'BIC', 'adifier' ); ?></p> <strong><?php echo $bank_bic_swift_number ?></strong> </li> </ul> <?php $content = ob_get_contents(); ob_end_clean(); $results = array_merge( $result, array( 'success' => $content ) ); } else{ $results = array( 'error' => '<div class="alert-error">'.esc_html__( 'We were unable to process your payment at the moment', 'adifier' ).'</div>' ); } echo json_encode( $results ); die(); } } add_filter( 'init', 'Adifier_Bank::start_payment' ); add_filter( 'adifier_payment_options', 'Adifier_Bank::register_in_options' ); } ?>