class );
// value must be array
if( !is_array($field['value']) )
{
// perhaps this is a default value with new lines in it?
if( strpos($field['value'], "\n") !== false )
{
// found multiple lines, explode it
$field['value'] = explode("\n", $field['value']);
}
else
{
$field['value'] = array( $field['value'] );
}
}
// trim value
$field['value'] = array_map('trim', $field['value']);
// html
echo '
';
echo '';
echo '';
echo '
';
}
function find_selected( $needle, $haystack, $type, $choices )
{
switch( $type )
{
case 'object':
case 'element':
$search = array( '' );
$string = str_replace( $search, '', $haystack[0] );
break;
case 'unicode':
$index = $choices[ $needle ];
if ( stristr( $index, $haystack[0] ) ) {
return 'selected="selected"';
}
return '';
case 'class':
$string = $haystack[0];
break;
}
if( $string == $needle )
return 'selected="selected"';
return '';
}
/*
* input_admin_enqueue_scripts()
*
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
* Use this action to add css + javascript to assist your create_field() action.
*
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
* @type action
* @since 3.6
* @date 23/01/13
*/
function input_admin_enqueue_scripts()
{
// register acf scripts
wp_enqueue_script('acf-input-font-awesome-select2', $this->settings['dir'] . 'js/select2/select2.min.js', array(), $this->settings['version']);
wp_enqueue_script('acf-input-font-awesome-edit-input', $this->settings['dir'] . 'js/edit_input.js', array(), $this->settings['version']);
wp_enqueue_style('acf-input-font-awesome-input', $this->settings['dir'] . 'css/input.css', array(), $this->settings['version']);
wp_enqueue_style('acf-input-font-awesome-fa', $this->stylesheet, array(), $this->version);
wp_enqueue_style('acf-input-font-awesome-select2-css', $this->settings['dir'] . 'css/select2.css', array(), $this->settings['version']);
}
/*
* field_group_admin_enqueue_scripts()
*
* This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited.
* Use this action to add css + javascript to assist your create_field_options() action.
*
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
* @type action
* @since 3.6
* @date 23/01/13
*/
function field_group_admin_enqueue_scripts()
{
// register acf scripts
wp_enqueue_script('font-awesome-select2', $this->settings['dir'] . 'js/select2/select2.min.js', array(), $this->settings['version']);
wp_enqueue_script('font-awesome-create-input', $this->settings['dir'] . 'js/create_input.js', array(), $this->settings['version']);
wp_localize_script( 'font-awesome-create-input', 'ACFFA', array(
'version' => 4
));
wp_enqueue_style('acf-input-font-awesome-input', $this->settings['dir'] . 'css/input.css', array(), $this->settings['version']);
wp_enqueue_style('acf-input-font-awesome-fa', $this->stylesheet, array(), $this->version);
wp_enqueue_style('acf-input-font-awesome-select2-css', $this->settings['dir'] . 'css/select2.css', array(), $this->settings['version']);
}
/*
* frontend_enqueue_scripts()
*
* This action is called in the wp_enqueue_scripts action on the front end.
*
* $info http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
* @type action
*/
function frontend_enqueue_scripts()
{
wp_register_style('font-awesome', $this->stylesheet, array(), $this->version);
wp_enqueue_style( array( 'font-awesome' ) );
}
/*
* load_value()
*
* This filter is appied to the $value after it is loaded from the db
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value - the value found in the database
* @param $post_id - the $post_id from which the value was loaded from
* @param $field - the field array holding all the field options
*
* @return $value - the value to be saved in te database
*/
function load_value($value, $post_id, $field)
{
if ( 'null' == $value ) {
return;
}
switch( $field['save_format'] )
{
case 'object':
$icon_unicode_string = $this->defaults['choices'][ $value ];
$icon_unicode_arr = explode( ' ', $icon_unicode_string );
$icon_unicode = $icon_unicode_arr[0];
$value = (object) array(
'unicode' => $icon_unicode,
'class' => $value,
'element' => ''
);
break;
case 'unicode':
$icon_unicode_string = $this->defaults['choices'][ $value ];
$icon_unicode_arr = explode( ' ', $icon_unicode_string );
$value = $icon_unicode_arr[0];
break;
case 'element':
$value = '';
break;
}
return $value;
}
}
new acf_field_font_awesome();