PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.6
Strong Testimonials v3.3.6
3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / includes / post-types.php
strong-testimonials / includes Last commit date
elementor 1 year ago logs 2 months ago strong-testimonials-beaver-block 1 year ago submodules 9 months ago class-strong-gutemberg.php 1 year ago class-strong-log.php 1 year ago class-strong-mail.php 1 year ago class-strong-testimonials-average-shortcode.php 1 year ago class-strong-testimonials-count-shortcode.php 1 year ago class-strong-testimonials-defaults.php 3 weeks ago class-strong-testimonials-form.php 2 months ago class-strong-testimonials-order.php 1 year ago class-strong-testimonials-privacy.php 1 year ago class-strong-testimonials-render.php 2 months ago class-strong-testimonials-templates.php 3 weeks ago class-strong-testimonials-view-shortcode.php 1 month ago class-strong-testimonials-view-widget.php 1 year ago class-strong-view-display.php 1 week ago class-strong-view-form.php 3 weeks ago class-strong-view-slideshow.php 1 month ago class-strong-view.php 1 month ago class-walker-strong-category-checklist-front.php 1 year ago deprecated.php 1 year ago filters.php 2 months ago functions-activation.php 3 weeks ago functions-content.php 1 year ago functions-image.php 7 months ago functions-rating.php 1 year ago functions-template-form.php 3 weeks ago functions-template.php 3 weeks ago functions-views.php 1 year ago functions.php 2 weeks ago l10n-polylang.php 1 year ago l10n-wpml.php 1 year ago post-types.php 1 week ago retro.php 1 year ago scripts.php 2 months ago
post-types.php
296 lines
1 <?php
2 /**
3 * Register Post Type and Taxonomy
4 *
5 * @since 1.4.0
6 * @since 1.8.0 $args['hierarchical'] => false
7 * @since 1.15.10 $args['exclude_from_search'] => false
8 * @since 2.4.0 Move 'custom-fields' to an option.
9 * Added 'wpmtst_testimonial_supports' filter.
10 * Added 'wpmtst_exclude_from_search' filter.
11 */
12 function wpmtst_register_cpt() {
13
14 if ( ! post_type_exists( 'wpm-testimonial' ) ) {
15 $args = wpmtst_get_cpt_defaults();
16
17 $args['labels'] = apply_filters( 'wpmtst_testimonial_labels', $args['labels'] );
18 $args['supports'] = apply_filters( 'wpmtst_testimonial_supports', $args['supports'] );
19 $args['exclude_from_search'] = apply_filters( 'wpmtst_exclude_from_search', $args['exclude_from_search'] );
20 $args['taxonomies'] = apply_filters( 'wpmtst_testimonial_taxonomies', $args['taxonomies'] );
21
22 //TODO error handling
23 register_post_type( 'wpm-testimonial', apply_filters( 'wpmtst_post_type', $args ) );
24 }
25
26 /**
27 * Our taxonomy.
28 */
29 if ( ! taxonomy_exists( 'wpm-testimonial-category' ) && apply_filters( 'wpmtst_register_taxonomy', true ) ) {
30 $args = wpmtst_get_tax_defaults();
31
32 $args['labels'] = apply_filters( 'wpmtst_taxonomy_labels', $args['labels'] );
33
34 register_taxonomy( 'wpm-testimonial-category', array( 'wpm-testimonial' ), apply_filters( 'wpmtst_taxonomy', $args ) );
35 }
36 }
37
38 add_action( 'init', 'wpmtst_register_cpt', 40 );
39
40
41 /**
42 * Return default values for our custom post type.
43 *
44 * ---------------------------------------------------------------
45 * For the [restore default] button to work, every value needs
46 * a default value even if we are not overriding WordPress default
47 * because we can't fetch those defaults (yet).
48 * ---------------------------------------------------------------
49 *
50 * @return array|string
51 */
52 function wpmtst_get_cpt_defaults() {
53 $labels = array(
54 'name' => esc_html_x( 'Testimonials', 'post type general name', 'strong-testimonials' ),
55 'singular_name' => esc_html_x( 'Testimonial', 'post type singular name', 'strong-testimonials' ),
56 'add_new' => esc_html__( 'Add New', 'strong-testimonials' ),
57 'add_new_item' => esc_html__( 'Add New Testimonial', 'strong-testimonials' ),
58 'edit_item' => esc_html__( 'Edit Testimonial', 'strong-testimonials' ),
59 'new_item' => esc_html__( 'New Testimonial', 'strong-testimonials' ),
60 'view_item' => esc_html__( 'View Testimonial', 'strong-testimonials' ),
61 'view_items' => esc_html__( 'View Testimonials', 'strong-testimonials' ),
62 'search_items' => esc_html__( 'Search Testimonials', 'strong-testimonials' ),
63 'not_found' => esc_html__( 'Nothing Found', 'strong-testimonials' ),
64 'not_found_in_trash' => esc_html__( 'Nothing found in Trash', 'strong-testimonials' ),
65 'all_items' => esc_html__( 'All Testimonials', 'strong-testimonials' ),
66 'archives' => esc_html__( 'Testimonial Archives', 'strong-testimonials' ),
67 'attributes' => esc_html__( 'Attributes', 'strong-testimonials' ),
68 'insert_into_item' => esc_html__( 'Insert into testimonial', 'strong-testimonials' ),
69 'uploaded_to_this_item' => esc_html__( 'Uploaded to this testimonial', 'strong-testimonials' ),
70 'featured_image' => esc_html__( 'Featured Image', 'strong-testimonials' ),
71 'set_featured_image' => esc_html__( 'Set featured image', 'strong-testimonials' ),
72 'remove_featured_image' => esc_html__( 'Remove featured image', 'strong-testimonials' ),
73 'use_featured_image' => esc_html__( 'Use as featured image', 'strong-testimonials' ),
74 'filter_items_list' => esc_html__( 'Filter testimonials list', 'strong-testimonials' ),
75 'items_list_navigation' => esc_html__( 'Testimonials list navigation', 'strong-testimonials' ),
76 'items_list' => esc_html__( 'Testimonials list', 'strong-testimonials' ),
77 'menu_name' => esc_html_x( 'Testimonials', 'admin menu name', 'strong-testimonials' ),
78 'name_admin_bar' => esc_html_x( 'Testimonial', 'admin bar menu name', 'strong-testimonials' ),
79 );
80
81 $supports = array(
82 'title',
83 'excerpt',
84 'editor',
85 'thumbnail',
86 'page-attributes',
87 );
88
89 $args = array(
90 'labels' => $labels,
91 'public' => true,
92 'hierarchical' => false,
93 'exclude_from_search' => false,
94 'show_ui' => true,
95 'show_in_menu' => true,
96 'show_in_nav_menus' => true,
97 'show_in_admin_bar' => true,
98 'menu_position' => 20,
99 'menu_icon' => 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iMzkiIHZpZXdCb3g9IjAgMCA1MCAzOSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5LjE0MjkgNUM4LjU3MDIzIDUgMCAxMi4wODY3IDAgMjEuNDg0MUMwIDMwLjg4MTYgOC41NzAyMyAzNy45NjgzIDE5LjE0MjkgMzcuOTY4M0MyMy4zNTU2IDM3Ljk2ODMgMjcuMjQ4MiAzNy4yODc1IDMwLjQwOTggMzUuMjM3N0wzOC4yODU3IDM4LjVMMzUuMTE4OSAzMC44NTVDMzcuMTE4NiAyOC4xNjcyIDM4LjI4NTcgMjQuOTQ3MyAzOC4yODU3IDIxLjQ4NDFDMzguMjg1NyAxMi4wODY3IDI5LjcxNTUgNSAxOS4xNDI5IDVaTTExLjgwNDYgMjcuODY1MVYyNS43MzgxQzExLjgwNDYgMjUuNzM4MSAxMy45MzE2IDI0Ljc4MzggMTMuOTMxNiAyMy42MTExQzExLjU4MiAyMy42MTExIDkuNjc3NjMgMjEuNzA2NyA5LjY3NzYzIDE5LjM1NzFDOS42Nzc2MyAxNy4wMDc2IDExLjU4MiAxNS4xMDMyIDEzLjkzMTYgMTUuMTAzMkMxNi4yODEyIDE1LjEwMzIgMTguMTg1NiAxNy4wMDc2IDE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RlIiBzdHJva2Utd2lkdGg9IjIiLz4KPC9zdmc+Cg==',
100 'capability_type' => 'post',
101 'supports' => $supports,
102 'taxonomies' => array( 'wpm-testimonial-category' ),
103 'has_archive' => false,
104 'rewrite' => array(
105 'slug' => 'testimonial',
106 'with_front' => true,
107 'feeds' => false,
108 'pages' => true,
109 ),
110 'can_export' => true,
111 );
112
113 return $args;
114 }
115
116
117 /**
118 * Return our custom taxonomy default values.
119 *
120 * @since 2.30.0
121 *
122 * @return array
123 */
124 function wpmtst_get_tax_defaults() {
125 $labels = array(
126 'name' => esc_html__( 'Testimonial Categories', 'strong-testimonials' ),
127 'singular_name' => esc_html__( 'Testimonial Category', 'strong-testimonials' ),
128 'menu_name' => esc_html__( 'Categories', 'strong-testimonials' ),
129 'all_items' => esc_html__( 'All categories', 'strong-testimonials' ),
130 );
131
132 $args = array(
133 'labels' => $labels,
134 'hierarchical' => true,
135 'rewrite' => array( 'slug' => 'testimonial-category' ),
136 );
137
138 return $args;
139 }
140
141
142 /**
143 * Modify testimonial features.
144 *
145 * @since 2.4.0
146 * @param $supports
147 *
148 * @return array
149 */
150 function wpmtst_testimonial_supports( $supports ) {
151 $options = get_option( 'wpmtst_options' );
152
153 $saved_value = isset( $options['support_custom_fields'] ) && $options['support_custom_fields'];
154 $support_custom_fields = apply_filters( 'wpmtst_support_custom_fields', $saved_value );
155 if ( $support_custom_fields ) {
156 $supports[] = 'custom-fields';
157 }
158
159 $support_comments = isset( $options['support_comments'] ) && $options['support_comments'];
160 $support_comments = apply_filters( 'wpmtst_support_comments', $support_comments );
161
162 if ( $support_comments ) {
163 if ( ! in_array( 'comments', $supports, true ) ) {
164 $supports[] = 'comments';
165 }
166 } else {
167 $supports = array_values( array_diff( $supports, array( 'comments' ) ) );
168 }
169
170 return $supports;
171 }
172 add_filter( 'wpmtst_testimonial_supports', 'wpmtst_testimonial_supports' );
173
174 /**
175 * Force comments open/closed on testimonials based on the "Enable comments" setting.
176 *
177 * Post type `supports` only controls the default comment_status for newly
178 * created posts and the admin meta box, so existing testimonials whose
179 * comment_status is already 'open' need this too.
180 *
181 * @since 3.3.5
182 *
183 * @param bool $open Whether the current post is open for comments.
184 * @param int $post_id Post ID.
185 *
186 * @return bool
187 */
188 function wpmtst_testimonial_comments_open( $open, $post_id ) {
189 $post = get_post( $post_id );
190 if ( ! $post || 'wpm-testimonial' !== $post->post_type ) {
191 return $open;
192 }
193
194 $options = get_option( 'wpmtst_options' );
195 $support_comments = isset( $options['support_comments'] ) && $options['support_comments'];
196
197 return apply_filters( 'wpmtst_support_comments', $support_comments ) ? $open : false;
198 }
199 add_filter( 'comments_open', 'wpmtst_testimonial_comments_open', 10, 2 );
200
201
202 /**
203 * Filters the post updated messages.
204 *
205 * @param $messages
206 * @since 2.12.0
207 *
208 * @return mixed
209 */
210 function wpmtst_updated_messages( $messages ) {
211 global $post;
212
213 $preview_url = get_preview_post_link( $post );
214
215 $permalink = get_permalink( $post->ID );
216 if ( ! $permalink ) {
217 $permalink = '';
218 }
219
220 // TODO Use WordPress translations as a basis for adding these to existing translation files.
221 // Preview post link.
222 $preview_post_link_html = sprintf(
223 ' <a target="_blank" href="%1$s">%2$s</a>',
224 esc_url( $preview_url ),
225 esc_html__( 'Preview testimonial', 'strong-testimonials' )
226 );
227
228 // View post link.
229 $view_post_link_html = sprintf(
230 ' <a href="%1$s">%2$s</a>',
231 esc_url( $permalink ),
232 esc_html__( 'View testimonial', 'strong-testimonials' )
233 );
234
235 // Scheduled post preview link.
236 $scheduled_post_link_html = sprintf(
237 ' <a target="_blank" href="%1$s">%2$s</a>',
238 esc_url( $permalink ),
239 esc_html__( 'Preview testimonial', 'strong-testimonials' )
240 );
241
242 /* translators: Publish box date format, see https://secure.php.net/date */
243 $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) );
244
245 $messages['wpm-testimonial'] = array(
246 0 => '', // Unused. Messages start at index 1.
247 1 => esc_html__( 'Testimonial updated.', 'strong-testimonials' ) . $view_post_link_html,
248 2 => esc_html__( 'Custom field updated.', 'strong-testimonials' ),
249 3 => esc_html__( 'Custom field deleted.', 'strong-testimonials' ),
250 4 => esc_html__( 'Testimonial updated.', 'strong-testimonials' ),
251 /* translators: %s: date and time of the revision */
252 5 => isset( $_GET['revision'] ) ? sprintf( esc_html__( 'Testimonial restored to revision from %s.', 'strong-testimonials' ), wp_post_revision_title( absint( $_GET['revision'] ), false ) ) : false,
253 6 => esc_html__( 'Testimonial published.', 'strong-testimonials' ) . $view_post_link_html,
254 7 => esc_html__( 'Testimonial saved.', 'strong-testimonials' ),
255 8 => esc_html__( 'Testimonial submitted.', 'strong-testimonials' ) . $preview_post_link_html,
256 /* translators: %s: date and time of the scheduled date */
257 9 => sprintf( esc_html__( 'Testimonial scheduled for: %s.', 'strong-testimonials' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
258 10 => esc_html__( 'Testimonial draft updated.', 'strong-testimonials' ) . $preview_post_link_html,
259 );
260
261 return $messages;
262 }
263 add_filter( 'post_updated_messages', 'wpmtst_updated_messages' );
264
265
266 /**
267 * Filters the bulk action updated messages.
268 *
269 * By default, custom post types use the messages for the 'post' post type.
270 *
271 * @param $bulk_messages
272 * @param $bulk_counts
273 *
274 * @since 2.18.0
275 *
276 * @return mixed
277 */
278 function wpmtst_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
279
280 $bulk_messages['wpm-testimonial'] = array(
281 // translators: %s is the number of testimonials that were updated.
282 'updated' => _n( '%s testimonial updated.', '%s testimonials updated.', $bulk_counts['updated'], 'strong-testimonials' ),
283 // translators: %s is the number of testimonials that were not updated because someone else is editing them.
284 'locked' => ( $bulk_counts['locked'] ) ? __( '1 testimonial not updated, somebody is editing it.', 'strong-testimonials' ) : _n( '%s testimonial not updated, somebody is editing it.', '%s testimonials not updated, somebody is editing them.', $bulk_counts['locked'], 'strong-testimonials' ),
285 // translators: %s is the number of testimonials that were permanently deleted.
286 'deleted' => _n( '%s testimonial permanently deleted.', '%s testimonials permanently deleted.', $bulk_counts['deleted'], 'strong-testimonials' ),
287 // translators: %s is the number of testimonials that were moved to the Trash.
288 'trashed' => _n( '%s testimonial moved to the Trash.', '%s testimonials moved to the Trash.', $bulk_counts['trashed'], 'strong-testimonials' ),
289 // translators: %s is the number of testimonials that were restored from the Trash.
290 'untrashed' => _n( '%s testimonial restored from the Trash.', '%s testimonials restored from the Trash.', $bulk_counts['untrashed'], 'strong-testimonials' ),
291 );
292
293 return $bulk_messages;
294 }
295 add_filter( 'bulk_post_updated_messages', 'wpmtst_bulk_updated_messages', 10, 2 );
296