PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.2
Strong Testimonials v3.3.2
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 / admin / class-strong-testimonials-debug.php
strong-testimonials / admin Last commit date
challenge 1 year ago css 1 day ago img 1 year ago js 1 month ago menu 1 month ago partials 1 week ago rest-api 1 day ago scss 1 year ago settings 1 day ago uninstall 1 year ago wpchill 1 month ago admin-notices.php 5 months ago admin.php 1 month ago class-strong-testimonials-addons.php 1 month ago class-strong-testimonials-admin-category-list.php 1 year ago class-strong-testimonials-admin-list.php 1 year ago class-strong-testimonials-admin-scripts.php 1 month ago class-strong-testimonials-admin.php 1 month ago class-strong-testimonials-debug.php 5 months ago class-strong-testimonials-exporter.php 1 year ago class-strong-testimonials-help.php 1 year ago class-strong-testimonials-helper.php 1 month ago class-strong-testimonials-list-table.php 1 year ago class-strong-testimonials-lite-vs-pro-page.php 1 month ago class-strong-testimonials-post-editor.php 6 months ago class-strong-testimonials-review.php 1 year ago class-strong-testimonials-updater.php 1 month ago class-strong-testimonials-upsell.php 1 day ago class-strong-views-list-table.php 1 month ago class-walker-strong-category-checklist.php 1 year ago class-walker-strong-form-category-checklist.php 1 year ago class-wpmtst-onboarding.php 1 year ago compat.php 1 year ago custom-fields-ajax.php 1 year ago custom-fields.php 1 day ago form-preview.php 1 year ago view-list-order.php 1 year ago views-ajax.php 1 month ago views-validate.php 1 year ago views.php 1 month ago
class-strong-testimonials-debug.php
279 lines
1 <?php
2
3
4 class Strong_Testimonials_Debug {
5
6 /**
7 * Holds the class object.
8 *
9 * @since 3.1.15
10 *
11 * @var object
12 */
13 public static $instance;
14
15 /**
16 * Strong_Testimonials_Debug constructor.
17 *
18 * @since 3.1.15
19 */
20 public function __construct() {
21
22 add_action( 'admin_init', array( $this, 'wpmtst_export_testimonial' ) );
23
24 /* Fire our meta box setup function on the post editor screen. */
25 add_action( 'load-post.php', array( $this, 'debug_meta_box_setup' ) );
26 add_action( 'load-post-new.php', array( $this, 'debug_meta_box_setup' ) );
27
28 // Hide debug testimonial by default
29 add_filter( 'hidden_meta_boxes', array( $this, 'hide_meta_box' ), 10, 2 );
30 }
31
32
33
34 /**
35 * Returns the singleton instance of the class.
36 *
37 * @return object The Strong_Testimonials_Debug object.
38 * @since 3.1.15
39 */
40 public static function get_instance() {
41
42 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Strong_Testimonials_Debug ) ) {
43 self::$instance = new Strong_Testimonials_Debug();
44 }
45
46 return self::$instance;
47 }
48
49 /**
50 * Export single testimonial
51 *
52 * @since 3.1.15
53 */
54 public function wpmtst_export_testimonial() {
55 // Check if the user is allowed to edit posts.
56 if ( ! current_user_can( 'manage_options' ) ) {
57 return;
58 }
59 if ( isset( $_GET['wpmtst_single_download'] ) ) {
60
61 // WXR_VERSION is declared here
62 require_once ABSPATH . 'wp-admin/includes/export.php';
63
64 $post = get_post( absint( $_GET['wpmtst_single_download'] ) );
65
66 if ( ! $post || 'wpm-testimonial' !== $post->post_type ) {
67 return;
68 }
69
70 global $wpdb;
71
72 $testimonial_name = sanitize_key( $post->post_name );
73 if ( ! empty( $testimonial_name ) ) {
74 $testimonial_name .= '.';
75 }
76 $date = gmdate( 'Y-m-d' );
77 $wp_filename = $testimonial_name . $date . '.xml';
78
79 header( 'Content-Description: File Transfer' );
80 header( 'Content-Disposition: attachment; filename=' . $wp_filename );
81 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
82
83 echo '<?xml version="1.0" encoding="' . esc_html( get_bloginfo( 'charset' ) ) . "\" ?>\n";
84
85 ?>
86 <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
87 <!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
88 <!-- You may use this file to transfer that content from one site to another. -->
89 <!-- This file is not intended to serve as a complete backup of your site. -->
90
91 <!-- To import this information into a WordPress site follow these steps: -->
92 <!-- 1. Log in to that site as an administrator. -->
93 <!-- 2. Go to Tools: Import in the WordPress admin panel. -->
94 <!-- 3. Install the "WordPress" importer from the list. -->
95 <!-- 4. Activate & Run Importer. -->
96 <!-- 5. Upload this file using the form provided on that page. -->
97 <!-- 6. You will first be asked to map the authors in this export file to users -->
98 <!-- on the site. For each author, you may choose to map to an -->
99 <!-- existing user on the site or to create a new user. -->
100 <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
101 <!-- contained in this file into your site. -->
102
103 <rss version="2.0"
104 xmlns:excerpt="http://wordpress.org/export/<?php echo esc_html( WXR_VERSION ); ?>/excerpt/"
105 xmlns:content="http://purl.org/rss/1.0/modules/content/"
106 xmlns:wfw="http://wellformedweb.org/CommentAPI/"
107 xmlns:dc="http://purl.org/dc/elements/1.1/"
108 xmlns:wp="http://wordpress.org/export/<?php echo esc_html( WXR_VERSION ); ?>/"
109 >
110
111 <channel>
112 <title><?php bloginfo_rss( 'name' ); ?></title>
113 <link><?php bloginfo_rss( 'url' ); ?></link>
114 <description><?php bloginfo_rss( 'description' ); ?></description>
115 <pubDate><?php echo esc_html( gmdate( 'D, d M Y H:i:s +0000' ) ); ?></pubDate>
116 <language><?php bloginfo_rss( 'language' ); ?></language>
117 <wp:wxr_version><?php echo esc_html( WXR_VERSION ); ?></wp:wxr_version>
118
119 <?php
120
121 $title = $post->post_title;
122
123 ?>
124 <item>
125 <title><?php echo esc_html( $title ); ?></title>
126 <link><?php the_permalink_rss(); ?></link>
127 <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
128 <dc:creator><?php echo $this->wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
129 <guid isPermaLink="false"><?php the_guid(); ?></guid>
130 <description></description>
131 <wp:post_id><?php echo (int) $post->ID; ?></wp:post_id>
132 <wp:post_date><?php echo $this->wxr_cdata( $post->post_date ); ?></wp:post_date>
133 <wp:post_date_gmt><?php echo $this->wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>
134 <wp:comment_status><?php echo $this->wxr_cdata( $post->comment_status ); ?></wp:comment_status>
135 <wp:ping_status><?php echo $this->wxr_cdata( $post->ping_status ); ?></wp:ping_status>
136 <wp:post_name><?php echo $this->wxr_cdata( $post->post_name ); ?></wp:post_name>
137 <wp:status><?php echo $this->wxr_cdata( $post->post_status ); ?></wp:status>
138 <wp:post_parent><?php echo (int) $post->post_parent; ?></wp:post_parent>
139 <wp:menu_order><?php echo (int) $post->menu_order; ?></wp:menu_order>
140 <wp:post_type><?php echo $this->wxr_cdata( $post->post_type ); ?></wp:post_type>
141 <wp:post_password><?php echo $this->wxr_cdata( $post->post_password ); ?></wp:post_password>
142 <?php
143 $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
144 foreach ( $postmeta as $meta ) :
145 /**
146 * Filters whether to selectively skip post meta used for WXR exports.
147 *
148 * Returning a truthy value from the filter will skip the current meta
149 * object from being exported.
150 *
151 * @param bool $skip Whether to skip the current post meta. Default false.
152 * @param string $meta_key Current meta key.
153 * @param object $meta Current meta object.
154 *
155 * @since 3.3.0
156 *
157 */
158 if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
159 continue;
160 }
161 ?>
162 <wp:postmeta>
163 <wp:meta_key><?php echo $this->wxr_cdata( $meta->meta_key ); ?></wp:meta_key>
164 <wp:meta_value><?php echo $this->wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
165 </wp:postmeta>
166 <?php
167 endforeach;
168 ?>
169 </item>
170 </channel>
171 </rss>
172 <?php
173 die();
174 }
175 }
176
177 /**
178 * Wrap given string in XML CDATA tag.
179 *
180 * @param string $str String to wrap in XML CDATA tag.
181 *
182 * @return string
183 * @since 3.1.15
184 *
185 */
186 private function wxr_cdata( $str ) {
187 if ( ! seems_utf8( $str ) ) {
188 $str = utf8_encode( $str );
189 }
190 // $str = ent2ncr(esc_html($str));
191 $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', wp_kses_post( $str ) ) . ']]>';
192
193 return $str;
194 }
195
196 /**
197 * Add Debug metabox
198 *
199 * @since 3.1.15
200 */
201 public function debug_meta_box_setup() {
202
203 /* Add meta boxes on the 'add_meta_boxes' hook. */
204 add_action( 'add_meta_boxes', array( $this, 'add_debug_meta_box' ), 10 );
205 }
206
207 /**
208 * Add Debug metabox
209 *
210 * @since 3.1.15
211 */
212 public function add_debug_meta_box() {
213 add_meta_box(
214 'wpmtst-debug', // Unique ID
215 esc_html__( 'Debug testimonial', 'strong-testimonials' ), // Title
216 array( $this, 'output_debug_meta' ), // Callback function
217 'wpm-testimonial', // Admin page (or post type)
218 'side', // Context
219 'low' // Priority
220 );
221 }
222
223 /**
224 * Default hidden debug metabox
225 *
226 * @since 3.1.15
227 */
228 public function hide_meta_box( $hidden, $screen ) {
229 $user_id = get_current_user_id();
230 if ( 0 === $user_id ) {
231 return $hidden;
232 }
233
234 $user_meta = get_user_meta( $user_id, 'metaboxhidden_wpm-testimonial', true );
235
236 //make sure we are dealing with the correct screen
237 if ( ( 'post' === $screen->base ) && ( 'wpm-testimonial' === $screen->id ) && is_array( $user_meta ) && in_array( 'wpmtst-debug', $user_meta, true ) ) {
238 $hidden[] = 'wpmtst-debug';
239 }
240
241 return $hidden;
242 }
243
244 /**
245 * Output the Debug testimonial metabox
246 *
247 * @since 3.1.15
248 */
249 public function output_debug_meta() {
250 ?>
251 <div class="wpmtst-upsells-carousel-wrapper">
252 <div class="wpmtst-upsells-carousel">
253 <div class="wpmtst-upsell wpmtst-upsell-item">
254 <p class="wpmtst-upsell-description"><?php echo esc_html__( 'Export the testimonial and send it to Strong Testimonial\'s support team so that we can debug your problem much easier.', 'strong-testimonials' ); ?></p>
255 <p>
256 <a href="
257 <?php
258 echo esc_url(
259 add_query_arg(
260 array(
261 'wpmtst_single_download' => absint( get_the_ID() ),
262 )
263 )
264 );
265 ?>
266 "
267 class="button"><?php esc_html_e( 'Export testimonial', 'strong-testimonials' ); ?></a>
268
269 </p>
270 <?php do_action( 'wpmtst_debug_metabox_content' ); ?>
271 </div>
272 </div>
273 </div>
274 <?php
275 }
276 }
277
278 $st_debug = Strong_Testimonials_Debug::get_instance();
279