name = 'scplaylist';
$this->label = __('Playlists (SoundCloud)');
$this->category = __("Content",'acf-scp');
$this->defaults = array(
'button_label' => __('Browse Playlist','acf-scp'),
'return_format' => 'array',
);
// do not delete!
parent::__construct();
}
/*
* create_options()
* @v5 render_field_settings()
*/
function create_options( $field ) {
// key is needed in the field names to correctly save the data
$key = $field['name'];
// Create Field Options HTML
?>
'text',
'value' => $field['button_label'],
'name' => 'fields['.$key.'][button_label]'
));
?>
'radio',
'value' => $field['return_format'],
'name' => 'fields['.$key.'][return_format]',
'layout' => 'horizontal',
'choices' => array(
'array' => __("Playlist Array",'acf-scp'),
'list' => __("List of Tracks",'acf-scp'),
)
));
?>
'',
'value' => array(),
);
$field = wp_parse_args( $field, $defaults );
extract( $field );
$input_values = scp_extract_values( $value );
$check_value = array_shift($value);
$label = ( !empty($check_value) ) ? scp_get_playlist_label( $input_values ) : $button_label;
if( is_scp_ready() ) :
?>
here', scp_settings_url( array() )),'acf-scp' ) ;
endif;
}
/*
* input_admin_enqueue_scripts()
*
*/
function input_admin_enqueue_scripts() {
$dir = plugin_dir_url( __FILE__ );
wp_enqueue_script('thickbox');
wp_register_script( 'scp-selectize-plug-js', "{$dir}assets/js/selectize.js", array('jquery'), '0.12.0' , false);
wp_enqueue_script('scp-selectize-plug-js');
wp_register_script( 'scp-scsdk-js', "//connect.soundcloud.com/sdk.js", array('jquery') );
wp_enqueue_script('scp-scsdk-js');
wp_register_script( 'scp-js', "{$dir}assets/js/acf_scp.js", array('jquery','scp-scsdk-js'), SCP_VERSION , false);
wp_enqueue_script('scp-js');
wp_enqueue_style('thickbox');
wp_register_style( 'scp-selectize-plug-style', "{$dir}assets/css/selectize.css" );
wp_enqueue_style('scp-selectize-plug-style');
wp_register_style( 'scp-style', "{$dir}assets/css/acf_scp.css", array(), SCP_VERSION , false );
wp_enqueue_style('scp-style');
}
/*
* input_admin_head()
*
*/
function input_admin_head() {
// add class .scp-active to body
add_filter( 'admin_body_class', array( $this, 'update_body_class' ) );
// browse playlist modal view
add_action('admin_footer', array( $this, 'input_admin_footer' ) );
}
/*
* format_value_for_api()
*
*/
function format_value_for_api( $value, $post_id, $field ) {
$value = scp_extract_values($value);
// bail early if no value
if( empty($value['id']) ) {
return;
}
$query = ( isset($_REQUEST['set']) && isset($_REQUEST['track']) ) ? $_SERVER['QUERY_STRING']: '';
if( !empty($query) ) :
// ready for displaying track
parse_str($query);
// bail early if not same set/playlist id
if( $set !== $value['id'] ) {
return;
}
$return = scp_get_track( $query, $track );
else :
// get value in order
$set = intval($value['id']);
$return = scp_get_tracks( $field['return_format'], $set );
endif;
return $return;
}
/*
* update_body_class()
* utility to add class name to admin body html
*
* @since 1.0
*/
function update_body_class( $classes ) {
// add .scp-active
$classes .= 'scp-active';
return $classes;
}
/*
* input_admin_footer()
* utility to add scrip in the admin footer
*
* @since 1.0
*/
function input_admin_footer() {
$dir = plugin_dir_url( __FILE__ );
$options = scp_get_app();
$acf_scp = array(
'fieldType' => $this->name,
'client_app_key' => $options['clientkey'],
'html_callback' => $dir . 'inc/callback.html',
);
// render browse playlist in the footer for global modal view
$this->render_scp_browse();
?>