Skip to content

Commit

Permalink
Merge pull request #4 from christopherldotcom/development
Browse files Browse the repository at this point in the history
Add link formatting support, new logo
  • Loading branch information
chrislarrycarl authored Apr 8, 2018
2 parents 5691c99 + 93aa049 commit 2579923
Show file tree
Hide file tree
Showing 15 changed files with 426 additions and 75 deletions.
12 changes: 8 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: chrislarrycarl
Donate link: https://utm.codes/pricing/
Tags: utm codes, google analytics, tracking links, campaign marketing, link generator
Requires at least: 4.7
Tested up to: 4.9.4
Tested up to: 4.9.5
Requires PHP: 5.6
Stable tag: 1.0.1
Stable tag: 1.1
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -20,13 +20,12 @@ For more information [visit the utm.codes website](https://utm.codes).
= Features =

- Easily create marketing links with the custom UTM codes for better campaign analytics
- Automatically format links elements in lowercase, remove spaces, and remove non alphanumeric characters
- Batch create links for all your social networks with just a click
- Search, filter, and easily find existing links for copy & paste use
- Automatically shorten links using Goo.gl for easier sharing
- Allow multiple users to share creation and management responsibilities within WordPress
- See your current link count in the admin dashboard "At a Glance"
- No additional plugins required
- No annoying ads or nags
- Works with PHP 5.6, 7.0, 7.1, and 7.2
- 100% Free and Open Source

Expand Down Expand Up @@ -58,6 +57,11 @@ Batch social link creation requires selection of social networks. Select network

== Changelog ==

= 1.1 =

- New link formatting options
- New Logo

= 1.0.1 =

Fixes bug in batch link creation where source/medium were omitted from first generated link.
Expand Down
2 changes: 1 addition & 1 deletion _build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion _build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "utm.codes",
"version": "1.0.1",
"version": "1.1",
"description": "Create and manage your marketing links with WordPress.",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions _build/sass/core.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Mixins
@import 'mixins/_toggle.scss';

// Partials
@import 'partials/dashboard';
@import 'partials/settings';
@import 'partials/meta-box';
Expand Down
101 changes: 101 additions & 0 deletions _build/sass/mixins/_toggle.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@mixin css-toggle($off-color: #444, $on-color: #0073AA, $button-color: #FFF, $text-color: #FFF, $width: 140px, $height: 36px) {

$shadow: 0 3px 3px rgba(black, 0.4);
$switch-width: $width/2;
$offset: 2px;
$transition: cubic-bezier(0, 1, 0.5, 1);

position: relative;

*,
*:before,
*:after {
box-sizing: border-box;
}

input[type="checkbox"] {
opacity: 0;
position: absolute;
top: 0;
left: 0;

&[disabled] {
~ label {
pointer-events: none;
color: rgba($off-color, 0.5);

div {
opacity: 0.5;
}
}
}

&:checked {

~ label {

div {
background-color: lighten($on-color, 5%);

&:before {
content: attr(data-off);
left: 0;
}

&:after {
content: attr(data-on);
color: darken($on-color, 5%);
transform: translate3d($width - ($switch-width + $offset),0,0);
}
}
}
}
}

label {
user-select: none;
position: relative;
display: flex;
align-items: center;

div {
position: relative;
transition: background-color 0.3s $transition;
background: lighten($off-color, 5%);
height: $height;
flex: 0 0 $width;

&:before,
&:after {
text-transform: uppercase;
text-align: center;
position: absolute;
}

&:before {
color: $text-color;
left: $width/2;
line-height: $height;
width: $width/2;
content: attr(data-on);
top: 0;
}

&:after {
top: $offset;
left: $offset;
width: $switch-width - $offset;
line-height: $height - ($offset*2);
transition: transform 0.3s $transition;
color: $off-color;
content: attr(data-off);
z-index: 5;
background: $button-color;
transform: translate3d(0,0,0);
}

}

}

}
4 changes: 4 additions & 0 deletions _build/sass/partials/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

&:before {
content: "\f103" !important;
color: transparent !important;
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0yMi4yMjIyMjIyMjIyMjIyMjUgLTIyLjIyMjIyMjIyMjIyMjIyNSAxNDQuNDQ0NDQ0NDQ0NDQ0NDYgMTU1LjU1NTU1NTU1NTU1NTU3IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTYuNjY2NjY2NjY2NjY2NjY0IC0xMS4xMTExMTExMTExMTExMSkgc2NhbGUoNS41NTU1NTU1NTU1NTU1NTUpIj48ZyBmaWxsPSIjODI4NzhjIj48cGF0aCBkPSJNMTUgMmMtMS42IDAtMy4xLjctNC4yIDEuNy44LjIgMS41LjUgMi4xLjkuNi0uNCAxLjMtLjYgMi4xLS42IDIuMiAwIDQgMS44IDQgNHY1YzAgMi4yLTEuOCA0LTQgNHMtNC0xLjgtNC00VjkuNWMtLjUtLjYtMS4yLTEtMi0xVjEzYzAgMy4zIDIuNyA2IDYgNnM2LTIuNyA2LTZWOGMwLTMuMy0yLjctNi02LTZ6Ij48L3BhdGg+PHBhdGggZD0iTTkgMjJjMS42IDAgMy4xLS43IDQuMi0xLjctLjgtLjItMS41LS41LTIuMS0uOS0uNi40LTEuMy42LTIuMS42LTIuMiAwLTQtMS44LTQtNHYtNWMwLTIuMiAxLjgtNCA0LTRzNCAxLjggNCA0djMuNWMuNS42IDEuMiAxIDIgMVYxMWMwLTMuMy0yLjctNi02LTZzLTYgMi43LTYgNnY1YzAgMy4zIDIuNyA2IDYgNnoiPjwvcGF0aD48L2c+PC9nPjwvc3ZnPg==") !important;
background-size: auto 100%;
background-repeat: no-repeat;
}

}
Expand Down
9 changes: 9 additions & 0 deletions _build/sass/partials/_settings.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#utm-dot-codes-logo {
width: 250px;
margin: auto;
display: block;
}

.utmdclinks {

&-settings {
Expand Down Expand Up @@ -33,6 +39,9 @@

}

&-toggle {
@include css-toggle();
}
}

}
56 changes: 55 additions & 1 deletion _test/tests/test-a-unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function test_post_type() {
$this->assertFalse( $post_object->show_in_nav_menus );
$this->assertTrue( $post_object->show_in_admin_bar );
$this->assertEquals( $post_object->menu_position, null );
$this->assertEquals( $post_object->menu_icon, 'dashicons-admin-links' );
$this->assertEquals( $post_object->menu_icon, 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0yMi4yMjIyMjIyMjIyMjIyMjUgLTIyLjIyMjIyMjIyMjIyMjIyNSAxNDQuNDQ0NDQ0NDQ0NDQ0NDYgMTU1LjU1NTU1NTU1NTU1NTU3IiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTYuNjY2NjY2NjY2NjY2NjY0IC0xMS4xMTExMTExMTExMTExMSkgc2NhbGUoNS41NTU1NTU1NTU1NTU1NTUpIj48ZyBmaWxsPSIjMDAwMDAwIj48cGF0aCBkPSJNMTUgMmMtMS42IDAtMy4xLjctNC4yIDEuNy44LjIgMS41LjUgMi4xLjkuNi0uNCAxLjMtLjYgMi4xLS42IDIuMiAwIDQgMS44IDQgNHY1YzAgMi4yLTEuOCA0LTQgNHMtNC0xLjgtNC00VjkuNWMtLjUtLjYtMS4yLTEtMi0xVjEzYzAgMy4zIDIuNyA2IDYgNnM2LTIuNyA2LTZWOGMwLTMuMy0yLjctNi02LTZ6Ij48L3BhdGg+PHBhdGggZD0iTTkgMjJjMS42IDAgMy4xLS43IDQuMi0xLjctLjgtLjItMS41LS41LTIuMS0uOS0uNi40LTEuMy42LTIuMS42LTIuMiAwLTQtMS44LTQtNHYtNWMwLTIuMiAxLjgtNCA0LTRzNCAxLjggNCA0djMuNWMuNS42IDEuMiAxIDIgMVYxMWMwLTMuMy0yLjctNi02LTZzLTYgMi43LTYgNnY1YzAgMy4zIDIuNyA2IDYgNnoiPjwvcGF0aD48L2c+PC9nPjwvc3ZnPg==' );
$this->assertEquals( $post_object->capability_type, 'post' );
$this->assertTrue( $post_object->map_meta_cap );
$this->assertEquals( count($post_object->taxonomies), 0 );
Expand Down Expand Up @@ -134,4 +134,58 @@ function test_batch_alternative_text() {
$this->assertTrue( $plugin->batch_alt('nothing') == '' );
}

/**
* @depends test_version_numbers_active
*/
function test_alphanumeric_elements() {
$plugin = new UtmDotCodes();

update_option( UtmDotCodes::POST_TYPE . '_alphanumeric', '' );
$unformatted = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890`~!@#$%^&* ()_+-= ?,./:";\'';
$setting_off = $plugin->filter_link_element( $unformatted );

$this->assertTrue( $unformatted == $setting_off );

update_option( UtmDotCodes::POST_TYPE . '_alphanumeric', 'on' );
$setting_on = $plugin->filter_link_element( $unformatted );

$this->assertTrue( $setting_on == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890 -' );
}

/**
* @depends test_version_numbers_active
*/
function test_nospaces_elements() {
$plugin = new UtmDotCodes();

update_option( UtmDotCodes::POST_TYPE . '_nospaces', '' );
$unformatted = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890`~!@#$%^&* ()_+-= ?,./:";\'';
$setting_off = $plugin->filter_link_element( $unformatted );

$this->assertTrue( $unformatted == $setting_off );

update_option( UtmDotCodes::POST_TYPE . '_nospaces', 'on' );
$setting_on = $plugin->filter_link_element( $unformatted );

$this->assertTrue( $setting_on == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-abcdefghijklmnopqrstuvwxyz-1234567890`~!@#$%^&*-()_+-=-?,./:";\'' );
}

/**
* @depends test_version_numbers_active
*/
function test_lowercase_elements() {
$plugin = new UtmDotCodes();

update_option( UtmDotCodes::POST_TYPE . '_lowercase', '' );
$unformatted = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890`~!@#$%^&* ()_+-= ?,./:";\'';
$setting_off = $plugin->filter_link_element( $unformatted );

$this->assertTrue( $unformatted == $setting_off );

update_option( UtmDotCodes::POST_TYPE . '_lowercase', 'on' );
$setting_on = $plugin->filter_link_element( $unformatted );

$this->assertTrue( $setting_on == 'abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz 1234567890`~!@#$%^&* ()_+-= ?,./:";\'' );
}

}
62 changes: 62 additions & 0 deletions _test/tests/test-b-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,67 @@ function test_post_create_batch_shorten() {
}, $test_posts );
}

/**
* @depends TestUtmDotCodesUnit::test_version_numbers_active
*/
function test_post_create_filter() {
$post = $this->factory->post->create_and_get( ['post_type' => UtmDotCodes::POST_TYPE] );

update_option( UtmDotCodes::POST_TYPE . '_alphanumeric', 'on' );
update_option( UtmDotCodes::POST_TYPE . '_nospaces', 'on' );
update_option( UtmDotCodes::POST_TYPE . '_lowercase', 'on' );

$test_data = [
'utm_source' => 'ASDF 2468 `~!@#$%^&*-()_+-=-?,./:";\' asdf 1357',
'utm_medium' => 'foo 999 `~!@#$%^&*-()_+-=-?,./:";\' BAR 555',
'utm_campaign' => 'ping `~!@#11$%^22&*-()_+33-=-?,./:";\' PONG',
'utm_term' => 'UTM `~!@#$%^d0t&*-()_+33-=-?,./:";\' CoDeS',
'utm_content' => '`~!@#v$%a^&*l-()i_+d-=-pArAmz?,./:";\'',
];

$query_string = '?' . http_build_query($test_data) . '&utm_gen=utmdc';

array_map(function($key, $value) use(&$test_data) {
$test_data[str_replace('utm', UtmDotCodes::POST_TYPE, $key)] = $value;
unset($test_data[$key]);
}, array_keys($test_data), $test_data );

$_POST = array_merge(
$test_data,
[
'post_ID' => $post->ID,
UtmDotCodes::POST_TYPE . '_url' => 'https://www.' . uniqid() . '.test',
UtmDotCodes::POST_TYPE . '_shorturl' => '',
UtmDotCodes::POST_TYPE . '_shorten' => '',
UtmDotCodes::POST_TYPE . '_batch' => '',
]
);

$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $user_id );

$test_id = edit_post();

$test_post = get_post($test_id);
$this->assertEquals( $test_post->post_type, UtmDotCodes::POST_TYPE );
$this->assertEquals( $test_post->post_content, $_POST[UtmDotCodes::POST_TYPE . '_url'] . '?utm_source=asdf-2468-----asdf-1357&utm_medium=foo-999-----bar-555&utm_campaign=ping-1122-33---pong&utm_term=utm-d0t-33---codes&utm_content=val-id--paramz&utm_gen=utmdc');
$this->assertEquals(
filter_var( $test_post->post_content, FILTER_VALIDATE_URL ),
$test_post->post_content
);
$this->assertEquals( $test_post->post_title, $_POST[UtmDotCodes::POST_TYPE . '_url'] );
$this->assertEquals( $test_post->post_status, 'publish' );

$test_meta = get_post_meta( $test_post->ID );
$this->assertEquals( $test_meta['utmdclink_url'][0], $_POST[UtmDotCodes::POST_TYPE . '_url'] );
$this->assertEquals( $test_meta['utmdclink_source'][0], 'asdf-2468-----asdf-1357' );
$this->assertEquals( $test_meta['utmdclink_medium'][0], 'foo-999-----bar-555' );
$this->assertEquals( $test_meta['utmdclink_campaign'][0], 'ping-1122-33---pong' );
$this->assertEquals( $test_meta['utmdclink_term'][0], 'utm-d0t-33---codes' );
$this->assertEquals( $test_meta['utmdclink_content'][0], 'val-id--paramz' );
$this->assertFalse( isset($test_meta['utmdclink_shorturl'][0]) );
}

/**
* @depends TestUtmDotCodesUnit::test_version_numbers_active
*/
Expand Down Expand Up @@ -655,4 +716,5 @@ function test_add_glance() {
)
);
}

}
Loading

0 comments on commit 2579923

Please sign in to comment.