-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of demonstration files
- Loading branch information
0 parents
commit 5b46036
Showing
5 changed files
with
188 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
codekit-config.json |
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,21 @@ | ||
<?php | ||
/** WordPress Administration Bootstrap */ | ||
require_once './admin.php'; | ||
if ( !current_user_can('edit_posts') ) | ||
wp_die(__('Cheatin’ uh?')); | ||
?> | ||
<div class="wrap"> | ||
<div id="icon-tools" class="icon32 icon32-posts-deprecated_log"><br></div><?php echo "<h2>".__('Iris Color Picker Demo')."</h2>";?> | ||
<form method="post" action="options.php"> | ||
<?php settings_fields( 'iris_cpdemo_plugin_options' ); ?> | ||
<?php $options = get_option( 'iris_cpdemo_options' );?> | ||
|
||
<ul> | ||
<li><label for="link_color"><?php echo __('Link Color'); ?>: </label> | ||
<input name="iris_cpdemo_options[link_color]" id="link-color" type="text" value="<?php if ( isset( $options['link_color'] ) ) echo $options['link_color']; ?>" /> | ||
</li> | ||
</ul> | ||
|
||
<?php submit_button();?> | ||
</form> | ||
</div> |
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,39 @@ | ||
/*! | ||
* Iris Color Picker Demo Script | ||
* @author: Rachel Baker ( rachel@rachelbaker.me ) | ||
*/ | ||
(function ($) { | ||
"use strict"; | ||
|
||
var default_color = 'fbfbfb'; | ||
|
||
function pickColor(color) { | ||
$('#link-color').val(color); | ||
} | ||
function toggle_text() { | ||
link_color = $('#link-color'); | ||
if ('' === link_color.val().replace('#', '')) { | ||
link_color.val(default_color); | ||
pickColor(default_color); | ||
} else { | ||
pickColor(link_color.val()); | ||
} | ||
} | ||
|
||
$(document).ready(function () { | ||
var link_color = $('#link-color'); | ||
link_color.wpColorPicker({ | ||
change: function (event, ui) { | ||
pickColor(link_color.wpColorPicker('color')); | ||
}, | ||
clear: function () { | ||
pickColor(''); | ||
} | ||
}); | ||
$('#link-color').click(toggle_text); | ||
|
||
toggle_text(); | ||
|
||
}); | ||
|
||
}(jQuery)); |
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,30 @@ | ||
/*! | ||
* Iris Color Picker Demo Script | ||
* @author: Rachel Baker ( rachel@rachelbaker.me ) | ||
*/(function($) { | ||
"use strict"; | ||
function pickColor(color) { | ||
$("#link-color").val(color); | ||
} | ||
function toggle_text() { | ||
link_color = $("#link-color"); | ||
if ("" === link_color.val().replace("#", "")) { | ||
link_color.val(default_color); | ||
pickColor(default_color); | ||
} else pickColor(link_color.val()); | ||
} | ||
var default_color = "fbfbfb"; | ||
$(document).ready(function() { | ||
var link_color = $("#link-color"); | ||
link_color.wpColorPicker({ | ||
change: function(event, ui) { | ||
pickColor(link_color.wpColorPicker("color")); | ||
}, | ||
clear: function() { | ||
pickColor(""); | ||
} | ||
}); | ||
$("#link-color").click(toggle_text); | ||
toggle_text(); | ||
}); | ||
})(jQuery); |
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,96 @@ | ||
<?php | ||
/* | ||
Plugin Name: Iris Color Picker Demo | ||
Plugin URI: http://www.rachelbaker.me | ||
Description: Demonstrating how to use the new Iris color picker | ||
Version: 1.0 | ||
Author: Rachel Baker | ||
Author URI: http://www.rachelbaker.me | ||
Author Email: rachel@rachelbaker.me | ||
License: | ||
Color Picker Demo | ||
Copyright (C) 2012 Rachel Baker, Plugged In Consulting, Inc. | ||
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 3 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, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
add_action('admin_init', 'iris_cpdemo_init' ); | ||
add_action('admin_menu', 'iris_cpdemo_add_options_page'); | ||
add_action( 'admin_enqueue_scripts', 'iris_cpdemo_admin_enqueue_scripts' ); | ||
|
||
/** | ||
* Uses the Settings_API to register the plugin options. | ||
* Options are saved in the wp_options table under the Option Name. | ||
* | ||
* Option group is iris_cpdemo_plugin_options | ||
* Option name is iris_cpdemo_options | ||
* | ||
* Initialized with admin_init hook | ||
*/ | ||
function iris_cpdemo_init(){ | ||
register_setting( 'iris_cpdemo_plugin_options', 'iris_cpdemo_options', 'iris_cpdemo_validate_options' ); | ||
} | ||
|
||
/** | ||
* Adds the plugin's option page to the Settings menu section. | ||
* Defines plugin options page parameters. | ||
* | ||
* Initialized with admin_menu hook | ||
*/ | ||
function iris_cpdemo_add_options_page() { | ||
add_options_page('Iris Color Picker Demo', 'Iris Demo', 'manage_options', __FILE__, 'iris_cpdemo_display_options'); | ||
} | ||
|
||
/** | ||
* Displays plugin options page view | ||
* | ||
* Initialized in iris_cpdemo_add_options_page() | ||
*/ | ||
function iris_cpdemo_display_options() { | ||
include "admin-option-view.php"; | ||
} | ||
|
||
/** | ||
* Santizes input from plugin options page. | ||
* Uses sanitize_text_field to strip html from input text. | ||
* @param array $input | ||
* @return array $input | ||
*/ | ||
function iris_cpdemo_validate_options($input) { | ||
// strip html from textboxes | ||
sanitize_text_field($input); | ||
return $input; | ||
} | ||
|
||
/** | ||
* Load the built-in 'wp-color-picker' script and style. | ||
* Load the plugin specific 'cp-demo-custom' script that handles | ||
* the use of the wp-color-picker script on our plugin options page. | ||
* | ||
* @param string $hook current admin screen suffix | ||
* | ||
* Initialized with admin_enqueue_scripts hook | ||
*/ | ||
function iris_cpdemo_admin_enqueue_scripts($hook) { | ||
// bail early if this is not the plugin option screen | ||
if( 'settings_page_color-picker-demo/cp-demo' !== $hook ) { | ||
return; | ||
} | ||
// load the wp-color-picker script and style | ||
wp_enqueue_script( 'wp-color-picker' ); | ||
wp_enqueue_script( 'cp_demo-custom', plugins_url( 'cp-demo-script.min.js', __FILE__ ), array( 'jquery', 'wp-color-picker' ), '1.0', true ); | ||
wp_enqueue_style( 'wp-color-picker' ); | ||
} |