PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.4.1
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.4.1
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / class-dokan-integration.php

class-dokan-integration.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.4.1, at includes/class-dokan-integration.php

153 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! class_exists( 'weForms_Dokan_Integration' ) ) :
4
5 /**
6 *
7 * Dokan Integration Class
8 *
9 * @since 1.2.9
10 */
11 class weForms_Dokan_Integration{
12
13 function __construct() {
14
15 add_filter( 'dokan_settings_sections', array( $this, 'add_settings_sections' ) );
16 add_filter( 'dokan_get_dashboard_nav', array( $this, 'add_dashboard_nav' ) );
17 add_action( 'dokan_load_custom_template', array( $this, 'load_form_template' ) );
18 add_filter( 'dokan_query_var_filter', array( $this, 'register_queryvar' ) );
19 add_filter( 'dokan_settings_fields', array( $this, 'dokan_settings' ) );
20
21 }
22
23 public function add_settings_sections( $sections ) {
24 $sections[] = array(
25 'id' => 'weforms_integration',
26 'title' => __( 'Vendor Contact Form', 'weforms' ),
27 'icon' => 'dashicons-admin-generic'
28 );
29
30 return $sections;
31 }
32
33 /**
34 * Insert new URL's to the dashboard navigation bar
35 *
36 * @param array $urls
37 *
38 * @since 1.2.9
39 *
40 * @return array $urls
41 */
42 public function add_dashboard_nav( $urls ) {
43 $access = dokan_get_option( 'allow_vendor_contact_form', 'weforms_integration' );
44 $section_label = dokan_get_option( 'vendor_contact_section_label', 'weforms_integration', __( 'Contact Admin', 'weforms' ) );
45
46 if ( $access == 'on' ) {
47 $urls['contact'] = array(
48 'title' => $section_label,
49 'icon' => '<i class="fa fa-envelope-open"></i>',
50 'url' => dokan_get_navigation_url( 'contact' ),
51 'pos' => 67
52 );
53 }
54
55 return $urls;
56 }
57
58 /**
59 * Load template for contact section
60 *
61 * @param array $query_vars
62 *
63 * @since 1.2.9
64 *
65 * @return void
66 */
67 public function load_form_template( $query_vars ) {
68 $access = dokan_get_option( 'allow_vendor_contact_form', 'weforms_integration' );
69
70 if ( isset( $query_vars['contact'] ) && $access == 'on' ) {
71 require_once WEFORMS_ROOT . '/includes/templates/dokan/dashboard-contact-section.php';
72 }
73
74 }
75
76 /**
77 * Register query var
78 *
79 * @param array $query_vars
80 *
81 * @since 1.2.9
82 *
83 * @return array $query_vars
84 */
85 public function register_queryvar( $query_vars ) {
86 $query_vars[] = 'contact';
87
88 return $query_vars;
89 }
90
91 /**
92 * Dokan settings for weForms integration
93 *
94 * @param array $settings_fields
95 *
96 * @since 1.2.9
97 *
98 * @return array $settings_fields
99 */
100 public function dokan_settings( $settings_fields ) {
101 $settings_fields['weforms_integration']['allow_vendor_contact_form'] = array(
102 'name' => 'allow_vendor_contact_form',
103 'label' => __( 'Vendor Can Contact', 'weforms' ),
104 'desc' => __( 'Allow Vendors to contact admin from the dashbaord area', 'weforms' ),
105 'type' => 'checkbox',
106 'default' => 'off'
107 );
108
109 $settings_fields['weforms_integration']['vendor_contact_section_label'] = array(
110 'name' => 'vendor_contact_section_label',
111 'label' => __( 'Contact Section Label', 'weforms' ),
112 'desc' => __( 'Label of contact section to show on vendor dashboard', 'weforms' ),
113 'type' => 'text',
114 'default' => __( 'Contact Admin', 'weforms' )
115 );
116
117 $settings_fields['weforms_integration']['vendor_contact_form'] = array(
118 'name' => 'vendor_contact_form',
119 'label' => __( 'Select Contact Form', 'weforms' ),
120 'desc' => __( 'Select a contact form that will show on the vendor dashboard.', 'weforms' ),
121 'type' => 'select',
122 'options' => $this->get_forms_dropdown_list(),
123 );
124
125 return $settings_fields;
126 }
127
128 /**
129 * Get all the contact forms
130 *
131 * @since 1.2.9
132 *
133 * @return array $post_forms
134 */
135 public function get_forms_dropdown_list() {
136 $list = array();
137 $forms = $this->get_all_forms();
138
139 foreach ( $forms as $form ) {
140 $list[$form->id] = $form->name;
141 }
142 return $list;
143 }
144
145 public function get_all_forms() {
146 $forms_data = weforms()->form->all();
147
148 return $forms_data['forms'];
149 }
150
151 }
152
153 endif;