PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / trunk
Strong Testimonials vtrunk
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 1 month ago strong-testimonials-beaver-block 1 year ago submodules 8 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 1 month ago class-strong-testimonials-form.php 1 month ago class-strong-testimonials-order.php 1 year ago class-strong-testimonials-privacy.php 1 year ago class-strong-testimonials-render.php 1 month ago class-strong-testimonials-templates.php 1 year ago class-strong-testimonials-view-shortcode.php 2 days ago class-strong-testimonials-view-widget.php 1 year ago class-strong-view-display.php 1 month ago class-strong-view-form.php 2 days ago class-strong-view-slideshow.php 1 month ago class-strong-view.php 11 months ago class-walker-strong-category-checklist-front.php 1 year ago deprecated.php 1 year ago filters.php 1 month ago functions-activation.php 1 month ago functions-content.php 11 months ago functions-image.php 5 months ago functions-rating.php 1 year ago functions-template-form.php 2 days ago functions-template.php 4 months ago functions-views.php 1 year ago functions.php 1 month ago l10n-polylang.php 1 year ago l10n-wpml.php 1 year ago post-types.php 2 days ago retro.php 1 year ago scripts.php 1 month ago
post-types.php
263 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 'comments',
88 );
89
90 $args = array(
91 'labels' => $labels,
92 'public' => true,
93 'hierarchical' => false,
94 'exclude_from_search' => false,
95 'show_ui' => true,
96 'show_in_menu' => true,
97 'show_in_nav_menus' => true,
98 'show_in_admin_bar' => true,
99 'menu_position' => 20,
100 'menu_icon' => 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iMzkiIHZpZXdCb3g9IjAgMCA1MCAzOSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE5LjE0MjkgNUM4LjU3MDIzIDUgMCAxMi4wODY3IDAgMjEuNDg0MUMwIDMwLjg4MTYgOC41NzAyMyAzNy45NjgzIDE5LjE0MjkgMzcuOTY4M0MyMy4zNTU2IDM3Ljk2ODMgMjcuMjQ4MiAzNy4yODc1IDMwLjQwOTggMzUuMjM3N0wzOC4yODU3IDM4LjVMMzUuMTE4OSAzMC44NTVDMzcuMTE4NiAyOC4xNjcyIDM4LjI4NTcgMjQuOTQ3MyAzOC4yODU3IDIxLjQ4NDFDMzguMjg1NyAxMi4wODY3IDI5LjcxNTUgNSAxOS4xNDI5IDVaTTExLjgwNDYgMjcuODY1MVYyNS43MzgxQzExLjgwNDYgMjUuNzM4MSAxMy45MzE2IDI0Ljc4MzggMTMuOTMxNiAyMy42MTExQzExLjU4MiAyMy42MTExIDkuNjc3NjMgMjEuNzA2NyA5LjY3NzYzIDE5LjM1NzFDOS42Nzc2MyAxNy4wMDc2IDExLjU4MiAxNS4xMDMyIDEzLjkzMTYgMTUuMTAzMkMxNi4yODEyIDE1LjEwMzIgMTguMTg1NiAxNy4wMDc2IDE4LjE4NTYgMTkuMzU3MUMxOC4xODU2IDIzLjYxMTEgM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',
101 'capability_type' => 'post',
102 'supports' => $supports,
103 'taxonomies' => array( 'wpm-testimonial-category' ),
104 'has_archive' => false,
105 'rewrite' => array(
106 'slug' => 'testimonial',
107 'with_front' => true,
108 'feeds' => false,
109 'pages' => true,
110 ),
111 'can_export' => true,
112 );
113
114 return $args;
115 }
116
117
118 /**
119 * Return our custom taxonomy default values.
120 *
121 * @since 2.30.0
122 *
123 * @return array
124 */
125 function wpmtst_get_tax_defaults() {
126 $labels = array(
127 'name' => esc_html__( 'Testimonial Categories', 'strong-testimonials' ),
128 'singular_name' => esc_html__( 'Testimonial Category', 'strong-testimonials' ),
129 'menu_name' => esc_html__( 'Categories', 'strong-testimonials' ),
130 'all_items' => esc_html__( 'All categories', 'strong-testimonials' ),
131 );
132
133 $args = array(
134 'labels' => $labels,
135 'hierarchical' => true,
136 'rewrite' => array( 'slug' => 'testimonial-category' ),
137 );
138
139 return $args;
140 }
141
142
143 /**
144 * Modify testimonial features.
145 *
146 * @since 2.4.0
147 * @param $supports
148 *
149 * @return array
150 */
151 function wpmtst_testimonial_supports( $supports ) {
152 $options = get_option( 'wpmtst_options' );
153
154 $saved_value = isset( $options['support_custom_fields'] ) && $options['support_custom_fields'];
155 $support_custom_fields = apply_filters( 'wpmtst_support_custom_fields', $saved_value );
156 if ( $support_custom_fields ) {
157 $supports[] = 'custom-fields';
158 }
159
160 if ( isset( $options['support_comments'] ) && $options['support_comments'] ) {
161 $supports[] = 'comments';
162 }
163
164 return $supports;
165 }
166 add_filter( 'wpmtst_testimonial_supports', 'wpmtst_testimonial_supports' );
167
168
169 /**
170 * Filters the post updated messages.
171 *
172 * @param $messages
173 * @since 2.12.0
174 *
175 * @return mixed
176 */
177 function wpmtst_updated_messages( $messages ) {
178 global $post;
179
180 $preview_url = get_preview_post_link( $post );
181
182 $permalink = get_permalink( $post->ID );
183 if ( ! $permalink ) {
184 $permalink = '';
185 }
186
187 // TODO Use WordPress translations as a basis for adding these to existing translation files.
188 // Preview post link.
189 $preview_post_link_html = sprintf(
190 ' <a target="_blank" href="%1$s">%2$s</a>',
191 esc_url( $preview_url ),
192 esc_html__( 'Preview testimonial', 'strong-testimonials' )
193 );
194
195 // View post link.
196 $view_post_link_html = sprintf(
197 ' <a href="%1$s">%2$s</a>',
198 esc_url( $permalink ),
199 esc_html__( 'View testimonial', 'strong-testimonials' )
200 );
201
202 // Scheduled post preview link.
203 $scheduled_post_link_html = sprintf(
204 ' <a target="_blank" href="%1$s">%2$s</a>',
205 esc_url( $permalink ),
206 esc_html__( 'Preview testimonial', 'strong-testimonials' )
207 );
208
209 /* translators: Publish box date format, see https://secure.php.net/date */
210 $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) );
211
212 $messages['wpm-testimonial'] = array(
213 0 => '', // Unused. Messages start at index 1.
214 1 => esc_html__( 'Testimonial updated.', 'strong-testimonials' ) . $view_post_link_html,
215 2 => esc_html__( 'Custom field updated.', 'strong-testimonials' ),
216 3 => esc_html__( 'Custom field deleted.', 'strong-testimonials' ),
217 4 => esc_html__( 'Testimonial updated.', 'strong-testimonials' ),
218 /* translators: %s: date and time of the revision */
219 5 => isset( $_GET['revision'] ) ? sprintf( esc_html__( 'Testimonial restored to revision from %s.', 'strong-testimonials' ), wp_post_revision_title( absint( $_GET['revision'] ), false ) ) : false,
220 6 => esc_html__( 'Testimonial published.', 'strong-testimonials' ) . $view_post_link_html,
221 7 => esc_html__( 'Testimonial saved.', 'strong-testimonials' ),
222 8 => esc_html__( 'Testimonial submitted.', 'strong-testimonials' ) . $preview_post_link_html,
223 /* translators: %s: date and time of the scheduled date */
224 9 => sprintf( esc_html__( 'Testimonial scheduled for: %s.', 'strong-testimonials' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
225 10 => esc_html__( 'Testimonial draft updated.', 'strong-testimonials' ) . $preview_post_link_html,
226 );
227
228 return $messages;
229 }
230 add_filter( 'post_updated_messages', 'wpmtst_updated_messages' );
231
232
233 /**
234 * Filters the bulk action updated messages.
235 *
236 * By default, custom post types use the messages for the 'post' post type.
237 *
238 * @param $bulk_messages
239 * @param $bulk_counts
240 *
241 * @since 2.18.0
242 *
243 * @return mixed
244 */
245 function wpmtst_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
246
247 $bulk_messages['wpm-testimonial'] = array(
248 // translators: %s is the number of testimonials that were updated.
249 'updated' => _n( '%s testimonial updated.', '%s testimonials updated.', $bulk_counts['updated'], 'strong-testimonials' ),
250 // translators: %s is the number of testimonials that were not updated because someone else is editing them.
251 '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' ),
252 // translators: %s is the number of testimonials that were permanently deleted.
253 'deleted' => _n( '%s testimonial permanently deleted.', '%s testimonials permanently deleted.', $bulk_counts['deleted'], 'strong-testimonials' ),
254 // translators: %s is the number of testimonials that were moved to the Trash.
255 'trashed' => _n( '%s testimonial moved to the Trash.', '%s testimonials moved to the Trash.', $bulk_counts['trashed'], 'strong-testimonials' ),
256 // translators: %s is the number of testimonials that were restored from the Trash.
257 'untrashed' => _n( '%s testimonial restored from the Trash.', '%s testimonials restored from the Trash.', $bulk_counts['untrashed'], 'strong-testimonials' ),
258 );
259
260 return $bulk_messages;
261 }
262 add_filter( 'bulk_post_updated_messages', 'wpmtst_bulk_updated_messages', 10, 2 );
263