settings = array(
'version' => '1.0.1',
'url' => plugin_dir_url( __FILE__ ),
'path' => plugin_dir_path( __FILE__ )
);
// set text domain
// https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
load_plugin_textdomain( 'acf-bbutton', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' );
// include field
add_action('acf/include_field_types', array($this, 'include_field_types')); // v5
add_action('acf/register_fields', array($this, 'include_field_types')); // v4
}
/*
* include_field_types
*
* This function will include the field type class
*
* @type function
* @date 17/02/2016
* @since 1.0.1
*
* @param $version (int) major ACF version. Defaults to false
* @return n/a
*/
function include_field_types( $version = false ) {
// support empty $version
if( !$version ) $version = 4;
// include
include_once('fields/acf-bbutton-v' . $version . '.php');
}
}
// initialize
new acf_plugin_bbutton();
function acf_bbutton_render($field){
$bbutton = "";
$active = ( $field['active'] ) ? " active" : "";
$class = trim($field['option'] . ' ' . $field['size'] . ' ' . $active . ' ' . $field['class']);
switch ($field['tag']){
case "a":
$class .= ( $field['disabled'] ) ? " disabled" : "";
$target = ( $field['target'] ) ? 'target="_blank"' : "";
$text = ( $field['text'] == "") ? $field['title'] : $field['text'];
$bbutton = sprintf('%s', esc_url($field['url']), $class, $target, $text);
break;
case "button":
$disabled = ( $field['disabled'] ) ? 'disabled="disabled"' : "";
$text = ( $field['text'] == "") ? $field['title'] : $field['text'];
$bbutton = sprintf('', $class, $disabled, $text);
break;
case "input":
$disabled = ( $field['disabled'] ) ? 'disabled="disabled"' : "";
$text = ( $field['text'] == "") ? $field['title'] : $field['text'];
$bbutton = sprintf('', $class, $disabled, $text);
break;
case "submit":
$disabled = ( $field['disabled'] ) ? 'disabled="disabled"' : "";
$text = ( $field['text'] == "") ? $field['title'] : $field['text'];
$bbutton = sprintf('', $class, $disabled, $text);
break;
}
return $bbutton;
}
// class_exists check
endif;
?>