public static function meta_box($tag = null, $taxonomy)
 {
     if ($taxonomy) {
         if (!self::$meta_box_nonce) {
             piklist_form::render_field(array('type' => 'hidden', 'field' => 'nonce', 'value' => wp_create_nonce(plugin_basename(piklist::$paths['piklist'] . '/piklist.php')), 'scope' => piklist::$prefix));
             self::$meta_box_nonce = true;
         }
         $wrapper = 'term_meta';
         foreach (self::$meta_boxes[$taxonomy] as $taxonomy => $meta_box) {
             piklist::render('shared/meta-box-start', array('meta_box' => $meta_box, 'wrapper' => $wrapper), false);
             piklist::render($meta_box['part'], array('taxonomy' => $taxonomy, 'prefix' => 'piklist', 'plugin' => 'piklist'), false);
             piklist::render('shared/meta-box-end', array('meta_box' => $meta_box, 'wrapper' => $wrapper), false);
         }
     }
 }
 public static function meta_box($user_id)
 {
     if (!empty(self::$meta_boxes)) {
         if (!self::$meta_box_nonce) {
             piklist_form::render_field(array('type' => 'hidden', 'field' => 'nonce', 'value' => wp_create_nonce(plugin_basename(piklist::$paths['piklist'] . '/piklist.php')), 'scope' => piklist::$prefix));
             self::$meta_box_nonce = true;
         }
         $user = get_userdata($user_id);
         foreach (self::$meta_boxes as $meta_box) {
             piklist::render('shared/meta-box-start', array('meta_box' => $meta_box, 'wrapper' => 'user_meta'), false);
             do_action('piklist_pre_render_user_meta_box', $user, $meta_box);
             piklist::render($meta_box['part'], array('user_id' => $user_id, 'prefix' => 'piklist', 'plugin' => 'piklist'), false);
             do_action('piklist_post_render_user_meta_box', $user, $meta_box);
             piklist::render('shared/meta-box-end', array('meta_box' => $meta_box, 'wrapper' => 'user_meta'), false);
         }
     }
 }
 public static function render_setting($setting)
 {
     piklist_form::render_field(wp_parse_args(array('scope' => $setting['section']['setting'], 'prefix' => false, 'disable_label' => true, 'position' => false, 'value' => piklist_form::get_field_value($setting['section']['setting'], $setting['field'], 'option')), $setting['field']));
 }
function piklist($option, $arguments = array())
{
    if (!is_array($arguments) && strstr($arguments, '=')) {
        parse_str($arguments, $arguments);
    }
    if (is_array($option) || is_object($option)) {
        $list = array();
        $arguments = is_array($arguments) ? $arguments : array($arguments);
        foreach ($option as $key => $value) {
            if (count($arguments) > 1) {
                if (in_array('_key', $arguments)) {
                    $_value = $arguments[1];
                    $list[$key] = is_object($value) ? $value->{$_value} : $value[$_value];
                } else {
                    $__key = $arguments[0];
                    $_key = is_object($value) ? $value->{$__key} : (isset($value[$__key]) ? $value[$__key] : null);
                    $_value = $arguments[1];
                    $list[$_key] = is_object($value) ? $value->{$_value} : (isset($value[$_value]) ? $value[$_value] : null);
                }
            } else {
                $_value = $arguments[0];
                array_push($list, is_object($value) && isset($value->{$_value}) ? $value->{$_value} : (isset($value[$_value]) ? $value[$_value] : null));
            }
        }
        return $list;
    } else {
        switch ($option) {
            case 'field':
                if (piklist_setting::get('active_section')) {
                    piklist_setting::register_setting($arguments);
                } else {
                    piklist_form::render_field($arguments, isset($arguments['return']) ? $arguments['return'] : false);
                }
                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 'performance':
                piklist::performance();
                break;
            case 'include_meta_boxes':
                // TODO: Improve
                if (isset($arguments['post_type'])) {
                    $post_type = $arguments['post_type'];
                    unset($arguments['post_type']);
                } else {
                    $post_type = null;
                }
                piklist::include_meta_boxes($arguments, $post_type);
                break;
            case 'include_actions':
                // TODO: Improve
                if (isset($arguments['action'])) {
                    $post_type = $arguments['action'];
                    unset($arguments['action']);
                }
                piklist::include_actions($action, $arguments);
                break;
            case 'include_user_profile_fields':
                piklist_user::include_user_profile_fields($arguments);
                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;
            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;
        }
    }
}
Esempio n. 5
0
/**
 * 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;
        }
    }
}
Esempio n. 6
0
 /**
  * render_setting
  * Render a setting.
  *
  * @param array $setting The setting object.
  *
  * @access public
  * @static
  * @since 1.0
  */
 public static function render_setting($setting)
 {
     $field = wp_parse_args(array('scope' => $setting['section']['data']['setting'], 'prefix' => false, 'disable_label' => true, 'position' => false, 'value' => piklist_form::get_field_value($setting['section']['data']['setting'], $setting['field'], 'option')), $setting['field']);
     if ($field['type'] == 'group' && !$field['field']) {
         foreach ($field['fields'] as &$column) {
             if (!isset($column['value'])) {
                 $column['value'] = null;
             }
             $column['value'] = piklist_form::get_field_value($setting['section']['data']['setting'], $column, 'option');
         }
     }
     piklist_form::render_field($field);
 }
 public static function meta_box($post, $meta_box)
 {
     global $typenow;
     if (!self::$meta_box_nonce) {
         piklist_form::render_field(array('type' => 'hidden', 'field' => 'nonce', 'value' => wp_create_nonce(plugin_basename(piklist::$paths['piklist'] . '/piklist.php')), 'scope' => piklist::$prefix));
         self::$meta_box_nonce = true;
     }
     do_action('piklist_pre_render_meta_box', $post, $meta_box);
     piklist::render(piklist::$paths[$meta_box['args']['add_on']] . '/parts/meta-boxes/' . $meta_box['args']['part'], array('type' => $typenow, 'prefix' => 'piklist', 'plugin' => 'piklist'), false);
     do_action('piklist_post_render_meta_box', $post, $meta_box);
 }
Esempio n. 8
0
 /**
  * edit_form
  * Appends piklist variables to the edit form if necessary.
  *
  * @access public
  * @static
  * @since 1.0
  */
 public static function edit_form()
 {
     $fields = array('post_id', 'admin_hide_ui');
     foreach ($fields as $field) {
         if (isset($_REQUEST[piklist::$prefix][$field]) && !empty($_REQUEST[piklist::$prefix][$field])) {
             piklist_form::render_field(array('type' => 'hidden', 'scope' => piklist::$prefix, 'field' => $field, 'value' => $_REQUEST[piklist::$prefix][$field]));
         }
     }
 }
Esempio n. 9
0
        if (!in_array($column['type'], array('group', 'editor')) && !$group_add_more && isset($attributes['data-piklist-field-addmore'])) {
            $column['attributes']['data-piklist-field-addmore'] = $attributes['data-piklist-field-addmore'];
            $group_add_more = true;
            if (isset($attributes['data-piklist-field-addmore-actions'])) {
                $column['attributes']['data-piklist-field-addmore-actions'] = $attributes['data-piklist-field-addmore-actions'];
            }
        }
        if (isset($column['add_more']) && $column['add_more']) {
            $column['attributes']['data-piklist-field-addmore-single'] = $attributes['data-piklist-field-addmore'];
        }
        if ($column['type'] == 'group') {
            foreach ($column['fields'] as &$_field) {
                $_field['field'] = $column['field'] . ':' . $column['index'] . ':' . $_field['field'];
            }
        }
        if (!empty($conditions)) {
            if (isset($column['conditions']) && is_array($column['conditions'])) {
                $column['conditions'] = array_merge($column['conditions'], $conditions);
                if (!isset($column['attributes']['class'])) {
                    $column['attributes']['class'] = array();
                } elseif (isset($column['attributes']['class']) && !is_array($column['attributes']['class'])) {
                    $column['attributes']['class'] = array($column['attributes']['class']);
                }
                array_push($column['attributes']['class'], 'piklist-field-condition');
            } else {
                $column['conditions'] = $conditions;
            }
        }
        piklist_form::render_field($column);
    }
}