No "NextGEN Gallery" option in Field Type
-
Hi!
I’m a bit desperate. I’ve installed and activated the NextGEN and ACF plugins and then this add-on but the “NextGEN Gallery” option doesn’t show up in Field Type as one of options. I’m not getting any error message so I can’t even specify what may be the problem. All plugins are activated, obviously.
I would really appreciate any clue.Regards,
Adam
https://www.ads-software.com/extend/plugins/advanced-custom-fields-nextgen-gallery-field-add-on/
-
It’s strange but reinstalling all plugins for the xth time has helped.
Regards,
Adami’ve the same problem and reinstalling doesn’t work for me ??
I’ve downgraded the Advanced Custom Fields plugin to the 3.5.8.2 version. It should help ??
ok works now but the rest does not!
found another solution!
This has been marked as resolved.
Can I confirm that the fix is to downgrade? I would consider that more a workaround than a resolution.
(although if the root of the problem is with ACF (is it? do all other ACF add-ons fail?) then I guess there’s not much you can do..)
I have same problem!
same problem. not found it on field type.
Same by me, wierd
Hello…
this with acf v4 api
admin area show , and save this field selected value …
front_end the_field and get_field do not test!replace code … (plugin file head comment do not remove!)
<?php
class acf_field_ACF_NGGallery_Field extends acf_field
{
// vars
var $settings, // will hold info such as dir / path
$defaults; // will hold default field options
/**
* Base directory
* @var string
*/
private $base_dir;/**
* Relative Uri from the WordPress ABSPATH constant
* @var string
*/
private $base_uri_rel;/**
* Absolute Uri
*
* This is used to create urls to CSS and JavaScript files.
* @var string
*/
private $base_uri_abs;/**
* WordPress Localization Text Domain
*
* The textdomain for the field is controlled by the helper class.
* @var string
*/
private $l10n_domain;/*
* __construct
*
* Set name / label needed for actions / filters
*
* @since 3.6
* @date 23/01/13
*/function __construct()
{// settings
$this->settings = array(
‘path’ => apply_filters(‘acf/helpers/get_path’, __FILE__),
‘dir’ => apply_filters(‘acf/helpers/get_dir’, __FILE__),
‘version’ => ‘1.0.0’
);//Get the textdomain from the Helper class
$this->l10n_domain =”acf-nggallery-field”;//Base directory of this field
$this->base_dir = rtrim( dirname( realpath( __FILE__ ) ), ‘/’ );//Build the base relative uri by searching backwards until we encounter the wordpress ABSPATH
$root = array_pop( explode( ‘/’, rtrim( ABSPATH, ‘/’ ) ) );
$path_parts = explode( ‘/’, $this->base_dir );
$parts = array();
while( $part = array_pop( $path_parts ) ) {
if( $part == $root )
break;
array_unshift( $parts, $part );
}
$this->base_uri_rel = ‘/’ . implode( ‘/’, $parts );
$this->base_uri_abs = get_site_url( null, $this->base_uri_rel );// $this->name = ‘nggallery-field’;
$post_title = ( !class_exists(‘nggdb’) ) ? ‘. ‘ . __( ‘NextGEN Gallery plugin is not installed or activated!’, $this->l10n_domain ) : false;
$this->label = __( ‘NextGEN Gallery’.$post_title, $this->l10n_domain );// vars
$this->name = ‘ACF_NGGallery_Field’;
// $this->label = __(‘{{field_label}}’);
$this->category = __(“Basic”,’acf’); // Basic, Content, Choice, etc
$this->defaults = array(
// add default here to merge into your field.
// This makes life easy when creating the field options as you don’t need to use any if( isset(”) ) logic. eg:
//’preview_size’ => ‘thumbnail’
);// add_action( ‘admin_print_scripts’, array( &$this, ‘admin_print_scripts’ ), 12, 0 );
// add_action( ‘admin_print_styles’, array( &$this, ‘admin_print_styles’ ), 12, 0 );// do not delete!
parent::__construct();
}
/**
* Populates the fields array with defaults for this field type
*
* @param array $field
* @return array
*/
private function set_field_defaults( &$field ) {
//$field[ ‘nggallery’ ] = ( array_key_exists( ‘nggallery’, $field ) && isset( $field[ ‘nggallery’ ] ) ) ? $field[ ‘nggallery’ ] : 0;
$field[ ‘nggallery’ ] = 0;
$field[ ‘input_type’ ] = ( array_key_exists( ‘input_type’, $field ) && isset( $field[ ‘input_type’ ] ) ) ? $field[ ‘input_type’ ] : ‘select’;
$field[ ‘input_size’ ] = ( array_key_exists( ‘input_size’, $field ) && isset( $field[ ‘input_size’ ] ) ) ? (int) $field[ ‘input_size’ ] : 5;
$field[ ‘allow_null’ ] = isset($field[‘allow_null’]) ? $field[‘allow_null’] : false;
return $field;
}/*
* create_options()
*
* Create extra options for your field. This is rendered when editing a field.
* The value of $field[‘name’] can be used (like bellow) to save extra data to the $field
*
* @type action
* @since 3.6
* @date 23/01/13
*
* @param $field – an array holding all the field’s data
*/function create_options( $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/
$this->set_field_defaults( $field );
// key is needed in the field names to correctly save the data
$key = $field[‘name’];?>
<tr class=”field_option field_option_<?php echo $this->name; ?>”>
<td class=”label”>
<label><?php _e(“Allow Null?”,’acf’); ?></label>
</td>
<td>
<?php
do_action(‘acf/create_field’,array(
‘type’ => ‘radio’,
‘name’ => ‘fields[‘.$key.’][allow_null]’,
‘value’ => $field[‘allow_null’],
‘choices’ => array(
‘1’ => ‘Yes’,
‘0’ => ‘No’,
),
‘layout’ => ‘horizontal’,
));
?>
</td>
</tr>
<tr class=”field_option field_option_<?php echo $this->name; ?>”>
<td class=”label”>
<label><?php _e( ‘Input Method’ , $this->l10n_domain ); ?></label>
<p class=”description”><?php _e( ”, $this->l10n_domain ); ?></p>
</td>
<td>
<?php
do_action(‘acf/create_field’, array(
‘type’ => ‘select’,
‘name’ => “fields[{$key}][input_type]”,
‘value’ => $field[ ‘input_type’ ],
‘class’ => “nggallery_input_type nggallery_input_type_{$key}”,
‘choices’ => array(
‘select’ => ‘Select’,
‘multiselect’ => ‘Multi-Select’,
//’token’ => ‘Input Tokenizer’,
)
) );
?>
</td>
</tr>
<tr id=”nggallery_input_size[<?php echo $key; ?>]” class=”field_option field_option_<?php echo $this->name; ?> nggallery_input_size nggallery_input_size_<?php echo $key; ?>”>
<td class=”label”>
<label><?php _e( ‘Multi-Select Size’ , $this->l10n_domain ); ?></label>
<p class=”description”><?php _e( ‘The number of rows to show at once in a multi-select.’, $this->l10n_domain ); ?></p>
</td>
<td>
<?php
do_action(‘acf/create_field’, array(
‘type’ => ‘select’,
‘name’ => “fields[{$key}][input_size]”,
‘value’ => $field[ ‘input_size’ ],
‘choices’ => array_combine( range( 3, 15, 2 ), range( 3, 15, 2 ) ),
) );
?>
</td>
</tr>
<script type=’text/javascript’>jQuery(document).ready(function() {
if ( jQuery(‘.nggallery_input_type_<?php echo $key; ?>’).val()==’select’ ) jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).hide();
else jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).show();jQuery(‘.nggallery_input_type_<?php echo $key; ?>’).change(function() {
if ( jQuery(‘.nggallery_input_type_<?php echo $key; ?>’).val()==’select’ ) jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).hide();
else jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).show();
});
});</script>
<?php}
/*
* create_field()
*
* Create the HTML interface for your field
*
* @param $field – an array holding all the field’s data
*
* @type action
* @since 3.6
* @date 23/01/13
*/function create_field( $field )
{
global $ngg, $nggdb, $wp_query;$this->set_field_defaults( $field );
$values = $field[ ‘value’ ];
if ( !empty($values[0]) ):
foreach ( $values as $form ) {
if ( in_array ( ‘gallery’, $form ) )
$values_gallery[]=$form[‘ngg_id’];if ( in_array ( ‘album’, $form ) )
$values_album[]=$form[‘ngg_id’];}
endif;
if ( class_exists(‘nggdb’) ) :
// Settings of NextGEN Gallery SQL query
$limit = 0;
$start = 0;
$order_by = ‘title’;
$order_dir = ‘ASC’;// Seek to all NextGEN Galleries
$gallerylist = $nggdb->find_all_galleries( $order_by, $order_dir , TRUE, $limit, $start, false);
$albumlist = $nggdb->find_all_album( ‘name’, $order_dir, $limit, $start);$haystack = array( ‘select’, ‘multiselect’ );
if( in_array( $field[ ‘input_type’ ], $haystack ) ) :
?>
<select name=”<?php echo $field[ ‘name’ ]; ?>[]” id=”<?php echo $field[ ‘name’ ]; ?>” class=”<?php echo $field[ ‘class’ ]; ?>” <?php echo ( $field[ ‘input_type’ ] == ‘multiselect’ ) ? ‘multiple=”multiple” size=”‘ . $field[ ‘input_size’ ] . ‘”‘ : ”; ?>>
<?php if($field[‘allow_null’] == ‘1’) echo ‘
<option value=”null”> – Select – </option>’;
?><optgroup label=”<?php _e(‘Galleries’,’nggallery’); ?>”>
<?php foreach( $gallerylist as $gallery ) : ?>
<option value=”<?php echo $gallery->gid.’,gallery’; ?>”<?php if ( $values_gallery ) selected( in_array( $gallery->gid, $values_gallery ) ); ?>><?php echo $gallery->title; ?></option>
<?php endforeach; ?>
</optgroup>
<optgroup label=”<?php _e(‘Albums’,’nggallery’); ?>”>
<?php foreach( $albumlist as $album ) : ?>
<option value=”<?php echo $album->id.’,album’; ?>”<?php if ( $values_album ) selected( in_array( $album->id, $values_album ) ); ?>><?php echo $album->name; ?></option>
<?php endforeach; ?>
</optgroup>
</select>
<?php
endif;else:
?>
<select name=”<?php echo $field[ ‘name’ ]; ?>[]” id=”<?php echo $field[ ‘name’ ]; ?>” class=”<?php echo $field[ ‘class’ ]; ?>”>
<option value=”0″ disabled=”true”><?php _e( ‘NextGEN Gallery plugin is not installed or activated!’, $this->l10n_domain ); ?></option>
</select>
<?php
endif;}
/*
* 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 https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_enqueue_scripts
* @type action
* @since 3.6
* @date 23/01/13
*/function input_admin_enqueue_scripts()
{
// Note: This function can be removed if not used//
// // register acf scripts
// wp_register_script( ‘acf-input-ACF_NGGallery_Field’, $this->settings[‘dir’] . ‘js/input.js’, array(‘acf-input’), $this->settings[‘version’] );
// wp_register_style( ‘acf-input-ACF_NGGallery_Field’, $this->settings[‘dir’] . ‘css/input.css’, array(‘acf-input’), $this->settings[‘version’] );
//
//
// // scripts
// wp_enqueue_script(array(
// ‘acf-input-ACF_NGGallery_Field’,
// ));
//
// // styles
// wp_enqueue_style(array(
// ‘acf-input-ACF_NGGallery_Field’,
// ));}
/*
* input_admin_head()
*
* This action is called in the admin_head action on the edit screen where your field is created.
* Use this action to add css and javascript to assist your create_field() action.
*
* @info https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_head
* @type action
* @since 3.6
* @date 23/01/13
*/function input_admin_head()
{
// Note: This function can be removed if not used
}/*
* 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 https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_enqueue_scripts
* @type action
* @since 3.6
* @date 23/01/13
*/function field_group_admin_enqueue_scripts()
{
// Note: This function can be removed if not used
}/*
* field_group_admin_head()
*
* This action is called in the admin_head action on the edit screen where your field is edited.
* Use this action to add css and javascript to assist your create_field_options() action.
*
* @info https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_head
* @type action
* @since 3.6
* @date 23/01/13
*/function field_group_admin_head()
{
// Note: This function can be removed if not used
}/*
* 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 )
{
// Note: This function can be removed if not used
return $value;
}/*
* update_value()
*
* This filter is appied to the $value before it is updated in the db
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value – the value which will be saved in the database
* @param $post_id – the $post_id of which the value will be saved
* @param $field – the field array holding all the field options
*
* @return $value – the modified value
*/function update_value( $value, $post_id, $field )
{ $this->set_field_defaults( $field );foreach( $value as $key=>$item ) {
$items = explode( ‘,’, $item );
foreach( $items as $item ) {
if( is_numeric( $item ) )
$values[$key][‘ngg_id’] = intval ( $item );
else
$values[$key][‘ngg_form’] = strval( $item );
}
}// parent::update_value( $post_id, $field, $values );
// Note: This function can be removed if not used
return $values;
}/*
* format_value()
*
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value – the value which was loaded from the database
* @param $post_id – the $post_id from which the value was loaded
* @param $field – the field array holding all the field options
*
* @return $value – the modified value
*/function format_value( $value, $post_id, $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/// perhaps use $field[‘preview_size’] to alter the $value?
// Note: This function can be removed if not used
return $value;
}/*
* format_value_for_api()
*
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value – the value which was loaded from the database
* @param $post_id – the $post_id from which the value was loaded
* @param $field – the field array holding all the field options
*
* @return $value – the modified value
*/function format_value_for_api( $value, $post_id, $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/// perhaps use $field[‘preview_size’] to alter the $value?
// Note: This function can be removed if not used
return $value;
}/*
* load_field()
*
* This filter is appied to the $field after it is loaded from the database
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $field – the field array holding all the field options
*
* @return $field – the field array holding all the field options
*/function load_field( $field )
{
// Note: This function can be removed if not used
return $field;
}/*
* update_field()
*
* This filter is appied to the $field before it is saved to the database
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $field – the field array holding all the field options
* @param $post_id – the field group ID (post_type = acf)
*
* @return $field – the modified field
*/function update_field( $field, $post_id )
{
// Note: This function can be removed if not used
return $field;
}}
// create field
new acf_field_ACF_NGGallery_Field();?>
This code doesn’t work, and i have the same problem ??
eggproject, where did you put that code? Did you replace the code in advanced-custom-fields-nextgen-gallery-field-add-on/nggallery-field.php ?
i create v4.php => copy my new v4 api code
and rewrite nggallery-field.php =>
/*
ORIGINAL PLUGIN COMMENT
*/add_action(‘acf/register_fields’, ‘my_register_fields’);
function my_register_fields()
{
require_once(rtrim( dirname( realpath( __FILE__ ) ), ‘/’ ).”/v4.php”);
}this work … wp 3.5.2 lastest acf… lastest nextgen…
sry i little speak english :(((
eggproject, i am doing with your help and working fine :),
many thanks.
please can you tell me (and maybe all of us) what you have done with this two code snippets from egg project? which code in which file? what should I replace, what should I append or merge? please let us know. thanks in advance
nggallery-field.php
<?php
/*
Plugin Name: Advanced Custom Fields – NextGEN Gallery Field add-on with egg BugFix migrate to acf v4 api
Plugin URI: https://www.ads-software.com/extend/plugins/advanced-custom-fields-nextgen-gallery-field-add-on/
Description: This plugin is an add-on for Advanced Custom Fields. It provides a dropdown of NextGEN Gallery and the ability to map the selected NextGEN Gallery to the post.
Version: 1.2.1
Requires at least: 3.0
Tested up to: 3.4.1
Author: Ales Loziak
Author URI: https://www.apollo1.cz
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
*
*
* Copyright (c) 2012, Ales Loziak
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Ales Loziak nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
add_action(‘acf/register_fields’, ‘my_register_fields’);function my_register_fields()
{
require_once(rtrim( dirname( realpath( __FILE__ ) ), ‘/’ ).”/v4.php”);
}v4.php
<?phpclass acf_field_ACF_NGGallery_Field extends acf_field
{
// vars
var $settings, // will hold info such as dir / path
$defaults; // will hold default field options
/**
* Base directory
* @var string
*/
private $base_dir;/**
* Relative Uri from the WordPress ABSPATH constant
* @var string
*/
private $base_uri_rel;/**
* Absolute Uri
*
* This is used to create urls to CSS and JavaScript files.
* @var string
*/
private $base_uri_abs;/**
* WordPress Localization Text Domain
*
* The textdomain for the field is controlled by the helper class.
* @var string
*/
private $l10n_domain;/*
* __construct
*
* Set name / label needed for actions / filters
*
* @since 3.6
* @date 23/01/13
*/function __construct()
{// settings
$this->settings = array(
‘path’ => apply_filters(‘acf/helpers/get_path’, __FILE__),
‘dir’ => apply_filters(‘acf/helpers/get_dir’, __FILE__),
‘version’ => ‘1.0.0’
);//Get the textdomain from the Helper class
$this->l10n_domain =”acf-nggallery-field”;//Base directory of this field
$this->base_dir = rtrim( dirname( realpath( __FILE__ ) ), ‘/’ );//Build the base relative uri by searching backwards until we encounter the wordpress ABSPATH
$root = array_pop( explode( ‘/’, rtrim( ABSPATH, ‘/’ ) ) );
$path_parts = explode( ‘/’, $this->base_dir );
$parts = array();
while( $part = array_pop( $path_parts ) ) {
if( $part == $root )
break;
array_unshift( $parts, $part );
}
$this->base_uri_rel = ‘/’ . implode( ‘/’, $parts );
$this->base_uri_abs = get_site_url( null, $this->base_uri_rel );// $this->name = ‘nggallery-field’;
$post_title = ( !class_exists(‘nggdb’) ) ? ‘. ‘ . __( ‘NextGEN Gallery plugin is not installed or activated!’, $this->l10n_domain ) : false;
$this->label = __( ‘NextGEN Gallery’.$post_title, $this->l10n_domain );// vars
$this->name = ‘ACF_NGGallery_Field’;
// $this->label = __(‘{{field_label}}’);
$this->category = __(“Basic”,’acf’); // Basic, Content, Choice, etc
$this->defaults = array(
// add default here to merge into your field.
// This makes life easy when creating the field options as you don’t need to use any if( isset(”) ) logic. eg:
//’preview_size’ => ‘thumbnail’
);// add_action( ‘admin_print_scripts’, array( &$this, ‘admin_print_scripts’ ), 12, 0 );
// add_action( ‘admin_print_styles’, array( &$this, ‘admin_print_styles’ ), 12, 0 );// do not delete!
parent::__construct();
}
/**
* Populates the fields array with defaults for this field type
*
* @param array $field
* @return array
*/
private function set_field_defaults( &$field ) {
//$field[ ‘nggallery’ ] = ( array_key_exists( ‘nggallery’, $field ) && isset( $field[ ‘nggallery’ ] ) ) ? $field[ ‘nggallery’ ] : 0;
$field[ ‘nggallery’ ] = 0;
$field[ ‘input_type’ ] = ( array_key_exists( ‘input_type’, $field ) && isset( $field[ ‘input_type’ ] ) ) ? $field[ ‘input_type’ ] : ‘select’;
$field[ ‘input_size’ ] = ( array_key_exists( ‘input_size’, $field ) && isset( $field[ ‘input_size’ ] ) ) ? (int) $field[ ‘input_size’ ] : 5;
$field[ ‘allow_null’ ] = isset($field[‘allow_null’]) ? $field[‘allow_null’] : false;
return $field;
}/*
* create_options()
*
* Create extra options for your field. This is rendered when editing a field.
* The value of $field[‘name’] can be used (like bellow) to save extra data to the $field
*
* @type action
* @since 3.6
* @date 23/01/13
*
* @param $field – an array holding all the field’s data
*/function create_options( $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/
$this->set_field_defaults( $field );
// key is needed in the field names to correctly save the data
$key = $field[‘name’];?>
<tr class=”field_option field_option_<?php echo $this->name; ?>”>
<td class=”label”>
<label><?php _e(“Allow Null?”,’acf’); ?></label>
</td>
<td>
<?php
do_action(‘acf/create_field’,array(
‘type’ => ‘radio’,
‘name’ => ‘fields[‘.$key.’][allow_null]’,
‘value’ => $field[‘allow_null’],
‘choices’ => array(
‘1’ => ‘Yes’,
‘0’ => ‘No’,
),
‘layout’ => ‘horizontal’,
));
?>
</td>
</tr>
<tr class=”field_option field_option_<?php echo $this->name; ?>”>
<td class=”label”>
<label><?php _e( ‘Input Method’ , $this->l10n_domain ); ?></label>
<p class=”description”><?php _e( ”, $this->l10n_domain ); ?></p>
</td>
<td>
<?php
do_action(‘acf/create_field’, array(
‘type’ => ‘select’,
‘name’ => “fields[{$key}][input_type]”,
‘value’ => $field[ ‘input_type’ ],
‘class’ => “nggallery_input_type nggallery_input_type_{$key}”,
‘choices’ => array(
‘select’ => ‘Select’,
‘multiselect’ => ‘Multi-Select’,
//’token’ => ‘Input Tokenizer’,
)
) );
?>
</td>
</tr>
<tr id=”nggallery_input_size[<?php echo $key; ?>]” class=”field_option field_option_<?php echo $this->name; ?> nggallery_input_size nggallery_input_size_<?php echo $key; ?>”>
<td class=”label”>
<label><?php _e( ‘Multi-Select Size’ , $this->l10n_domain ); ?></label>
<p class=”description”><?php _e( ‘The number of rows to show at once in a multi-select.’, $this->l10n_domain ); ?></p>
</td>
<td>
<?php
do_action(‘acf/create_field’, array(
‘type’ => ‘select’,
‘name’ => “fields[{$key}][input_size]”,
‘value’ => $field[ ‘input_size’ ],
‘choices’ => array_combine( range( 3, 15, 2 ), range( 3, 15, 2 ) ),
) );
?>
</td>
</tr>
<script type=’text/javascript’>jQuery(document).ready(function() {
if ( jQuery(‘.nggallery_input_type_<?php echo $key; ?>’).val()==’select’ ) jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).hide();
else jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).show();jQuery(‘.nggallery_input_type_<?php echo $key; ?>’).change(function() {
if ( jQuery(‘.nggallery_input_type_<?php echo $key; ?>’).val()==’select’ ) jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).hide();
else jQuery(‘.nggallery_input_size_<?php echo $key; ?>’).show();
});
});</script>
<?php}
/*
* create_field()
*
* Create the HTML interface for your field
*
* @param $field – an array holding all the field’s data
*
* @type action
* @since 3.6
* @date 23/01/13
*/function create_field( $field )
{
global $ngg, $nggdb, $wp_query;$this->set_field_defaults( $field );
$values = $field[ ‘value’ ];
if ( !empty($values[0]) ):
foreach ( $values as $form ) {
if ( in_array ( ‘gallery’, $form ) )
$values_gallery[]=$form[‘ngg_id’];if ( in_array ( ‘album’, $form ) )
$values_album[]=$form[‘ngg_id’];}
endif;
if ( class_exists(‘nggdb’) ) :
// Settings of NextGEN Gallery SQL query
$limit = 0;
$start = 0;
$order_by = ‘title’;
$order_dir = ‘ASC’;// Seek to all NextGEN Galleries
$gallerylist = $nggdb->find_all_galleries( $order_by, $order_dir , TRUE, $limit, $start, false);
$albumlist = $nggdb->find_all_album( ‘name’, $order_dir, $limit, $start);$haystack = array( ‘select’, ‘multiselect’ );
if( in_array( $field[ ‘input_type’ ], $haystack ) ) :
?>
<select name=”<?php echo $field[ ‘name’ ]; ?>[]” id=”<?php echo $field[ ‘name’ ]; ?>” class=”<?php echo $field[ ‘class’ ]; ?>” <?php echo ( $field[ ‘input_type’ ] == ‘multiselect’ ) ? ‘multiple=”multiple” size=”‘ . $field[ ‘input_size’ ] . ‘”‘ : ”; ?>>
<?php if($field[‘allow_null’] == ‘1’) echo ‘
<option value=”null”> – Select – </option>’;
?><optgroup label=”<?php _e(‘Galleries’,’nggallery’); ?>”>
<?php foreach( $gallerylist as $gallery ) : ?>
<option value=”<?php echo $gallery->gid.’,gallery’; ?>”<?php if ( $values_gallery ) selected( in_array( $gallery->gid, $values_gallery ) ); ?>><?php echo $gallery->title; ?></option>
<?php endforeach; ?>
</optgroup>
<optgroup label=”<?php _e(‘Albums’,’nggallery’); ?>”>
<?php foreach( $albumlist as $album ) : ?>
<option value=”<?php echo $album->id.’,album’; ?>”<?php if ( $values_album ) selected( in_array( $album->id, $values_album ) ); ?>><?php echo $album->name; ?></option>
<?php endforeach; ?>
</optgroup>
</select>
<?php
endif;else:
?>
<select name=”<?php echo $field[ ‘name’ ]; ?>[]” id=”<?php echo $field[ ‘name’ ]; ?>” class=”<?php echo $field[ ‘class’ ]; ?>”>
<option value=”0″ disabled=”true”><?php _e( ‘NextGEN Gallery plugin is not installed or activated!’, $this->l10n_domain ); ?></option>
</select>
<?php
endif;}
/*
* 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 https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_enqueue_scripts
* @type action
* @since 3.6
* @date 23/01/13
*/function input_admin_enqueue_scripts()
{
// Note: This function can be removed if not used//
// // register acf scripts
// wp_register_script( ‘acf-input-ACF_NGGallery_Field’, $this->settings[‘dir’] . ‘js/input.js’, array(‘acf-input’), $this->settings[‘version’] );
// wp_register_style( ‘acf-input-ACF_NGGallery_Field’, $this->settings[‘dir’] . ‘css/input.css’, array(‘acf-input’), $this->settings[‘version’] );
//
//
// // scripts
// wp_enqueue_script(array(
// ‘acf-input-ACF_NGGallery_Field’,
// ));
//
// // styles
// wp_enqueue_style(array(
// ‘acf-input-ACF_NGGallery_Field’,
// ));}
/*
* input_admin_head()
*
* This action is called in the admin_head action on the edit screen where your field is created.
* Use this action to add css and javascript to assist your create_field() action.
*
* @info https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_head
* @type action
* @since 3.6
* @date 23/01/13
*/function input_admin_head()
{
// Note: This function can be removed if not used
}/*
* 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 https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_enqueue_scripts
* @type action
* @since 3.6
* @date 23/01/13
*/function field_group_admin_enqueue_scripts()
{
// Note: This function can be removed if not used
}/*
* field_group_admin_head()
*
* This action is called in the admin_head action on the edit screen where your field is edited.
* Use this action to add css and javascript to assist your create_field_options() action.
*
* @info https://codex.www.ads-software.com/Plugin_API/Action_Reference/admin_head
* @type action
* @since 3.6
* @date 23/01/13
*/function field_group_admin_head()
{
// Note: This function can be removed if not used
}/*
* 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 )
{
// Note: This function can be removed if not used
return $value;
}/*
* update_value()
*
* This filter is appied to the $value before it is updated in the db
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value – the value which will be saved in the database
* @param $post_id – the $post_id of which the value will be saved
* @param $field – the field array holding all the field options
*
* @return $value – the modified value
*/function update_value( $value, $post_id, $field )
{ $this->set_field_defaults( $field );foreach( $value as $key=>$item ) {
$items = explode( ‘,’, $item );
foreach( $items as $item ) {
if( is_numeric( $item ) )
$values[$key][‘ngg_id’] = intval ( $item );
else
$values[$key][‘ngg_form’] = strval( $item );
}
}// parent::update_value( $post_id, $field, $values );
// Note: This function can be removed if not used
return $values;
}/*
* format_value()
*
* This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value – the value which was loaded from the database
* @param $post_id – the $post_id from which the value was loaded
* @param $field – the field array holding all the field options
*
* @return $value – the modified value
*/function format_value( $value, $post_id, $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/// perhaps use $field[‘preview_size’] to alter the $value?
// Note: This function can be removed if not used
return $value;
}/*
* format_value_for_api()
*
* This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value – the value which was loaded from the database
* @param $post_id – the $post_id from which the value was loaded
* @param $field – the field array holding all the field options
*
* @return $value – the modified value
*/function format_value_for_api( $value, $post_id, $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/// perhaps use $field[‘preview_size’] to alter the $value?
// Note: This function can be removed if not used
return $value;
}/*
* load_field()
*
* This filter is appied to the $field after it is loaded from the database
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $field – the field array holding all the field options
*
* @return $field – the field array holding all the field options
*/function load_field( $field )
{
// Note: This function can be removed if not used
return $field;
}/*
* update_field()
*
* This filter is appied to the $field before it is saved to the database
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $field – the field array holding all the field options
* @param $post_id – the field group ID (post_type = acf)
*
* @return $field – the modified field
*/function update_field( $field, $post_id )
{
// Note: This function can be removed if not used
return $field;
}}
// create field
new acf_field_ACF_NGGallery_Field();?>
- The topic ‘No "NextGEN Gallery" option in Field Type’ is closed to new replies.