Skip to content

Commit

Permalink
changed ALL THE THINGS.
Browse files Browse the repository at this point in the history
  • Loading branch information
norcross committed Jul 18, 2015
1 parent e4e0f61 commit 1666681
Show file tree
Hide file tree
Showing 17 changed files with 986 additions and 598 deletions.
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

22 changes: 22 additions & 0 deletions LICENSE-MIT
@@ -0,0 +1,22 @@
Copyright (c) 2013 Andrew Norcross

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
9 changes: 8 additions & 1 deletion README.md
@@ -1,4 +1,11 @@
Gravity Tooltips
================

Adds a custom field to each form element for tooltips
Add custom tooltips in Gravity Forms.

**Note:** Version 2.0.0 has numerous changes from previous versions, including a switch to using the [hint.css library by Kushagra Gour](http://kushagragour.in/lab/hint/ "hint.css library by Kushagra Gour") and removing all JS requirements. It may not be compatible with current implementations, please backup and test before updating any production sites.


## License
Copyright (c) 2013 Andrew Norcross
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
218 changes: 60 additions & 158 deletions gravity-tooltips.php
Expand Up @@ -4,7 +4,7 @@
Plugin URI: http://andrewnorcross.com/plugins/gravity-tooltips/
Description: Add custom tooltips in Gravity Forms.
Author: Andrew Norcross
Version: 1.0.1
Version: 2.0.0
Requires at least: 3.8
Author URI: http://andrewnorcross.com
*/
Expand All @@ -30,203 +30,105 @@
}

if( ! defined( 'GFT_VER' ) ) {
define( 'GFT_VER', '1.0.1' );
define( 'GFT_VER', '2.0.0' );
}

class GF_Tooltips
{

/**
* This is our constructor
*
* @return GF_Tooltips
* Static property to hold our singleton instance
* @var instance
*/
public function __construct() {
add_action ( 'plugins_loaded', array( $this, 'textdomain' ) );
add_action ( 'plugins_loaded', array( $this, 'load_files' ) );
}
static $instance = false;

/**
* load textdomain
* This is our constructor
*
* @return string load_plugin_textdomain
*/

public function textdomain() {

load_plugin_textdomain( 'gravity-tooltips', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

}

/**
* [load_files description]
* @return [type] [description]
*/
public function load_files() {

require_once( 'lib/admin.php' );
require_once( 'lib/front.php' );

}

/**
* [show_field_item_types description]
* @return [type] [description]
* @return GF_Tooltips
*/
static function show_field_item_types() {

$defaults = array(
'text',
'creditcard',
'website',
'phone',
'number',
'date',
'time',
'textarea',
'select',
'multiselect',
'checkbox',
'radio',
'name',
'address',
'fileupload',
'email',
'post_title',
'post_content',
'post_excerpt',
'post_tags',
'post_category',
'post_image',
'captcha',
'product',
'singleproduct',
'calculation',
'price',
'hiddenproduct',
'list',
'shipping',
'singleshipping',
'option',
'quantity',
'donation',
'total',
'post_custom_field',
'password'
);

$defaults = apply_filters( 'gf_tooltips_allowed_fields', $defaults );

return $defaults;
private function __construct() {
add_action( 'plugins_loaded', array( $this, 'textdomain' ) );
add_action( 'plugins_loaded', array( $this, 'load_files' ) );

// activation hooks
register_activation_hook( __FILE__, array( $this, 'set_options' ) );
}

/**
* [get_qtip_placement description]
* @param [type] $current [description]
* @return [type] [description]
* If an instance exists, this returns it. If not, it creates one and
* retuns it.
*
* @return
*/
static function get_qtip_placement( $current ) {

$options = array(
'topLeft' => __( 'Top Left', 'gravity-tooltips' ),
'topMiddle' => __( 'Top Middle', 'gravity-tooltips' ),
'topRight' => __( 'Top Right', 'gravity-tooltips' ),
'rightTop' => __( 'Right Top', 'gravity-tooltips' ),
'rightMiddle' => __( 'Right Middle', 'gravity-tooltips' ),
'rightBottom' => __( 'Right Bottom', 'gravity-tooltips' ),
'bottomRight' => __( 'Bottom Right', 'gravity-tooltips' ),
'bottomMiddle' => __( 'Bottom Middle', 'gravity-tooltips' ),
'bottomLeft' => __( 'Bottom Left', 'gravity-tooltips' ),
'leftBottom' => __( 'Left Bottom', 'gravity-tooltips' ),
'leftMiddle' => __( 'Left Middle', 'gravity-tooltips' ),
'leftTop' => __( 'Left Top', 'gravity-tooltips' )
);

$dropdown = '';

foreach ( $options as $key => $label ) :

$dropdown .= '<option value="' . $key . '"' . selected( $current, $key, false ) . '>' . $label . '</option>';
public static function getInstance() {

endforeach;

return $dropdown;
// check for an instance of the class before loading
if ( ! self::$instance ) {
self::$instance = new self;
}

// return the instance
return self::$instance;
}

/**
* [get_qtip_designs description]
* @param [type] $current [description]
* @return [type] [description]
* load textdomain
*
* @return string load_plugin_textdomain
*/
static function get_qtip_designs( $current ) {

$options = array(
'cream' => __( 'Cream', 'gravity-tooltips' ),
'dark' => __( 'Dark', 'gravity-tooltips' ),
'green' => __( 'Green', 'gravity-tooltips' ),
'light' => __( 'Light', 'gravity-tooltips' ),
'red' => __( 'Red', 'gravity-tooltips' ),
'blue' => __( 'Blue', 'gravity-tooltips' )
);

$dropdown = '';

foreach ( $options as $key => $label ) :

$dropdown .= '<option value="' . $key . '"' . selected( $current, $key, false ) . '>' . $label . '</option>';

endforeach;

return $dropdown;

public function textdomain() {
load_plugin_textdomain( 'gravity-tooltips', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}

/**
* [get_tooltip_icon_img description]
* load our files
*
* @return [type] [description]
*/
static function get_tooltip_icon_img() {
public function load_files() {

// set the default with a filter
$icon = apply_filters( 'gf_tooltips_icon_img', plugins_url( 'lib/img/tooltip-icon.png', __FILE__) );
// load our admin setup
if ( is_admin() ) {
require_once( 'lib/admin.php' );
}

// return without markup i.e. the URL of the icon
return esc_url( $icon );
// load our front end setup
if ( ! is_admin() ) {
require_once( 'lib/front.php' );
}

// load our helper
require_once( 'lib/helper.php' );
}

/**
* do a string replace on the first instance only
* @param [type] $search [description]
* @param [type] $replace [description]
* @param [type] $string [description]
* @param integer $limit [description]
* @return [type] [description]
* set our options if
*/
static function str_replace_limit( $search, $replace, $string, $limit = 1 ) {
public function set_options() {

if ( is_bool( $pos = ( strpos( $string, $search ) ) ) ) {
return $string;
}
// check for data first
$exist = get_option( 'gf-tooltips' );

$length = strlen( $search );

for ( $i = 0; $i < $limit; $i++ ) {

$string = substr_replace( $string, $replace, $pos, $length );

if ( is_bool( $pos = ( strpos( $string, $search ) ) ) ) {
break;
}
// we have it. leave it alone
if ( ! empty( $exist ) ) {
return;
}

return $string;
}
// set a data array
$data = array(
'type' => 'icon',
'design' => 'light',
'target' => 'right',
);

// add the option
update_option( 'gf-tooltips', $data, 'no' );
}

/// end class
}

new GF_Tooltips();
// Instantiate our class
$GF_Tooltips = GF_Tooltips::getInstance();

0 comments on commit 1666681

Please sign in to comment.