интегрировать str_repace в apply_filters () - Wordpress - PullRequest
1 голос
/ 12 января 2020

У меня есть функция в моем плагине WordPress, это часть кода:

            function get_input_fields() {
                $html = '';
                $input_fields = array();
                for ( $i = 1; $i <= apply_filters( 'alg_wc_custom_payment_gateways_values', 1, 'total_input_fields', $this ); $i++ ) {
                    if ( '' !== ( $title = $this->get_option( 'input_fields_title_' . $i, '' ) ) ) {
                        $input_fields[] = array(
                            'title'       => $title,
                            'required'    => ( 'yes' === $this->get_option( 'input_fields_required_' . $i, 'no' ) ),
                            'type'        => $this->get_option( 'input_fields_type_' . $i, 'text' ),
                            'placeholder' => $this->get_option( 'input_fields_placeholder_' . $i, '' ),
                            'class'       => $this->get_option( 'input_fields_class_' . $i, '' ),
                            'value'       => $this->get_option( 'input_fields_value_' . $i, '' ),
                            'options'     => $this->get_option( 'input_fields_options_' . $i, '' ),
                        );
                    }
                }

Мне нужно интегрировать здесь str_replace, что-то вроде этого:

apply_filters( 'alg_wc_custom_payment_gateway_custom_return_url', str_replace( array( '%order_id%', '%order_key%' ), array( $order->get_id(), $order->get_order_key()), htmlspecialchars_decode( $this->custom_return_url ) ), $order )

Код для другой функции.

, поэтому, когда я устанавливаю в wp-admin% order_id%, он должен заменить параметр value на php string в представлении внешнего интерфейса

...