Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save badabingbreda/408831b4133633e6fac590c6c8002688 to your computer and use it in GitHub Desktop.

Select an option

Save badabingbreda/408831b4133633e6fac590c6c8002688 to your computer and use it in GitHub Desktop.
toolbox - Example Adding the Youtubepicker Fieldtype
<?php
add_filter( 'toolbox/helpers/settings/type=youtubepicker' , 'toolboxConnectors::settings_text', 10, 2 );
add_filter( 'toolbox/helpers/sc_attr/type=youtubepicker' , 'toolbox::return_shortcode_attr_default' , 10, 1 );
// add_filter( 'toolbox/helpers/get_acf_field/type=youtubepicker' , 'toolbox::post_object_to_array' , 20, 5 );
add_filter( 'toolbox/helpers/get_acf_field/type=youtubepicker' , 'display_youtubepicker' , 10, 5 );
/**
* Default behavior for the Youtubepicker fieldtype
* @param mixed $string [passed in value/string/array/object]
* @param array $field_object [this fields field_object]
* @param mixed $value [this fields returned_value]
* @param array $atts [shortcode attributes or users settings]
* @param int $postid [postid to query]
* @return mixed [returned value for next callback or output]
*/
function display_youtubepicker( $string , $field_object , $value , $atts , $postid ) {
if ( $field_object['multiple'] ) {
$return = '<div class="uk-child-width-1-3@s uk-grid-small uk-grid-match" uk-grid>';
for ($i=0; $i<sizeof($value);$i++) {
$return .= '<div><div>' . $value[$i]['iframe'] . '</div></div>';
}
$return .= '</div>';
} else {
$return = $value['iframe'];
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment