1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Shortcodes; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Database; |
6
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\TinymcePopupGenerator; |
7
|
|
|
|
8
|
|
|
class SiteReviewsFormPopup extends TinymcePopupGenerator |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @return array |
12
|
|
|
*/ |
13
|
1 |
|
public function fields() |
14
|
|
|
{ |
15
|
|
|
return [[ |
16
|
1 |
|
'type' => 'container', |
17
|
1 |
|
'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
18
|
|
|
],[ |
19
|
1 |
|
'label' => esc_html__( 'Title', 'site-reviews' ), |
20
|
1 |
|
'name' => 'title', |
21
|
1 |
|
'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
22
|
1 |
|
'type' => 'textbox', |
23
|
|
|
],[ |
24
|
1 |
|
'label' => esc_html__( 'Description', 'site-reviews' ), |
25
|
1 |
|
'minHeight' => 60, |
26
|
1 |
|
'minWidth' => 240, |
27
|
|
|
'multiline' => true, |
28
|
1 |
|
'name' => 'description', |
29
|
1 |
|
'tooltip' => __( 'Enter a custom shortcode description.', 'site-reviews' ), |
30
|
1 |
|
'type' => 'textbox', |
31
|
|
|
], |
32
|
1 |
|
$this->getTerms(), |
33
|
|
|
[ |
34
|
1 |
|
'label' => esc_html__( 'Assign To', 'site-reviews' ), |
35
|
1 |
|
'name' => 'assign_to', |
36
|
1 |
|
'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ), |
37
|
1 |
|
'type' => 'textbox', |
38
|
|
|
],[ |
39
|
1 |
|
'label' => esc_html__( 'Classes', 'site-reviews' ), |
40
|
1 |
|
'name' => 'class', |
41
|
1 |
|
'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
42
|
1 |
|
'type' => 'textbox', |
43
|
|
|
],[ |
44
|
1 |
|
'columns' => 2, |
45
|
|
|
'items' => [[ |
46
|
1 |
|
'name' => 'hide_content', |
47
|
1 |
|
'text' => esc_html__( 'Content', 'site-reviews' ), |
48
|
1 |
|
'tooltip' => __( 'Hide the content field?', 'site-reviews' ), |
49
|
1 |
|
'type' => 'checkbox', |
50
|
|
|
],[ |
51
|
1 |
|
'name' => 'hide_email', |
52
|
1 |
|
'text' => esc_html__( 'Email', 'site-reviews' ), |
53
|
1 |
|
'tooltip' => __( 'Hide the email field?', 'site-reviews' ), |
54
|
1 |
|
'type' => 'checkbox', |
55
|
|
|
],[ |
56
|
1 |
|
'name' => 'hide_name', |
57
|
1 |
|
'text' => esc_html__( 'Name', 'site-reviews' ), |
58
|
1 |
|
'tooltip' => __( 'Hide the name field?', 'site-reviews' ), |
59
|
1 |
|
'type' => 'checkbox', |
60
|
|
|
],[ |
61
|
1 |
|
'name' => 'hide_rating', |
62
|
1 |
|
'text' => esc_html__( 'Rating', 'site-reviews' ), |
63
|
1 |
|
'tooltip' => __( 'Hide the rating field?', 'site-reviews' ), |
64
|
1 |
|
'type' => 'checkbox', |
65
|
|
|
],[ |
66
|
1 |
|
'name' => 'hide_terms', |
67
|
1 |
|
'text' => esc_html__( 'Terms', 'site-reviews' ), |
68
|
1 |
|
'tooltip' => __( 'Hide the terms field?', 'site-reviews' ), |
69
|
1 |
|
'type' => 'checkbox', |
70
|
|
|
],[ |
71
|
1 |
|
'name' => 'hide_title', |
72
|
1 |
|
'text' => esc_html__( 'Title', 'site-reviews' ), |
73
|
1 |
|
'tooltip' => __( 'Hide the title field?', 'site-reviews' ), |
74
|
1 |
|
'type' => 'checkbox', |
75
|
|
|
]], |
76
|
1 |
|
'label' => esc_html__( 'Hide', 'site-reviews' ), |
77
|
1 |
|
'layout' => 'grid', |
78
|
1 |
|
'spacing' => 5, |
79
|
1 |
|
'type' => 'container', |
80
|
|
|
],[ |
81
|
|
|
'hidden' => true, |
82
|
|
|
'name' => 'id', |
83
|
|
|
'type' => 'textbox', |
84
|
|
|
]]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
1 |
|
public function getTerms() |
91
|
|
|
{ |
92
|
1 |
|
$terms = glsr( Database::class )->getTerms(); |
93
|
1 |
|
if( empty( $terms )) { |
94
|
1 |
|
return []; |
95
|
|
|
} |
96
|
|
|
return [ |
97
|
|
|
'label' => esc_html__( 'Category', 'site-reviews' ), |
98
|
|
|
'name' => 'category', |
99
|
|
|
'options' => $terms, |
100
|
|
|
'tooltip' => __( 'Automatically assign a category to reviews submitted with this shortcode.', 'site-reviews' ), |
101
|
|
|
'type' => 'listbox', |
102
|
|
|
]; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|