PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 2.38
Strong Testimonials v2.38
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
integrations 7 years ago class-strong-form.php 7 years ago class-strong-log.php 7 years ago class-strong-mail.php 7 years ago class-strong-templates.php 7 years ago class-strong-testimonials-order.php 7 years ago class-strong-testimonials-privacy.php 7 years ago class-strong-testimonials-render.php 7 years ago class-strong-testimonials-shortcode-average.php 7 years ago class-strong-testimonials-shortcode-count.php 7 years ago class-strong-testimonials-shortcode.php 7 years ago class-strong-view-display.php 7 years ago class-strong-view-form.php 7 years ago class-strong-view-slideshow.php 7 years ago class-strong-view.php 7 years ago class-walker-strong-category-checklist-front.php 7 years ago deprecated.php 7 years ago filters.php 7 years ago functions-activation.php 7 years ago functions-content.php 7 years ago functions-image.php 7 years ago functions-rating.php 7 years ago functions-template-form.php 7 years ago functions-template.php 7 years ago functions-views.php 7 years ago functions.php 7 years ago l10n-polylang.php 7 years ago l10n-wpml.php 7 years ago post-types.php 7 years ago retro.php 7 years ago scripts.php 7 years ago widget2.php 7 years ago
post-types.php
249 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 // Less than 15 for WPML compatibility.
38 add_action( 'init', 'wpmtst_register_cpt', 12 );
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' => _x( 'Testimonials', 'post type general name', 'strong-testimonials' ),
55 'singular_name' => _x( 'Testimonial', 'post type singular name', 'strong-testimonials' ),
56 'add_new' => __( 'Add New', 'strong-testimonials' ),
57 'add_new_item' => __( 'Add New Testimonial', 'strong-testimonials' ),
58 'edit_item' => __( 'Edit Testimonial', 'strong-testimonials' ),
59 'new_item' => __( 'New Testimonial', 'strong-testimonials' ),
60 'view_item' => __( 'View Testimonial', 'strong-testimonials' ),
61 'view_items' => __( 'View Testimonials', 'strong-testimonials' ),
62 'search_items' => __( 'Search Testimonials', 'strong-testimonials' ),
63 'not_found' => __( 'Nothing Found', 'strong-testimonials' ),
64 'not_found_in_trash' => __( 'Nothing found in Trash', 'strong-testimonials' ),
65 'all_items' => __( 'All Testimonials', 'strong-testimonials' ),
66 'archives' => __( 'Testimonial Archives', 'strong-testimonials' ),
67 'attributes' => __( 'Attributes', 'strong-testimonials' ),
68 'insert_into_item' => __( 'Insert into testimonial', 'strong-testimonials' ),
69 'uploaded_to_this_item' => __( 'Uploaded to this testimonial', 'strong-testimonials' ),
70 'featured_image' => __( 'Featured Image', 'strong-testimonials' ),
71 'set_featured_image' => __( 'Set featured image', 'strong-testimonials' ),
72 'remove_featured_image' => __( 'Remove featured image', 'strong-testimonials' ),
73 'use_featured_image' => __( 'Use as featured image', 'strong-testimonials' ),
74 'filter_items_list' => __( 'Filter testimonials list', 'strong-testimonials' ),
75 'items_list_navigation' => __( 'Testimonials list navigation', 'strong-testimonials' ),
76 'items_list' => __( 'Testimonials list', 'strong-testimonials' ),
77 'menu_name' => _x( 'Testimonials', 'admin menu name', 'strong-testimonials' ),
78 'name_admin_bar' => _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' => 'dashicons-editor-quote',
100 'capability_type' => 'post',
101 'supports' => $supports,
102 'taxonomies' => array( 'wpm-testimonial-category' ),
103 'has_archive' => false,
104 'rewrite' => array(
105 'slug' => _x( 'testimonial', 'slug', 'strong-testimonials' ),
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' => __( 'Testimonial Categories', 'strong-testimonials' ),
127 'singular_name' => __( 'Testimonial Category', 'strong-testimonials' ),
128 'menu_name' => __( 'Categories', 'strong-testimonials' ),
129 'all_items' => __( 'All categories', 'strong-testimonials' ),
130 );
131
132 $args = array(
133 'labels' => $labels,
134 'hierarchical' => true,
135 'rewrite' => array( 'slug' => _x( 'testimonial-category', 'slug', 'strong-testimonials' ) ),
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 if ( isset( $options['support_custom_fields'] ) && $options['support_custom_fields'] )
154 $supports[] = 'custom-fields';
155
156 if ( isset( $options['support_comments'] ) && $options['support_comments'] )
157 $supports[] = 'comments';
158
159 return $supports;
160 }
161 add_filter( 'wpmtst_testimonial_supports', 'wpmtst_testimonial_supports' );
162
163
164 /**
165 * Filters the post updated messages.
166 *
167 * @param $messages
168 * @since 2.12.0
169 *
170 * @return mixed
171 */
172 function wpmtst_updated_messages( $messages ) {
173 global $post;
174
175 $preview_url = get_preview_post_link( $post );
176
177 $permalink = get_permalink( $post->ID );
178 if ( ! $permalink ) {
179 $permalink = '';
180 }
181
182 // TODO Use WordPress translations as a basis for adding these to existing translation files.
183 // Preview post link.
184 $preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
185 esc_url( $preview_url ),
186 __( 'Preview testimonial', 'strong-testimonials' )
187 );
188
189 // View post link.
190 $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
191 esc_url( $permalink ),
192 __( 'View testimonial', 'strong-testimonials' )
193 );
194
195 // Scheduled post preview link.
196 $scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
197 esc_url( $permalink ),
198 __( 'Preview testimonial', 'strong-testimonials' )
199 );
200
201 /* translators: Publish box date format, see https://secure.php.net/date */
202 $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) );
203
204 $messages['wpm-testimonial'] = array(
205 0 => '', // Unused. Messages start at index 1.
206 1 => __( 'Testimonial updated.', 'strong-testimonials' ) . $view_post_link_html,
207 2 => __( 'Custom field updated.', 'strong-testimonials' ),
208 3 => __( 'Custom field deleted.', 'strong-testimonials' ),
209 4 => __( 'Testimonial updated.', 'strong-testimonials' ),
210 /* translators: %s: date and time of the revision */
211 5 => isset($_GET['revision']) ? sprintf( __( 'Testimonial restored to revision from %s.', 'strong-testimonials' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
212 6 => __( 'Testimonial published.', 'strong-testimonials' ) . $view_post_link_html,
213 7 => __( 'Testimonial saved.', 'strong-testimonials' ),
214 8 => __( 'Testimonial submitted.', 'strong-testimonials' ) . $preview_post_link_html,
215 9 => sprintf( __( 'Testimonial scheduled for: %s.', 'strong-testimonials' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
216 10 => __( 'Testimonial draft updated.', 'strong-testimonials' ) . $preview_post_link_html,
217 );
218
219 return $messages;
220 }
221 add_filter( 'post_updated_messages', 'wpmtst_updated_messages' );
222
223
224 /**
225 * Filters the bulk action updated messages.
226 *
227 * By default, custom post types use the messages for the 'post' post type.
228 *
229 * @param $bulk_messages
230 * @param $bulk_counts
231 *
232 * @since 2.18.0
233 *
234 * @return mixed
235 */
236 function wpmtst_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
237
238 $bulk_messages['wpm-testimonial'] = array(
239 'updated' => _n( '%s testimonial updated.', '%s testimonials updated.', $bulk_counts['updated'], 'strong-testimonials' ),
240 'locked' => ( 1 == $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' ),
241 'deleted' => _n( '%s testimonial permanently deleted.', '%s testimonials permanently deleted.', $bulk_counts['deleted'], 'strong-testimonials' ),
242 'trashed' => _n( '%s testimonial moved to the Trash.', '%s testimonials moved to the Trash.', $bulk_counts['trashed'], 'strong-testimonials' ),
243 'untrashed' => _n( '%s testimonial restored from the Trash.', '%s testimonials restored from the Trash.', $bulk_counts['untrashed'], 'strong-testimonials' ),
244 );
245
246 return $bulk_messages;
247 }
248 add_filter( 'bulk_post_updated_messages', 'wpmtst_bulk_updated_messages', 10, 2 );
249