33 * Plugin Name: Quicq for WebP images
44 * Plugin URI: https://afosto.com/apps/quicq/
55 * Description: Quicq integration for Wordpress.
6- * Version: 1.5 .0
6+ * Version: 1.6 .0
77 * Author: Afosto
88 * Author URI: https://afosto.com
99 * Domain Path: /languages
3131
3232/**
3333 * hook that defines if quicq is active
34- * @since 1.4
34+ * @since 1.6
3535 */
36- add_action ( 'init ' , 'quicq_active ' , 1 );
36+ if ( ! is_admin () && get_option ( 'quicq_enabled ' ) == 1 ) {
37+ add_filter ( 'the_content ' , 'quicq_activated ' );
38+ }
39+
40+ /**
41+ * hook that defines if quicq is active
42+ * @since 1.6
43+ */
44+ add_action ( 'init ' , 'quicq_version_check ' , 2 );
3745/**
3846 * added hooks when deactivating and removing
3947 * @since 1.2
4351register_activation_hook ( __FILE__ , 'quicq_activate ' );
4452
4553/**
46- * hook that handles updates
47- * @since 1.4.3
54+ * hook that checks if there plugin has been updated
55+ * @since 1.6.0
4856 */
49- add_action ( 'upgrader_process_complete ' , 'quicq_upgrader_process_complete ' , 10 , 2 );
50-
51-
52-
53-
54- if ( ! function_exists ( ' quicq_upgrader_process_complete ' ) ) {
55- function quicq_upgrader_process_complete ( $ upgrader_object , $ options ) {
56- $ current_plugin_path_name = plugin_basename ( __FILE__ );
57-
58- if ( $ options ['action ' ] == 'update ' && $ options ['type ' ] == 'plugin ' ) {
59- foreach ( $ options ['plugins ' ] as $ each_plugin ) {
60- if ( $ each_plugin == $ current_plugin_path_name ) {
61- // Set a transient to record that our plugin has just been updated
62- set_transient ( 'wp_quicq_updated ' , 1 );
63- }
57+ if ( ! function_exists ( 'quicq_version_check ' ) ) {
58+ function quicq_version_check () {
59+ if ( get_option ( 'quicq_enabled ' ) == 1 ) {
60+ $ currentVersion = null ;
61+ if ( preg_match ( '/\*[\s\t]+?version:[\s\t]+?([0-9.]+)/i ' , file_get_contents ( __FILE__ ), $ v ) ) {
62+ $ currentVersion = $ v [1 ];
63+ }
64+ if ( $ currentVersion != null && strcasecmp ( $ currentVersion , get_option ( "quicq_version " ) ) != 0 ) {
65+ quicq_trigger_update ( $ currentVersion );
6466 }
6567 }
6668 }
6769}
6870
69-
7071/**
7172 * notifies Quicq about the version update so it can match the plugin version
73+ * @since 1.6.0
7274 */
73- if ( ! function_exists ( ' quicq_trigger_update ' ) ) {
74- function quicq_trigger_update () {
75+ if ( ! function_exists ( 'quicq_trigger_update ' ) ) {
76+ function quicq_trigger_update ( $ plugin_version ) {
7577 // Check the transient to see if we've just updated the plugin
76- if ( get_transient ( 'wp_quicq_updated ' ) ) {
7778
78- global $ wp_version ;
79- $ plugin_version = null ;
80- if ( preg_match ( '/\*[\s\t]+?version:[\s\t]+?([0-9.]+)/i ' , file_get_contents ( __FILE__ ), $ v ) ) {
81- $ plugin_version = $ v [1 ];
82- }
79+ global $ wp_version ;
80+ $ siteKey = str_replace ( "https://cdn.quicq.io/ " , "" , get_option ( 'quicq_key ' ) );
81+
82+ wp_remote_request ( sprintf ( "https://afosto.app/api/storage/quicq/proxies/%s/wordpress/upgrade " , $ siteKey ), [
83+ "method " => "PUT " ,
84+ "headers " => [
85+ "content-type " => "application/vnd.afosto.api.v1+json "
86+ ],
87+ "body " => json_encode ( [
88+ "data " => [
89+ "site_key " => $ siteKey ,
90+ "version " => $ plugin_version ,
91+ "site_url " => site_url (),
92+ "wordpress_version " => $ wp_version ,
93+ ]
94+ ] )
95+ ]
96+ );
8397
84- $ siteKey = str_replace ( "https://cdn.quicq.io/ " , "" , get_option ( 'quicq_key ' ) );
85- wp_remote_request ( sprintf ( "https://afosto.app/api/storage/quicq/proxies/%s/wordpress/upgrade " , $ siteKey ), [
86- "method " => "PUT " ,
87- "headers " => [
88- "content-type " => "application/vnd.afosto.api.v1+json "
89- ],
90- "body " => json_encode ( [
91- "data " => [
92- "site_key " => $ siteKey ,
93- "version " => $ plugin_version ,
94- "site_url " => site_url (),
95- "wordpress_version " => $ wp_version ,
96- ]
97- ] )
98- ]
99- );
100- delete_transient ( 'wp_quicq_updated ' );
101- }
98+ update_option ("quicq_version " ,$ plugin_version );
10299 }
103- quicq_trigger_update ();
104100}
105101
102+
106103if ( isset ( $ _GET ['page ' ] ) ) {
107104 if ( $ _GET ['page ' ] == 'quicq_adminpage ' ) {
108105 add_action ( 'admin_enqueue_scripts ' , 'quicq_add_styles ' , 0 );
@@ -112,7 +109,7 @@ function quicq_trigger_update() {
112109 * Multilanguage function
113110 * @since 1.0.0
114111 */
115- if ( ! function_exists ( ' quicq_load_textdomain ' ) ) {
112+ if ( ! function_exists ( 'quicq_load_textdomain ' ) ) {
116113 function quicq_load_textdomain () {
117114 if ( is_textdomain_loaded ( 'quicq ' ) ) {
118115 return ;
@@ -126,7 +123,7 @@ function quicq_load_textdomain() {
126123 * function that starts the content rewrite if quicq is enabled
127124 * @since 1.0.0
128125 */
129- if ( ! function_exists ( ' quicq_active ' ) ) {
126+ if ( ! function_exists ( 'quicq_active ' ) ) {
130127 function quicq_active () {
131128 if ( get_option ( 'quicq_enabled ' ) == 1 && ! is_admin () ) {
132129 ob_start ( "quicq_activated " );
@@ -138,7 +135,7 @@ function quicq_active() {
138135 * function that rewrites the the urls within the html content
139136 * @since 1.4.0
140137 */
141- if ( ! function_exists ( ' quicq_activated ' ) ) {
138+ if ( ! function_exists ( 'quicq_activated ' ) ) {
142139 function quicq_activated ( $ content ) {
143140 $ content = preg_replace_callback ( '/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}(\.[a-zA-Z0-9()]{1,6}|:\d+)\b([-a-zA-Z0-9()@:%_+.~#?&\/\/=]*))(.png|.jpe?g|webp|.svg)/ ' , 'quicq_rewrite_url ' , $ content );
144141
@@ -150,7 +147,7 @@ function quicq_activated( $content ) {
150147 * function thar replaces an wp-content url to the quicq cdn url
151148 * @since 1.4.0
152149 */
153- if ( ! function_exists ( ' quicq_rewrite_url ' ) ) {
150+ if ( ! function_exists ( 'quicq_rewrite_url ' ) ) {
154151 function quicq_rewrite_url ( $ images ) {
155152 $ quicq_url = get_option ( 'quicq_key ' );
156153 foreach ( $ images as &$ imageUrl ) {
@@ -166,7 +163,7 @@ function quicq_rewrite_url( $images ) {
166163 * function for when the plugin is being deactivated
167164 * @since 1.2.0
168165 */
169- if ( ! function_exists ( ' quicq_deactivate ' ) ) {
166+ if ( ! function_exists ( 'quicq_deactivate ' ) ) {
170167 function quicq_deactivate () {
171168 update_option ( 'quicq_enabled ' , 0 );
172169 }
@@ -176,7 +173,7 @@ function quicq_deactivate() {
176173 * function for when the plugin is being deactivated
177174 * @since 1.2.0
178175 */
179- if ( ! function_exists ( ' quicq_activate ' ) ) {
176+ if ( ! function_exists ( 'quicq_activate ' ) ) {
180177 function quicq_activate () {
181178 if ( get_option ( 'quicq_key ' ) != "" ) {
182179 update_option ( 'quicq_enabled ' , 1 );
@@ -189,7 +186,7 @@ function quicq_activate() {
189186 * function which uninstalls the plugin, removes traces for settings
190187 * @since 1.2.0
191188 */
192- if ( ! function_exists ( ' quicq_uninstall ' ) ) {
189+ if ( ! function_exists ( 'quicq_uninstall ' ) ) {
193190 function quicq_uninstall () {
194191 delete_option ( 'quicq_enabled ' );
195192 delete_option ( 'quicq_key ' );
@@ -203,7 +200,7 @@ function quicq_uninstall() {
203200 * @since 1.0.0
204201 */
205202
206- if ( ! function_exists ( ' quicq_add_styles ' ) ) {
203+ if ( ! function_exists ( 'quicq_add_styles ' ) ) {
207204 function quicq_add_styles () {
208205 $ plugin_url = plugin_dir_url ( __FILE__ );
209206
@@ -219,7 +216,7 @@ function quicq_add_styles() {
219216 * Adds quicq settings page
220217 * @since 1.0
221218 */
222- if ( ! function_exists ( ' quicq_init_page ' ) ) {
219+ if ( ! function_exists ( 'quicq_init_page ' ) ) {
223220 function quicq_init_page () {
224221 $ plugin_url = plugin_dir_url ( __FILE__ );
225222 $ imageurl = $ plugin_url . 'images/quicqicon.png ' ;
@@ -239,7 +236,7 @@ function quicq_init_page() {
239236 * Adds quicq settings
240237 * @since 1.0
241238 */
242- if ( ! function_exists ( ' quicq_add_settings ' ) ) {
239+ if ( ! function_exists ( 'quicq_add_settings ' ) ) {
243240 function quicq_add_settings () {
244241 register_setting ( 'quicq-page ' , 'quicq_enabled ' );
245242 register_setting ( 'quicq-page ' , 'quicq_key ' );
@@ -251,19 +248,19 @@ function quicq_add_settings() {
251248 * Quicq SVG logo
252249 * @since 1.0
253250 */
254- if ( ! function_exists ( ' quicq_logo ' ) ) {
251+ if ( ! function_exists ( 'quicq_logo ' ) ) {
255252 function quicq_logo () {
256253 echo '<svg style="height:60px" class="logo-light" viewBox="0 0 72 41" fill="none"><path fill="#C1CED7" class="logo-transparent" d="M15.74 38v-7h2.46c.5 0 .9.08 1.22.24.33.15.57.37.73.64.16.27.24.57.24.9 0 .45-.12.81-.37 1.07-.24.26-.53.44-.87.54a1.66 1.66 0 011.21.91 1.87 1.87 0 01-.07 1.76c-.17.29-.43.52-.77.69a2.8 2.8 0 01-1.24.25h-2.54zm.84-3.94h1.56c.45 0 .79-.1 1.03-.31s.36-.5.36-.88c0-.35-.12-.64-.36-.85-.23-.21-.59-.32-1.06-.32h-1.53v2.36zm0 3.24h1.61c.48 0 .85-.11 1.11-.33.26-.23.39-.54.39-.94 0-.4-.14-.7-.41-.94a1.62 1.62 0 00-1.11-.36h-1.59v2.57zm5.67 2.9l1.23-2.68h-.3l-1.96-4.48h.9l1.65 3.86 1.74-3.86h.87l-3.25 7.16h-.88zm7.27-2.2l2.58-7h.89l2.57 7h-.9l-.63-1.8h-2.98L30.4 38h-.88zm1.78-2.48h2.48l-1.24-3.46-1.24 3.46zM36.65 38v-4.25h-.75v-.71h.75v-.86c0-.48.12-.83.36-1.05.24-.22.6-.33 1.05-.33h.5v.72h-.37c-.25 0-.43.05-.54.16-.1.1-.16.27-.16.52v.84h1.22v.71H37.5V38h-.84zm5.13.12a2.36 2.36 0 01-2.15-1.22c-.22-.4-.32-.85-.32-1.38 0-.53.1-.98.33-1.37.22-.4.51-.7.89-.91.38-.21.8-.32 1.27-.32.46 0 .88.1 1.26.32.37.21.66.52.88.91.22.39.33.84.33 1.37 0 .53-.11.99-.33 1.38-.22.39-.52.69-.9.9-.38.21-.8.32-1.26.32zm0-.72a1.57 1.57 0 001.4-.84c.15-.28.23-.63.23-1.04 0-.41-.08-.76-.23-1.04a1.5 1.5 0 00-1.38-.84 1.57 1.57 0 00-1.4.84c-.16.28-.23.63-.23 1.04 0 .41.07.76.23 1.04.15.28.35.49.59.63s.5.21.79.21zm5.56.72c-.6 0-1.1-.15-1.48-.45-.4-.3-.63-.7-.7-1.22h.87c.05.26.19.49.4.68.23.19.54.28.92.28.35 0 .6-.07.78-.22a.71.71 0 00.25-.54c0-.3-.11-.5-.33-.6a4.2 4.2 0 00-.91-.27 5.15 5.15 0 01-.8-.23c-.27-.1-.5-.24-.67-.42a1 1 0 01-.27-.73c0-.43.16-.79.48-1.06.32-.28.76-.42 1.32-.42a2 2 0 011.29.4c.34.26.53.63.59 1.12h-.83a.84.84 0 00-.33-.59 1.12 1.12 0 00-.73-.22c-.3 0-.54.06-.7.19a.6.6 0 00-.24.5c0 .2.1.36.3.47.22.11.5.21.87.29.3.07.6.15.87.25.28.1.5.24.68.43.18.19.27.46.27.82 0 .45-.17.82-.51 1.11-.34.29-.8.43-1.4.43zm4.83-.12a1.6 1.6 0 01-1.07-.33c-.26-.22-.39-.62-.39-1.19v-2.73h-.86v-.71h.86l.11-1.19h.73v1.19h1.46v.71h-1.46v2.73c0 .31.06.53.2.64.12.1.34.16.66.16h.52V38h-.76zm4.03.12c-.46 0-.88-.1-1.26-.32a2.35 2.35 0 01-.89-.9c-.21-.4-.32-.85-.32-1.38 0-.53.11-.98.33-1.37.22-.4.52-.7.9-.91.37-.21.8-.32 1.26-.32.47 0 .89.1 1.26.32.38.21.67.52.88.91.22.39.33.84.33 1.37 0 .53-.1.99-.33 1.38-.22.39-.52.69-.9.9-.37.21-.8.32-1.26.32zm0-.72a1.57 1.57 0 001.4-.84c.16-.28.23-.63.23-1.04 0-.41-.07-.76-.23-1.04a1.5 1.5 0 00-1.38-.84 1.57 1.57 0 00-1.4.84c-.15.28-.23.63-.23 1.04 0 .41.08.76.23 1.04.16.28.35.49.6.63.24.14.5.21.78.21z"></path><path fill="#000" class="logo-opaque" fill-rule="evenodd" clip-rule="evenodd" d="M59.6 21.07c.71.33 1.5.5 2.35.5 1.01 0 1.91-.2 2.7-.6a4.91 4.91 0 001.92-1.82v4.94h-1.52c-.44 0-.67.5-.35.79l3.22 2.98c.2.19.51.19.71 0l3.22-2.98c.32-.3.1-.8-.35-.8H70V8.9h-3v2.16a5.51 5.51 0 00-4.65-2.37 6.21 6.21 0 00-5.82 3.9 7.3 7.3 0 00-.03 5.06 6.08 6.08 0 003.08 3.44zm8.32 3.02h-.02.02zm-2.76-5.8a3.75 3.75 0 01-3.41.28 3.54 3.54 0 01-1.9-1.94 4.05 4.05 0 010-2.87c.19-.46.44-.86.74-1.21.33-.37.7-.65 1.13-.86a3.44 3.44 0 013.54.43 3.6 3.6 0 011.31 1.76v2.94c-.4.6-.86 1.1-1.4 1.47z"></path><path fill="#000" class="logo-opaque" d="M13.5 20.24c-.67.38-1.39.68-2.16.9-.77.2-1.59.31-2.46.31a8.8 8.8 0 01-8.24-5.39 8.16 8.16 0 011.9-9.12c.8-.79 1.75-1.41 2.85-1.87a8.87 8.87 0 013.56-.71 8.77 8.77 0 018.83 8.6 8.35 8.35 0 01-2.39 5.8l2.5 2.57h-3.34l-1.05-1.09zm-4.6-1.68c.47 0 .9-.05 1.29-.15.4-.1.78-.25 1.13-.42l-2.78-2.9h3.34l1.26 1.3a6.32 6.32 0 001.07-3.49A5.94 5.94 0 0012.79 9 4.93 4.93 0 008.9 7.25a5.05 5.05 0 00-3.95 1.78A5.94 5.94 0 003.6 12.9c0 .73.12 1.44.36 2.12a5.3 5.3 0 002.7 3.06 5.2 5.2 0 002.25.48zM24.24 21.57c-1.38 0-2.43-.41-3.15-1.23-.72-.83-1.08-2.05-1.08-3.66V8.89h3.44V16c0 1.92.74 2.87 2.23 2.87.67 0 1.31-.18 1.93-.54a4.16 4.16 0 001.54-1.71V8.89h3.43v8.79c0 .33.06.57.18.7.14.15.35.23.64.25v2.7a7.72 7.72 0 01-1.48.15c-.62 0-1.12-.13-1.52-.38-.37-.27-.6-.64-.66-1.1l-.08-1a5.6 5.6 0 01-2.31 1.93c-.94.43-1.98.64-3.1.64zM36 21.33V8.9h3.44v12.44H36zm0-14.17V4h3.44v3.16H36zM41.7 15.11a5.98 5.98 0 011.9-4.51 6.92 6.92 0 012.22-1.4 7.9 7.9 0 012.96-.52c1.47 0 2.72.29 3.74.88a5.8 5.8 0 012.34 2.3l-3.36.95c-.3-.46-.68-.8-1.16-1.05-.48-.25-1-.38-1.59-.38-.5 0-.96.1-1.39.29a3.3 3.3 0 00-1.87 1.92 4.32 4.32 0 00.03 3.04c.19.46.43.86.74 1.19.33.33.7.6 1.13.78a3.57 3.57 0 003.05-.16c.53-.29.9-.64 1.1-1.05l3.37.95a5.4 5.4 0 01-2.29 2.33c-1.06.6-2.33.9-3.82.9a7.9 7.9 0 01-2.95-.52 6.57 6.57 0 01-3.67-3.47 6.44 6.44 0 01-.49-2.47z"></path></svg> ' ;
257254 }
258255}
259256
260- if ( ! function_exists ( ' quicq_doc_icon ' ) ) {
257+ if ( ! function_exists ( 'quicq_doc_icon ' ) ) {
261258 function quicq_doc_icon () {
262259 echo '<svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="file-alt" class="svg-inline--fa fa-file-alt fa-w-12" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zm-22.6 22.7c2.1 2.1 3.5 4.6 4.2 7.4H256V32.5c2.8.7 5.3 2.1 7.4 4.2l83.9 83.9zM336 480H48c-8.8 0-16-7.2-16-16V48c0-8.8 7.2-16 16-16h176v104c0 13.3 10.7 24 24 24h104v304c0 8.8-7.2 16-16 16zm-48-244v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm0 64v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm0 64v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12z"/></svg> ' ;
263260 }
264261}
265262
266- if ( ! function_exists ( ' quicq_arrow_icon ' ) ) {
263+ if ( ! function_exists ( 'quicq_arrow_icon ' ) ) {
267264 function quicq_arrow_icon () {
268265 echo '<svg style="height:12px; margin-left: 5px;"aria-hidden="true" focusable="false" data-prefix="far" data-icon="long-arrow-right" class="svg-inline--fa fa-long-arrow-right fa-w-14 fa-fw fa-xs ml-8" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M295.515 115.716l-19.626 19.626c-4.753 4.753-4.675 12.484.173 17.14L356.78 230H12c-6.627 0-12 5.373-12 12v28c0 6.627 5.373 12 12 12h344.78l-80.717 77.518c-4.849 4.656-4.927 12.387-.173 17.14l19.626 19.626c4.686 4.686 12.284 4.686 16.971 0l131.799-131.799c4.686-4.686 4.686-12.284 0-16.971L312.485 115.716c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg> ' ;
269266 }
@@ -273,7 +270,7 @@ function quicq_arrow_icon() {
273270 * Adds quicq menu style
274271 * @since 1.0
275272 */
276- if ( ! function_exists ( ' quicq_plugin_style ' ) ) {
273+ if ( ! function_exists ( 'quicq_plugin_style ' ) ) {
277274 function quicq_plugin_style () {
278275 ?>
279276 <style media="screen">
@@ -295,7 +292,7 @@ function quicq_plugin_style() {
295292 * Styles inline for pagespeed
296293 * @since 1.0
297294 */
298- if ( ! function_exists ( ' quicq_adminpage ' ) ) {
295+ if ( ! function_exists ( 'quicq_adminpage ' ) ) {
299296 function quicq_adminpage () {
300297
301298 if ( current_user_can ( 'manage_options ' ) ) {
0 commit comments