PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.3.6.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.3.6.1
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / functions / options.php

options.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.3.6.1, at inc/functions/options.php

78 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3
4 /**
5 * A wrapper to easily get imagify option
6 *
7 * @since 1.0
8 *
9 * @param string $option The option name
10 * @param bool $default The default value of option
11 * @return mixed The option value
12 */
13 function get_imagify_option( $option, $default = false ) {
14 /**
15 * Pre-filter any Imagify option before read
16 *
17 * @since 1.0
18 *
19 * @param variant $default The default value
20 */
21 $value = apply_filters( 'pre_get_imagify_option_' . $option, NULL, $default );
22
23 if ( NULL !== $value ) {
24 return $value;
25 }
26
27 $plugins = get_site_option( 'active_sitewide_plugins');
28 $options = isset( $plugins[ IMAGIFY_SLUG . '/imagify.php' ] ) ? get_site_option( IMAGIFY_SETTINGS_SLUG ) : get_option( IMAGIFY_SETTINGS_SLUG );
29 $value = isset( $options[ $option ] ) && $options[ $option ] !== '' ? $options[ $option ] : $default;
30
31 if ( 'api_key' === $option && ( defined( 'IMAGIFY_API_KEY' ) && IMAGIFY_API_KEY ) ) {
32 $value = IMAGIFY_API_KEY;
33 }
34
35 /**
36 * Filter any Imagify option after read
37 *
38 * @since 1.0
39 *
40 * @param variant $default The default value
41 */
42 return apply_filters( 'get_imagify_option_' . $option, $value, $default );
43 }
44
45 /**
46 * Determine if the Imagify API key is valid
47 *
48 * @since 1.0
49 *
50 * @return bool True if the API key is valid
51 */
52 function imagify_valid_key() {
53 static $imagify_valid_key = null;
54
55 if ( null !== $imagify_valid_key ) {
56 return $imagify_valid_key;
57 }
58
59 if ( ! get_imagify_option( 'api_key', false ) ) {
60 $imagify_valid_key = false;
61 return false;
62 }
63
64 if ( get_site_transient( 'imagify_check_licence_1' ) ) {
65 $imagify_valid_key = true;
66 return true;
67 }
68
69 if ( is_wp_error( get_imagify_user() ) ) {
70 $imagify_valid_key = false;
71 return false;
72 }
73
74 $imagify_valid_key = true;
75 set_site_transient( 'imagify_check_licence_1', true, YEAR_IN_SECONDS );
76
77 return true;
78 }