/** * piklist * The core helper function for the Piklist framework. * * @since 1.0 */ function piklist($option, $arguments = array()) { if (!is_array($arguments) && strstr($arguments, '=')) { parse_str($arguments, $arguments); } if (is_array($option) || is_object($option)) { return empty($arguments) ? piklist::object_format($option) : piklist::pluck($option, $arguments); } else { switch ($option) { case 'field': if (piklist_setting::get('active_section')) { piklist_setting::register_setting($arguments); } else { return piklist_form::render_field($arguments, isset($arguments['return']) ? $arguments['return'] : false); } break; case 'form': return piklist_form::render_form($arguments['form'], isset($arguments['add_on']) ? $arguments['add_on'] : null); break; case 'list_table': piklist_list_table::render($arguments); break; case 'post_type_labels': return piklist::post_type_labels($arguments); break; case 'taxonomy_labels': return piklist::taxonomy_labels($arguments); break; case 'option': case 'post_custom': case 'post_meta': case 'get_post_custom': case 'user_custom': case 'user_meta': case 'get_user_custom': case 'term_custom': case 'term_meta': case 'get_term_custom': switch ($option) { case 'user_custom': case 'user_meta': case 'get_user_custom': $type = 'user'; break; case 'term_custom': case 'term_meta': case 'get_term_custom': $type = 'term'; break; case 'post_custom': case 'post_meta': case 'get_post_custom': $type = 'post'; break; default: $type = 'option'; break; } return piklist::object($type, $arguments); break; case 'dashes': return piklist::dashes($arguments); break; case 'slug': return piklist::slug($arguments); break; case 'humanize': return piklist::humanize($arguments); break; case 'performance': piklist::performance(); break; case 'comments_template': $file = isset($arguments[0]) ? $arguments[0] : '/comments.php'; $seperate_comments = isset($arguments[1]) ? $arguments[1] : false; piklist_comments::comments_template($file, $seperate_comments); break; case 'include_meta_boxes': piklist::render('shared/notice', array('content' => sprintf(__('This page is using the old Piklist WorkFlow system. Please update your code to the %snew WorkFlow system%s.', 'piklist'), '<a href="https://piklist.com/user-guide/docs/building-workflows-piklist-v0-9-9/" target="_blank">', '</a>'), 'notice_type' => 'error')); break; case 'prefix': return piklist::$prefix; break; case 'url': return isset(piklist::$add_ons[$arguments]) ? piklist::$add_ons[$arguments]['url'] : null; break; case 'path': return isset(piklist::$add_ons[$arguments]) ? piklist::$add_ons[$arguments]['path'] : null; break; default: $return = isset($arguments['return']) ? $arguments['return'] : false; $loop = isset($arguments['loop']) ? $arguments['loop'] : null; unset($arguments['return']); unset($arguments['loop']); return piklist::render($option, $arguments, $return, $loop); break; } } }