This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Headline testing via Experiment API #1
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
83c9cb1
Add box in admin view for listing alternate headlines
0f856ee
Add code for creating and applying variations (content.php)
8e7c4a5
Get API credentials in plugin settings page + check for them
17dac9b
Refactored admin.php into admin + config.php
thatsjonsense 8e42d89
Use new authentication (incomplete)
thatsjonsense e725bc5
API connection working!
16f1c45
Variation template
e2e23f4
Missing )
ef9946e
PHP API binding
1eed52e
Choose project from drop down + generate snippet!
45507e9
All the API calls...except they don't work :/
thatsjonsense 27dc384
JS API connection implemented
fe5003c
THE PLUGIN WORKS OMGOMGOMG
30a79b1
Separated create/edit experiment
6a8dc43
Lots of refactoring, new auth
1493644
Code cleanup + save data async
059d417
Goal creation (in progress)
ca989ca
Goals working
af4f9b4
Added inline comments/explanations + turned num_variations into a con…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Javascript for plugin settings page | ||
|
||
function optimizelyConfigPage() { | ||
var $ = jQuery; | ||
|
||
/* | ||
|
||
AUTHENTICATION W/ OPTIMIZELY | ||
|
||
When the user presses the button, we call the GET projects/ endpoint to list out all the projects in their account. For each project, we show its name in the dropdown and store its ID in the value attribute for submission to a form. | ||
|
||
*/ | ||
|
||
$("button#connect_optimizely").click(function(event) { | ||
event.preventDefault(); | ||
$("#project_id").html("<option>Loading projects...</option>"); | ||
|
||
optly = new OptimizelyAPI($("#token").val()); | ||
|
||
optly.get('projects', function(response) { | ||
$("#project_id").empty(); | ||
|
||
$.each(response, function(key, val) { | ||
$("#project_id").append("<option value='" + val.id + "'>" + val.project_name + "</option>"); | ||
}); | ||
|
||
$("#project_id").change(); // update project code w/ the default value | ||
}); | ||
|
||
/* | ||
|
||
CHOOSING A PROJECT | ||
|
||
When the user selects a project from the dropdown, we populate the project code box with the Optimizely snippet for that project ID. | ||
|
||
*/ | ||
$('#project_id').change(function() { | ||
var id = $('#project_id').val(); | ||
var name = $('#project_id option:selected').text(); | ||
var project_code = '<script src="//cdn.optimizely.com/js/' + id + '.js"></script>'; | ||
$('#project_code').text(project_code); | ||
$('#project_name').val(name); | ||
}); | ||
|
||
|
||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div class="wrap"> | ||
<h2><?php _e('Optimizely Configuration'); ?></h2> | ||
<div class="narrow"> | ||
<form action="" method="post" id="optimizely-conf"> | ||
<?php optimizely_nonce_field($optimizely_nonce) ?> | ||
<h3>About Optimizely</h3> | ||
<p>Simple, fast, and powerful. <a href="http://www.optimizely.com" target="_blank">Optimizely</a> is a dramatically easier way for you to improve your website through A/B testing. Create an experiment in minutes with absolutely no coding or engineering required. Convert your website visitors into customers and earn more revenue: create an account at <a href="http://www.optimizely.com" target="_blank">optimizely.com</a> and start A/B testing today!</p> | ||
<h3>Optimizely API tokens</h3> | ||
<p>Once you create an account, you can find your API Token on your account page at <a href="https://www.optimizely.com/account">optimizely.com/account</a>. | ||
<p> | ||
<label for="token"><strong>API Token</strong></label> | ||
<br /> | ||
<input id="token" name="token" type="text" maxlength="80" value="<?= get_option('optimizely_token'); ?>" class="code" /> | ||
</p> | ||
|
||
<button id="connect_optimizely" class="button">Connect Optimizely</button> | ||
|
||
<h3>Choose a Project</h3> | ||
<input type="hidden" id="project_name" name="project_name" value="<?= get_option('optimizely_project_name') ?>" /> | ||
<select id="project_id" name="project_id"> | ||
<?php if (get_option('optimizely_project_id')) { ?> | ||
<option value="<?= get_option('optimizely_project_id') ?>" selected><?= get_option('optimizely_project_name') ?></option> | ||
<?php } ?> | ||
<option value="">Connect Optimizely to choose a project...</option> | ||
</select> | ||
<p>Optimizely will add the following project code to your page automatically:</p> | ||
<textarea class="code" id="project_code" name="project_code" readonly><?= get_option('optimizely_project_code') ?></textarea> | ||
|
||
|
||
<h3>Variation Code</h3> | ||
<p>Optimizely will use this variation code to change headlines on your site. We've provided code that works with the default theme, but you might want to add or change it to work with your themes and plugins.</p> | ||
|
||
<textarea class="code" rows="5" name="variation_template" id="variation_template"><?= get_option('optimizely_variation_template') ?></textarea> | ||
|
||
<p>You can use the variables $POST_ID, $OLD_TITLE, and $NEW_TITLE in your code.</p> | ||
|
||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Submit »'); ?>" class="button-primary" /></p> | ||
|
||
|
||
</form> | ||
<script type="text/javascript"> | ||
optimizelyConfigPage(); | ||
</script> | ||
|
||
|
||
|
||
</div> | ||
</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a head's up, "empty" in PHP is rather inclusive. The following are considered empty:
"" (an empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
$var; (a variable declared, but without a value)
Just makes sure this jibes with what you want to do here.