-
Notifications
You must be signed in to change notification settings - Fork 0
/
superior-wp-testimonial.php
234 lines (203 loc) · 9.01 KB
/
superior-wp-testimonial.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/*
* Plugin Name: Superior WP Testimonial
* Plugin URI: https://wordpress.org/plugins/superior-wp-testimonial/
* Description: Superior WP Testimonial is a plugin for displaying the client's review on the website.
* Version: 1.0
* Requires at least: 6.0
* Requires PHP: 7.2
* Author: Md. Ibrahim Khalil
* Author URI: https://www.ibrahimkhalil.xyz/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: spwptm
*/
/**
* spwptm enqueue styles of this Plugin
**/
function spwptm_enqueue_styles() {
wp_enqueue_style( 'spwptm-owl-carousel', 'https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css' );
wp_enqueue_style( 'spwptm-owl-theme', 'https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css' );
wp_enqueue_style( 'spwptm-fontawesome', plugins_url( 'css/fontawesome-all.min.css', __FILE__) );
wp_enqueue_style( 'spwptm-style', plugins_url( 'css/spwptm-style.css', __FILE__) );
}
add_action( 'wp_enqueue_scripts', 'spwptm_enqueue_styles' );
/**
* spwptm enqueue scripts of this Plugin
**/
function spwptm_enqueue_scripts() {
wp_enqueue_script( 'spwptm-jquery-min', 'https://code.jquery.com/jquery-1.12.0.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'spwptm-owl-min', 'https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'spwptm-script', plugins_url( 'js/spwptm-scripts.js', __FILE__), array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'spwptm_enqueue_scripts' );
/**
* spwptm enqueue (Style & Script) a custom stylesheet in the WordPress admin.
**/
function spwptm_enqueue_custom_admin_style() {
wp_enqueue_style( 'spwptm-admin-style', plugins_url( 'css/spwptm-admin-style.css', __FILE__), false, '1.0.0' );
wp_enqueue_style('wp-color-picker');
wp_enqueue_script('iris-js', admin_url('js/iris.min.js'), array('jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch'), false, 1);
wp_enqueue_script('cp-active-js', plugins_url( 'js/cp-active.js', __FILE__), array('jquery'), '', true);
}
add_action( 'admin_enqueue_scripts', 'spwptm_enqueue_custom_admin_style' );
/**
* Function - spwptm custom post type
**/
if ( ! function_exists('spwptm_custom_post_type') ) {
// spwptm Register Custom Post Type
function spwptm_custom_post_type() {
$labels = array(
'name' => _x( 'Testimonials', 'Post Type General Name', 'spwptm' ),
'singular_name' => _x( 'Testimonial Type', 'Post Type Singular Name', 'spwptm' ),
'menu_name' => __( 'Testimonials', 'spwptm' ),
'name_admin_bar' => __( 'Post Type', 'spwptm' ),
'archives' => __( 'Item Archives', 'spwptm' ),
'attributes' => __( 'Item Attributes', 'spwptm' ),
'parent_item_colon' => __( 'Parent Item:', 'spwptm' ),
'all_items' => __( 'All Items', 'spwptm' ),
'add_new_item' => __( 'Add New Item', 'spwptm' ),
'add_new' => __( 'Add New', 'spwptm' ),
'new_item' => __( 'New Item', 'spwptm' ),
'edit_item' => __( 'Edit Item', 'spwptm' ),
'update_item' => __( 'Update Item', 'spwptm' ),
'view_item' => __( 'View Item', 'spwptm' ),
'view_items' => __( 'View Items', 'spwptm' ),
'search_items' => __( 'Search Item', 'spwptm' ),
'not_found' => __( 'Not found', 'spwptm' ),
'not_found_in_trash' => __( 'Not found in Trash', 'spwptm' ),
'featured_image' => __( 'Featured Image', 'spwptm' ),
'set_featured_image' => __( 'Set featured image', 'spwptm' ),
'remove_featured_image' => __( 'Remove featured image', 'spwptm' ),
'use_featured_image' => __( 'Use as featured image', 'spwptm' ),
'insert_into_item' => __( 'Insert into item', 'spwptm' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'spwptm' ),
'items_list' => __( 'Items list', 'spwptm' ),
'items_list_navigation' => __( 'Items list navigation', 'spwptm' ),
'filter_items_list' => __( 'Filter items list', 'spwptm' ),
);
$args = array(
'label' => __( 'Testimonial Type', 'spwptm' ),
'description' => __( 'Testimonial Description', 'spwptm' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
'menu_icon' => 'dashicons-testimonial',
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'testimonial', $args );
}
add_action( 'init', 'spwptm_custom_post_type', 0 );
}
/**
****************** spwptm post loop function() ******************
**/
function spwptm_testimonial_loop(){
ob_start();
?>
<div id="testimonial-slider" class="owl-carousel">
<?php
// spwptm WP_Query arguments
$args = array(
'post_type' => array( 'testimonial' ),
'post_status' => array( 'publish' ),
'post_per_page' => 10
);
// spwptm loop query
$spwptm_query = new WP_Query( $args );
// spwptm loop for post
if ( $spwptm_query->have_posts() ) {
while ( $spwptm_query->have_posts() ) {
$spwptm_query->the_post();
// post loop logic
?>
<div class="testimonial">
<div class="pic">
<img src="<?php echo get_the_post_thumbnail_url(get_the_ID(),'full'); ?>" alt="<?php the_title(); ?>">
</div>
<h3 class="title"><?php the_title(); ?></h3>
<p class="description"><?php the_excerpt(); ?></p>
<div class="testimonial-content">
<div class="testimonial-profile">
<h3 class="name"><?php echo get_post_meta( get_the_ID(), 'spwptm_testi_name_area', true ); ?></h3>
<span class="post"><?php echo get_post_meta( get_the_ID(), 'spwptm_rating_give', true ); ?></span>
</div>
<ul class="rating">
<?php
//rating print
$spwptm_client_review = get_post_meta( get_the_ID(), 'spwptm_testi_designation', true);
if($spwptm_client_review == 1){
echo "<li class='fa fa-star'></li>";
}elseif($spwptm_client_review == 2){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($spwptm_client_review == 3){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($spwptm_client_review == 4){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($spwptm_client_review == 5){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}elseif($spwptm_client_review == "1.5"){
echo "<li class='fa fa-star'></li><li class='fas fa-star-half'></li>";
}elseif($spwptm_client_review == "2.5"){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fas fa-star-half'></li>";
}elseif($spwptm_client_review == "3.5"){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fas fa-star-half'></li>";
}elseif($spwptm_client_review == "4.5"){
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fas fa-star-half'></li>";
}else{
echo "<li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li><li class='fa fa-star'></li>";
}
?>
</ul>
</div>
</div>
<?php }
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
</div>
<?php
return ob_get_clean();
}
/**
****************** spwptm shortcode ******************
**/
function spwptm_testimonial_shortcode() {
add_shortcode( 'SPWPTESTIMONIAL', 'spwptm_testimonial_loop' );
}
add_action( 'init', 'spwptm_testimonial_shortcode' );
/**
****************** spwptm redirect to plugin's setting page ******************
**/
register_activation_hook(__FILE__, 'spwptm_plugin_activate');
add_action('admin_init', 'spwptm_plugin_redirect');
function spwptm_plugin_activate(){
add_option('spwptm_plugin_do_activation_redirect', true);
}
function spwptm_plugin_redirect(){
if(get_option('spwptm_plugin_do_activation_redirect', false)){
delete_option('spwptm_plugin_do_activation_redirect');
if(!isset($_GET['active-multi']))
{
wp_redirect("edit.php?post_type=testimonial&page=spwptm-settings-pages");
}
}
}
/**
****************** spwptm get all php file ******************
**/
foreach ( glob ( plugin_dir_path( __FILE__ ) ."inc/*.php" ) as $php_file ){
include_once $php_file;
}