Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utm tracking to links, add meta key prefix #34

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/class-tiny-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function get_api_key_pending_notice() {

public function add_limit_reached_notice( $email ) {
$encoded_email = str_replace( '%20', '%2B', rawurlencode( $email ) );
$url = 'https://tinypng.com/dashboard/api?type=upgrade&mail=' . $encoded_email;
$url = 'https://tinypng.com/dashboard/api?type=upgrade&mail=' . $encoded_email . '&utm_source=installation&utm_medium=wordpress-plugin';
$link = '<a href="' . $url . '" target="_blank">' .
esc_html__( 'TinyPNG API account', 'tiny-compress-images' ) . '</a>';

Expand Down
46 changes: 46 additions & 0 deletions src/compatibility/class-tiny-migration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/*
* Tiny Compress Images - WordPress plugin.
* Copyright (C) 2015-2018 Tinify B.V.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

class Tiny_Migration {

public static function migrate_meta_key_on_update() {
$saved_version = get_option('tiny_png_plugin_version');

if ($saved_version !== TINY_PNG_PLUGIN_VERSION) {
global $wpdb;

$posts = $wpdb->get_results("
SELECT post_id, meta_value
FROM {$wpdb->postmeta}
WHERE meta_key = 'tiny_compress_images'
");

foreach ($posts as $post) {
update_post_meta($post->post_id, Tiny_Config::META_KEY, $post->meta_value);

delete_post_meta($post->post_id, 'tiny_compress_images');
}

update_option('tiny_png_plugin_version', TINY_PNG_PLUGIN_VERSION);
}
}
}

add_action('plugins_loaded', array('Tiny_Migration', 'migrate_meta_key_on_update'));
2 changes: 1 addition & 1 deletion src/config/class-tiny-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class Tiny_Config {
const SHRINK_URL = 'https://api.tinify.com/shrink';
const KEYS_URL = 'https://api.tinify.com/keys';
const MONTHLY_FREE_COMPRESSIONS = 500;
const META_KEY = 'tiny_compress_images';
const META_KEY = '_tiny_compress_images';
}
4 changes: 2 additions & 2 deletions src/views/account-status-connected.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<div class="update" style="display: none">
<h4><?php esc_html_e( 'Change your API key', 'tiny-compress-images' ); ?></h4>
<p class="introduction"><?php
$link = sprintf( '<a href="https://tinypng.com/dashboard/api" target="_blank">%s</a>',
$link = sprintf( '<a href="https://tinypng.com/dashboard/api?utm_source=installation&utm_medium=wordpress-plugin" target="_blank">%s</a>',
esc_html__( 'API dashboard', 'tiny-compress-images' )
);
/* translators: %s: link saying API dashboard */
Expand All @@ -90,7 +90,7 @@
<div class="button-container">
<div class="box">
<?php $encoded_email = str_replace( '%20', '%2B', rawurlencode( self::get_email_address() ) ); ?>
<a href="https://tinypng.com/dashboard/api?type=upgrade&mail=<?php echo $encoded_email; ?>" target="_blank" class="button button-primary upgrade-account">
<a href="https://tinypng.com/dashboard/api?type=upgrade&mail=<?php echo $encoded_email; ?>&utm_source=installation&utm_medium=wordpress-plugin" target="_blank" class="button button-primary upgrade-account">
<?php esc_html_e( 'Upgrade account', 'tiny-compress-images' ); ?>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/views/account-status-create-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
?></h4>

<p class="introduction"><?php
$link = sprintf( '<a href="https://tinypng.com/dashboard/api" target="_blank">%s</a>',
$link = sprintf( '<a href="https://tinypng.com/dashboard/api?utm_source=installation&utm_medium=wordpress-plugin" target="_blank">%s</a>',
esc_html__( 'API dashboard', 'tiny-compress-images' )
);
/* translators: %s: link saying API dashboard */
Expand Down
2 changes: 1 addition & 1 deletion src/views/account-status-create-simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="update">
<h4><?php esc_html_e( 'Configure your account', 'tiny-compress-images' ); ?></h4>
<p class="introduction"><?php
$link = sprintf( '<a href="https://tinypng.com/developers" target="_blank">%s</a>',
$link = sprintf( '<a href="https://tinypng.com/developers?utm_source=installation&utm_medium=wordpress-plugin" target="_blank">%s</a>',
esc_html__( 'TinyPNG developer section', 'tiny-compress-images' )
);

Expand Down
2 changes: 1 addition & 1 deletion src/views/bulk-optimization-upgrade-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</p>
</div>
<?php $encoded_email = str_replace( '%20', '%2B', rawurlencode( $email_address ) ); ?>
<a href="https://tinypng.com/dashboard/api?type=upgrade&mail=<?php echo $encoded_email; ?>" target="_blank" class="button button-primary button-hero upgrade-account">
<a href="https://tinypng.com/dashboard/api?type=upgrade&mail=<?php echo $encoded_email; ?>&utm_source=installation&utm_medium=wordpress-plugin" target="_blank" class="button button-primary button-hero upgrade-account">
<?php esc_html_e( 'Upgrade account', 'tiny-compress-images' ); ?>
</a>
<?php if ( $remaining_credits > 0 ) { ?>
Expand Down
2 changes: 1 addition & 1 deletion src/views/bulk-optimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
'a' => array(
'href' => array(),
),
) ), Tiny_Config::MONTHLY_FREE_COMPRESSIONS, esc_html__( 'image sizes', 'tiny-compress-images' ), '<a target="_blank" href="https://tinypng.com/dashboard/api?type=upgrade&mail=' . str_replace( '%20', '%2B', rawurlencode( $email_address ) ) . '">' . esc_html__( ' upgrade here', 'tiny-compress-images' ) . '</a>' );
) ), Tiny_Config::MONTHLY_FREE_COMPRESSIONS, esc_html__( 'image sizes', 'tiny-compress-images' ), '<a target="_blank" href="https://tinypng.com/dashboard/api?type=upgrade&mail=' . str_replace( '%20', '%2B', rawurlencode( $email_address ) ) . '&utm_source=installation&utm_medium=wordpress-plugin">' . esc_html__( ' upgrade here', 'tiny-compress-images' ) . '</a>' );
?></p>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions tiny-compress-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* License: GPLv2 or later
*/

define('TINY_PNG_PLUGIN_VERSION', '3.4.4');

require dirname( __FILE__ ) . '/src/compatibility/class-tiny-migration.php';
require dirname( __FILE__ ) . '/src/config/class-tiny-config.php';
require dirname( __FILE__ ) . '/src/class-tiny-helpers.php';
require dirname( __FILE__ ) . '/src/class-tiny-php.php';
Expand Down