Skip to content

Commit 7a5e02f

Browse files
authored
Fix/template override not working (#1075)
* fix: various integration template override fixed * phpcs fixes
1 parent 927d4f9 commit 7a5e02f

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

includes/class-dokan-integration.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if ( !class_exists( 'WPUF_Dokan_Integration' ) ) {
3+
if ( ! class_exists( 'WPUF_Dokan_Integration' ) ) {
44

55
/**
66
* WPUF Dokan Integration Class
@@ -10,7 +10,7 @@
1010
class WPUF_Dokan_Integration {
1111

1212
public function __construct() {
13-
add_filter( 'dokan_get_dashboard_nav', [$this, 'add_wpuf_posts_page' ] );
13+
add_filter( 'dokan_get_dashboard_nav', [ $this, 'add_wpuf_posts_page' ] );
1414
add_action( 'dokan_load_custom_template', [ $this, 'load_wpuf_posts_template' ] );
1515
add_filter( 'dokan_query_var_filter', [ $this, 'register_wpuf_posts_queryvar' ] );
1616
add_filter( 'dokan_settings_fields', [ $this, 'dokan_wpuf_settings' ] );
@@ -27,9 +27,9 @@ public function __construct() {
2727
* @return array
2828
*/
2929
public function add_wpuf_posts_page( $urls ) {
30-
$access = dokan_get_option( 'allow_wpuf_post', 'dokan_general' );
30+
$access = dokan_get_option( 'allow_wpuf_post', 'dokan_general' );
3131

32-
if ( $access == 'on' ) {
32+
if ( $access === 'on' ) {
3333
$urls['posts'] = [
3434
'title' => __( 'Posts', 'wp-user-frontend' ),
3535
'icon' => '<i class="fa fa-wordpress"></i>',
@@ -52,7 +52,7 @@ public function add_wpuf_posts_page( $urls ) {
5252
*/
5353
public function load_wpuf_posts_template( $query_vars ) {
5454
if ( isset( $query_vars['posts'] ) ) {
55-
require_once WPUF_ROOT . '/templates/dokan/posts.php';
55+
wpuf_load_template( 'dokan/posts.php' );
5656
}
5757
}
5858

@@ -110,7 +110,7 @@ public function dokan_wpuf_settings( $settings_fields ) {
110110
*
111111
* @return array $post_forms
112112
*/
113-
public function get_post_forms( $post_type='post' ) {
113+
public function get_post_forms( $post_type = 'post' ) {
114114
$post_forms = [];
115115

116116
$args = [
@@ -122,11 +122,11 @@ public function get_post_forms( $post_type='post' ) {
122122
$form_posts = get_posts( $args );
123123

124124
foreach ( $form_posts as $form ) {
125-
$form_settings = wpuf_get_form_settings( $form->ID );
125+
$form_settings = wpuf_get_form_settings( $form->ID );
126126
$form_post_type = isset( $form_settings['post_type'] ) ? $form_settings['post_type'] : '';
127127

128-
if ( $form_post_type == $post_type ) {
129-
$post_forms[$form->ID] = $form->post_title;
128+
if ( $form_post_type === $post_type ) {
129+
$post_forms[ $form->ID ] = $form->post_title;
130130
}
131131
}
132132

includes/class-wc-vendors-integration.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if ( !class_exists( 'WPUF_WC_Vendors_Integration' ) ) {
3+
if ( ! class_exists( 'WPUF_WC_Vendors_Integration' ) ) {
44

55
/**
66
* WC Vendors Integration Class
@@ -63,7 +63,7 @@ public function add_wpuf_options( $settings, $current_section ) {
6363
*
6464
* @return array $post_forms
6565
*/
66-
public function get_post_forms( $post_type='post' ) {
66+
public function get_post_forms( $post_type = 'post' ) {
6767
$post_forms = [];
6868

6969
$args = [
@@ -78,8 +78,8 @@ public function get_post_forms( $post_type='post' ) {
7878
$form_settings = wpuf_get_form_settings( $form->ID );
7979
$form_post_type = isset( $form_settings['post_type'] ) ? $form_settings['post_type'] : '';
8080

81-
if ( $form_post_type == $post_type ) {
82-
$post_forms[$form->ID] = $form->post_title;
81+
if ( $form_post_type === $post_type ) {
82+
$post_forms[ $form->ID ] = $form->post_title;
8383
}
8484
}
8585

@@ -96,13 +96,15 @@ public function get_post_forms( $post_type='post' ) {
9696
* @return array
9797
*/
9898
public function add_wpuf_posts_page() {
99-
$allow_wpuf_post = get_option( 'allow_wcvendors_wpuf_post', 'no' );
99+
$allow_wpuf_post = get_option( 'allow_wcvendors_wpuf_post', 'no' );
100100

101-
if ( $allow_wpuf_post == 'yes' ) {
101+
if ( $allow_wpuf_post === 'yes' ) {
102102
$dashboard_url = get_permalink( get_option( 'wcvendors_vendor_dashboard_page_id' ) );
103-
$post_page_url = add_query_arg( [
104-
'action' => 'post-listing',
105-
], $dashboard_url );
103+
$post_page_url = add_query_arg(
104+
[
105+
'action' => 'post-listing',
106+
], $dashboard_url
107+
);
106108

107109
$output = '<a href="' . $post_page_url . '" class="button">';
108110
$output .= __( 'Posts', 'wp-user-frontend' );
@@ -118,8 +120,8 @@ public function add_wpuf_posts_page() {
118120
public function after_dashboard() {
119121
$action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
120122

121-
if ( $action == 'post-listing' || $action == 'new-post' || $action == 'edit-post' || $action == 'del' ) {
122-
require_once WPUF_ROOT . '/templates/wc-vendors/posts.php'; ?>
123+
if ( $action === 'post-listing' || $action === 'new-post' || $action === 'edit-post' || $action === 'del' ) {
124+
wpuf_load_template( 'wc-vendors/posts.php' ); ?>
123125
<script type="text/javascript">
124126
var WPUFContent = document.querySelector('.wpuf-wc-vendors-submit-post-page');
125127
var WCVendorArea = WPUFContent.parentElement;
@@ -160,7 +162,7 @@ public function after_dashboard() {
160162
background: #007acc;
161163
}
162164
</style>
163-
<?php
165+
<?php
164166
}
165167
}
166168

@@ -199,7 +201,7 @@ public function update_edit_post_redirect_url( $response, $post_id, $form_id, $f
199201
$role = (array) $user->roles;
200202
$selected_form = get_option( 'wcvendors_wpuf_allowed_post_form', '' );
201203

202-
if ( $role[0] == 'vendor' && $form_id == $selected_form && $form_settings['edit_redirect_to'] == 'same' ) {
204+
if ( $role[0] === 'vendor' && $form_id === $selected_form && $form_settings['edit_redirect_to'] === 'same' ) {
203205
$post_page_url = get_permalink( get_option( 'wcvendors_vendor_dashboard_page_id' ) );
204206

205207
$redirect_url = add_query_arg(

includes/class-wcmp-integration.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if ( !class_exists( 'WPUF_WCMp_Integration' ) ) {
3+
if ( ! class_exists( 'WPUF_WCMp_Integration' ) ) {
44

55
/**
66
* WC Marketplace Integration Class
@@ -97,7 +97,7 @@ public function add_dashboard_endpoints( $settings_tab_options ) {
9797
* Update option field data
9898
*/
9999
public function endpoint_option_fields_sanitize( $new_input, $input ) {
100-
if ( isset( $input['wcmp_vendor_submit_post_endpoint'] ) && !empty( $input['wcmp_vendor_submit_post_endpoint'] ) ) {
100+
if ( isset( $input['wcmp_vendor_submit_post_endpoint'] ) && ! empty( $input['wcmp_vendor_submit_post_endpoint'] ) ) {
101101
$new_input['wcmp_vendor_submit_post_endpoint'] = sanitize_text_field( $input['wcmp_vendor_submit_post_endpoint'] );
102102
}
103103

@@ -108,9 +108,9 @@ public function endpoint_option_fields_sanitize( $new_input, $input ) {
108108
* Template for vendor submit post page
109109
*/
110110
public function wcmp_vendor_dashboard_submit_post_endpoint() {
111+
//phpcs:ignore
111112
global $WCMp, $wp;
112-
113-
require_once WPUF_ROOT . '/templates/wc-marketplace/posts.php';
113+
wpuf_load_template( 'wc-marketplace/posts.php' );
114114
}
115115

116116
/**
@@ -157,7 +157,7 @@ public function add_query_var( $query_vars ) {
157157
*
158158
* @return array $post_forms
159159
*/
160-
public function get_post_forms( $post_type='post' ) {
160+
public function get_post_forms( $post_type = 'post' ) {
161161
$post_forms = [];
162162

163163
$args = [
@@ -172,8 +172,8 @@ public function get_post_forms( $post_type='post' ) {
172172
$form_settings = wpuf_get_form_settings( $form->ID );
173173
$form_post_type = isset( $form_settings['post_type'] ) ? $form_settings['post_type'] : '';
174174

175-
if ( $form_post_type == $post_type ) {
176-
$post_forms[$form->ID] = $form->post_title;
175+
if ( $form_post_type === $post_type ) {
176+
$post_forms[ $form->ID ] = $form->post_title;
177177
}
178178
}
179179

@@ -215,7 +215,7 @@ public function update_edit_post_redirect_url( $response, $post_id, $form_id, $f
215215
$role = (array) $user->roles;
216216
$selected_form = ( get_wcmp_vendor_settings( 'wpuf_post_forms', 'general' ) ) ? get_wcmp_vendor_settings( 'wpuf_post_forms', 'general' ) : '';
217217

218-
if ( $role[0] == 'dc_vendor' && $form_id == $selected_form && $form_settings['edit_redirect_to'] == 'same' ) {
218+
if ( $role[0] === 'dc_vendor' && $form_id === $selected_form && $form_settings['edit_redirect_to'] === 'same' ) {
219219
$post_page_url = wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( 'wcmp_vendor_submit_post_endpoint', 'vendor', 'general', 'submit-post' ) );
220220

221221
$redirect_url = add_query_arg(

0 commit comments

Comments
 (0)