- This topic has 2 replies, 2 voices, and was last updated 4 years, 6 months ago by
cdcorey.
-
AuthorPosts
-
-
December 16, 2015 at 11:17 am #5360
jcristMemberHi Steve,
Maybe I’m missing it somewhere but how do I add and process custom data in the comment block (in a settings field if that makes a difference)? I thought it would be the filter ‘piklist_part_data_parameter’ but when I print_r, I don’t see my custom comment. Example:
<?php /* Title: Staff Order: 10 Tab: Organization Setting: site_functionality Flow: Functionality Workflow Site Type: attorney */ ?>Thanks!
-
December 17, 2015 at 10:01 am #5369
jcristMemberI should have given more background…What I’d like to do is conditionally show meta-boxes based on the Site Type which the user selects on tab 1. I found this this thread which pointed me in the right direction.
Here’s what I’m trying:
add_filter('piklist_part_data_parameter', 'site_type_filter', 10, 2); function site_type_filter($value, $parameter) { if($parameter == 'site_type') { $value = piklist::explode(',', $value, 'strtolower'); $value = array_filter($value); $value = empty($value) ? null : $value; } return $value; }Then I’m printing out the part array:
add_filter('piklist_part_process-settings', 'show_part_array', 20, 2); function show_part_array( $part ) { print_r($part); return $part; }But ‘site_type’ is not in the array. Looks like I don’t know how to properly use this filter, could you post a code sample?
Also, once I this this working, I would use the ‘piklist_part_process’ filter to unset the part if it shouldn’t be shown?
-
July 26, 2017 at 6:04 pm #8335
cdcoreyMemberFor anyone else who comes across this on Google, it’s actually very simple to do:
add_filter('piklist_part_data', function ($data, $folder) { $data['foo'] = 'Foo'; return $data; }, 10, 2);In this example, ‘Foo’ is the text you’ll include in comment blocks, like so:
/* Foo: Bar */While ‘foo’ will be the key in the part’s data array:
add_filter('piklist_part_process', function ($part, $folder) { if ($part['data']['foo'] == 'Bar') { // Do something... } }, 10, 2);
-
-
AuthorPosts
- You must be logged in to reply to this topic.