Beispiel #1
0
$title_editable = pods_var($form_field_type . '_edit_title', $options, 0);
if ('images' == $limit_file_type) {
    $limit_types = 'jpg,jpeg,png,gif';
} elseif ('video' == $limit_file_type) {
    $limit_types = 'mpg,mov,flv,mp4';
} elseif ('audio' == $limit_file_type) {
    $limit_types = 'mp3,m4a,wav,wma';
} elseif ('text' == $limit_file_type) {
    $limit_types = 'txt,rtx,csv,tsv';
} elseif ('any' == $limit_file_type) {
    $limit_types = '';
} else {
    $limit_types = pods_var($form_field_type . '_allowed_extensions', $options, '', null, true);
}
$limit_types = trim(str_replace(array(' ', '.', "\n", "\t", ';'), array('', ',', ',', ','), $limit_types), ',');
if (pods_version_check('wp', '3.5')) {
    $mime_types = wp_get_mime_types();
    if (in_array($limit_file_type, array('images', 'audio', 'video'))) {
        $new_limit_types = array();
        foreach ($mime_types as $type => $mime) {
            if (0 === strpos($mime, $limit_file_type)) {
                $type = explode('|', $type);
                $new_limit_types = array_merge($new_limit_types, $type);
            }
        }
        if (!empty($new_limit_types)) {
            $limit_types = implode(',', $new_limit_types);
        }
    } elseif ('any' != $limit_file_type) {
        $new_limit_types = array();
        $limit_types = explode(',', $limit_types);
Beispiel #2
0
/**
 * Check if Pods is compatible with WP / PHP / MySQL or not
 *
 * @return bool
 *
 * @since 1.10
 */
function pods_compatibility_check()
{
    $compatible = true;
    if (!pods_version_check('wp', PODS_WP_VERSION_MINIMUM)) {
        $compatible = false;
        add_action('admin_notices', 'pods_version_notice_wp');
    }
    if (!pods_version_check('php', PODS_PHP_VERSION_MINIMUM)) {
        $compatible = false;
        add_action('admin_notices', 'pods_version_notice_php');
    }
    if (!pods_version_check('mysql', PODS_MYSQL_VERSION_MINIMUM)) {
        $compatible = false;
        add_action('admin_notices', 'pods_version_notice_mysql');
    }
    return $compatible;
}
Beispiel #3
0
 /**
  * Add a meta group of fields to add/edit forms
  *
  * @param string|array $pod The pod or type of element to attach the group to.
  * @param string $label Title of the edit screen section, visible to user.
  * @param string|array $fields Either a comma separated list of text fields or an associative array containing field infomration.
  * @param string $context (optional) The part of the page where the edit screen section should be shown ('normal', 'advanced', or 'side').
  * @param string $priority (optional) The priority within the context where the boxes should show ('high', 'core', 'default' or 'low').
  *
  * @since 2.0
  *
  * @return mixed|void
  */
 public function group_add($pod, $label, $fields, $context = 'normal', $priority = 'default')
 {
     if (!is_array($pod)) {
         $_pod = pods_api()->load_pod(array('name' => $pod), false);
         if (!empty($_pod)) {
             $pod = $_pod;
         } else {
             $type = 'post_type';
             if (in_array($pod, array('media', 'user', 'comment'))) {
                 $type = $pod;
             }
             $pod = array('name' => $pod, 'type' => $type);
         }
     }
     if (is_array($pod) && !isset($pod['id'])) {
         $defaults = array('name' => '', 'type' => 'post_type');
         $pod = array_merge($defaults, $pod);
     }
     if ('post' == $pod['type']) {
         $pod['type'] = 'post_type';
     }
     if (empty($pod['name']) && isset($pod['object']) && !empty($pod['object'])) {
         $pod['name'] = $pod['object'];
     } elseif (!isset($pod['object']) || empty($pod['object'])) {
         $pod['object'] = $pod['name'];
     }
     if (empty($pod['object'])) {
         return pods_error(__('Object required to add a Pods meta group', 'pods'));
     }
     $object_name = $pod['object'];
     if ('pod' == $pod['type']) {
         $object_name = $pod['name'];
     }
     if (!isset(self::$groups[$pod['type']])) {
         self::$groups[$pod['type']] = array();
     }
     if (!isset(self::$groups[$pod['type']][$object_name])) {
         self::$groups[$pod['type']][$object_name] = array();
     }
     $_fields = array();
     if (!is_array($fields)) {
         $fields = explode(',', $fields);
     }
     foreach ($fields as $k => $field) {
         $name = $k;
         $defaults = array('name' => $name, 'label' => $name, 'type' => 'text');
         if (!is_array($field)) {
             $name = trim($field);
             $field = array('name' => $name, 'label' => $name);
         }
         $field = array_merge($defaults, $field);
         $field['name'] = trim($field['name']);
         if (isset($pod['fields']) && isset($pod['fields'][$field['name']])) {
             $field = array_merge($field, $pod['fields'][$field['name']]);
         }
         $_fields[$k] = $field;
     }
     // Setup field options
     $fields = PodsForm::fields_setup($_fields);
     $group = array('pod' => $pod, 'label' => $label, 'fields' => $fields, 'context' => $context, 'priority' => $priority);
     // Filter group data, pass vars separately for reference down the line (in case array changed by other filter)
     $group = apply_filters('pods_meta_group_add_' . $pod['type'] . '_' . $object_name, $group, $pod, $label, $fields);
     $group = apply_filters('pods_meta_group_add_' . $pod['type'], $group, $pod, $label, $fields);
     $group = apply_filters('pods_meta_group_add', $group, $pod, $label, $fields);
     self::$groups[$pod['type']][$object_name][] = $group;
     // Hook it up!
     if ('post_type' == $pod['type']) {
         if (!has_action('add_meta_boxes', array($this, 'meta_post_add'))) {
             add_action('add_meta_boxes', array($this, 'meta_post_add'));
         }
         /*if ( !has_action( 'save_post', array( $this, 'save_post' ), 10, 2 ) )
           add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );*/
     } elseif ('taxonomy' == $pod['type']) {
         if (!has_action($pod['object'] . '_edit_form_fields', array($this, 'meta_taxonomy'), 10, 2)) {
             add_action($pod['object'] . '_edit_form_fields', array($this, 'meta_taxonomy'), 10, 2);
             add_action($pod['object'] . '_add_form_fields', array($this, 'meta_taxonomy'), 10, 1);
         }
         if (!has_action('edit_term', array($this, 'save_taxonomy'), 10, 3)) {
             add_action('edit_term', array($this, 'save_taxonomy'), 10, 3);
             add_action('create_term', array($this, 'save_taxonomy'), 10, 3);
         }
     } elseif ('media' == $pod['type']) {
         if (!has_filter('wp_update_attachment_metadata', array($this, 'save_media'), 10, 2)) {
             if (pods_version_check('wp', '3.5')) {
                 add_action('add_meta_boxes', array($this, 'meta_post_add'));
                 add_action('wp_ajax_save-attachment-compat', array($this, 'save_media_ajax'), 0);
             }
             add_filter('attachment_fields_to_edit', array($this, 'meta_media'), 10, 2);
             add_filter('attachment_fields_to_save', array($this, 'save_media'), 10, 2);
             add_filter('wp_update_attachment_metadata', array($this, 'save_media'), 10, 2);
         }
     } elseif ('user' == $pod['type']) {
         if (!has_action('show_user_profile', array($this, 'meta_user'))) {
             add_action('show_user_profile', array($this, 'meta_user'));
             add_action('edit_user_profile', array($this, 'meta_user'));
             add_action('personal_options_update', array($this, 'save_user'));
             add_action('edit_user_profile_update', array($this, 'save_user'));
         }
     } elseif ('comment' == $pod['type']) {
         if (!has_action('comment_form_logged_in_after', array($this, 'meta_comment_new_logged_in'), 10, 2)) {
             add_action('comment_form_logged_in_after', array($this, 'meta_comment_new_logged_in'), 10, 2);
             add_filter('comment_form_default_fields', array($this, 'meta_comment_new'));
             add_action('add_meta_boxes_comment', array($this, 'meta_comment_add'));
             add_action('wp_insert_comment', array($this, 'save_comment'));
             add_action('edit_comment', array($this, 'save_comment'));
         }
     }
 }
Beispiel #4
0
 /**
  * Get list of Pod options
  *
  * @return array
  */
 public function admin_setup_edit_options($pod)
 {
     $options = array();
     // @todo fill this in
     $options['labels'] = array('temporary' => 'This has the fields hardcoded');
     if ('post_type' == $pod['type']) {
         $options['admin-ui'] = array('description' => array('label' => __('Post Type Description', 'pods'), 'help' => __('A short descriptive summary of what the post type is.', 'pods'), 'type' => 'text', 'default' => ''), 'show_ui' => array('label' => __('Show Admin UI', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'show_in_menu' => array('label' => __('Show Admin Menu in Dashboard', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'dependency' => true, 'boolean_yes_label' => ''), 'menu_location_custom' => array('label' => __('Parent Menu ID (optional)', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('show_in_menu' => true)), 'menu_name' => array('label' => __('Menu Name', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_in_menu' => true)), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('show_in_menu' => true)), 'menu_icon' => array('label' => __('Menu Icon', 'pods'), 'help' => __('URL or Dashicon name for the menu icon. You may specify the path to the icon using one of the <a href="http://pods.io/docs/build/special-magic-tags/#site-tags" target="_blank">site tag</a> type <a href="http://pods.io/docs/build/special-magic-tags/" target="_blank">special magic tags</a>. For example, for a file in your theme directory, use "{@template-url}/path/to/image.png". You may also use the name of a <a href="http://melchoyce.github.io/dashicons/" target="_blank">Dashicon</a>. For example, to use the empty star icon, use "dashicons-star-empty".', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_in_menu' => true)), 'show_in_nav_menus' => array('label' => __('Show in Navigation Menus', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'show_in_admin_bar' => array('label' => __('Show in Admin Bar "New" Menu', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''));
         $options['advanced'] = array('public' => array('label' => __('Public', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'publicly_queryable' => array('label' => __('Publicly Queryable', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'exclude_from_search' => array('label' => __('Exclude from Search', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => !pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'capability_type' => array('label' => __('User Capability', 'pods'), 'help' => __('Uses these capabilties for access to this post type: edit_{capability}, read_{capability}, and delete_{capability}', 'pods'), 'type' => 'pick', 'default' => 'post', 'data' => array('post' => 'post', 'page' => 'page', 'custom' => __('Custom Capability', 'pods')), 'dependency' => true), 'capability_type_custom' => array('label' => __('Custom User Capability', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => pods_var_raw('name', $pod), 'depends-on' => array('capability_type' => 'custom')), 'capability_type_extra' => array('label' => __('Additional User Capabilities', 'pods'), 'help' => __('Enables additional capabilities for this Post Type including: delete_{capability}s, delete_private_{capability}s, delete_published_{capability}s, delete_others_{capability}s, edit_private_{capability}s, and edit_published_{capability}s', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'has_archive' => array('label' => __('Enable Archive Page', 'pods'), 'help' => __('If enabled, creates an archive page with list of of items in this custom post type. Functions like a category page for posts. Can be controlled with a template in your theme called "archive-{$post-type}.php".', 'pods'), 'type' => 'boolean', 'default' => false, 'dependency' => true, 'boolean_yes_label' => ''), 'has_archive_slug' => array('label' => __('Archive Page Slug Override', 'pods'), 'help' => __('If archive page is enabled, you can override the slug used by WordPress, which defaults to the name of the post type.', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('has_archive' => true)), 'hierarchical' => array('label' => __('Hierarchical', 'pods'), 'help' => __('Allows for parent/ child relationships between items, just like with Pages. Note: To edit relationships in the post editor, you must enable "Page Attributes" in the "Supports" section below.', 'pods'), 'type' => 'boolean', 'default' => false, 'dependency' => true, 'boolean_yes_label' => ''), 'label_parent_item_colon' => array('label' => __('<strong>Label: </strong> Parent <span class="pods-slugged" data-sluggable="label_singular">Item</span>', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('hierarchical' => true)), 'label_parent' => array('label' => __('<strong>Label: </strong> Parent', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('hierarchical' => true)), 'rewrite' => array('label' => __('Rewrite', 'pods'), 'help' => __('Allows you to use pretty permalinks, if set in WordPress Settings->Reading. If not enbabled, your links will be in the form of "example.com/?pod_name=post_slug" regardless of your permalink settings.', 'pods'), 'type' => 'boolean', 'default' => true, 'dependency' => true, 'boolean_yes_label' => ''), 'rewrite_custom_slug' => array('label' => __('Custom Rewrite Slug', 'pods'), 'help' => __('Changes the first segment of the URL, which by default is the name of the Pod. For example, if your Pod is called "foo", if this field is left blank, your link will be "example.com/foo/post_slug", but if you were to enter "bar" your link will be "example.com/bar/post_slug".', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('rewrite' => true)), 'rewrite_with_front' => array('label' => __('Rewrite with Front', 'pods'), 'help' => __('Allows permalinks to be prepended with your front base (example: if your permalink structure is /blog/, then your links will be: Unchecked->/news/, Checked->/blog/news/)', 'pods'), 'type' => 'boolean', 'default' => true, 'depends-on' => array('rewrite' => true), 'boolean_yes_label' => ''), 'rewrite_feeds' => array('label' => __('Rewrite Feeds', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => false, 'depends-on' => array('rewrite' => true), 'boolean_yes_label' => ''), 'rewrite_pages' => array('label' => __('Rewrite Pages', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'depends-on' => array('rewrite' => true), 'boolean_yes_label' => ''), 'query_var' => array('label' => __('Query Var', 'pods'), 'help' => __('The Query Var is used in the URL and underneath the WordPress Rewrite API to tell WordPress what page or post type you are on. For a list of reserved Query Vars, read <a href="http://codex.wordpress.org/WordPress_Query_Vars">WordPress Query Vars</a> from the WordPress Codex.', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'can_export' => array('label' => __('Exportable', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'default_status' => array('label' => __('Default Status', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'pick_object' => 'post-status', 'default' => apply_filters('pods_api_default_status_' . pods_var_raw('name', $pod, 'post_type', null, true), 'draft', $pod)));
     } elseif ('taxonomy' == $pod['type']) {
         $options['admin-ui'] = array('show_ui' => array('label' => __('Show Admin UI', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'dependency' => true, 'boolean_yes_label' => ''), 'menu_name' => array('label' => __('Menu Name', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_ui' => true)), 'menu_location' => array('label' => __('Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'default', 'depends-on' => array('show_ui' => true), 'data' => array('default' => __('Default - Add to associated Post Type(s) menus', 'pods'), 'settings' => __('Add to Settings menu', 'pods'), 'appearances' => __('Add to Appearances menu', 'pods'), 'objects' => __('Make a top-level menu item', 'pods'), 'top' => __('Make a new top-level menu item below Settings', 'pods'), 'submenu' => __('Add a submenu item to another menu', 'pods')), 'dependency' => true), 'menu_location_custom' => array('label' => __('Custom Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('menu_location' => 'submenu')), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('menu_location' => array('objects', 'top'))), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('menu_location' => array('objects', 'top'))), 'show_in_nav_menus' => array('label' => __('Show in Navigation Menus', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'show_tagcloud' => array('label' => __('Allow in Tagcloud Widget', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('show_ui', $pod, pods_var_raw('public', $pod, true)), 'boolean_yes_label' => ''));
         if (pods_version_check('wp', '3.5')) {
             $options['admin-ui']['show_admin_column'] = array('label' => __('Show Taxonomy column on Post Types', 'pods'), 'help' => __('Whether to add a column for this taxonomy on the associated post types manage screens', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '');
         }
         // Integration for Single Value Taxonomy UI
         if (function_exists('tax_single_value_meta_box')) {
             $options['admin-ui']['single_value'] = array('label' => __('Single Value Taxonomy', 'pods'), 'help' => __('Use a drop-down for the input instead of the WordPress default', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '');
             $options['admin-ui']['single_value_required'] = array('label' => __('Single Value Taxonomy - Required', 'pods'), 'help' => __('A term will be selected by default in the Post Editor, not optional', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '');
         }
         // @todo fill this in
         $options['advanced'] = array('temporary' => 'This type has the fields hardcoded');
     } elseif ('settings' == $pod['type']) {
         $options['admin-ui'] = array('ui_style' => array('label' => __('Admin UI Style', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'settings', 'data' => array('settings' => __('Normal Settings Form', 'pods'), 'post_type' => __('Post Type UI', 'pods'), 'custom' => __('Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods')), 'dependency' => true), 'menu_location' => array('label' => __('Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'settings', 'data' => array('settings' => __('Add to Settings menu', 'pods'), 'appearances' => __('Add to Appearances menu', 'pods'), 'top' => __('Make a new top-level menu item below Settings', 'pods'), 'submenu' => __('Add a submenu item to another menu', 'pods')), 'dependency' => true), 'menu_location_custom' => array('label' => __('Custom Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('menu_location' => 'submenu')), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('menu_location' => 'top')), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('menu_location' => 'top')));
         // @todo fill this in
         $options['advanced'] = array('temporary' => 'This type has the fields hardcoded');
     } elseif ('pod' == $pod['type']) {
         $options['admin-ui'] = array('ui_style' => array('label' => __('Admin UI Style', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'settings', 'data' => array('post_type' => __('Normal (Looks like the Post Type UI)', 'pods'), 'custom' => __('Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods')), 'dependency' => true), 'show_in_menu' => array('label' => __('Show Admin Menu in Dashboard', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '', 'dependency' => true), 'menu_location_custom' => array('label' => __('Parent Menu ID (optional)', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('show_in_menu' => true)), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('show_in_menu' => true)), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('This is the icon shown to the left of the menu text for this content type.', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_in_menu' => true)), 'ui_icon' => array('label' => __('Header Icon', 'pods'), 'help' => __('This is the icon shown to the left of the heading text at the top of the manage pages for this content type.', 'pods'), 'type' => 'file', 'default' => '', 'file_edit_title' => 0, 'depends-on' => array('show_in_menu' => true)), 'ui_actions_enabled' => array('label' => __('Actions Available', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 1 == pods_var('ui_export', $pod) ? array('add', 'edit', 'duplicate', 'delete', 'export') : array('add', 'edit', 'duplicate', 'delete'), 'data' => array('add' => __('Add New', 'pods'), 'edit' => __('Edit', 'pods'), 'duplicate' => __('Duplicate', 'pods'), 'delete' => __('Delete', 'pods'), 'reorder' => __('Reorder', 'pods'), 'export' => __('Export', 'pods')), 'pick_format_type' => 'multi', 'dependency' => true), 'ui_reorder_field' => array('label' => __('Reorder Field', 'pods'), 'help' => __('This is the field that will be reordered on, it should be numeric.', 'pods'), 'type' => 'text', 'default' => 'menu_order', 'depends-on' => array('ui_actions_enabled' => 'reorder')), 'ui_fields_manage' => array('label' => __('Admin Table Columns', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => array(), 'data' => array(), 'pick_format_type' => 'multi'), 'ui_filters' => array('label' => __('Search Filters', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => array(), 'data' => array(), 'pick_format_type' => 'multi'));
         if (!empty($pod['fields'])) {
             if (isset($pod['fields'][pods_var_raw('pod_index', $pod, 'name')])) {
                 $options['admin-ui']['ui_fields_manage']['default'][] = pods_var_raw('pod_index', $pod, 'name');
             }
             if (isset($pod['fields']['modified'])) {
                 $options['admin-ui']['ui_fields_manage']['default'][] = 'modified';
             }
             foreach ($pod['fields'] as $field) {
                 $type = '';
                 if (isset($field_types[$field['type']])) {
                     $type = ' <small>(' . $field_types[$field['type']]['label'] . ')</small>';
                 }
                 $options['admin-ui']['ui_fields_manage']['data'][$field['name']] = $field['label'] . $type;
                 $options['admin-ui']['ui_filters']['data'][$field['name']] = $field['label'] . $type;
             }
             $options['admin-ui']['ui_fields_manage']['data']['id'] = 'ID';
         } else {
             unset($options['admin-ui']['ui_fields_manage']);
             unset($options['admin-ui']['ui_filters']);
         }
         // @todo fill this in
         $options['advanced'] = array('temporary' => 'This type has the fields hardcoded');
     }
     /**
      * Add admin fields to the Pods editor for a specific Pod
      *
      * @params array $options The Options fields
      * @params object $pod Current Pods object
      *
      * @since unkown
      */
     $options = apply_filters('pods_admin_setup_edit_options_' . $pod['type'] . '_' . $pod['name'], $options, $pod);
     /**
      * Add admin fields to the Pods editor for any Pod of a specific content type.
      */
     $options = apply_filters('pods_admin_setup_edit_options_' . $pod['type'], $options, $pod);
     /**
      * Add admin fields to the Pods editor for all Pods
      */
     $options = apply_filters('pods_admin_setup_edit_options', $options, $pod);
     return $options;
 }
/**
 * Set a variable
 *
 * @param mixed $value The value to be set
 * @param mixed $var The variable name, or URI segment position / query var name (if $type is 'url')
 * @param string|array|object $type (optional) Super globals, url/url-relative, constants, globals, user data, Pod field values
 *
 * @return mixed Updated URL (if $type is 'url'), $value (if $type is 'constant'), Item ID (if $type is 'pods'), $type, or false if not set
 * @since 2.3.10
 */
function pods_v_set($value, $var, $type = 'get')
{
    $ret = false;
    if (null === $var || '' === $var) {
        // Invalid $var
    } elseif (null === $type || '' === $type) {
        // Invalid $type
    } elseif (is_array($type)) {
        $type[$var] = $value;
        $ret = $type;
    } elseif (is_object($type)) {
        $type->{$var} = $value;
        $ret = $type;
    } else {
        $type = strtolower($type);
        if ('get' == $type) {
            $_GET[$var] = $value;
            $ret = $_GET;
        } elseif ('post' == $type) {
            $_POST[$var] = $value;
            $ret = $_POST;
        } elseif ('request' == $type) {
            $_REQUEST[$var] = $value;
            $ret = $_REQUEST;
        } elseif ('url' == $type) {
            if (is_numeric($var) && function_exists('http_build_url')) {
                $url = parse_url(pods_current_url());
                $uri = trim($url['path'], '/');
                $uri = array_filter(explode('/', $uri));
                if ('first' == $var) {
                    $var = 0;
                } elseif ('last' == $var) {
                    $var = -1;
                }
                if ($var < 0) {
                    $uri[count($uri) + $var] = $value;
                } else {
                    $uri[$var] = $value;
                }
                $url['path'] = '/' . implode('/', $uri) . '/';
                $url['path'] = trim($url['path'], '/');
                $ret = http_build_url($url);
            } else {
                $ret = add_query_arg(array($var => $value));
            }
        } elseif ('server' == $type) {
            $_SERVER[$var] = $value;
            $ret = $_SERVER;
        } elseif (in_array($type, array('global', 'globals'))) {
            $GLOBALS[$var] = $value;
            $ret = $GLOBALS;
        } elseif ('session' == $type) {
            // Session start
            pods_session_start();
            $_SESSION[$var] = $value;
            $ret = $_SESSION;
        } elseif ('cookie' == $type && !headers_sent()) {
            setcookie($var, $value, time() + 10 * DAY_IN_SECONDS, COOKIEPATH);
            $ret = $_COOKIE;
        } elseif ('constant' == $type && !defined($var) && (is_scalar($value) || null === $value)) {
            define($var, $value);
            $ret = constant($var);
        } elseif ('user' == $type && is_user_logged_in()) {
            $user = get_userdata(get_current_user_id());
            if (!pods_version_check('wp', '3.5')) {
                $user_data = get_object_vars($user->data);
            } else {
                $user_data = $user->to_array();
            }
            // Role
            if ('role' == $var) {
                $user->set_role($value);
            } elseif (isset($user_data[$var])) {
                wp_update_user(array('ID' => $user->ID, $var => $value));
            } else {
                update_user_meta($user->ID, $var, $value);
            }
            $ret = get_userdata($user->ID);
        } elseif ('pods' == $type) {
            /**
             * @var $pods Pods
             */
            global $pods;
            if (is_object($pods) && 'Pods' == get_class($pods) && $pods->exists()) {
                $ret = $pods->save($var, $value);
            }
        } else {
            $ret = apply_filters('pods_var_set_' . $type, $value, $var);
        }
    }
    return $ret;
}
Beispiel #6
0
 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (is_array($value)) {
         $value = implode(' ', $value);
     }
     // Farbtastic for below 3.5
     if (pods_version_check('wp', '3.5', '>')) {
         pods_view(PODS_DIR . 'ui/fields/farbtastic.php', compact(array_keys(get_defined_vars())));
     } else {
         pods_view(PODS_DIR . 'ui/fields/color.php', compact(array_keys(get_defined_vars())));
     }
 }
Beispiel #7
0
 /**
  * Handle plupload AJAX
  *
  * @since 2.3
  */
 public function admin_ajax_upload()
 {
     if (false === headers_sent()) {
         if ('' == session_id()) {
             @session_start();
         }
     }
     // Sanitize input
     $params = stripslashes_deep((array) $_POST);
     foreach ($params as $key => $value) {
         if ('action' == $key) {
             continue;
         }
         unset($params[$key]);
         $params[str_replace('_podsfix_', '', $key)] = $value;
     }
     $params = (object) $params;
     $methods = array('upload');
     if (!isset($params->method) || !in_array($params->method, $methods) || !isset($params->pod) || !isset($params->field) || !isset($params->uri) || empty($params->uri)) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     } elseif (!empty($params->pod) && empty($params->field)) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     } elseif (empty($params->pod) && !current_user_can('upload_files')) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     }
     // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
     if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
         $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
     } elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
         $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
     }
     if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) {
         $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
     }
     global $current_user;
     unset($current_user);
     /**
      * Access Checking
      */
     $upload_disabled = false;
     if (defined('PODS_DISABLE_FILE_UPLOAD') && true === PODS_DISABLE_FILE_UPLOAD) {
         $upload_disabled = true;
     } elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && true === PODS_UPLOAD_REQUIRE_LOGIN && !is_user_logged_in()) {
         $upload_disabled = true;
     } elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && !is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && (!is_user_logged_in() || !current_user_can(PODS_UPLOAD_REQUIRE_LOGIN))) {
         $upload_disabled = true;
     }
     $uid = @session_id();
     if (is_user_logged_in()) {
         $uid = 'user_' . get_current_user_id();
     }
     $nonce_check = 'pods_upload_' . (int) $params->pod . '_' . $uid . '_' . $params->uri . '_' . (int) $params->field;
     if (true === $upload_disabled || !isset($params->_wpnonce) || false === wp_verify_nonce($params->_wpnonce, $nonce_check)) {
         pods_error(__('Unauthorized request', 'pods'), PodsInit::$admin);
     }
     $pod = array();
     $field = array('type' => 'file', 'options' => array());
     $api = pods_api();
     if (!empty($params->pod)) {
         $pod = $api->load_pod(array('id' => (int) $params->pod));
         $field = $api->load_field(array('id' => (int) $params->field));
         if (empty($pod) || empty($field) || $pod['id'] != $field['pod_id'] || !isset($pod['fields'][$field['name']])) {
             pods_error(__('Invalid field request', 'pods'), PodsInit::$admin);
         }
         if (!in_array($field['type'], PodsForm::file_field_types())) {
             pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
         }
     }
     $method = $params->method;
     // Cleaning up $params
     unset($params->action);
     unset($params->method);
     unset($params->_wpnonce);
     $params->post_id = pods_var('post_id', $params, 0, null, true);
     /**
      * Upload a new file (advanced - returns URL and ID)
      */
     if ('upload' == $method) {
         $file = $_FILES['Filedata'];
         $limit_size = pods_var($field['type'] . '_restrict_filesize', $field['options']);
         if (!empty($limit_size)) {
             if (false !== stripos($limit_size, 'MB')) {
                 $limit_size = (double) trim(str_ireplace('MB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025;
                 // convert to KB to B
             } elseif (false !== stripos($limit_size, 'KB')) {
                 $limit_size = (double) trim(str_ireplace('KB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025;
                 // convert to B
             } elseif (false !== stripos($limit_size, 'GB')) {
                 $limit_size = (double) trim(str_ireplace('GB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025 * 1025;
                 // convert to MB to KB to B
             } elseif (false !== stripos($limit_size, 'B')) {
                 $limit_size = (double) trim(str_ireplace('B', '', $limit_size));
             } else {
                 $limit_size = wp_max_upload_size();
             }
             if (0 < $limit_size && $limit_size < $file['size']) {
                 $error = __('File size too large, max size is %s', 'pods');
                 $error = sprintf($error, pods_var($field['type'] . '_restrict_filesize', $field['options']));
                 pods_error('<div style="color:#FF0000">Error: ' . $error . '</div>');
             }
         }
         $limit_file_type = pods_var($field['type'] . '_type', $field['options'], 'images');
         if ('images' == $limit_file_type) {
             $limit_types = 'jpg,png,gif';
         } elseif ('video' == $limit_file_type) {
             $limit_types = 'mpg,mov,flv,mp4';
         } elseif ('audio' == $limit_file_type) {
             $limit_types = 'mp3,m4a,wav,wma';
         } elseif ('text' == $limit_file_type) {
             $limit_types = 'txt,rtx,csv,tsv';
         } elseif ('any' == $limit_file_type) {
             $limit_types = '';
         } else {
             $limit_types = pods_var($field['type'] . '_allowed_extensions', $field['options'], '', null, true);
         }
         $limit_types = trim(str_replace(array(' ', '.', "\n", "\t", ';'), array('', ',', ',', ','), $limit_types), ',');
         if (pods_version_check('wp', '3.5')) {
             $mime_types = wp_get_mime_types();
             if (in_array($limit_file_type, array('images', 'audio', 'video'))) {
                 $new_limit_types = array();
                 foreach ($mime_types as $type => $mime) {
                     if (0 === strpos($mime, $limit_file_type)) {
                         $type = explode('|', $type);
                         $new_limit_types = array_merge($new_limit_types, $type);
                     }
                 }
                 if (!empty($new_limit_types)) {
                     $limit_types = implode(',', $new_limit_types);
                 }
             } elseif ('any' != $limit_file_type) {
                 $new_limit_types = array();
                 $limit_types = explode(',', $limit_types);
                 foreach ($limit_types as $k => $limit_type) {
                     $found = false;
                     foreach ($mime_types as $type => $mime) {
                         if (0 === strpos($mime, $limit_type)) {
                             $type = explode('|', $type);
                             foreach ($type as $t) {
                                 if (!in_array($t, $new_limit_types)) {
                                     $new_limit_types[] = $t;
                                 }
                             }
                             $found = true;
                         }
                     }
                     if (!$found) {
                         $new_limit_types[] = $limit_type;
                     }
                 }
                 if (!empty($new_limit_types)) {
                     $limit_types = implode(',', $new_limit_types);
                 }
             }
         }
         $limit_types = explode(',', $limit_types);
         $limit_types = array_filter(array_unique($limit_types));
         if (!empty($limit_types)) {
             $ok = false;
             foreach ($limit_types as $limit_type) {
                 $limit_type = '.' . trim($limit_type, ' .');
                 $pos = strlen($file['name']) - strlen($limit_type);
                 if ($pos === stripos($file['name'], $limit_type)) {
                     $ok = true;
                     break;
                 }
             }
             if (false === $ok) {
                 $error = __('File type not allowed, please use one of the following: %s', 'pods');
                 $error = sprintf($error, '.' . implode(', .', $limit_types));
                 pods_error('<div style="color:#FF0000">Error: ' . $error . '</div>');
             }
         }
         $custom_handler = apply_filters('pods_upload_handle', null, 'Filedata', $params->post_id, $params);
         if (null === $custom_handler) {
             $attachment_id = media_handle_upload('Filedata', $params->post_id);
             if (is_object($attachment_id)) {
                 $errors = array();
                 foreach ($attachment_id->errors['upload_error'] as $error_code => $error_message) {
                     $errors[] = '[' . $error_code . '] ' . $error_message;
                 }
                 pods_error('<div style="color:#FF0000">Error: ' . implode('</div><div>', $errors) . '</div>');
             } else {
                 $attachment = get_post($attachment_id, ARRAY_A);
                 $attachment['filename'] = basename($attachment['guid']);
                 $thumb = wp_get_attachment_image_src($attachment['ID'], 'thumbnail', true);
                 $attachment['thumbnail'] = $thumb[0];
                 $attachment = apply_filters('pods_upload_attachment', $attachment, $params->post_id);
                 wp_send_json($attachment);
             }
         }
     }
     die;
     // KBAI!
 }
Beispiel #8
0
 /**
  * Register Post Types and Taxonomies
  */
 public function setup_content_types($force = false)
 {
     $post_types = PodsMeta::$post_types;
     $taxonomies = PodsMeta::$taxonomies;
     $existing_post_types = get_post_types();
     $existing_taxonomies = get_taxonomies();
     $pods_cpt_ct = pods_transient_get('pods_wp_cpt_ct');
     $cpt_positions = array();
     if (empty($pods_cpt_ct) && (!empty($post_types) || !empty($taxonomies))) {
         $force = true;
     } elseif (!empty($pods_cpt_ct) && empty($pods_cpt_ct['post_types']) && !empty($post_types)) {
         $force = true;
     } elseif (!empty($pods_cpt_ct) && empty($pods_cpt_ct['taxonomies']) && !empty($taxonomies)) {
         $force = true;
     }
     if (false === $pods_cpt_ct || $force) {
         $pods_cpt_ct = array('post_types' => array(), 'taxonomies' => array());
         $pods_post_types = $pods_taxonomies = array();
         $supported_post_types = $supported_taxonomies = array();
         foreach ($post_types as $post_type) {
             // Post Type exists already
             if (isset($pods_cpt_ct['post_types'][$post_type['name']])) {
                 continue;
             } elseif (!empty($post_type['object']) && isset($existing_post_types[$post_type['object']])) {
                 continue;
             } elseif (!$force && isset($existing_post_types[$post_type['name']])) {
                 continue;
             }
             $post_type['options']['name'] = $post_type['name'];
             $post_type = array_merge($post_type, (array) $post_type['options']);
             // Labels
             $cpt_label = esc_html(pods_var_raw('label', $post_type, ucwords(str_replace('_', ' ', pods_var_raw('name', $post_type))), null, true));
             $cpt_singular = esc_html(pods_var_raw('label_singular', $post_type, ucwords(str_replace('_', ' ', pods_var_raw('label', $post_type, pods_var('name', $post_type), null, true))), null, true));
             $cpt_labels = array();
             $cpt_labels['name'] = $cpt_label;
             $cpt_labels['singular_name'] = $cpt_singular;
             $cpt_labels['menu_name'] = pods_var_raw('menu_name', $post_type, '', null, true);
             $cpt_labels['add_new'] = pods_var_raw('label_add_new', $post_type, '', null, true);
             $cpt_labels['add_new_item'] = pods_var_raw('label_add_new_item', $post_type, '', null, true);
             $cpt_labels['new_item'] = pods_var_raw('label_new_item', $post_type, '', null, true);
             $cpt_labels['edit'] = pods_var_raw('label_edit', $post_type, '', null, true);
             $cpt_labels['edit_item'] = pods_var_raw('label_edit_item', $post_type, '', null, true);
             $cpt_labels['view'] = pods_var_raw('label_view', $post_type, '', null, true);
             $cpt_labels['view_item'] = pods_var_raw('label_view_item', $post_type, '', null, true);
             $cpt_labels['all_items'] = pods_var_raw('label_all_items', $post_type, '', null, true);
             $cpt_labels['search_items'] = pods_var_raw('label_search_items', $post_type, '', null, true);
             $cpt_labels['not_found'] = pods_var_raw('label_not_found', $post_type, '', null, true);
             $cpt_labels['not_found_in_trash'] = pods_var_raw('label_not_found_in_trash', $post_type, '', null, true);
             $cpt_labels['parent'] = pods_var_raw('label_parent', $post_type, '', null, true);
             $cpt_labels['parent_item_colon'] = pods_var_raw('label_parent_item_colon', $post_type, '', null, true);
             // Supported
             $cpt_supported = array('title' => (bool) pods_var('supports_title', $post_type, false), 'editor' => (bool) pods_var('supports_editor', $post_type, false), 'author' => (bool) pods_var('supports_author', $post_type, false), 'thumbnail' => (bool) pods_var('supports_thumbnail', $post_type, false), 'excerpt' => (bool) pods_var('supports_excerpt', $post_type, false), 'trackbacks' => (bool) pods_var('supports_trackbacks', $post_type, false), 'custom-fields' => (bool) pods_var('supports_custom_fields', $post_type, false), 'comments' => (bool) pods_var('supports_comments', $post_type, false), 'revisions' => (bool) pods_var('supports_revisions', $post_type, false), 'page-attributes' => (bool) pods_var('supports_page_attributes', $post_type, false), 'post-formats' => (bool) pods_var('supports_post_formats', $post_type, false));
             // Custom Supported
             $cpt_supported_custom = pods_var('supports_custom', $post_type, '');
             if (!empty($cpt_supported_custom)) {
                 $cpt_supported_custom = explode(',', $cpt_supported_custom);
                 $cpt_supported_custom = array_filter(array_unique($cpt_supported_custom));
                 foreach ($cpt_supported_custom as $cpt_support) {
                     $cpt_supported[$cpt_support] = true;
                 }
             }
             // Genesis Support
             if (function_exists('genesis')) {
                 $cpt_supported['genesis-seo'] = (bool) pods_var('supports_genesis_seo', $post_type, false);
                 $cpt_supported['genesis-layouts'] = (bool) pods_var('supports_genesis_layouts', $post_type, false);
                 $cpt_supported['genesis-simple-sidebars'] = (bool) pods_var('supports_genesis_simple_sidebars', $post_type, false);
             }
             // WP needs something, if this was empty and none were enabled, it would show title+editor pre 3.5 :(
             $cpt_supports = array();
             if (!pods_version_check('wp', '3.5')) {
                 $cpt_supports = array('_bug_fix_pre_35');
             }
             foreach ($cpt_supported as $cpt_support => $supported) {
                 if (true === $supported) {
                     $cpt_supports[] = $cpt_support;
                 }
             }
             if (empty($cpt_supports) && pods_version_check('wp', '3.5')) {
                 $cpt_supports = false;
             }
             // Rewrite
             $cpt_rewrite = (bool) pods_var('rewrite', $post_type, true);
             $cpt_rewrite_array = array('slug' => pods_var('rewrite_custom_slug', $post_type, str_replace('_', '-', pods_var('name', $post_type)), null, true), 'with_front' => (bool) pods_var('rewrite_with_front', $post_type, true), 'feeds' => (bool) pods_var('rewrite_feeds', $post_type, (bool) pods_var('has_archive', $post_type, false)), 'pages' => (bool) pods_var('rewrite_pages', $post_type, true));
             if (false !== $cpt_rewrite) {
                 $cpt_rewrite = $cpt_rewrite_array;
             }
             $capability_type = pods_var('capability_type', $post_type, 'post');
             if ('custom' == $capability_type) {
                 $capability_type = pods_var('capability_type_custom', $post_type, 'post');
             }
             $show_in_menu = (bool) pods_var('show_in_menu', $post_type, true);
             if ($show_in_menu && 0 < strlen(pods_var_raw('menu_location_custom', $post_type))) {
                 $show_in_menu = pods_var_raw('menu_location_custom', $post_type);
             }
             // Register Post Type
             $pods_post_types[pods_var('name', $post_type)] = array('label' => $cpt_label, 'labels' => $cpt_labels, 'description' => esc_html(pods_var_raw('description', $post_type)), 'public' => (bool) pods_var('public', $post_type, true), 'publicly_queryable' => (bool) pods_var('publicly_queryable', $post_type, (bool) pods_var('public', $post_type, true)), 'exclude_from_search' => (bool) pods_var('exclude_from_search', $post_type, (bool) pods_var('public', $post_type, true) ? false : true), 'show_ui' => (bool) pods_var('show_ui', $post_type, (bool) pods_var('public', $post_type, true)), 'show_in_menu' => $show_in_menu, 'show_in_admin_bar' => (bool) pods_var('show_in_admin_bar', $post_type, (bool) pods_var('show_in_menu', $post_type, true)), 'menu_position' => (int) pods_var('menu_position', $post_type, 0, null, true), 'menu_icon' => pods_var('menu_icon', $post_type, null, null, true), 'capability_type' => $capability_type, 'map_meta_cap' => (bool) pods_var('capability_type_extra', $post_type, true), 'hierarchical' => (bool) pods_var('hierarchical', $post_type, false), 'supports' => $cpt_supports, 'has_archive' => (bool) pods_var('has_archive', $post_type, false), 'rewrite' => $cpt_rewrite, 'query_var' => false !== (bool) pods_var('query_var', $post_type, true) ? pods_var('query_var_string', $post_type, pods_var('name', $post_type), null, true) : false, 'can_export' => (bool) pods_var('can_export', $post_type, true), 'show_in_nav_menus' => (bool) pods_var('show_in_nav_menus', $post_type, (bool) pods_var('public', $post_type, true)));
             if (25 == $pods_post_types[pods_var('name', $post_type)]['menu_position']) {
                 $pods_post_types[pods_var('name', $post_type)]['menu_position']++;
             }
             if ($pods_post_types[pods_var('name', $post_type)]['menu_position'] < 1 || in_array($pods_post_types[pods_var('name', $post_type)]['menu_position'], $cpt_positions)) {
                 unset($pods_post_types[pods_var('name', $post_type)]['menu_position']);
             } else {
                 $cpt_positions[] = $pods_post_types[pods_var('name', $post_type)]['menu_position'];
                 // This would be nice if WP supported floats in menu_position
                 // $pods_post_types[ pods_var( 'name', $post_type ) ][ 'menu_position' ] = $pods_post_types[ pods_var( 'name', $post_type ) ][ 'menu_position' ] . '.1';
             }
             // Taxonomies
             $cpt_taxonomies = array();
             $_taxonomies = get_taxonomies();
             $_taxonomies = array_merge_recursive($_taxonomies, $pods_taxonomies);
             $ignore = array('nav_menu', 'link_category', 'post_format');
             foreach ($_taxonomies as $taxonomy => $label) {
                 if (in_array($taxonomy, $ignore)) {
                     continue;
                 }
                 if (false !== (bool) pods_var('built_in_taxonomies_' . $taxonomy, $post_type, false)) {
                     $cpt_taxonomies[] = $taxonomy;
                     if (isset($supported_post_types[$taxonomy]) && !in_array(pods_var('name', $post_type), $supported_post_types[$taxonomy])) {
                         $supported_post_types[$taxonomy][] = pods_var('name', $post_type);
                     }
                 }
             }
             if (isset($supported_taxonomies[pods_var('name', $post_type)])) {
                 $supported_taxonomies[pods_var('name', $post_type)] = array_merge((array) $supported_taxonomies[pods_var('name', $post_type)], $cpt_taxonomies);
             } else {
                 $supported_taxonomies[pods_var('name', $post_type)] = $cpt_taxonomies;
             }
         }
         foreach ($taxonomies as $taxonomy) {
             // Taxonomy Type exists already
             if (isset($pods_cpt_ct['taxonomies'][$taxonomy['name']])) {
                 continue;
             } elseif (!empty($taxonomy['object']) && isset($existing_taxonomies[$taxonomy['object']])) {
                 continue;
             } elseif (!$force && isset($existing_taxonomies[$taxonomy['name']])) {
                 continue;
             }
             $taxonomy['options']['name'] = $taxonomy['name'];
             $taxonomy = array_merge($taxonomy, (array) $taxonomy['options']);
             // Labels
             $ct_label = esc_html(pods_var_raw('label', $taxonomy, ucwords(str_replace('_', ' ', pods_var_raw('name', $taxonomy))), null, true));
             $ct_singular = esc_html(pods_var_raw('label_singular', $taxonomy, ucwords(str_replace('_', ' ', pods_var_raw('label', $taxonomy, pods_var_raw('name', $taxonomy), null, true))), null, true));
             $ct_labels = array();
             $ct_labels['name'] = $ct_label;
             $ct_labels['singular_name'] = $ct_singular;
             $ct_labels['menu_name'] = pods_var_raw('menu_name', $taxonomy, '', null, true);
             $ct_labels['search_items'] = pods_var_raw('label_search_items', $taxonomy, '', null, true);
             $ct_labels['popular_items'] = pods_var_raw('label_popular_items', $taxonomy, '', null, true);
             $ct_labels['all_items'] = pods_var_raw('label_all_items', $taxonomy, '', null, true);
             $ct_labels['parent_item'] = pods_var_raw('label_parent_item', $taxonomy, '', null, true);
             $ct_labels['parent_item_colon'] = pods_var_raw('label_parent_item_colon', $taxonomy, '', null, true);
             $ct_labels['edit_item'] = pods_var_raw('label_edit_item', $taxonomy, '', null, true);
             $ct_labels['update_item'] = pods_var_raw('label_update_item', $taxonomy, '', null, true);
             $ct_labels['add_new_item'] = pods_var_raw('label_add_new_item', $taxonomy, '', null, true);
             $ct_labels['new_item_name'] = pods_var_raw('label_new_item_name', $taxonomy, '', null, true);
             $ct_labels['separate_items_with_commas'] = pods_var_raw('label_separate_items_with_commas', $taxonomy, '', null, true);
             $ct_labels['add_or_remove_items'] = pods_var_raw('label_add_or_remove_items', $taxonomy, '', null, true);
             $ct_labels['choose_from_most_used'] = pods_var_raw('label_choose_from_the_most_used', $taxonomy, '', null, true);
             // Rewrite
             $ct_rewrite = (bool) pods_var('rewrite', $taxonomy, true);
             $ct_rewrite_array = array('slug' => pods_var('rewrite_custom_slug', $taxonomy, str_replace('_', '-', pods_var('name', $taxonomy)), null, true), 'with_front' => (bool) pods_var('rewrite_with_front', $taxonomy, true), 'hierarchical' => (bool) pods_var('rewrite_hierarchical', $taxonomy, (bool) pods_var('hierarchical', $taxonomy, false)));
             if (false !== $ct_rewrite) {
                 $ct_rewrite = $ct_rewrite_array;
             }
             // Register Taxonomy
             $pods_taxonomies[pods_var('name', $taxonomy)] = array('label' => $ct_label, 'labels' => $ct_labels, 'public' => (bool) pods_var('public', $taxonomy, true), 'show_in_nav_menus' => (bool) pods_var('show_in_nav_menus', $taxonomy, (bool) pods_var('public', $taxonomy, true)), 'show_ui' => (bool) pods_var('show_ui', $taxonomy, (bool) pods_var('public', $taxonomy, true)), 'show_tagcloud' => (bool) pods_var('show_tagcloud', $taxonomy, (bool) pods_var('show_ui', $taxonomy, (bool) pods_var('public', $taxonomy, true))), 'hierarchical' => (bool) pods_var('hierarchical', $taxonomy, false), 'update_count_callback' => pods_var('update_count_callback', $taxonomy, null, null, true), 'query_var' => false !== (bool) pods_var('query_var', $taxonomy, true) ? pods_var('query_var_string', $taxonomy, pods_var('name', $taxonomy), null, true) : false, 'rewrite' => $ct_rewrite, 'show_admin_column' => (bool) pods_var('show_admin_column', $taxonomy, false), 'sort' => (bool) pods_var('sort', $taxonomy, false));
             if (is_array($ct_rewrite) && !$pods_taxonomies[pods_var('name', $taxonomy)]['query_var']) {
                 $pods_taxonomies[pods_var('name', $taxonomy)]['query_var'] = pods_var('query_var_string', $taxonomy, pods_var('name', $taxonomy), null, true);
             }
             // Post Types
             $ct_post_types = array();
             $_post_types = get_post_types();
             $_post_types = array_merge_recursive($_post_types, $pods_post_types);
             $ignore = array('revision', 'nav_menu_item');
             foreach ($_post_types as $post_type => $options) {
                 if (in_array($post_type, $ignore)) {
                     continue;
                 }
                 if (false !== (bool) pods_var('built_in_post_types_' . $post_type, $taxonomy, false)) {
                     $ct_post_types[] = $post_type;
                     if (isset($supported_taxonomies[$post_type]) && !in_array(pods_var('name', $taxonomy), $supported_taxonomies[$post_type])) {
                         $supported_taxonomies[$post_type][] = pods_var('name', $taxonomy);
                     }
                 }
             }
             if (isset($supported_post_types[pods_var('name', $taxonomy)])) {
                 $supported_post_types[pods_var('name', $taxonomy)] = array_merge($supported_post_types[pods_var('name', $taxonomy)], $ct_post_types);
             } else {
                 $supported_post_types[pods_var('name', $taxonomy)] = $ct_post_types;
             }
         }
         $pods_post_types = apply_filters('pods_wp_post_types', $pods_post_types);
         $pods_taxonomies = apply_filters('pods_wp_taxonomies', $pods_taxonomies);
         $supported_post_types = apply_filters('pods_wp_supported_post_types', $supported_post_types);
         $supported_taxonomies = apply_filters('pods_wp_supported_taxonomies', $supported_taxonomies);
         foreach ($pods_taxonomies as $taxonomy => $options) {
             $ct_post_types = null;
             if (isset($supported_post_types[$taxonomy]) && !empty($supported_post_types[$taxonomy])) {
                 $ct_post_types = $supported_post_types[$taxonomy];
             }
             $pods_cpt_ct['taxonomies'][$taxonomy] = array('post_types' => $ct_post_types, 'options' => $options);
         }
         foreach ($pods_post_types as $post_type => $options) {
             if (isset($supported_taxonomies[$post_type]) && !empty($supported_taxonomies[$post_type])) {
                 $options['taxonomies'] = $supported_taxonomies[$post_type];
             }
             $pods_cpt_ct['post_types'][$post_type] = $options;
         }
         pods_transient_set('pods_wp_cpt_ct', $pods_cpt_ct);
     }
     foreach ($pods_cpt_ct['taxonomies'] as $taxonomy => $options) {
         if (isset(self::$content_types_registered['taxonomies']) && in_array($taxonomy, self::$content_types_registered['taxonomies'])) {
             continue;
         }
         $ct_post_types = $options['post_types'];
         $options = $options['options'];
         $options = apply_filters('pods_register_taxonomy_' . $taxonomy, $options);
         $options = self::object_label_fix($options, 'taxonomy');
         // Max length for taxonomies are 32 characters
         $taxonomy = substr($taxonomy, 0, 32);
         // i18n compatibility for plugins that override it
         if (is_array($options['rewrite']) && isset($options['rewrite']['slug']) && !empty($options['rewrite']['slug'])) {
             $options['rewrite']['slug'] = _x($options['rewrite']['slug'], 'URL taxonomy slug', 'pods');
         }
         if (1 == pods_var('pods_debug_register', 'get', 0) && pods_is_admin(array('pods'))) {
             pods_debug(array($taxonomy, $ct_post_types, $options));
         }
         register_taxonomy($taxonomy, $ct_post_types, $options);
         if (!isset(self::$content_types_registered['taxonomies'])) {
             self::$content_types_registered['taxonomies'] = array();
         }
         self::$content_types_registered['taxonomies'][] = $taxonomy;
     }
     foreach ($pods_cpt_ct['post_types'] as $post_type => $options) {
         if (isset(self::$content_types_registered['post_types']) && in_array($post_type, self::$content_types_registered['post_types'])) {
             continue;
         }
         $options = apply_filters('pods_register_post_type_' . $post_type, $options);
         $options = self::object_label_fix($options, 'post_type');
         // Max length for post types are 20 characters
         $post_type = substr($post_type, 0, 20);
         // i18n compatibility for plugins that override it
         if (is_array($options['rewrite']) && isset($options['rewrite']['slug']) && !empty($options['rewrite']['slug'])) {
             $options['rewrite']['slug'] = _x($options['rewrite']['slug'], 'URL slug', 'pods');
         }
         if (1 == pods_var('pods_debug_register', 'get', 0) && pods_is_admin(array('pods'))) {
             pods_debug(array($post_type, $options));
         }
         register_post_type($post_type, $options);
         if (!isset(self::$content_types_registered['post_types'])) {
             self::$content_types_registered['post_types'] = array();
         }
         self::$content_types_registered['post_types'][] = $post_type;
     }
     $flush = pods_transient_get('pods_flush_rewrites');
     if (1 == $flush) {
         global $wp_rewrite;
         $wp_rewrite->flush_rules();
         $wp_rewrite->init();
         pods_transient_set('pods_flush_rewrites', 0);
     }
 }
Beispiel #9
0
 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (!is_admin()) {
         include_once ABSPATH . '/wp-admin/includes/template.php';
         if (is_multisite()) {
             include_once ABSPATH . '/wp-admin/includes/ms.php';
         }
     }
     if ((defined('PODS_DISABLE_FILE_UPLOAD') && true === PODS_DISABLE_FILE_UPLOAD || defined('PODS_UPLOAD_REQUIRE_LOGIN') && is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && true === PODS_UPLOAD_REQUIRE_LOGIN && !is_user_logged_in() || defined('PODS_UPLOAD_REQUIRE_LOGIN') && !is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && (!is_user_logged_in() || !current_user_can(PODS_UPLOAD_REQUIRE_LOGIN))) && (defined('PODS_DISABLE_FILE_BROWSER') && true === PODS_DISABLE_FILE_BROWSER || defined('PODS_FILES_REQUIRE_LOGIN') && is_bool(PODS_FILES_REQUIRE_LOGIN) && true === PODS_FILES_REQUIRE_LOGIN && !is_user_logged_in() || defined('PODS_FILES_REQUIRE_LOGIN') && !is_bool(PODS_FILES_REQUIRE_LOGIN) && (!is_user_logged_in() || !current_user_can(PODS_FILES_REQUIRE_LOGIN)))) {
         ?>
     <p>You do not have access to upload / browse files. Contact your website admin to resolve.</p>
     <?php 
         return;
     }
     if ('plupload' == pods_var(self::$type . '_uploader', $options)) {
         $field_type = 'plupload';
     } elseif ('attachment' == pods_var(self::$type . '_uploader', $options)) {
         if (!pods_version_check('wp', '3.5') || !is_admin()) {
             // @todo test frontend media modal
             $field_type = 'attachment';
         } else {
             $field_type = 'media';
         }
     } else {
         // Support custom File Uploader integration
         do_action('pods_form_ui_field_avatar_uploader_' . pods_var(self::$type . '_uploader', $options), $name, $value, $options, $pod, $id);
         do_action('pods_form_ui_field_avatar_uploader', pods_var(self::$type . '_uploader', $options), $name, $value, $options, $pod, $id);
         return;
     }
     pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
 }
Beispiel #10
0
 /**
  * @param $object_type
  * @param $object_id
  * @param string $aux
  *
  * @return bool|mixed
  */
 public function get_object($object_type, $object_id, $aux = '')
 {
     global $wpdb;
     if ('term' == $object_type) {
         $object_type = 'taxonomy';
     }
     if ('post_type' == $object_type) {
         $objects = self::$post_types;
     } elseif ('taxonomy' == $object_type) {
         $objects = self::$taxonomies;
     } elseif ('media' == $object_type) {
         $objects = self::$media;
     } elseif ('user' == $object_type) {
         $objects = self::$user;
     } elseif ('comment' == $object_type) {
         $objects = self::$comment;
     } elseif ('settings' == $object_type) {
         $objects = self::$settings;
     } else {
         return false;
     }
     if (empty($objects) || !is_array($objects)) {
         return false;
     }
     $object_name = null;
     if ('media' == $object_type) {
         return @current($objects);
     } elseif ('user' == $object_type) {
         return @current($objects);
     } elseif ('comment' == $object_type) {
         return @current($objects);
     } elseif ('post_type' == $object_type) {
         $object = get_post($object_id);
         if (!is_object($object) || !isset($object->post_type)) {
             return false;
         }
         $object_name = $object->post_type;
     } elseif ('taxonomy' == $object_type) {
         if (pods_version_check('wp', '4.4')) {
             $object = get_term($object_id);
             if (!is_object($object) || !isset($object->taxonomy)) {
                 return false;
             }
             $object_name = $object->taxonomy;
         } elseif (empty($aux)) {
             $object_name = $wpdb->get_var($wpdb->prepare("SELECT `taxonomy` FROM `{$wpdb->term_taxonomy}` WHERE `term_id` = %d", $object_id));
         } else {
             $object_name = $aux;
         }
     } elseif ('settings' == $object_type) {
         $object = $object_id;
     } else {
         return false;
     }
     $reserved_post_types = array('revision');
     $reserved_post_types = apply_filters('pods_meta_reserved_post_types', $reserved_post_types, $object_type, $object_id, $object_name, $objects);
     if (empty($object_name) || ('post_type' == $object_type && 0 === strpos($object_name, '_pods_') || in_array($object_name, $reserved_post_types))) {
         return false;
     } elseif ('attachment' == $object_name) {
         return @current(self::$media);
     }
     $recheck = array();
     // Return first created by Pods, save extended for later
     foreach ($objects as $pod) {
         if ($object_name == $pod['object']) {
             $recheck[] = $pod;
         }
         if ('' == $pod['object'] && $object_name == $pod['name']) {
             return $pod;
         }
     }
     // If no objects created by Pods, return first extended
     foreach ($recheck as $pod) {
         return $pod;
     }
     return false;
 }
Beispiel #11
0
 /**
  * Get list of Pod options
  *
  * @return array
  */
 public function admin_setup_edit_options($pod)
 {
     $options = array();
     // @todo fill this in
     $options['labels'] = array('temporary' => 'This has the fields hardcoded');
     if ('post_type' == $pod['type']) {
         $options['admin-ui'] = array('description' => array('label' => __('Post Type Description', 'pods'), 'help' => __('A short descriptive summary of what the post type is.', 'pods'), 'type' => 'text', 'default' => ''), 'show_ui' => array('label' => __('Show Admin UI', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'show_in_menu' => array('label' => __('Show Admin Menu in Dashboard', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'dependency' => true, 'boolean_yes_label' => ''), 'menu_location_custom' => array('label' => __('Parent Menu ID (optional)', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('show_in_menu' => true)), 'menu_name' => array('label' => __('Menu Name', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_in_menu' => true)), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('show_in_menu' => true)), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_in_menu' => true)), 'show_in_nav_menus' => array('label' => __('Show in Navigation Menus', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'show_in_admin_bar' => array('label' => __('Show in Admin Bar "New" Menu', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''));
         $options['advanced'] = array('public' => array('label' => __('Public', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'publicly_queryable' => array('label' => __('Publicly Queryable', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'exclude_from_search' => array('label' => __('Exclude from Search', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => !pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'capability_type' => array('label' => __('User Capability', 'pods'), 'help' => __('Uses these capabilties for access to this post type: edit_{capability}, read_{capability}, and delete_{capability}', 'pods'), 'type' => 'pick', 'default' => 'post', 'data' => array('post' => 'post', 'page' => 'page', 'custom' => __('Custom Capability', 'pods')), 'dependency' => true), 'capability_type_custom' => array('label' => __('Custom User Capability', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => pods_var_raw('name', $pod), 'depends-on' => array('capability_type' => 'custom')), 'capability_type_extra' => array('label' => __('Additional User Capabilities', 'pods'), 'help' => __('Enables additional capabilities for this Post Type including: delete_{capability}s, delete_private_{capability}s, delete_published_{capability}s, delete_others_{capability}s, edit_private_{capability}s, and edit_published_{capability}s', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'has_archive' => array('label' => __('Has Archive', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => ''), 'hierarchical' => array('label' => __('Hierarchical', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => false, 'dependency' => true, 'boolean_yes_label' => ''), 'label_parent_item_colon' => array('label' => __('<strong>Label: </strong> Parent <span class="pods-slugged" data-sluggable="label_singular">Item</span>', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('hierarchical' => true)), 'label_parent' => array('label' => __('<strong>Label: </strong> Parent', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('hierarchical' => true)), 'rewrite' => array('label' => __('Rewrite', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'dependency' => true, 'boolean_yes_label' => ''), 'rewrite_custom_slug' => array('label' => __('Custom Rewrite Slug', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('rewrite' => true)), 'rewrite_with_front' => array('label' => __('Rewrite with Front', 'pods'), 'help' => __('Allows permalinks to be prepended with your front base (example: if your permalink structure is /blog/, then your links will be: Unchecked->/news/, Checked->/blog/news/)', 'pods'), 'type' => 'boolean', 'default' => true, 'depends-on' => array('rewrite' => true), 'boolean_yes_label' => ''), 'rewrite_feeds' => array('label' => __('Rewrite Feeds', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => false, 'depends-on' => array('rewrite' => true), 'boolean_yes_label' => ''), 'rewrite_pages' => array('label' => __('Rewrite Pages', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'depends-on' => array('rewrite' => true), 'boolean_yes_label' => ''), 'query_var' => array('label' => __('Query Var', 'pods'), 'help' => __('The Query Var is used in the URL and underneath the WordPress Rewrite API to tell WordPress what page or post type you are on. For a list of reserved Query Vars, read <a href="http://codex.wordpress.org/WordPress_Query_Vars">WordPress Query Vars</a> from the WordPress Codex.', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'can_export' => array('label' => __('Exportable', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => true, 'boolean_yes_label' => ''), 'default_status' => array('label' => __('Default Status', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'pick_object' => 'post-status', 'default' => apply_filters('pods_api_default_status_' . pods_var_raw('name', $pod, 'post_type', null, true), 'draft', $pod)));
     } elseif ('taxonomy' == $pod['type']) {
         $options['admin-ui'] = array('show_ui' => array('label' => __('Show Admin UI', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'dependency' => true, 'boolean_yes_label' => ''), 'menu_name' => array('label' => __('Menu Name', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_ui' => true)), 'menu_location' => array('label' => __('Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'default', 'depends-on' => array('show_ui' => true), 'data' => array('default' => __('Default - Add to associated Post Type(s) menus', 'pods'), 'settings' => __('Add to Settings menu', 'pods'), 'appearances' => __('Add to Appearances menu', 'pods'), 'objects' => __('Make a top-level menu item', 'pods'), 'top' => __('Make a new top-level menu item below Settings', 'pods'), 'submenu' => __('Add a submenu item to another menu', 'pods')), 'dependency' => true), 'menu_location_custom' => array('label' => __('Custom Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('menu_location' => 'submenu')), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('menu_location' => array('objects', 'top'))), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('menu_location' => array('objects', 'top'))), 'show_in_nav_menus' => array('label' => __('Show in Navigation Menus', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('public', $pod, true), 'boolean_yes_label' => ''), 'show_tagcloud' => array('label' => __('Allow in Tagcloud Widget', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => pods_var_raw('show_ui', $pod, pods_var_raw('public', $pod, true)), 'boolean_yes_label' => ''));
         if (pods_version_check('wp', '3.5')) {
             $options['admin-ui']['show_admin_column'] = array('label' => __('Show Taxonomy column on Post Types', 'pods'), 'help' => __('Whether to add a column for this taxonomy on the associated post types manage screens', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '');
         }
         // Integration for Single Value Taxonomy UI
         if (function_exists('tax_single_value_meta_box')) {
             $options['admin-ui']['single_value'] = array('label' => __('Single Value Taxonomy', 'pods'), 'help' => __('Use a drop-down for the input instead of the WordPress default', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '');
             $options['admin-ui']['single_value_required'] = array('label' => __('Single Value Taxonomy - Required', 'pods'), 'help' => __('A term will be selected by default in the Post Editor, not optional', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '');
         }
         // @todo fill this in
         $options['advanced'] = array('temporary' => 'This type has the fields hardcoded');
     } elseif ('settings' == $pod['type']) {
         $options['admin-ui'] = array('ui_style' => array('label' => __('Admin UI Style', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'settings', 'data' => array('settings' => __('Normal Settings Form', 'pods'), 'post_type' => __('Post Type UI', 'pods'), 'custom' => __('Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods')), 'dependency' => true), 'menu_location' => array('label' => __('Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'settings', 'data' => array('settings' => __('Add to Settings menu', 'pods'), 'appearances' => __('Add to Appearances menu', 'pods'), 'top' => __('Make a new top-level menu item below Settings', 'pods'), 'submenu' => __('Add a submenu item to another menu', 'pods')), 'dependency' => true), 'menu_location_custom' => array('label' => __('Custom Menu Location', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('menu_location' => 'submenu')), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('menu_location' => 'top')), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('menu_location' => 'top')));
         // @todo fill this in
         $options['advanced'] = array('temporary' => 'This type has the fields hardcoded');
     } elseif ('pod' == $pod['type']) {
         $options['admin-ui'] = array('ui_style' => array('label' => __('Admin UI Style', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 'settings', 'data' => array('post_type' => __('Normal (Looks like the Post Type UI)', 'pods'), 'custom' => __('Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods')), 'dependency' => true), 'show_in_menu' => array('label' => __('Show Admin Menu in Dashboard', 'pods'), 'help' => __('help', 'pods'), 'type' => 'boolean', 'default' => false, 'boolean_yes_label' => '', 'dependency' => true), 'menu_location_custom' => array('label' => __('Parent Menu ID (optional)', 'pods'), 'help' => __('help', 'pods'), 'type' => 'text', 'depends-on' => array('show_in_menu' => true)), 'menu_position' => array('label' => __('Menu Position', 'pods'), 'help' => __('help', 'pods'), 'type' => 'number', 'default' => 0, 'depends-on' => array('show_in_menu' => true)), 'menu_icon' => array('label' => __('Menu Icon URL', 'pods'), 'help' => __('This is the icon shown to the left of the menu text for this content type.', 'pods'), 'type' => 'text', 'default' => '', 'depends-on' => array('show_in_menu' => true)), 'ui_icon' => array('label' => __('Header Icon', 'pods'), 'help' => __('This is the icon shown to the left of the heading text at the top of the manage pages for this content type.', 'pods'), 'type' => 'file', 'default' => '', 'file_edit_title' => 0, 'depends-on' => array('show_in_menu' => true)), 'ui_actions_enabled' => array('label' => __('Actions Available', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => 1 == pods_var('ui_export', $pod) ? array('add', 'edit', 'duplicate', 'delete', 'export') : array('add', 'edit', 'duplicate', 'delete'), 'data' => array('add' => __('Add New', 'pods'), 'edit' => __('Edit', 'pods'), 'duplicate' => __('Duplicate', 'pods'), 'delete' => __('Delete', 'pods'), 'reorder' => __('Reorder', 'pods'), 'export' => __('Export', 'pods')), 'pick_format_type' => 'multi', 'dependency' => true), 'ui_reorder_field' => array('label' => __('Reorder Field', 'pods'), 'help' => __('This is the field that will be reordered on, it should be numeric.', 'pods'), 'type' => 'text', 'default' => 'menu_order', 'depends-on' => array('ui_actions_enabled' => 'reorder')), 'ui_fields_manage' => array('label' => __('Admin Table Columns', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => array(), 'data' => array(), 'pick_format_type' => 'multi'), 'ui_filters' => array('label' => __('Search Filters', 'pods'), 'help' => __('help', 'pods'), 'type' => 'pick', 'default' => array(), 'data' => array(), 'pick_format_type' => 'multi'));
         if (!empty($pod['fields'])) {
             if (isset($pod['fields'][pods_var_raw('pod_index', $pod, 'name')])) {
                 $options['admin-ui']['ui_fields_manage']['default'][] = pods_var_raw('pod_index', $pod, 'name');
             }
             if (isset($pod['fields']['modified'])) {
                 $options['admin-ui']['ui_fields_manage']['default'][] = 'modified';
             }
             foreach ($pod['fields'] as $field) {
                 $type = '';
                 if (isset($field_types[$field['type']])) {
                     $type = ' <small>(' . $field_types[$field['type']]['label'] . ')</small>';
                 }
                 $options['admin-ui']['ui_fields_manage']['data'][$field['name']] = $field['label'] . $type;
                 $options['admin-ui']['ui_filters']['data'][$field['name']] = $field['label'] . $type;
             }
             $options['admin-ui']['ui_fields_manage']['data']['id'] = 'ID';
         } else {
             unset($options['admin-ui']['ui_fields_manage']);
             unset($options['admin-ui']['ui_filters']);
         }
         // @todo fill this in
         $options['advanced'] = array('temporary' => 'This type has the fields hardcoded');
     }
     $options = apply_filters('pods_admin_setup_edit_options_' . $pod['type'] . '_' . $pod['name'], $options, $pod);
     $options = apply_filters('pods_admin_setup_edit_options_' . $pod['type'], $options, $pod);
     $options = apply_filters('pods_admin_setup_edit_options', $options, $pod);
     return $options;
 }
Beispiel #12
0
 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (is_array($value)) {
         $value = implode(' ', $value);
     }
     // WP Color Picker for 3.5+
     if (pods_version_check('wp', '3.5')) {
         $field_type = 'color';
     } else {
         $field_type = 'farbtastic';
     }
     if (isset($options['name']) && false === PodsForm::permission(self::$type, $options['name'], $options, null, $pod, $id)) {
         if (pods_v('read_only', $options, false)) {
             $options['readonly'] = true;
             $field_type = 'text';
         } else {
             return;
         }
     } elseif (!pods_has_permissions($options) && pods_v('read_only', $options, false)) {
         $options['readonly'] = true;
         $field_type = 'text';
     }
     pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
 }
Beispiel #13
0
/**
 * Filter input and return unslashed output
 *
 * @param mixed $input The string, array, or object to unsanitize
 *
 * @return array|mixed|object|string|void
 *
 * @since 2.3.9
 *
 * @see wp_unslash
 */
function pods_unslash($input)
{
    $output = array();
    if (empty($input)) {
        $output = $input;
    } elseif (is_object($input)) {
        $input = get_object_vars($input);
        foreach ($input as $key => $val) {
            $output[$key] = pods_unslash($val);
        }
        $output = (object) $output;
    } elseif (is_array($input)) {
        foreach ($input as $key => $val) {
            $output[$key] = pods_unslash($val);
        }
    } else {
        $output = pods_version_check('wp', '3.6') ? wp_unslash($input) : stripslashes($input);
    }
    return $output;
}