Forum Replies Created

Viewing 15 posts - 241 through 255 (of 330 total)
  • Author
    Posts
  • in reply to: Kevin, Steve, how much damage am I doing? :-) #2395
    Jason
    Keymaster

    Hahah! Yeah.. I hear that. Piklist is super awesome.. but still in beta. 😉

    I think what I would do is make my own little function for handling this issue personally:

    function get_single_post_meta($id, $key) {
      $meta = get_post_meta($id, $key, true);
      return ( is_array($meta) && count($meta) == 1 ) ? $meta[0] : $meta;
    }

    That will at least save you a line of code wherever you have the issue. 🙂

    in reply to: Values don't load on conditional change #2389
    Jason
    Keymaster

    Whoops! Never noticed that. Thanks, Steve!

    in reply to: Datepicker Validation #2386
    Jason
    Keymaster

    Check this out on how to create custom validations: https://piklist.com/user-guide/

    You can also see an example of a date validation I made in my PiklistHelper class (free to use): https://gist.github.com/JasonTheAdams/4a9fc4b2ad0104ab219f (search for “check_date_range).

    What you’ll need to do is use the strtotime() function with something like strtotime(‘-2 weeks’), then compare the user date to that date.

    Hope this helps! 🙂

    in reply to: Kevin, Steve, how much damage am I doing? :-) #2381
    Jason
    Keymaster

    That’s definitely a thought. I’ve run into that one before. I’m not sure I’d agree that single should always return a single, though. Technically, it does return a single database row, it’s just serialized. Groups, for example, ought to be retrieved as a single row, but certainly aren’t a single value.

    I’ve mentioned this to Steve in the past, but I feel the proper solution would be to provide field qualifiers (implicitly, one called “multiple” is already used). This would also help build a foundation for custom fields down the road.

    Maybe I’m over-complicating, but I’d be leery to return a string every time an array had a single value (even in the circumstance that $single === true). I think it’d be better to handle this sort of thing on insertion, rather than retrieval.

    Jason
    Keymaster

    I just tested this.. and the hook name {option_page} is misleading. Don’t use the menu slug, as that doesn’t work. Use the setting. The following works:

    add_filter('piklist_post_types', 'add_program_post_type');
    function add_program_post_type( $post_types ) {
      $post_types[PROGRAM_TYPE] = array(
        'labels'          => piklist('post_type_labels', 'Program'),
        'title'           => __('Title'),
        'supports'        => array( 'title' ),
        'public'          => true,
        'has_archive'     => true,
        'rewrite'         => array( 'slug' => 'does' ),
        'capability_type' => 'post',
        'hide_meta_box'   => array( 'slug' ),
        'post_states'     => false
      );
    
      return $post_types;
    }
    
    add_filter('piklist_admin_pages', 'add_program_admin_pages');
    function add_program_admin_pages($pages) {
      $pages[] = array(
        'page_title'    => __('Archive Settings'),
        'menu_title'    => __('Archive Settings'),
        'sub_menu'      => 'edit.php?post_type=' . PROGRAM_TYPE,
        'capability'    => 'edit_others_posts',
        'menu_slug'     => 'program-archive-settings',
        'setting'       => 'program-settings'
      );
    
      return $pages;
    }
    
    add_filter('option_page_capability_program-settings', 'set_program_archive_capability');
    function set_program_archive_capability() {
      return 'edit_others_posts';
    }

    Notice that I’m using “program-settings” in the hook, not “program-archive-settings”.

    Jason
    Keymaster

    Wow, that’s one of those annoying, undocumented hooks: http://wphooks.info/filters/option_page_capability_%7B$option_page%7D/

    @Steve, it’d probably be a publicly spirited move to include information about this hook in the settings doc.

    Jason
    Keymaster

    Ah, I see what you’re saying. Well.. that does make sense. The capability provided simply determines whether or not the capability necessary for the page to show up. But it would seem like a WordPress limit that only users with “manage_options” can actually.. manage options. 🙂

    I assume Piklist is only passing that parameter along since it’s there in add_menu_page. In that context, though, you might make a page for displaying data, etc., so you’re not always saving settings. I guess the benefit here is that at least users without said capability can at least view the settings.

    Jason
    Keymaster

    The “capability” element is simply a way to limit what level of capabilities the user has to have in order to save. You can use any of the capabilities listed here: http://codex.wordpress.org/Roles_and_Capabilities

    If you don’t want “manage_options” (administrator capability) level necessary, then select a capability from a lower role. For example, “edit_other_posts” would require them to be at least an Editor.

    Hope this helps!

    in reply to: Some goodies for Piklist #2367
    Jason
    Keymaster

    I made some revisions to PiklistHelper:

    • Consolidated piklist_validation_rules hooks to a single function.
    • Added further docblock information to indicate when functions were added.
    • Added a new validation, ‘group-mismatch’ that checks every field in a group to make sure no two fields have the same value.

    Happy coding!

    Jason
    Keymaster

    I wouldn’t say it’s a limitation of the select field in Piklist, as much as in general. Outside of a fields that provides options as you search, I can’t think of a UI element that provides options while simultaneously being changeable. Sort of defeats the purpose.

    If I really want fields, in Piklist, to be definable, and they don’t come from a post type, taxonomy, etc., then I often make a “Settings” section somewhere and provide the ability to define stuff there. So, for example, I’d have a “Programs” repeatable text field. I’d then pull the options when making the meta-box and use those for the list.

    Hope this helps!

    Jason
    Keymaster

    Ah, I think I see what you’re saying. So you want the Program select to be an adjustable list of items. A combobox is what’s coming to mind: http://jsfiddle.net/ivkremer/yq2TD/

    Is that along what you’re thinking? Otherwise you can’t have a disassociated taxonomy; it has to belong to a post type. You could always create a post type that’s publicly invisible or create an admin page and have the list generated from an add_more there.

    Help me to know if I’m thinking in the right direction.

    Jason
    Keymaster

    Thanks for posting the code and picture! That helps!

    I’m still a bit unclear as to where the taxonomy fits in all this. Are you saying you want to list taxonomies into a select? or are you trying to list all the terms of a specific taxonomy into a select?

    We’ll get there! 😉

    Jason
    Keymaster

    I’m sorry, can you please try explaining that differently? I follow that you have an add_more group and want to do something with it concerning taxonomies, but that’s as much as I’m understanding. Have you tried doing what your explaining? Do you have any code (even not working) that you could show?

    in reply to: Feature Request: Plain Admin Pages #2335
    Jason
    Keymaster

    The only reason I don’t think so, is because admin-pages can’t be included as tabs of a setting.. can they?

    Jason
    Keymaster

    Ahhh.. We’re talking in the wrong direction, then. What you want to do is change where that column is getting it’s value. That’s a totally different route. Checkout what I put here:

    https://piklist.com/support/topic/can-piklist-enable-significant-customizing-of-list-tables/

    Hope this helps!

Viewing 15 posts - 241 through 255 (of 330 total)