示例#1
0
 /**
  * assets_localize
  * Add data to the local piklist variable
  *
  * @return array Current data.
  *
  * @access public
  * @static
  * @since 1.0
  */
 public static function assets_localize($localize)
 {
     $localize['shortcodes'] = array();
     foreach (self::$shortcodes as $shortcode => $data) {
         unset($data['extend'], $data['extend_method'], $data['part']);
         $localize['shortcodes'][$shortcode] = $data['data'];
     }
     $shortcodes = piklist::get_settings('piklist_core', 'shortcode_ui');
     if ($shortcodes) {
         foreach ($shortcodes as $data) {
             $shortcode = $data['tag'];
             $options = is_array($data['options']) ? $data['options'] : array($data['options']);
             $preview = in_array('preview', $options);
             if (!empty($shortcode) && isset(self::$shortcodes[$shortcode])) {
                 self::$shortcodes[$shortcode]['data']['preview'] = $preview;
                 $localize['shortcodes'][$shortcode]['preview'] = $preview;
             } else {
                 $localize['shortcodes'][$shortcode] = array('name' => piklist::humanize($shortcode), 'description' => __('Click on this box to edit the shortcode properties.', 'piklist'), 'shortcode' => $shortcode, 'icon' => 'dashicons-cloud', 'preview' => $preview);
             }
         }
     }
     return $localize;
 }
示例#2
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;
        }
    }
}
示例#3
0
文件: shortcode.php 项目: a42/piklist
     foreach ($shortcodes[$name]['render'] as $render) {
         if (strstr($render, '-form.php')) {
             array_push($forms, $render);
         }
     }
 }
 if (!empty($forms)) {
     $data = $shortcode_data;
     $data['attributes'] = $shortcode;
     $data['index'] = $index;
     foreach ($forms as $form) {
         piklist::render($form, array('shortcode' => $data));
     }
 } elseif ($shortcode) {
     foreach ($shortcode as $attribute => $value) {
         piklist('field', array('type' => 'text', 'scope' => 'shortcode', 'field' => $attribute, 'label' => piklist::humanize($attribute), 'attributes' => array('class' => 'large-text')));
     }
 }
 piklist('field', array('type' => 'hidden', 'scope' => 'shortcode', 'field' => '_index', 'value' => $index));
 foreach ($shortcode_data as $attribute => $value) {
     switch ($attribute) {
         case 'content':
             piklist('field', array('type' => 'editor', 'scope' => 'shortcode_data', 'field' => $attribute, 'label' => __('Shortcode Content', 'piklist'), 'description' => __('This is the content that the shortcode is wrapped around.', 'piklist'), 'options' => array('shortcode_buttons' => true)));
             break;
         default:
             piklist('field', array('type' => 'hidden', 'scope' => 'shortcode_data', 'field' => $attribute));
             break;
     }
 }
 ?>