[], 'hr' => ['class' => [], 'style' => []], 'a' => ['href' => ['protocols' => ['http', 'https', 'mailto']], 'target' => [], 'class' => [], 'style' => []], 'i' => ['class' => [], 'style' => []], 'em' => ['class' => [], 'style' => []], 'strong' => ['class' => [], 'style' => []], 'b' => ['class' => [], 'style' => []], 'span' => ['class' => [], 'style' => []], 'div' => ['class' => [], 'style' => []], 'h1' => ['class' => [], 'style' => []], 'h2' => ['class' => [], 'style' => []], 'h3' => ['class' => [], 'style' => []], 'h4' => ['class' => [], 'style' => []], 'h5' => ['class' => [], 'style' => []], 'h6' => ['class' => [], 'style' => []], ]; public static $allow_only_svg = [ 'svg' => [ 'xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, 'fill' => true, 'stroke' => true, ], 'g' => [ 'fill' => true, 'stroke' => true, ], 'path' => [ 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'fill-rule' => true, ], 'circle' => [ 'cx' => true, 'cy' => true, 'r' => true, 'fill' => true, ], 'rect' => [ 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'fill' => true, ], ]; #region General views /** * Echo a view * @param $view * @param $model */ public static function partial($view, $model = null) { ob_start(); $dir = trailingslashit(wapf_get_setting('path')) . 'views/' . $view; include $dir . '.php'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ob_get_clean(); } /** * return a view. * @param $view * @param $model * * @return string */ public static function view($view, $model = null) { ob_start(); $dir = trailingslashit(wapf_get_setting('path')) . 'views/' . $view; include $dir . '.php'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return ob_get_clean(); } #endregion #region Admin Functions public static function help_modal($text,$title = '', $button_text = '') { $model = [ 'content' => $text, 'title' => $title, 'button' => $button_text ]; ob_start(); $path = trailingslashit(wapf_get_setting('path')) . 'views/admin/help-modal.php'; include $path; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ob_get_clean(); } public static function setting($model = []) { if(!isset($model['type'])) return; ob_start(); $dir = trailingslashit(wapf_get_setting('path')) . 'views/admin/settings/' . $model['type']; include $dir . '.php'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ob_get_clean(); } public static function admin_field($field = [], $type = 'wapf_product') { ob_start(); $path = trailingslashit(wapf_get_setting('path')) . 'views/admin/field.php'; include $path; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ob_get_clean(); } public static function wp_list_table($view_name,$model,$list) { ob_start(); $path = trailingslashit(wapf_get_setting('path')) . 'views/admin/'.$view_name.'.php'; include $path; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ob_get_clean(); } #endregion #region Product-related Functions public static function product_totals( $product ) { $product_id = $product->get_id(); $product_type = $product->get_type() === 'variation' ? 'variable' : $product->get_type(); $product_price = wc_get_price_to_display( $product ); ob_start(); $path = trailingslashit( wapf_get_setting( 'path' ) ) . 'views/frontend/product-totals.php'; include $path; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $totals_html = ob_get_clean(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo apply_filters( 'wapf/html/product_totals', $totals_html, $product ); } #endregion #region Field Groups and Fields public static function field_group($product, FieldGroup $field_group, $data = [] ) { if(empty($field_group) || empty($field_group->fields)) return ''; ob_start(); $dir = trailingslashit(wapf_get_setting('path')) . 'views/frontend/field-group.php'; include $dir; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return ob_get_clean(); } public static function field($product,Field $field, $fieldgroup_id) { $model = [ 'product' => $product, 'field' => $field, 'field_value' => self::field_value($field), 'field_attributes' => self::field_attributes($product,$field,$fieldgroup_id) ]; // Prior to 1.5.7, the "paragraph" file name would be used but then if they upgrade // to premium, it would throw error because there "content.php" is used. // We can probably delete this a year after 1.5.7 is released. $file_name = sanitize_key( $field->type === 'paragraph' ? 'content' : $field->type ); return self::view('frontend/fields/' . $file_name, $model); } public static function field_description(Field $field) { if(!empty($field->description)) { return '