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;
        }
    }
}
 public static function admin_page()
 {
     $page = false;
     foreach (self::$admin_pages as $admin_page) {
         if ($_REQUEST['page'] === $admin_page['menu_slug']) {
             $page = $admin_page;
             break;
         }
     }
     if ($page) {
         $setting_tabs = piklist_setting::get('setting_tabs');
         piklist::render('shared/admin-page', array('section' => $page['menu_slug'], 'icon' => isset($page['icon']) ? $page['icon'] : false, 'page_icon' => isset($page['page_icon']) ? $page['page_icon'] : (isset($page['icon']) ? $page['icon'] : null), 'single_line' => isset($page['single_line']) ? $page['single_line'] : false, 'title' => $page['page_title'], 'setting' => isset($page['setting']) ? $page['setting'] : false, 'tabs' => isset($page['setting']) && isset($setting_tabs[$page['setting']]) ? $setting_tabs[$page['setting']] : self::$admin_page_tabs[$page['menu_slug']], 'page_sections' => isset(self::$admin_page_sections[$page['menu_slug']]) ? self::$admin_page_sections[$page['menu_slug']] : array(), 'save' => isset($page['save']) ? $page['save'] : true, 'save_text' => isset($page['save_text']) ? $page['save_text'] : __('Save Changes', 'piklist'), 'page' => isset($admin_page['page']) ? $admin_page['page'] : false));
     }
 }
Пример #3
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;
        }
    }
}
Пример #4
0
<?php 
$values = array_keys($choices);
foreach ($choices as $_add_on => $_name) {
    if (piklist_add_on::$available_add_ons[$_add_on]['plugin']) {
        unset($choices[$_add_on]);
    }
}
$settings = piklist_setting::get('settings');
$values = array_keys($choices);
$attributes['style'] = 'display: none !important;';
for ($index = 0; $index < count($choices); $index++) {
    $active = !is_array($value) && $value == $values[$index] || is_array($value) && in_array($values[$index], $value);
    ?>
    
    <div class="piklist-field-add-on">  
  
      <h3>
        <?php 
    echo piklist_add_on::$available_add_ons[$values[$index]]['Name'];
    ?>
      </h3>
    
      <p>
        <?php 
    echo piklist_add_on::$available_add_ons[$values[$index]]['Description'];
    ?>
      </p>
    
      <input 
        type="checkbox"
Пример #5
0
        
        <?php 
        do_action('piklist_pre_render_settings_form');
        ?>

    <?php 
    }
    ?>
            

    <?php 
    if ($layout == 'meta-boxes') {
        ?>
      
      <?php 
        piklist_setting::do_settings_sections($setting);
        ?>
    
    <?php 
    } else {
        ?>
      
      <?php 
        do_settings_sections($setting);
        ?>
    
    <?php 
    }
    ?>
    
    <?php