_template; } protected function _render( $options ) { extract( $options ); ob_start(); include $this->_get_template(); $output = ob_get_contents(); ob_end_clean(); return $output; } /** * @param string|null|false $lang * @return string */ public static function get_form_action( $lang = null ) { $path = 'admin-post.php'; if ( false !== $lang ) { if ( ! $lang ) { $lang = $lang ?: FQP::get_curr_lang(); $lang = rawurlencode( $lang ); } $path .= "?lang={$lang}"; } return admin_url( $path ); } public static function get_form_ajax_action( $lang = null ) { $lang = $lang ?: FQP::get_curr_lang(); $lang = rawurlencode( $lang ); return admin_url( "admin-ajax.php?lang={$lang}" ); } public static function get_page_url( $lang = null ) { $url = ''; $option = get_option( FQP::QUOTE_FORM_PAGE_ID_OPTION ); if ( $option ) { if ( null === $lang ) { $lang = FQP::get_curr_lang(); } if ( array_key_exists( $lang, $option ) && !empty( $option[$lang] ) ) { $post_ID = $option[$lang]; } else { $post_ID = reset( $option ); } if ( $post_ID ) { $url = get_permalink( $post_ID ); } } return $url; } protected function _get_template_options() { $options = []; $options['curr_lang'] = FQP::get_curr_lang(); $options['entry_types'] = DB::get_entry_types(); $options['backing_types'] = DB::get_backing_types(); $options['action'] = self::get_form_action(false); return $options; } public function exec() { $options = $this->_get_template_options(); return $this->_render( $options ); } public function sanitize_spaces( array &$data ) { if ( empty( $data ) ) { return $this; } foreach ( $data as &$item ) { if ( is_array( $item ) ) { $this->sanitize_spaces( $item ); } else { $item = trim( $item ); } } return $this; } }