Version Description
- Released!
=
Download this release
Release Info
Developer | richardgabriel |
Plugin | Easy Testimonials |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- css/style.css +19 -0
- easy-testimonials.php +190 -0
- include/easy_testimonial_options.php +77 -0
- include/ik-custom-post-type.php +235 -0
- random_testimonial_widget.php +57 -0
- readme.txt +48 -0
css/style.css
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* CSS */
|
2 |
+
blockquote.easy_testimonial{
|
3 |
+
}
|
4 |
+
|
5 |
+
blockquote.easy_testimonial p{
|
6 |
+
}
|
7 |
+
|
8 |
+
blockquote.easy_testimonial p a{
|
9 |
+
}
|
10 |
+
|
11 |
+
blockquote.easy_testimonial p a:hover{
|
12 |
+
}
|
13 |
+
|
14 |
+
blockquote.easy_testimonial cite{
|
15 |
+
}
|
16 |
+
|
17 |
+
.widgets blockquote.easy_testimonial{
|
18 |
+
margin: 5px auto;
|
19 |
+
}
|
easy-testimonials.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Easy Testimonials
|
4 |
+
Plugin URI: http://illuminatikarate.com/easy-testimonials/
|
5 |
+
Description: Easy Testimonials - Provides custom post type, shortcode, sidebar widget, and other functionality for testimonials.
|
6 |
+
Author: Illuminati Karate
|
7 |
+
Version: 1.0
|
8 |
+
Author URI: http://illuminatikarate.com
|
9 |
+
|
10 |
+
This file is part of Easy Testimonials.
|
11 |
+
|
12 |
+
Easy Testimonials is free software: you can redistribute it and/or modify
|
13 |
+
it under the terms of the GNU General Public License as published by
|
14 |
+
the Free Software Foundation, either version 3 of the License, or
|
15 |
+
(at your option) any later version.
|
16 |
+
|
17 |
+
Easy Testimonials is distributed in the hope that it will be useful,
|
18 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
+
GNU General Public License for more details.
|
21 |
+
|
22 |
+
You should have received a copy of the GNU General Public License
|
23 |
+
along with Easy Testimonials . If not, see <http://www.gnu.org/licenses/>.
|
24 |
+
*/
|
25 |
+
|
26 |
+
//add Testimonial CSS to header
|
27 |
+
function ik_setup_css() {
|
28 |
+
wp_register_style( 'easy_testimonial_style', plugins_url('css/style.css', __FILE__) );
|
29 |
+
wp_enqueue_style( 'easy_testimonial_style' );
|
30 |
+
}
|
31 |
+
|
32 |
+
if(!function_exists('word_trim')):
|
33 |
+
function word_trim($string, $count, $ellipsis = FALSE)
|
34 |
+
{
|
35 |
+
$words = explode(' ', $string);
|
36 |
+
if (count($words) > $count)
|
37 |
+
{
|
38 |
+
array_splice($words, $count);
|
39 |
+
$string = implode(' ', $words);
|
40 |
+
// trim of punctionation
|
41 |
+
$string = rtrim($string, ',;.');
|
42 |
+
|
43 |
+
// add ellipsis if needed
|
44 |
+
if (is_string($ellipsis)) {
|
45 |
+
$string .= $ellipsis;
|
46 |
+
} elseif ($ellipsis) {
|
47 |
+
$string .= '…';
|
48 |
+
}
|
49 |
+
}
|
50 |
+
return $string;
|
51 |
+
}
|
52 |
+
endif;
|
53 |
+
|
54 |
+
//setup custom post type for testimonials
|
55 |
+
function ik_setup_testimonials(){
|
56 |
+
//include custom post type code
|
57 |
+
include('include/ik-custom-post-type.php');
|
58 |
+
//include options code
|
59 |
+
include('include/easy_testimonial_options.php');
|
60 |
+
$easy_testimonial_options = new easyTestimonialOptions();
|
61 |
+
|
62 |
+
//setup post type for testimonials
|
63 |
+
$postType = array('name' => 'Testimonial', 'plural' =>'Testimonials' );
|
64 |
+
$fields = array();
|
65 |
+
$fields[] = array('name' => 'client', 'title' => 'Client Name', 'description' => "Name of the Client giving the testimonial. Appears below the Testimonial.", 'type' => 'text');
|
66 |
+
$fields[] = array('name' => 'position', 'title' => 'Position / Location / Other', 'description' => "The information that appears below the client's name.", 'type' => 'text');
|
67 |
+
$myCustomType = new ikTestimonialsCustomPostType($postType, $fields);
|
68 |
+
}
|
69 |
+
|
70 |
+
//load testimonials into an array and output a random one
|
71 |
+
function outputRandomTestimonial($atts){
|
72 |
+
//load shortcode attributes into an array
|
73 |
+
extract( shortcode_atts( array(
|
74 |
+
'testimonials_link' => get_option('testimonials_link'),
|
75 |
+
'word_limit' => false,
|
76 |
+
'body_class' => 'testimonial_body',
|
77 |
+
'author_class' => 'testimonial_author',
|
78 |
+
'short_version' => false,
|
79 |
+
), $atts ) );
|
80 |
+
|
81 |
+
//load testimonials into an array
|
82 |
+
$i = 0;
|
83 |
+
$loop = new WP_Query(array( 'post_type' => 'testimonial','posts_per_page' => '-1'));
|
84 |
+
while($loop->have_posts()) : $loop->the_post();
|
85 |
+
$postid = get_the_ID();
|
86 |
+
$testimonials[$i]['content'] = get_post_meta($postid, '_ikcf_short_content', true);
|
87 |
+
|
88 |
+
//if nothing is set for the short content, use the long content
|
89 |
+
if(strlen($testimonials[$i]['content']) < 2){
|
90 |
+
$testimonials[$i]['content'] = get_the_content($postid);
|
91 |
+
}
|
92 |
+
|
93 |
+
if ($word_limit) {
|
94 |
+
$testimonials[$i]['content'] = word_trim($testimonials[$i]['content'], 65, TRUE);
|
95 |
+
}
|
96 |
+
|
97 |
+
$testimonials[$i]['client'] = get_post_meta($postid, '_ikcf_client', true);
|
98 |
+
$testimonials[$i]['position'] = get_post_meta($postid, '_ikcf_position', true);
|
99 |
+
$i++;
|
100 |
+
endwhile;
|
101 |
+
wp_reset_query();
|
102 |
+
|
103 |
+
$rand = rand(0, $i-1);
|
104 |
+
|
105 |
+
ob_start();
|
106 |
+
|
107 |
+
if(!$short_version){
|
108 |
+
?><blockquote class="easy_testimonial">
|
109 |
+
<p class="<?=$body_class?>">
|
110 |
+
<?=$testimonials[$rand]['content'];?>
|
111 |
+
<?php if(strlen($testimonials_link)>2):?><a href="<?php echo $testimonials_link; ?>">Read More</a><?php endif; ?></p>
|
112 |
+
<?php if(strlen($testimonials[$rand]['client'])>0 || strlen($testimonials[$rand]['position'])>0 ): ?>
|
113 |
+
<p class="<?=$author_class?>">
|
114 |
+
<cite><?=$testimonials[$rand]['client'];?><br/><?=$testimonials[$rand]['position'];?></cite>
|
115 |
+
</p>
|
116 |
+
<?php endif; ?>
|
117 |
+
</blockquote><?php
|
118 |
+
} else {
|
119 |
+
echo $testimonials[$rand]['content'];
|
120 |
+
}
|
121 |
+
|
122 |
+
$content = ob_get_contents();
|
123 |
+
ob_end_clean();
|
124 |
+
|
125 |
+
return $content;
|
126 |
+
}
|
127 |
+
|
128 |
+
//output all testimonials
|
129 |
+
function outputTestimonials($atts){
|
130 |
+
|
131 |
+
//load shortcode attributes into an array
|
132 |
+
extract( shortcode_atts( array(
|
133 |
+
'testimonials_link' => get_option('testimonials_link')
|
134 |
+
), $atts ) );
|
135 |
+
|
136 |
+
ob_start();
|
137 |
+
|
138 |
+
//load testimonials into an array
|
139 |
+
$loop = new WP_Query(array( 'post_type' => 'testimonial','posts_per_page' => '-1'));
|
140 |
+
while($loop->have_posts()) : $loop->the_post();
|
141 |
+
$postid = get_the_ID();
|
142 |
+
$testimonial['content'] = get_post_meta($postid, '_ikcf_short_content', true);
|
143 |
+
|
144 |
+
//if nothing is set for the short content, use the long content
|
145 |
+
if(strlen($testimonial['content']) < 2){
|
146 |
+
$testimonial['content'] = get_the_content($postid);
|
147 |
+
}
|
148 |
+
|
149 |
+
$testimonial['client'] = get_post_meta($postid, '_ikcf_client', true);
|
150 |
+
$testimonial['position'] = get_post_meta($postid, '_ikcf_position', true);
|
151 |
+
|
152 |
+
?><blockquote class="easy_testimonial">
|
153 |
+
<p>
|
154 |
+
<?=$testimonial['content'];?>
|
155 |
+
<?php if(strlen($testimonials_link)>2):?><a href="<?php echo $testimonials_link; ?>">Read More</a><?php endif; ?></p>
|
156 |
+
<?php if(strlen($testimonial['client'])>0 || strlen($testimonial['position'])>0 ): ?>
|
157 |
+
<p>
|
158 |
+
<cite><?=$testimonial['client'];?><br/><?=$testimonial['position'];?></cite>
|
159 |
+
</p>
|
160 |
+
<?php endif; ?>
|
161 |
+
</blockquote><?php
|
162 |
+
endwhile;
|
163 |
+
wp_reset_query();
|
164 |
+
|
165 |
+
$content = ob_get_contents();
|
166 |
+
ob_end_clean();
|
167 |
+
|
168 |
+
return $content;
|
169 |
+
}
|
170 |
+
|
171 |
+
//register any widgets here
|
172 |
+
function easy_testimonials_register_widgets() {
|
173 |
+
include('random_testimonial_widget.php');
|
174 |
+
|
175 |
+
register_widget( 'randomTestimonialWidget' );
|
176 |
+
}
|
177 |
+
|
178 |
+
//create shortcodes
|
179 |
+
add_shortcode('random_testimonial', 'outputRandomTestimonial');
|
180 |
+
add_shortcode('testimonials', 'outputTestimonials');
|
181 |
+
|
182 |
+
//add CSS
|
183 |
+
add_action( 'wp_head', 'ik_setup_css' );
|
184 |
+
|
185 |
+
//register sidebar widgets
|
186 |
+
add_action( 'widgets_init', 'easy_testimonials_register_widgets' );
|
187 |
+
|
188 |
+
//do stuff
|
189 |
+
add_action( 'after_setup_theme', 'ik_setup_testimonials' );
|
190 |
+
?>
|
include/easy_testimonial_options.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This file is part of Easy Testimonials.
|
4 |
+
|
5 |
+
Easy Testimonials is free software: you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License as published by
|
7 |
+
the Free Software Foundation, either version 3 of the License, or
|
8 |
+
(at your option) any later version.
|
9 |
+
|
10 |
+
Easy Testimonials is distributed in the hope that it will be useful,
|
11 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
GNU General Public License for more details.
|
14 |
+
|
15 |
+
You should have received a copy of the GNU General Public License
|
16 |
+
along with The Easy Testimonials. If not, see <http://www.gnu.org/licenses/>.
|
17 |
+
*/
|
18 |
+
|
19 |
+
class easyTestimonialOptions
|
20 |
+
{
|
21 |
+
function __construct(){
|
22 |
+
//may be running in non WP mode (for example from a notification)
|
23 |
+
if(function_exists('add_action')){
|
24 |
+
//add a menu item
|
25 |
+
add_action('admin_menu', array($this, 'add_admin_menu_item'));
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function add_admin_menu_item(){
|
30 |
+
$title = "Easy Testimonial Settings";
|
31 |
+
$page_title = "Easy Testimonials Settings";
|
32 |
+
|
33 |
+
//create new top-level menu
|
34 |
+
add_menu_page($page_title, $title, 'administrator', __FILE__, array($this, 'settings_page'));
|
35 |
+
|
36 |
+
//call register settings function
|
37 |
+
add_action( 'admin_init', array($this, 'register_settings'));
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
function register_settings(){
|
42 |
+
//register our settings
|
43 |
+
register_setting( 'easy-testimonials-settings-group', 'testimonials_link' );
|
44 |
+
}
|
45 |
+
|
46 |
+
function settings_page(){
|
47 |
+
$title = "Easy Testimonials Settings";
|
48 |
+
$message = "Easy Testimonials Settings Updated.";
|
49 |
+
?>
|
50 |
+
<div class="wrap">
|
51 |
+
<h2><?php echo $title; ?></h2>
|
52 |
+
|
53 |
+
<?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') : ?>
|
54 |
+
<div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<form method="post" action="options.php">
|
58 |
+
<?php settings_fields( 'easy-testimonials-settings-group' ); ?>
|
59 |
+
|
60 |
+
<table class="form-table">
|
61 |
+
<tr valign="top">
|
62 |
+
<th scope="row"><label for="testimonials_link">Testimonials Read More Link</label></th>
|
63 |
+
<td><input type="text" name="testimonials_link" id="testimonials_link" value="<?php echo get_option('testimonials_link'); ?>" style="width: 250px" />
|
64 |
+
<p class="description">This is the URL of the 'Read More' Link. If not set, no Read More Link is output. If set, Read More Link will be output next to testimonial that will go to this page.</p>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
</table>
|
68 |
+
|
69 |
+
<p class="submit">
|
70 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
71 |
+
</p>
|
72 |
+
</form>
|
73 |
+
</div>
|
74 |
+
<?php } // end settings_page function
|
75 |
+
|
76 |
+
} // end class
|
77 |
+
?>
|
include/ik-custom-post-type.php
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This file is part of Easy Testimonials.
|
4 |
+
|
5 |
+
Easy Testimonials is free software: you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License as published by
|
7 |
+
the Free Software Foundation, either version 3 of the License, or
|
8 |
+
(at your option) any later version.
|
9 |
+
|
10 |
+
Easy Testimonials is distributed in the hope that it will be useful,
|
11 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
GNU General Public License for more details.
|
14 |
+
|
15 |
+
You should have received a copy of the GNU General Public License
|
16 |
+
along with Easy Testimonials. If not, see <http://www.gnu.org/licenses/>.
|
17 |
+
*/
|
18 |
+
class ikTestimonialsCustomPostType
|
19 |
+
{
|
20 |
+
var $customFields = false;
|
21 |
+
var $customPostTypeName = 'custompost';
|
22 |
+
var $customPostTypeSingular = 'customPost';
|
23 |
+
var $customPostTypePlural = 'customPosts';
|
24 |
+
var $prefix = '_ikcf_';
|
25 |
+
|
26 |
+
function setupCustomPostType($postType)
|
27 |
+
{
|
28 |
+
$singular = ucwords($postType['name']);
|
29 |
+
$plural = isset($postType['plural']) ? ucwords($postType['plural']) : $singular . 's';
|
30 |
+
|
31 |
+
$this->customPostTypeName = strtolower($singular);
|
32 |
+
$this->customPostTypeSingular = $singular;
|
33 |
+
$this->customPostTypePlural = $plural;
|
34 |
+
|
35 |
+
if ($this->customPostTypeName != 'post' && $this->customPostTypeName != 'page')
|
36 |
+
{
|
37 |
+
$labels = array
|
38 |
+
(
|
39 |
+
'name' => _x($plural, 'post type general name'),
|
40 |
+
'singular_name' => _x($singular, 'post type singular name'),
|
41 |
+
'add_new' => _x('Add New ' . $singular, strtolower($singular)),
|
42 |
+
'add_new_item' => __('Add New ' . $singular),
|
43 |
+
'edit_item' => __('Edit ' . $singular),
|
44 |
+
'new_item' => __('New ' . $singular),
|
45 |
+
'view_item' => __('View ' . $singular),
|
46 |
+
'search_items' => __('Search ' . $plural),
|
47 |
+
'not_found' => __('No ' . strtolower($plural) . ' found'),
|
48 |
+
'not_found_in_trash' => __('No ' . strtolower($plural) . ' found in Trash'),
|
49 |
+
'parent_item_colon' => ''
|
50 |
+
);
|
51 |
+
|
52 |
+
$args = array(
|
53 |
+
'labels' => $labels,
|
54 |
+
'public' => true,
|
55 |
+
'publicly_queryable' => true,
|
56 |
+
'show_ui' => true,
|
57 |
+
'query_var' => true,
|
58 |
+
'rewrite' => true,
|
59 |
+
'capability_type' => 'post',
|
60 |
+
'hierarchical' => false,
|
61 |
+
'menu_position' => 20,
|
62 |
+
'supports' => array('title','editor','author','thumbnail','excerpt','comments','custom-fields'),
|
63 |
+
);
|
64 |
+
$this->customPostTypeArgs = $args;
|
65 |
+
|
66 |
+
// register hooks
|
67 |
+
add_action( 'init', array( &$this, 'registerPostTypes' ) );
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
function registerPostTypes()
|
72 |
+
{
|
73 |
+
register_post_type($this->customPostTypeName,$this->customPostTypeArgs);
|
74 |
+
}
|
75 |
+
|
76 |
+
function setupCustomFields($fields)
|
77 |
+
{
|
78 |
+
$this->customFields = array();
|
79 |
+
foreach ($fields as $f)
|
80 |
+
{
|
81 |
+
$this->customFields[] = array
|
82 |
+
(
|
83 |
+
"name" => $f['name'],
|
84 |
+
"title" => $f['title'],
|
85 |
+
"description" => isset($f['description']) ? $f['description'] : '',
|
86 |
+
"type" => isset($f['type']) ? $f['type'] : "text",
|
87 |
+
"scope" => array( $this->customPostTypeName ),
|
88 |
+
"capability" => "edit_posts"
|
89 |
+
);
|
90 |
+
}
|
91 |
+
// register hooks
|
92 |
+
add_action( 'admin_menu', array( &$this, 'createCustomFields' ) );
|
93 |
+
add_action( 'save_post', array( &$this, 'saveCustomFields' ), 1, 2 );
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Remove the default Custom Fields meta box
|
98 |
+
*/
|
99 |
+
function removeDefaultCustomFields( $type, $context, $post )
|
100 |
+
{
|
101 |
+
foreach ( array( 'normal', 'advanced', 'side' ) as $context )
|
102 |
+
{
|
103 |
+
remove_meta_box( 'postcustom', 'post', $context );
|
104 |
+
remove_meta_box( 'postcustom', 'page', $context );
|
105 |
+
remove_meta_box( 'postcustom', $this->customPostTypeName, $context );//RWG
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Create the new Custom Fields meta box
|
111 |
+
*/
|
112 |
+
function createCustomFields()
|
113 |
+
{
|
114 |
+
if ( function_exists( 'add_meta_box' ) )
|
115 |
+
{
|
116 |
+
//add_meta_box( 'my-custom-fields', 'Custom Fields', array( &$this, 'displayCustomFields' ), 'page', 'normal', 'high' );
|
117 |
+
//add_meta_box( 'my-custom-fields', 'Custom Fields', array( &$this, 'displayCustomFields' ), 'post', 'normal', 'high' );
|
118 |
+
add_meta_box( 'my-custom-fields'.md5(serialize($this->customFields)), $this->customPostTypeSingular . ' Information', array( &$this, 'displayCustomFields' ), $this->customPostTypeName, 'normal', 'high' );//RWG
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Display the new Custom Fields meta box
|
124 |
+
*/
|
125 |
+
function displayCustomFields() {
|
126 |
+
global $post;
|
127 |
+
?>
|
128 |
+
<div class="form-wrap">
|
129 |
+
<?php
|
130 |
+
wp_nonce_field( 'my-custom-fields', 'my-custom-fields_wpnonce', false, true );
|
131 |
+
foreach ( $this->customFields as $customField ) {
|
132 |
+
// Check scope
|
133 |
+
$scope = $customField[ 'scope' ];
|
134 |
+
$output = false;
|
135 |
+
foreach ( $scope as $scopeItem ) {
|
136 |
+
switch ( $scopeItem ) {
|
137 |
+
case "post": {
|
138 |
+
// Output on any post screen
|
139 |
+
if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="post-new.php" || $post->post_type=="post" )
|
140 |
+
$output = true;
|
141 |
+
break;
|
142 |
+
}
|
143 |
+
case "page": {
|
144 |
+
// Output on any page screen
|
145 |
+
if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="page-new.php" || $post->post_type=="page" )
|
146 |
+
$output = true;
|
147 |
+
break;
|
148 |
+
}
|
149 |
+
default:{//RWG
|
150 |
+
if ($post->post_type==$scopeItem )
|
151 |
+
$output = true;
|
152 |
+
break;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
if ( $output ) break;
|
156 |
+
}
|
157 |
+
// Check capability
|
158 |
+
if ( !current_user_can( $customField['capability'], $post->ID ) )
|
159 |
+
$output = false;
|
160 |
+
// Output if allowed
|
161 |
+
if ( $output ) { ?>
|
162 |
+
<div class="form-field form-required">
|
163 |
+
<?php
|
164 |
+
switch ( $customField[ 'type' ] ) {
|
165 |
+
case "checkbox": {
|
166 |
+
// Checkbox
|
167 |
+
echo '<label for="' . $this->prefix . $customField[ 'name' ] .'" style="display:inline;"><b>' . $customField[ 'title' ] . '</b></label> ';
|
168 |
+
echo '<input type="checkbox" name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" value="yes"';
|
169 |
+
if ( get_post_meta( $post->ID, $this->prefix . $customField['name'], true ) == "yes" )
|
170 |
+
echo ' checked="checked"';
|
171 |
+
echo '" style="width: auto;" />';
|
172 |
+
break;
|
173 |
+
}
|
174 |
+
case "textarea": {
|
175 |
+
// Text area
|
176 |
+
echo '<label for="' . $this->prefix . $customField[ 'name' ] .'"><b>' . $customField[ 'title' ] . '</b></label>';
|
177 |
+
echo '<textarea name="' . $this->prefix . $customField[ 'name' ] . '" id="' . $this->prefix . $customField[ 'name' ] . '" columns="30" rows="3">' . htmlspecialchars( get_post_meta( $post->ID, $this->prefix . $customField[ 'name' ], true ) ) . '</textarea>';
|
178 |
+
break;
|
179 |
+
}
|
180 |
+
default: {
|
181 |
+
// Plain text field
|
182 |
+
echo '<label for="' . $this->prefix . $customField[ 'name' ] .'"><b>' . $customField[ 'title' ] . '</b></label>';
|
183 |
+
echo '<input type="text" name="' . $this->prefix . $customField[ 'name' ] . '" id="' . $this->prefix . $customField[ 'name' ] . '" value="' . htmlspecialchars( get_post_meta( $post->ID, $this->prefix . $customField[ 'name' ], true ) ) . '" />';
|
184 |
+
break;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
?>
|
188 |
+
<?php if ( $customField[ 'description' ] ) echo '<p>' . $customField[ 'description' ] . '</p>'; ?>
|
189 |
+
</div>
|
190 |
+
<?php
|
191 |
+
}
|
192 |
+
} ?>
|
193 |
+
</div>
|
194 |
+
<?php
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Save the new Custom Fields values
|
199 |
+
*/
|
200 |
+
function saveCustomFields( $post_id, $post ) {
|
201 |
+
if ( !wp_verify_nonce( $_POST[ 'my-custom-fields_wpnonce' ], 'my-custom-fields' ) )
|
202 |
+
return;
|
203 |
+
if ( !current_user_can( 'edit_post', $post_id ) )
|
204 |
+
return;
|
205 |
+
//if ( $post->post_type != 'page' && $post->post_type != 'post')//RWG
|
206 |
+
// return;
|
207 |
+
foreach ( $this->customFields as $customField ) {
|
208 |
+
if ( current_user_can( $customField['capability'], $post_id ) ) {
|
209 |
+
if ( isset( $_POST[ $this->prefix . $customField['name'] ] ) && trim( $_POST[ $this->prefix . $customField['name'] ] ) ) {
|
210 |
+
update_post_meta( $post_id, $this->prefix . $customField[ 'name' ], $_POST[ $this->prefix . $customField['name'] ] );
|
211 |
+
} else {
|
212 |
+
delete_post_meta( $post_id, $this->prefix . $customField[ 'name' ] );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
function __construct($postType, $customFields = false, $removeDefaultCustomFields = true)
|
219 |
+
{
|
220 |
+
$this->setupCustomPostType($postType);
|
221 |
+
|
222 |
+
if ($customFields)
|
223 |
+
{
|
224 |
+
$this->setupCustomFields($customFields);
|
225 |
+
}
|
226 |
+
|
227 |
+
// remove the standard custom fields box if desired
|
228 |
+
if ($removeDefaultCustomFields)
|
229 |
+
{
|
230 |
+
add_action( 'do_meta_boxes', array( &$this, 'removeDefaultCustomFields' ), 10, 3 );
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
}
|
235 |
+
?>
|
random_testimonial_widget.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
This file is part of IK Facebook.
|
4 |
+
|
5 |
+
IK Facebook is free software: you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License as published by
|
7 |
+
the Free Software Foundation, either version 3 of the License, or
|
8 |
+
(at your option) any later version.
|
9 |
+
|
10 |
+
IK Facebook is distributed in the hope that it will be useful,
|
11 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
GNU General Public License for more details.
|
14 |
+
|
15 |
+
You should have received a copy of the GNU General Public License
|
16 |
+
along with IK Facebook. If not, see <http://www.gnu.org/licenses/>.
|
17 |
+
|
18 |
+
Shout out to http://www.makeuseof.com/tag/how-to-create-wordpress-widgets/ for the help
|
19 |
+
*/
|
20 |
+
|
21 |
+
class randomTestimonialWidget extends WP_Widget
|
22 |
+
{
|
23 |
+
function randomTestimonialWidget(){
|
24 |
+
$widget_ops = array('classname' => 'randomTestimonialWidget', 'description' => 'Displays a random Testimonial.' );
|
25 |
+
$this->WP_Widget('randomTestimonialWidget', 'Easy Random Testimonial', $widget_ops);
|
26 |
+
}
|
27 |
+
|
28 |
+
function form($instance){
|
29 |
+
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
|
30 |
+
$title = $instance['title'];
|
31 |
+
?>
|
32 |
+
<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
|
33 |
+
<?php
|
34 |
+
}
|
35 |
+
|
36 |
+
function update($new_instance, $old_instance){
|
37 |
+
$instance = $old_instance;
|
38 |
+
$instance['title'] = $new_instance['title'];
|
39 |
+
return $instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
function widget($args, $instance){
|
43 |
+
extract($args, EXTR_SKIP);
|
44 |
+
|
45 |
+
echo $before_widget;
|
46 |
+
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
|
47 |
+
|
48 |
+
if (!empty($title)){
|
49 |
+
echo $before_title . $title . $after_title;;
|
50 |
+
}
|
51 |
+
|
52 |
+
echo outputRandomTestimonial(array('testimonials_link' => get_option('testimonials_link')));
|
53 |
+
|
54 |
+
echo $after_widget;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: richardgabriel
|
3 |
+
Tags: testimonials, testimonial widget, testimonial feed, random testimonials
|
4 |
+
Requires at least: 3.0.1
|
5 |
+
Tested up to: 3.5.2
|
6 |
+
Stable tag: 1.0
|
7 |
+
License: GPLv3 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
+
|
10 |
+
Easy Testimonials is a simple plugin for adding Testimonials to your WordPress Theme.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
Easy Testimonials is an easy-to-use plugin that allows users to add Testimonials to the sidebar, as a widget, or to embed them into a Page or Post using the shortcode. The Easy Testimonials also allows you to insert a list of all Testimonials or output a Random Testimonial.
|
15 |
+
|
16 |
+
Easy Testimonials includes options to set the URL of the Read More Link, and more!
|
17 |
+
|
18 |
+
Easy Testimonials plugin will inherit the styling from your Theme - just install and get to work!
|
19 |
+
|
20 |
+
== Installation ==
|
21 |
+
|
22 |
+
This section describes how to install the plugin and get it working.
|
23 |
+
|
24 |
+
1. Upload the contents of `/easy_testmonials/` to the `/wp-content/plugins/` directory
|
25 |
+
2. Activate Easy Testimonials through the 'Plugins' menu in WordPress
|
26 |
+
3. Visit this address for information on how to configure the plugin: https://illuminatikarate.com/easy-testimonials/
|
27 |
+
|
28 |
+
= Outputting Testimonials =
|
29 |
+
* To output a Random Testimonial, place the shortcode [random_testimonial] in the desired area of the Page or Post Content.
|
30 |
+
* To ouput a list of All Testimonials, place the shortcode [testimonials] in the desired area of the Page or Post Content.
|
31 |
+
* To output a Testimonial in the Sidebar, use the Widgets section of your WordPress Theme.
|
32 |
+
|
33 |
+
== Frequently Asked Questions ==
|
34 |
+
|
35 |
+
= Help! I need more information! =
|
36 |
+
|
37 |
+
OK! We have a great page with some helpful information here: https://illuminatikarate.com/easy-testimonials/
|
38 |
+
|
39 |
+
== Screenshots ==
|
40 |
+
|
41 |
+
1. This is the Settings page.
|
42 |
+
|
43 |
+
== Changelog ==
|
44 |
+
|
45 |
+
= 1.0 =
|
46 |
+
* Released!
|
47 |
+
|
48 |
+
== Upgrade Notice ==
|