PluginProbe
picu – Online Photo Proofing Gallery / 2.3.4
picu – Online Photo Proofing Gallery v2.3.4
3.9.0 3.8.1 3.8.0 3.7.0 3.6.1 3.6.0 trunk 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.3.0 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 All 46 releases
picu / picu.php

picu.php in picu – Online Photo Proofing Gallery 2.3.4, at picu.php

595 lines 21.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: picu
4 * Plugin URI: https://picu.io/
5 * Description: Send a collection of photographs to your client for approval.
6 * Version: 2.3.4
7 * Requires at least: 6.0
8 * Requires PHP: 7.4
9 * Author: Haptiq
10 * Author URI: https://picu.io/
11 * License: GPLv3
12 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
13 * Text Domain: picu
14 */
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18 /**
19 * Include functions for picu
20 *
21 * @since 0.2.0
22 */
23 if ( ! function_exists( 'picu_setup' ) ) {
24
25 function picu_setup() {
26
27 // Define plugin version
28 define( 'PICU_VERSION', '2.3.4' );
29
30 // Define path for this plugin
31 define( 'PICU_PATH', plugin_dir_path(__FILE__) );
32
33 // Define URL for this plugin
34 define( 'PICU_URL', plugin_dir_url(__FILE__) );
35
36 // Define picu upload dir
37 $upload_dir = wp_upload_dir();
38 define( 'PICU_UPLOAD_DIR', $upload_dir['basedir'] . '/picu' );
39
40 // Define telemetry URL
41 define( 'PICU_TELEMETRY_URL', 'https://picu.io/wp-json/picu-telemetry/v1/' );
42
43 // Include functions to render admin menu and settings page
44 require PICU_PATH . 'backend/includes/picu-settings.php';
45
46 // Include functions to render add-ons page
47 require PICU_PATH . 'backend/includes/picu-addons-page.php';
48
49 // Include function for registering custom post type collection
50 require PICU_PATH . 'backend/includes/picu-cpt-collection.php';
51
52 // Include welcome screen
53 require PICU_PATH . 'backend/includes/picu-welcome-screen.php';
54
55 // Include functions for admin notices and error messages
56 require PICU_PATH . 'backend/includes/picu-admin-notices.php';
57
58 // Everything that doesn't fit anywhere else...
59 require PICU_PATH . 'backend/includes/picu-helper.php';
60
61 // Include custom metabox and our custom edit screen
62 require PICU_PATH . 'backend/includes/picu-edit-collection.php';
63
64 // Picu media handling
65 require PICU_PATH . 'backend/includes/picu-media.php';
66
67 // Handle ajax requests
68 require PICU_PATH . 'backend/includes/picu-ajax.php';
69
70 // Fix third party stuff
71 require PICU_PATH . 'backend/includes/picu-opp.php';
72
73 // Picu Email sending class
74 require PICU_PATH . 'backend/includes/emails/class-picu-emails.php';
75
76 // Picu Email sending functions
77 require PICU_PATH . 'backend/includes/emails/picu-emails.php';
78
79 // Include template redirection etc. for collections
80 require PICU_PATH . 'frontend/includes/picu-template-functions.php';
81
82 // Deprecated functions, filters and hooks
83 require PICU_PATH . 'backend/includes/deprecated.php';
84
85 // Handle picu telemetry
86 require PICU_PATH . 'backend/includes/picu-telemetry.php';
87
88 // Autoload classes installed via composer (emogrify)
89 require PICU_PATH . 'vendor/autoload.php';
90
91 // Add picu debug info to Site Health screen
92 require PICU_PATH . 'backend/includes/picu-site-health.php';
93
94 // Check the settings version, run upgrader
95 $settings_version = get_option( 'picu_settings_version' );
96 // Version upgrade is needed
97 if ( empty( $settings_version ) ) {
98 picu_settings_upgrade();
99 }
100 }
101 }
102
103 add_action( 'after_setup_theme', 'picu_setup' );
104
105
106 /**
107 * Run upgrades after update
108 *
109 * Since 2.3.0
110 */
111 function picu_upgrade() {
112 $settings_version = get_option( 'picu_settings_version' );
113
114 if ( version_compare( $settings_version, PICU_VERSION, '<' ) ) {
115 picu_collections_upgrade();
116 }
117 }
118
119 // This needs to run after `init` so everything we need is in place!
120 add_action( 'init', 'picu_upgrade', 11 );
121
122
123 /**
124 * Set transient to display welcome screen on activation
125 *
126 * @since 0.7.0
127 */
128 function picu_activate_welcome_screen() {
129 // Set transient for redirect to activation screen
130 set_transient( '_picu_welcome_screen_activation_redirect', true, 30 );
131 }
132
133 register_activation_hook( __FILE__, 'picu_activate_welcome_screen' );
134
135
136 /**
137 * Flush rewrite rules on plugin activation/deactivation
138 *
139 * @since 0.7.0
140 */
141 function picu_flush_rewrites() {
142
143 // Include custom post type registration
144 include( plugin_dir_path(__FILE__) . 'backend/includes/picu-cpt-collection.php' );
145
146 // Make sure our custom post types are defined first
147 picu_register_cpt_collection();
148
149 // Flush the rewrite rules
150 flush_rewrite_rules();
151
152 }
153
154 register_deactivation_hook( __FILE__, 'flush_rewrite_rules' );
155 register_activation_hook( __FILE__, 'picu_flush_rewrites' );
156
157
158 /**
159 * Load some custom styling for our admin screens.
160 *
161 * @since 0.3.2
162 */
163 function picu_admin_styles_scripts() {
164
165 global $post;
166
167 $current_screen = get_current_screen();
168
169 // Prevent conflicts in case no current_screen is set
170 if ( empty( $current_screen ) ) {
171 return;
172 }
173
174 // Only load those styles on edit collection screens
175 if ( is_admin() ) {
176 wp_enqueue_style( 'picu-admin', PICU_URL . 'backend/css/picu-admin.css', false, filemtime( PICU_PATH . 'backend/css/picu-admin.css' ) );
177
178 global $pagenow;
179 if ( $current_screen->post_type == 'picu_collection' AND get_post_type() == 'picu_collection' AND $pagenow == 'post-new.php' || $pagenow == 'post.php' ) {
180 // Enqueue wp.media scripts manually, because we don't load the default editor on collections
181 // Post needs to be provided, or uploaded media will not get attached to the collection
182 $args = array( 'post' => $post->ID );
183 wp_enqueue_media( $args );
184 }
185
186 if ( $current_screen->base == 'picu_page_picu-design-appearance' ) {
187 // Add the color picker css file
188 wp_enqueue_style( 'wp-color-picker' );
189 }
190
191 // Make sure we are on the right screen
192 if ( ( $current_screen->post_type == 'picu_collection' && get_post_type() == 'picu_collection' && $pagenow == 'post-new.php' || $pagenow == 'post.php' ) || ( $current_screen->base == 'dashboard_page_picu-welcome-screen' ) || ( $current_screen->post_type == 'picu_collection' AND get_post_type() == 'picu_collection' AND $pagenow == 'edit.php' ) || strpos( $current_screen->base, 'picu_page_picu-' ) !== false ) {
193
194 // Enqueue media
195 wp_enqueue_media();
196
197 // Enqueue script
198 wp_enqueue_script( 'picu-admin', PICU_URL . 'backend/js/picu-admin.min.js', array( 'jquery', 'jquery-ui-draggable', 'jquery-ui-sortable', 'underscore', 'backbone', 'wp-color-picker' ), filemtime( PICU_PATH . 'backend/js/picu-admin.min.js' ), true );
199
200 $post_id = false;
201 if ( isset( $post->ID ) AND ! empty( $post->ID ) ) {
202 $post_id = $post->ID;
203 }
204
205 // Localize it
206 $picu_localization_strings = array(
207 'ajaxurl' => admin_url( 'admin-ajax.php' ),
208 'ajax_nonce' => wp_create_nonce( 'picu_ajax' ),
209 'postID' => $post_id,
210 'media_modal_title' => __( 'Upload Images', 'picu' ),
211 'media_modal_button_insert_text' => __( 'Insert Images', 'picu' ),
212 'sent_option_label' => __( 'Sent', 'picu' ),
213 'approved_option_label' => __( 'Approved', 'picu' ),
214 'expired_option_label' => __( 'Expired', 'picu' ),
215 'button_text_publish' => __( 'Publish', 'picu' ),
216 'button_text_send_to_client' => __( 'Send to Client', 'picu' ),
217 'selection_table_no_match' => __( 'No images found', 'picu' ),
218 );
219
220 $picu_localization_strings = apply_filters( 'picu_localization_strings', $picu_localization_strings );
221
222 wp_localize_script( 'picu-admin', 'picu_admin', $picu_localization_strings );
223 }
224
225 }
226
227 }
228
229 add_action( 'admin_enqueue_scripts', 'picu_admin_styles_scripts' );
230
231
232 /**
233 * Add settings link in plugins overview
234 *
235 * @param array $actions An array of links
236 * @since 1.0.0
237 */
238 function picu_plugin_action_links( $actions ) {
239
240 $action = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=picu-settings' ), __( 'Settings', 'picu' ) );
241 array_unshift( $actions, $action );
242
243 return $actions;
244 }
245
246 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ) , 'picu_plugin_action_links', 10 );
247
248
249 /**
250 * Custom capability to manage picu collections.
251 *
252 * Defaults to administrator privileges, can be filtered using 'picu_capability'.
253 *
254 * @since 1.1.0
255 */
256 function picu_capability() {
257 $picu_capability = 'manage_options';
258 $picu_capability = apply_filters( 'picu_capability', $picu_capability );
259
260 return $picu_capability;
261 }
262
263
264 /**
265 * Redirect /picu to collection overview in WordPress admin
266 *
267 * @since 1.2.1
268 */
269 function picu_redirect_to_overview() {
270 if ( $_SERVER['REQUEST_URI'] == '/picu' OR $_SERVER['REQUEST_URI'] == '/picu/' ) {
271 wp_redirect( admin_url() . 'edit.php?post_type=picu_collection' );
272 exit;
273 }
274 }
275
276 add_action( 'init', 'picu_redirect_to_overview' );
277
278
279 /**
280 * Check picu Pro compatibility
281 *
282 * @since 2.0.0
283 */
284 function picu_check_pro_compat() {
285 if ( defined( 'PICU_PRO' ) && version_compare( PICU_PRO, '1.4.5' ) < 0 ) {
286 /* translators: Admin notice, %s = opening and closing link tags */
287 $notice = sprintf ( __( '🚨 <strong>Action required:</strong> The version of picu Pro you are using is not compatible with this version of picu. %sPlease update to the latest version of picu Pro%s.', 'picu' ), '<a href="' . admin_url( 'plugins.php?s=picu%20pro&plugin_status=all' ) . '">', '</a>' );
288 $notice_type = 'error';
289
290 // Display admin notice
291 add_action( 'admin_notices', function() use ( $notice, $notice_type ) {
292 ?>
293 <div class="picu-pro-module-notice notice notice-<?php echo $notice_type; ?>">
294 <p><?php echo $notice; ?></p>
295 </div>
296 <?php
297 });
298 }
299 }
300
301 add_action( 'init', 'picu_check_pro_compat' );
302
303
304 /**
305 * Add picu Pro upgrade box
306 *
307 * @since 1.3.1
308 */
309 function picu_add_pro_metabox() {
310 if ( ! picu_is_pro_license_valid() ) {
311
312 add_meta_box(
313 'picu-pro-metabox',
314 __( 'Get picu pro', 'picu' ),
315 'picu_display_pro_metabox',
316 'picu_collection',
317 'side',
318 'high'
319 );
320 }
321 }
322
323 add_action( 'add_meta_boxes', 'picu_add_pro_metabox' );
324
325
326 /**
327 * Render the Pro metabox.
328 *
329 * @since 1.3.1
330 * @since 2.0.0 New box design and content
331 */
332 function picu_display_pro_metabox() {
333 ?>
334 <div class="picu-pro-meta-box">
335 <h2 class="picu-pro-meta-box__title"><?php echo __( 'Upgrade Your Proofing Workflow', 'picu' ); ?></h2>
336 <div class="picu-pro-meta-box__content">
337 <ul>
338 <li><?php _e( 'Add personal branding', 'picu' ); ?></li>
339 <li><?php _e( 'Send collections to multiple clients', 'picu' ); ?></li>
340 <li><?php _e( 'Enable markers and comments on individual images', 'picu' ); ?></li>
341 <li><?php _e( 'Many more professional features', 'picu' ); ?></li>
342 </ul>
343 <p class="picu-pro-meta-box__button-wrap"><a class="button button-primary picu-pro__button" href="https://go.picu.io/get-picu-pro" target="_blank"><?php _e( 'Get picu Pro', 'picu' ); ?> <svg style="transform: translateY(3px);" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#007791" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h13M12 5l7 7-7 7"/></svg></a></p>
344 <div class="picu-pro-meta-box__reviews">
345 <p>
346 <svg width="16" height="16" viewBox="0 0 16 15" xmlns="http://www.w3.org/2000/svg"><path d="m6.75365082.46448007c.30569615-.61930676 1.1888161-.61930676 1.49451225 0l1.86507723 3.77985326 4.1748568.61109495c.6453032.09432073.9240557.84870204.5363234 1.33810964l-.0754029.08342717-3.0197773 2.94036824.7130072 4.15513057c.1106198.6449702-.5249381 1.144844-1.1119645.922308l-.0972521-.0438773-3.73279062-1.9635613-3.73145727 1.9635613c-.57918124.3045856-1.25104449-.1453116-1.22088044-.7723782l.01166386-.1060525.71167385-4.15513057-3.018444-2.94036824c-.46718009-.45503341-.25023224-1.22945432.35090953-1.39822842l.11001096-.02330839 4.17352351-.61109495z" fill="#ffd700" transform="translate(.5 .5)"/></svg>
347 <svg width="16" height="16" viewBox="0 0 16 15" xmlns="http://www.w3.org/2000/svg"><path d="m6.75365082.46448007c.30569615-.61930676 1.1888161-.61930676 1.49451225 0l1.86507723 3.77985326 4.1748568.61109495c.6453032.09432073.9240557.84870204.5363234 1.33810964l-.0754029.08342717-3.0197773 2.94036824.7130072 4.15513057c.1106198.6449702-.5249381 1.144844-1.1119645.922308l-.0972521-.0438773-3.73279062-1.9635613-3.73145727 1.9635613c-.57918124.3045856-1.25104449-.1453116-1.22088044-.7723782l.01166386-.1060525.71167385-4.15513057-3.018444-2.94036824c-.46718009-.45503341-.25023224-1.22945432.35090953-1.39822842l.11001096-.02330839 4.17352351-.61109495z" fill="#ffd700" transform="translate(.5 .5)"/></svg>
348 <svg width="16" height="16" viewBox="0 0 16 15" xmlns="http://www.w3.org/2000/svg"><path d="m6.75365082.46448007c.30569615-.61930676 1.1888161-.61930676 1.49451225 0l1.86507723 3.77985326 4.1748568.61109495c.6453032.09432073.9240557.84870204.5363234 1.33810964l-.0754029.08342717-3.0197773 2.94036824.7130072 4.15513057c.1106198.6449702-.5249381 1.144844-1.1119645.922308l-.0972521-.0438773-3.73279062-1.9635613-3.73145727 1.9635613c-.57918124.3045856-1.25104449-.1453116-1.22088044-.7723782l.01166386-.1060525.71167385-4.15513057-3.018444-2.94036824c-.46718009-.45503341-.25023224-1.22945432.35090953-1.39822842l.11001096-.02330839 4.17352351-.61109495z" fill="#ffd700" transform="translate(.5 .5)"/></svg>
349 <svg width="16" height="16" viewBox="0 0 16 15" xmlns="http://www.w3.org/2000/svg"><path d="m6.75365082.46448007c.30569615-.61930676 1.1888161-.61930676 1.49451225 0l1.86507723 3.77985326 4.1748568.61109495c.6453032.09432073.9240557.84870204.5363234 1.33810964l-.0754029.08342717-3.0197773 2.94036824.7130072 4.15513057c.1106198.6449702-.5249381 1.144844-1.1119645.922308l-.0972521-.0438773-3.73279062-1.9635613-3.73145727 1.9635613c-.57918124.3045856-1.25104449-.1453116-1.22088044-.7723782l.01166386-.1060525.71167385-4.15513057-3.018444-2.94036824c-.46718009-.45503341-.25023224-1.22945432.35090953-1.39822842l.11001096-.02330839 4.17352351-.61109495z" fill="#ffd700" transform="translate(.5 .5)"/></svg>
350 <svg width="16" height="16" viewBox="0 0 16 15" xmlns="http://www.w3.org/2000/svg"><g fill="none" transform="translate(.5 .5)"><path d="m6.75365082.46448007c.30569615-.61930676 1.1888161-.61930676 1.49451225 0l1.86507723 3.77985326 4.1748568.61109495c.6453032.09432073.9240557.84870204.5363234 1.33810964l-.0754029.08342717-3.0197773 2.94036824.7130072 4.15513057c.1106198.6449702-.5249381 1.144844-1.1119645.922308l-.0972521-.0438773-3.73279062-1.9635613-3.73145727 1.9635613c-.57918124.3045856-1.25104449-.1453116-1.22088044-.7723782l.01166386-.1060525.71167385-4.15513057-3.018444-2.94036824c-.46718009-.45503341-.25023224-1.22945432.35090953-1.39822842l.11001096-.02330839 4.17352351-.61109495z" fill="#fffdf0"/><path d="m7.50024028.00000364v12.28732966l-3.73145727 1.9635613c-.57918124.3045856-1.25104449-.1453116-1.22088044-.7723782l.01166386-.1060525.71167385-4.15513057-3.018444-2.94036824c-.46718009-.45503341-.25023224-1.22945432.35090953-1.39822842l.11001096-.02330839 4.17352351-.61109495 1.86641054-3.77985326c.13336744-.27018775.37733399-.42249948.63539651-.45693517z" fill="#ffd700"/></g></svg>
351 <span class="picu-pro-meta-box__rating">4.7 / 5</span>
352 </p>
353 <p><a class="picu-pro-meta-box__link" href="https://go.picu.io/user-reviews" target="_blank"><?php _e( 'Check out picu user reviews', 'picu' ); ?></a></p>
354 </div>
355 </div>
356 </div>
357 <?php
358 }
359
360
361 /**
362 * Hide admin bar for now
363 */
364 add_filter( 'picu_show_admin_bar', '__return_false' );
365
366
367 /**
368 * Check if collection slug has changed
369 *
370 * @since 1.5.0
371 */
372 function picu_check_collection_slug() {
373
374 // Only run if collection or 404
375 if ( 'picu_collection' != get_post_type() AND ! is_404() ) {
376 return;
377 }
378
379 // Only run, if pretty permalinks are active
380 if ( ! get_option( 'permalink_structure' ) ) {
381 return;
382 }
383
384 // Get current collection slug
385 $post_type = get_post_type_object( 'picu_collection' );
386 $post_type_slug = $post_type->rewrite['slug'];
387
388 // Get saved slug. Set, if empty
389 $saved_slug = get_transient( 'picu_collection_slug' );
390
391 if ( empty( $saved_slug ) ) {
392 set_transient( 'picu_collection_slug', $post_type_slug, 0 );
393 return;
394 }
395
396 // Compare current with saved collection slug
397 if ( $post_type_slug != $saved_slug ) {
398 $old_picu_slugs = get_transient( 'picu_collection_old_slugs' );
399 $old_picu_slugs[] = $saved_slug;
400 set_transient( 'picu_collection_old_slugs', array_unique( $old_picu_slugs ) );
401 set_transient( 'picu_collection_slug', $post_type_slug, 0 );
402 flush_rewrite_rules( false );
403 }
404 }
405
406 add_action( 'wp', 'picu_check_collection_slug' );
407
408
409 /**
410 * Redirect when old collection base slug is used
411 *
412 * @since 1.5.0
413 */
414 function picu_redirect_from_old_slug() {
415
416 // Only run, if this is a 404
417 if ( ! is_404() ) {
418 return;
419 }
420
421 // Only run, if pretty permalinks are active
422 if ( ! get_option( 'permalink_structure' ) ) {
423 return;
424 }
425
426 // Check if the old slug transient is set
427 $old_picu_slugs = get_transient( 'picu_collection_old_slugs' );
428
429 if ( empty( $old_picu_slugs ) ) {
430 return;
431 }
432
433 // Get current url & path
434 global $wp;
435 $current_url = home_url( $wp->request );
436 $url = parse_url( $current_url );
437 $path = '';
438 if ( ! empty( $url['path'] ) ) {
439 $path = explode( '/', $url['path'] );
440 }
441
442 // Get current picu collection slug
443 $post_type_object = get_post_type_object( 'picu_collection' );
444 $current_slug = $post_type_object->rewrite['slug'];
445
446 if ( empty( $path[1] ) OR ! in_array( $path[1], $old_picu_slugs ) OR $path[1] == $current_slug ) {
447 return;
448 }
449
450 // Replace old slug with the new one
451 $new_url = $url['scheme'] . '://' . $url['host'] . '/' . $current_slug . '/' . $path[2] . '/';
452
453 // Get post type by url for the collection
454 $post_type = get_post_type( url_to_postid( $new_url ) );
455
456 // Redirect if the url is actually a collection
457 if ( 'picu_collection' == $post_type ) {
458 wp_redirect( trailingslashit( $new_url ), 301 );
459 }
460 }
461
462 add_filter( 'wp', 'picu_redirect_from_old_slug' );
463
464
465 /**
466 * Initialize proof file download
467 *
468 * @since 1.5.0
469 */
470 function picu_trigger_proof_file_download() {
471 if ( ! empty( $_REQUEST['picu-download'] ) AND $_REQUEST['picu-download'] == 'picu-proof-file' ) {
472 picu_create_proof_file( $_REQUEST['post'] );
473 exit;
474 }
475 }
476
477 add_action( 'init', 'picu_trigger_proof_file_download' );
478
479
480 /**
481 * Display Pro hint between image upload and sharing options
482 *
483 * @since 1.6.0
484 */
485 function picu_display_pro_hint() {
486 if ( ! picu_is_pro_active() ) {
487
488 $pro_hints = [
489 [
490 /* translators: Opening and closing link tags */
491 'text' => sprintf( __( '<strong>Get precise feedback</strong> &ndash; Learn %show to enable comments & markers%s on individual images.', 'picu' ), ' <a href="https://go.picu.io/get-feedback" target="_blank">', '</a>' ),
492 'icon' => '🖍️'
493 ],
494 [
495 /* translators: Opening and closing link tags */
496 'text' => sprintf( __( '<strong>Dealing with a lot of images?</strong> Learn %show to upload via FTP and import from your web server%s.', 'picu' ), '<a href="https://go.picu.io/lots-of-images" target="_blank">', '</a>' ),
497 'icon' => '😱'
498 ],
499 [
500 /* translators: Opening and closing link tags */
501 'text' => sprintf( __( '<strong>Protect your images</strong> &ndash; Learn %show to automatically add a watermark%s to your images.', 'picu' ), ' <a href="https://go.picu.io/protect-your-images" target="_blank">', '</a>' ),
502 'icon' => '🔒'
503 ],
504 [
505 /* translators: Opening and closing link tags */
506 'text' => sprintf( __( '<strong>Need more control?</strong> Learn %show to define the number of images%s your client needs to select.', 'picu' ), ' <a href="https://go.picu.io/more-control" target="_blank">', '</a>' ),
507 'icon' => '🎚️'
508 ],
509 [
510 /* translators: Opening and closing link tags */
511 'text' => sprintf( __( '<strong>Allow image downloads?</strong> Learn %show to enable image downloads%s for your collections.', 'picu' ), ' <a href="https://go.picu.io/allow-image-downloads" target="_blank">', '</a>' ),
512 'icon' => '⬇️'
513 ],
514 [
515 /* translators: Opening and closing link tags */
516 'text' => sprintf( __( '<strong>Done with post processing?</strong> Learn %show to deliver your final images%s to your clients.', 'picu' ), ' <a href="https://go.picu.io/done-post-processing" target="_blank">', '</a>' ),
517 'icon' => '�
518 '
519 ]
520 ];
521
522 // Randomize which pro hint to display
523 $display_pro_hint = rand( 1, count( $pro_hints ) ) - 1;
524 ?>
525 <div class="picu-pro-hint">
526 <div class="picu-pro-hint-inner">
527 <div class="picu-pro-hint-content">
528 <span class="picu-pro-hint-icon"><?php echo $pro_hints[$display_pro_hint]['icon']; ?></span>
529 <?php echo $pro_hints[$display_pro_hint]['text']; ?>
530 </div>
531 <div class="picu-pro-hint__badge">Pro</div>
532
533 </div>
534 </div>
535 <?php
536 }
537 }
538
539
540 /**
541 * Determine if Pro is active and license is valid.
542 *
543 * @since 1.6.0
544 * @since 1.9.0 Use function from Pro plugin, also checking license status
545 * @since 2.0.1 No longer checking license status
546 *
547 * @return bool Whether Pro is active or not
548 */
549 function picu_is_pro_active() {
550 if ( is_plugin_active( 'picu-pro/picu-pro.php' ) ) {
551 return true;
552 }
553
554 return false;
555 }
556
557
558 /**
559 * Determine if there is a valid Pro license.
560 *
561 * @since 2.0.1
562 *
563 * @return bool Whether there is an active Pro license
564 */
565 function picu_is_pro_license_valid() {
566 $valid = false;
567
568 if ( function_exists( 'picu_pro_get_license_status' ) ) {
569 $license_status = picu_pro_get_license_status();
570 if ( $license_status == 'valid' ) {
571 $valid = true;
572 }
573 }
574
575 return $valid;
576 }
577
578
579 /**
580 * Never use "private" post status.
581 *
582 * @since 2.3.3
583 *
584 * @param array $data An array of slashed, sanitized, and processed post data
585 * @return array Filtered post data
586 */
587 function picu_remove_post_status_private( $data ) {
588 if ( $data['post_type'] == 'picu_collection' && $data['post_status'] == 'private' ) {
589 $data['post_status'] = 'approved';
590 }
591
592 return $data;
593 }
594
595 add_action( 'wp_insert_post_data', 'picu_remove_post_status_private', 10 );