コード例 #1
0
 /**
  * Output admin page
  */
 public static function admin_page()
 {
     include_once 'Pods_Jobs_Queue_API.php';
     /**
      * @var $wpdb wpdb
      */
     global $wpdb;
     $table = Pods_Jobs_Queue_API::table();
     Pods_Jobs_Queue_API::install();
     $ui = array('item' => __('Job', 'pods-jobs-queue'), 'items' => __('Jobs', 'pods-jobs-queue'), 'header' => array('view' => __('View Job Info', 'pods-jobs-queue')), 'sql' => array('table' => $table, 'field_id' => 'id', 'field_index' => 'callback'), 'orderby' => '( `t`.`status` = "queued" ) DESC, ( `t`.`status` = "completed" ) DESC, `t`.`date_queued` DESC, `t`.`date_completed` DESC', 'fields' => array('manage' => array('callback' => array('name' => 'callback', 'label' => 'Callback', 'type' => 'text'), 'group' => array('name' => 'group', 'label' => 'Group', 'type' => 'text'), 'memo' => array('name' => 'memo', 'label' => 'Memo', 'type' => 'text'), 'status' => array('name' => 'status', 'label' => 'Status', 'type' => 'pick', 'pick_object' => 'custom-simple', 'data' => array('queued' => __('Queued', 'pods-jobs-queue'), 'processing' => __('Processing', 'pods-jobs-queue'), 'completed' => __('Completed', 'pods-jobs-queue'), 'failed' => __('Failed', 'pods-jobs-queue'))), 'date_queued' => array('name' => 'date_queued', 'label' => 'Time Queued', 'type' => 'datetime', 'options' => array('datetime_allow_empty' => 1)), 'date_started' => array('name' => 'date_started', 'label' => 'Time Started', 'type' => 'datetime', 'options' => array('datetime_allow_empty' => 1)), 'date_completed' => array('name' => 'date_completed', 'label' => 'Time Completed', 'type' => 'datetime', 'options' => array('datetime_allow_empty' => 1))), 'search' => array()), 'filters' => array('callback', 'memo', 'group', 'status', 'date_queued', 'date_started', 'date_completed'), 'filters_enhanced' => true, 'actions_disabled' => array('add', 'edit', 'duplicate', 'export'), 'actions_custom' => array('process_job' => array('callback' => array(__CLASS__, 'admin_page_process_job')), 'view' => array('callback' => array(__CLASS__, 'admin_page_view_job')), 'delete' => array('callback' => array(__CLASS__, 'admin_page_delete_job'))), 'actions_bulk' => array('delete' => array('label' => __('Delete', 'pods')), 'process_jobs' => array('callback' => array(__CLASS__, 'admin_page_process_jobs'))));
     $ui['fields']['search']['callback'] = $ui['fields']['manage']['callback'];
     $ui['fields']['search']['memo'] = $ui['fields']['manage']['memo'];
     $ui['fields']['search']['group'] = $ui['fields']['manage']['group'];
     $ui['fields']['search']['status'] = $ui['fields']['manage']['status'];
     $ui['fields']['search']['date_queued'] = $ui['fields']['manage']['date_queued'];
     $ui['fields']['search']['date_started'] = $ui['fields']['manage']['date_started'];
     $ui['fields']['search']['date_completed'] = $ui['fields']['manage']['date_completed'];
     $ui['fields']['view'] = $ui['fields']['manage'];
     unset($ui['fields']['view']['callback']);
     $ui['fields']['view']['arguments'] = array('name' => 'arguments', 'label' => 'Callback Arguments', 'type' => 'paragraph');
     $ui['fields']['view']['log'] = array('name' => 'log', 'label' => 'Callback Log', 'type' => 'text');
     $ui['fields']['view']['blog_id'] = array('name' => 'blog_id', 'label' => 'Blog ID', 'type' => 'number', 'options' => array('number_format_type' => '9999.99', 'number_decimals' => 0), 'width' => '5%');
     if (!defined('PODS_JOBS_QUEUE_GROUPS') || !PODS_JOBS_QUEUE_GROUPS) {
         unset($ui['fields']['manage']['group']);
         unset($ui['fields']['manage']['search']);
         unset($ui['fields']['manage']['view']);
         unset($ui['filters'][array_search('group', $ui['filters'])]);
     }
     if (1 == pods_v('deleted_bulk')) {
         unset($ui['actions_custom']['delete']);
     }
     pods_ui($ui);
 }
コード例 #2
0
function SLUG_new_salad_redirect()
{
    //check if new_salad GET variable isset, act only if it is
    if (false !== ($new_salad_id = pods_v('new_salad', 'get', false, true))) {
        //use the value to get the link to the item and then redirect to it.
        //get peramlink only works for post types.
        ///Use get_term_link for taxonomies or build link manually for advanced content types
        pods_redirect(get_permalink($new_salad_id));
    }
}
コード例 #3
0
/**
 * Note: This is needed due to a bug issued here https://github.com/pods-framework/pods/issues/2284
 * The forum thread is: http://pods.io/forums/topic/some-lesson-learned/#post-185783
 *
 * Add Shortcode to generate a pods (template or form) that support a id passed vía GET (this is generic)
 * If we need to work with a related var (sub collection) you can indicate the "related pod" and a "where"
 * clause will be generated
 *    
 * @params
 *   id_get_var   is the id var passed via get that holds the id (i.e: give me a concrete author by its id
 *   related_pod  optional. If exists there's a related field to a one to many relation and is used in combination with id_get_var
 *                this is used to get a collection where subrelated field is equal to the id provided (i.e: all books from and author)
 * @usage
 *   [podsid name="author" form="1" id_get_var="author_id" fields="post_title, type_author" label="Save Author"/]
 *   [podsid name="books" id_get_var="author_id" related_pod="author" template="Books View" limit="10" pagination="1"/]
 */
function get_pod_id_shortcode($atts, $content = "")
{
    // get the pods form user attributes
    extract(shortcode_atts(array('id_get_var' => 'id', 'related_pod' => '', 'name' => '', 'fields' => '', 'form' => '0', 'template' => '', 'limit' => '', 'pagination' => '', 'label' => ''), $atts, 'podsid'));
    // get the id
    $id = pods_v($id_get_var, 'get', null, true);
    // where
    if ($related_pod == '') {
        $where = $id > 0 ? 't.ID = ' . $id : '';
    } else {
        $where = $id > 0 ? $related_pod . '.id = ' . $id : '';
    }
    $params = array('limit' => $limit, 'where' => $where);
    $_pod = pods($name, $params);
    if ($form == 1) {
        return $_pod->form($fields, $label);
    } else {
        return $_pod->template($template, $content);
    }
}
コード例 #4
0
 /**
  * Get the data from the field
  *
  * @param string $name The name of the field
  * @param string|array $value The value of the field
  * @param array $options
  * @param array $pod
  * @param int $id
  * @param boolean $in_form
  *
  * @return array Array of possible field data
  *
  * @since 2.0
  */
 public function data($name, $value = null, $options = null, $pod = null, $id = null, $in_form = true)
 {
     if ('checkbox' != pods_v(self::$type . '_format_type', $options)) {
         $data = array(1 => pods_var_raw(self::$type . '_yes_label', $options), 0 => pods_var_raw(self::$type . '_no_label', $options));
     } else {
         $data = array(1 => pods_var_raw(self::$type . '_yes_label', $options));
     }
     return $data;
 }
コード例 #5
0
        var select_container = default_select.match( /<select[^<]*>/g );

        $el.find( '.pods-sister-field' ).html( select_container + '<option value=""><?php 
esc_attr_e('Loading available fields..', 'pods');
?>
</option></select>' );

        postdata = {
            action : 'pods_admin',
            method : 'load_sister_fields',
            _wpnonce : '<?php 
echo esc_js(wp_create_nonce('pods-load_sister_fields'));
?>
',
            pod : '<?php 
echo esc_js(pods_v('name', $pod));
?>
',
            related_pod : related_pod_name
        };

        jQuery.ajax( {
            type : 'POST',
            dataType : 'html',
            url : ajaxurl + '?pods_ajax=1',
            cache : false,
            data : postdata,
            success : function ( d ) {
                if ( -1 == d.indexOf( '<e>' ) && -1 == d.indexOf('</e>') && -1 != d && '[]' != d ) {
                    var json = d.match( /{.*}$/ );
コード例 #6
0
ファイル: PodsAPI.php プロジェクト: satokora/IT354Project
 /**
  *
  * Load the information about an objects MySQL table
  *
  * @param $object_type
  * @param string $object The object to look for
  * @param null $name (optional) Name of the pod to load
  * @param array $pod (optional) Array with pod information
  *
  * @return array
  *
  * @since 2.5
  */
 public function get_table_info_load($object_type, $object, $name = null, $pod = null)
 {
     $info = array();
     if ('pod' == $object_type && null === $pod) {
         if (empty($name)) {
             $prefix = 'pod-';
             // Make sure we actually have the prefix before trying anything with the name
             if (0 === strpos($object_type, $prefix)) {
                 $name = substr($object_type, strlen($prefix), strlen($object_type));
             }
         }
         if (empty($name) && !empty($object)) {
             $name = $object;
         }
         $pod = $this->load_pod(array('name' => $name, 'table_info' => false), false);
         if (!empty($pod)) {
             $object_type = $pod['type'];
             $name = $pod['name'];
             $object = $pod['object'];
             $info['pod'] = $pod;
         }
     } elseif (null === $pod) {
         if (empty($name)) {
             $prefix = $object_type . '-';
             // Make sure we actually have the prefix before trying anything with the name
             if (0 === strpos($object_type, $prefix)) {
                 $name = substr($object_type, strlen($prefix), strlen($object_type));
             }
         }
         if (empty($name) && !empty($object)) {
             $name = $object;
         }
         if (!empty($name)) {
             $pod = $this->load_pod(array('name' => $name, 'table_info' => false), false);
             if (!empty($pod) && (null === $object_type || $object_type == $pod['type'])) {
                 $object_type = $pod['type'];
                 $name = $pod['name'];
                 $object = $pod['object'];
                 $info['pod'] = $pod;
             }
         }
     } elseif (!empty($pod)) {
         $info['pod'] = $pod;
     }
     if (0 === strpos($object_type, 'pod')) {
         if (empty($name)) {
             $prefix = 'pod-';
             // Make sure we actually have the prefix before trying anything with the name
             if (0 === strpos($object_type, $prefix)) {
                 $name = substr($object_type, strlen($prefix), strlen($object_type));
             }
         }
         $info['type'] = 'pod';
         global $wpdb;
         $info['table'] = $info['meta_table'] = $wpdb->prefix . 'pods_' . (empty($object) ? $name : $object);
         if (is_array($info['pod']) && 'pod' == pods_v('type', $info['pod'])) {
             $info['pod_field_index'] = $info['field_index'] = $info['meta_field_index'] = $info['meta_field_value'] = pods_v('pod_index', $info['pod']['options'], 'id', true);
             $slug_field = get_posts(array('post_type' => '_pods_field', 'posts_per_page' => 1, 'nopaging' => true, 'post_parent' => $info['pod']['id'], 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_query' => array(array('key' => 'type', 'value' => 'slug'))));
             if (!empty($slug_field)) {
                 $slug_field = $slug_field[0];
                 $info['field_slug'] = $info['pod_field_slug'] = $slug_field->post_name;
             }
             if (1 == pods_v('hierarchical', $info['pod']['options'], 0)) {
                 $parent_field = pods_v('pod_parent', $info['pod']['options'], 'id', true);
                 if (!empty($parent_field) && isset($info['pod']['fields'][$parent_field])) {
                     $info['object_hierarchical'] = true;
                     $info['pod_field_parent'] = $info['field_parent'] = $parent_field . '_select';
                     $info['field_parent_select'] = '`' . $parent_field . '`.`id` AS `' . $info['field_parent'] . '`';
                 }
             }
         }
     }
     return $info;
 }
コード例 #7
0
//meta title
$pods->meta['title'] = __('Your Meta Title Here', 'text-domain');
//meta descrioption
$pods->meta['description'] = __('Your Meta Description Here', 'text-domain');
/**
 * SEO Fields for Pods advanced content types. Using dynamically generated content.
 *
 * Goes in Pods Page precode field.
 *
 * Be sure to note inline comments about fields that are presumed to exist that DO NOT exist by default.
 */
/**Setup Pods Object**/
//get current url
$slug = pods_v('last', 'url');
//get pod name
$pod_name = pods_v(0, 'url');
//get pods object for current item
$pods = pods($pod_name, $slug);
/*title field*/
//assumes field name of meta_title exists
$pods->meta['title'] = __($pods->field('meta_title'), 'translation-domain') . '&nbsp;|&nbsp;';
/*meta description*/
//presumes field name of 'meta_desc' exists
$pods->meta['description'] = __($pods->field('meta_desc'), 'translation-domain');
$pods->meta_properties['og:description'] = __($pods->field('meta_desc', 'translation-domain'));
/**Google+ Profile Link**/
//Presumes users is extended with a field called 'google_plus'
//Also presumes ACT has a field called page_author, related to Users
$author = $pods->field('page_author');
echo '<link rel="author" href="' . esc_url(get_the_author_meta('google_plus', $author['ID'])) . ' "/>';
/*OpenGrpah Image*/
コード例 #8
0
						return {
							// Simply use the new tag term as the id
							//we might want to append 'new' to all newly created term IDs for processing in PodsAPI.php
							id: term.trim(),
							text: term.trim()
						};
					}
				},
			<?php 
}
?>

            width : 'resolve',

			<?php 
if (1 == (int) pods_v($form_field_type . '_allow_html', $options)) {
    ?>
				escapeMarkup : function (m) { return m; },
			<?php 
}
?>

            initSelection : function ( element, callback ) {
                var data = [];

                jQuery( element.val().split( "," ) ).each( function () {
                    if ( 'undefined' != typeof <?php 
echo esc_js(pods_js_name($attributes['id']));
?>
_data[ this ] ) {
                        data.push( {
コード例 #9
0
ファイル: PodsUI.php プロジェクト: Ingenex/redesign
    /**
     * @return bool|mixed
     * @since 2.3.10
     */
    public function view()
    {
        if (false !== $this->callback_action('view')) {
            return null;
        }
        if (empty($this->row)) {
            $this->get_row();
        }
        if (empty($this->row)) {
            return $this->error(sprintf(__('<strong>Error:</strong> %s not found.', 'pods'), $this->item));
        }
        $pod =& $this->pod;
        $fields = array();
        if (isset($this->fields[$this->action])) {
            $fields = $this->fields[$this->action];
        }
        if (is_object($this->pod)) {
            $object_fields = (array) pods_var_raw('object_fields', $this->pod->pod_data, array(), null, true);
            $object_field_objects = array('post_type', 'taxonomy', 'media', 'user', 'comment');
            if (empty($object_fields) && in_array($this->pod->pod_data['type'], $object_field_objects)) {
                $object_fields = $this->pod->api->get_wp_object_fields($this->pod->pod_data['type'], $this->pod->pod_data);
            }
            if (empty($fields)) {
                // Add core object fields if $fields is empty
                $fields = array_merge($object_fields, $this->pod->fields);
            }
        }
        $view_fields = $fields;
        // Temporary
        $fields = array();
        foreach ($view_fields as $k => $field) {
            $name = $k;
            $defaults = array('name' => $name, 'type' => 'text', 'options' => 'text');
            if (!is_array($field)) {
                $name = $field;
                $field = array('name' => $name);
            }
            $field = array_merge($defaults, $field);
            $field['name'] = trim($field['name']);
            $value = pods_var_raw('default', $field);
            if (empty($field['name'])) {
                $field['name'] = trim($name);
            }
            if (isset($object_fields[$field['name']])) {
                $field = array_merge($field, $object_fields[$field['name']]);
            } elseif (isset($this->pod->fields[$field['name']])) {
                $field = array_merge($this->pod->fields[$field['name']], $field);
            }
            if (pods_v('hidden', $field, false, null, true) || 'hidden' == $field['type']) {
                continue;
            } elseif (!PodsForm::permission($field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id())) {
                continue;
            }
            $fields[$field['name']] = $field;
            if (empty($this->id) && null !== $value) {
                $this->pod->row_override[$field['name']] = $value;
            }
        }
        unset($view_fields);
        // Cleanup
        ?>
		<div class="wrap pods-ui">
			<div id="icon-edit-pages" class="icon32"<?php 
        if (false !== $this->icon) {
            ?>
 style="background-position:0 0;background-size:100%;background-image:url(<?php 
            echo $this->icon;
            ?>
);"<?php 
        }
        ?>
><br /></div>
			<h2>
				<?php 
        echo $this->do_template($this->header['view']);
        if (!in_array('add', $this->actions_disabled) && !in_array('add', $this->actions_hidden)) {
            $link = pods_query_arg(array('action' . $this->num => 'add', 'id' . $this->num => '', 'do' . ($this->num = '')), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['add'])) {
                $link = $this->action_links['add'];
            }
            ?>
					<a href="<?php 
            echo $link;
            ?>
" class="add-new-h2"><?php 
            echo $this->heading['add'];
            ?>
</a>
				<?php 
        } elseif (!in_array('manage', $this->actions_disabled) && !in_array('manage', $this->actions_hidden)) {
            $link = pods_query_arg(array('action' . $this->num => 'manage', 'id' . $this->num => ''), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['manage'])) {
                $link = $this->action_links['manage'];
            }
            ?>
					<a href="<?php 
            echo $link;
            ?>
" class="add-new-h2">&laquo; <?php 
            echo sprintf(__('Back to %s', 'pods'), $this->heading['manage']);
            ?>
</a>
				<?php 
        }
        pods_view(PODS_DIR . 'ui/admin/view.php', compact(array_keys(get_defined_vars())));
        ?>

			</h2>
		</div>
	<?php 
    }
コード例 #10
0
ファイル: PodsData.php プロジェクト: ngdinhbinh/fine-interior
 /**
  * Recursively join tables based on fields
  *
  * @param array $traverse_recurse Array of traversal options
  *
  * @return array Array of table joins
  *
  * @since 2.0
  */
 function traverse_recurse($traverse_recurse)
 {
     global $wpdb;
     $defaults = array('pod' => null, 'fields' => array(), 'joined' => 't', 'depth' => 0, 'joined_id' => 'id', 'joined_index' => 'id', 'params' => new stdClass(), 'last_table_info' => array());
     $traverse_recurse = array_merge($defaults, $traverse_recurse);
     $joins = array();
     if (0 == $traverse_recurse['depth'] && !empty($traverse_recurse['pod']) && !empty($traverse_recurse['last_table_info']) && isset($traverse_recurse['last_table_info']['id'])) {
         $pod_data = $traverse_recurse['last_table_info'];
     } elseif (empty($traverse_recurse['pod'])) {
         if (!empty($traverse_recurse['params']) && !empty($traverse_recurse['params']->table) && 0 === strpos($traverse_recurse['params']->table, $wpdb->prefix)) {
             if ($wpdb->posts == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'post_type';
             } elseif ($wpdb->terms == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'taxonomy';
             } elseif ($wpdb->users == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'user';
             } elseif ($wpdb->comments == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'comment';
             } else {
                 return $joins;
             }
             $pod_data = array();
             if (in_array($traverse_recurse['pod'], array('user', 'comment'))) {
                 $pod = $this->api->load_pod(array('name' => $traverse_recurse['pod'], 'table_info' => true));
                 if (!empty($pod) && $pod['type'] == $pod) {
                     $pod_data = $pod;
                 }
             }
             if (empty($pod_data)) {
                 $pod_data = array('id' => 0, 'name' => '_table_' . $traverse_recurse['pod'], 'type' => $traverse_recurse['pod'], 'storage' => 'taxonomy' == $traverse_recurse['pod'] ? 'none' : 'meta', 'fields' => array(), 'object_fields' => $this->api->get_wp_object_fields($traverse_recurse['pod']));
                 $pod_data = array_merge($this->api->get_table_info($traverse_recurse['pod'], ''), $pod_data);
             }
             $traverse_recurse['pod'] = $pod_data['name'];
         } else {
             return $joins;
         }
     } else {
         $pod_data = $this->api->load_pod(array('name' => $traverse_recurse['pod'], 'table_info' => true), false);
         if (empty($pod_data)) {
             return $joins;
         }
     }
     if (isset($pod_data['object_fields'])) {
         $pod_data['fields'] = array_merge($pod_data['fields'], $pod_data['object_fields']);
     }
     $tableless_field_types = PodsForm::tableless_field_types();
     $simple_tableless_objects = PodsForm::simple_tableless_objects();
     $file_field_types = PodsForm::file_field_types();
     if (!isset($this->traversal[$traverse_recurse['pod']])) {
         $this->traversal[$traverse_recurse['pod']] = array();
     }
     if ((empty($pod_data['meta_table']) || $pod_data['meta_table'] == $pod_data['table']) && (empty($traverse_recurse['fields']) || empty($traverse_recurse['fields'][$traverse_recurse['depth']]))) {
         return $joins;
     }
     $field = $traverse_recurse['fields'][$traverse_recurse['depth']];
     $ignore_aliases = array('wpml_languages', 'polylang_languages');
     $ignore_aliases = apply_filters('pods_data_traverse_recurse_ignore_aliases', $ignore_aliases, $field, $traverse_recurse, $this);
     if (in_array($field, $ignore_aliases)) {
         return $joins;
     }
     $meta_data_table = false;
     if (!isset($pod_data['fields'][$field]) && 'd' == $field && isset($traverse_recurse['fields'][$traverse_recurse['depth'] - 1])) {
         $field = $traverse_recurse['fields'][$traverse_recurse['depth'] - 1];
         $field_type = 'pick';
         if (isset($traverse_recurse['last_table_info']['pod']['fields'][$field])) {
             $field_type = $traverse_recurse['last_table_info']['pod']['fields'][$field]['type'];
         } elseif (isset($traverse_recurse['last_table_info']['pod']['object_fields'][$field])) {
             $field_type = $traverse_recurse['last_table_info']['pod']['object_fields'][$field]['type'];
         }
         $pod_data['fields'][$field] = array('id' => 0, 'name' => $field, 'type' => $field_type, 'pick_object' => $traverse_recurse['last_table_info']['pod']['type'], 'pick_val' => $traverse_recurse['last_table_info']['pod']['name']);
         $meta_data_table = true;
     }
     // Fallback to meta table if the pod type supports it
     if (!isset($pod_data['fields'][$field])) {
         $last = end($traverse_recurse['fields']);
         if ('post_type' == $pod_data['type'] && !isset($pod_data['object_fields'])) {
             $pod_data['object_fields'] = $this->api->get_wp_object_fields('post_type', $pod_data);
         }
         if ('post_type' == $pod_data['type'] && isset($pod_data['object_fields'][$field]) && in_array($pod_data['object_fields'][$field]['type'], $tableless_field_types)) {
             $pod_data['fields'][$field] = $pod_data['object_fields'][$field];
         } elseif ('meta_value' === $last && in_array($pod_data['type'], array('post_type', 'media', 'user', 'comment'))) {
             $pod_data['fields'][$field] = PodsForm::field_setup(array('name' => $field));
         } else {
             if ('post_type' == $pod_data['type']) {
                 $pod_data['object_fields'] = $this->api->get_wp_object_fields('post_type', $pod_data, true);
                 if ('post_type' == $pod_data['type'] && isset($pod_data['object_fields'][$field]) && in_array($pod_data['object_fields'][$field]['type'], $tableless_field_types)) {
                     $pod_data['fields'][$field] = $pod_data['object_fields'][$field];
                 } else {
                     return $joins;
                 }
             } else {
                 return $joins;
             }
         }
     } elseif (isset($pod_data['object_fields']) && isset($pod_data['object_fields'][$field]) && !in_array($pod_data['object_fields'][$field]['type'], $tableless_field_types)) {
         return $joins;
     }
     $traverse = $pod_data['fields'][$field];
     if ('taxonomy' == $traverse['type']) {
         $traverse['table_info'] = $this->api->get_table_info($traverse['type'], $traverse['name']);
     } elseif (in_array($traverse['type'], $file_field_types)) {
         $traverse['table_info'] = $this->api->get_table_info('post_type', 'attachment');
     } elseif (!in_array($traverse['type'], $tableless_field_types)) {
         $traverse['table_info'] = $this->api->get_table_info($pod_data['type'], $pod_data['name'], $pod_data['name'], $pod_data);
     } elseif (empty($traverse['table_info']) || in_array($traverse['pick_object'], $simple_tableless_objects) && !empty($traverse_recurse['last_table_info'])) {
         if (in_array($traverse['pick_object'], $simple_tableless_objects) && !empty($traverse_recurse['last_table_info'])) {
             $traverse['table_info'] = $traverse_recurse['last_table_info'];
             if (!empty($traverse['table_info']['meta_table'])) {
                 $meta_data_table = true;
             }
         } elseif (!in_array($traverse['type'], $tableless_field_types) && !empty($traverse_recurse['last_table_info']) && 0 == $traverse_recurse['depth']) {
             $traverse['table_info'] = $traverse_recurse['last_table_info'];
         } else {
             if (!isset($traverse['pod'])) {
                 $traverse['pod'] = null;
             }
             $traverse['table_info'] = $this->api->get_table_info($traverse['pick_object'], $traverse['pick_val'], null, $traverse['pod'], $traverse);
         }
     }
     if (isset($this->traversal[$traverse_recurse['pod']][$traverse['name']])) {
         $traverse = array_merge($traverse, (array) $this->traversal[$traverse_recurse['pod']][$traverse['name']]);
     }
     $traverse = apply_filters('pods_data_traverse', $traverse, compact('pod', 'fields', 'joined', 'depth', 'joined_id', 'params'), $this);
     if (empty($traverse)) {
         return $joins;
     }
     $traverse['id'] = (int) $traverse['id'];
     if (empty($traverse['id'])) {
         $traverse['id'] = $field;
     }
     $table_info = $traverse['table_info'];
     $this->traversal[$traverse_recurse['pod']][$field] = $traverse;
     $field_joined = $field;
     if (0 < $traverse_recurse['depth'] && 't' != $traverse_recurse['joined']) {
         if ($meta_data_table && ('pick' != $traverse['type'] || !in_array(pods_var('pick_object', $traverse), $simple_tableless_objects))) {
             $field_joined = $traverse_recurse['joined'] . '_d';
         } else {
             $field_joined = $traverse_recurse['joined'] . '_' . $field;
         }
     }
     $rel_alias = 'rel_' . $field_joined;
     if (pods_v('search', $traverse_recurse['params'], false) && empty($traverse_recurse['params']->filters)) {
         if (0 < strlen(pods_var('filter_' . $field_joined, 'get'))) {
             $val = absint(pods_var('filter_' . $field_joined, 'get'));
             $search = "`{$field_joined}`.`{$table_info['field_id']}` = {$val}";
             if ('text' == $this->search_mode) {
                 $val = pods_var('filter_' . $field_joined, 'get');
                 $search = "`{$field_joined}`.`{$traverse['name']}` = '{$val}'";
             } elseif ('text_like' == $this->search_mode) {
                 $val = pods_sanitize(pods_sanitize_like(pods_var_raw('filter_' . $field_joined)));
                 $search = "`{$field_joined}`.`{$traverse['name']}` LIKE '%{$val}%'";
             }
             $this->search_where[] = " {$search} ";
         }
     }
     $the_join = null;
     $joined_id = $table_info['field_id'];
     $joined_index = $table_info['field_index'];
     if ('taxonomy' == $traverse['type']) {
         $rel_tt_alias = 'rel_tt_' . $field_joined;
         if ($meta_data_table) {
             $the_join = "\n                    LEFT JOIN `{$table_info['pod_table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['pod_field_id']}` = `{$traverse_recurse['rel_alias']}`.`{$traverse_recurse['joined_id']}`\n                ";
         } else {
             $the_join = "\n                    LEFT JOIN `{$wpdb->term_relationships}` AS `{$rel_alias}` ON\n                        `{$rel_alias}`.`object_id` = `{$traverse_recurse['joined']}`.`ID`\n\n                    LEFT JOIN `{$wpdb->term_taxonomy}` AS `{$rel_tt_alias}` ON\n                        `{$rel_tt_alias}`.`taxonomy` = '{$traverse['name']}'\n                        AND `{$rel_tt_alias}`.`term_taxonomy_id` = `{$rel_alias}`.`term_taxonomy_id`\n\n                    LEFT JOIN `{$table_info['table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['field_id']}` = `{$rel_tt_alias}`.`{$table_info['field_id']}`\n                ";
             // Override $rel_alias
             $rel_alias = $field_joined;
             $joined_id = $table_info['field_id'];
             $joined_index = $table_info['field_index'];
         }
     } elseif (in_array($traverse['type'], $tableless_field_types) && ('pick' != $traverse['type'] || !in_array(pods_v('pick_object', $traverse), $simple_tableless_objects))) {
         if (pods_tableless()) {
             $the_join = "\n                    LEFT JOIN `{$table_info['meta_table']}` AS `{$rel_alias}` ON\n                        `{$rel_alias}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n                        AND `{$rel_alias}`.`{$table_info['meta_field_id']}` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n\n                    LEFT JOIN `{$table_info['meta_table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n                        AND `{$field_joined}`.`{$table_info['meta_field_id']}` = CONVERT( `{$rel_alias}`.`{$table_info['meta_field_value']}`, SIGNED )\n                ";
             $joined_id = $table_info['meta_field_id'];
             $joined_index = $table_info['meta_field_index'];
         } elseif ($meta_data_table) {
             if ($traverse['id'] !== $traverse['pick_val']) {
                 // This must be a relationship
                 $joined_id = 'related_item_id';
             } else {
                 $joined_id = $traverse_recurse['joined_id'];
             }
             $the_join = "\n                     LEFT JOIN `{$table_info['pod_table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['pod_field_id']}` = `{$traverse_recurse['rel_alias']}`.`{$joined_id}`\n                 ";
         } else {
             $the_join = "\n                    LEFT JOIN `@wp_podsrel` AS `{$rel_alias}` ON\n                        `{$rel_alias}`.`field_id` = {$traverse['id']}\n                        AND `{$rel_alias}`.`item_id` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n\n                    LEFT JOIN `{$table_info['table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['field_id']}` = `{$rel_alias}`.`related_item_id`\n                ";
         }
     } elseif ('meta' == $pod_data['storage']) {
         if ($traverse_recurse['depth'] + 2 == count($traverse_recurse['fields']) && ('pick' != $traverse['type'] || !in_array(pods_var('pick_object', $traverse), $simple_tableless_objects)) && $table_info['meta_field_value'] == $traverse_recurse['fields'][$traverse_recurse['depth'] + 1]) {
             $the_join = "\n                    LEFT JOIN `{$table_info['meta_table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n                        AND `{$field_joined}`.`{$table_info['meta_field_id']}` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n                ";
             $table_info['recurse'] = false;
         } else {
             $the_join = "\n                    LEFT JOIN `{$table_info['meta_table']}` AS `{$field_joined}` ON\n                        `{$field_joined}`.`{$table_info['meta_field_index']}` = '{$traverse['name']}'\n                        AND `{$field_joined}`.`{$table_info['meta_field_id']}` = `{$traverse_recurse['joined']}`.`{$traverse_recurse['joined_id']}`\n                ";
             $joined_id = $table_info['meta_field_id'];
             $joined_index = $table_info['meta_field_index'];
         }
     }
     $traverse_recursive = array('pod' => pods_var_raw('name', pods_var_raw('pod', $table_info)), 'fields' => $traverse_recurse['fields'], 'joined' => $field_joined, 'depth' => $traverse_recurse['depth'] + 1, 'joined_id' => $joined_id, 'joined_index' => $joined_index, 'params' => $traverse_recurse['params'], 'rel_alias' => $rel_alias, 'last_table_info' => $table_info);
     $the_join = apply_filters('pods_data_traverse_the_join', $the_join, $traverse_recurse, $traverse_recursive, $this);
     if (empty($the_join)) {
         return $joins;
     }
     $joins[$traverse_recurse['pod'] . '_' . $traverse_recurse['depth'] . '_' . $traverse['id']] = $the_join;
     if ($traverse_recurse['depth'] + 1 < count($traverse_recurse['fields']) && !empty($traverse_recurse['pod']) && false !== $table_info['recurse']) {
         $joins = array_merge($joins, $this->traverse_recurse($traverse_recursive));
     }
     return $joins;
 }
コード例 #11
0
 /**
  * Throw admin warnings for post types that have archive templates set, but don't support archives
  *
  * @since 2.4.5
  */
 function archive_warning()
 {
     //create $page variable to check if we are on pods admin page
     $page = pods_v('page', 'get', false, true);
     //check if we are on Pods Admin page
     if ($page === 'pods') {
         $archive_test = $this->archive_test();
         if (is_array($archive_test)) {
             foreach ($archive_test as $label => $test) {
                 if ($test === 'fail') {
                     echo sprintf('<div id="message" class="error"><p>%s</p></div>', sprintf(__('The Pods post type %1$s has an archive template set to be displayed using Pods auto template, but the Pod does not have an archive. You can enable post type archives in the "Advanced Options" tab.', 'pfat'), $label));
                 }
             }
         }
     }
 }
コード例 #12
0
/**
 * Output a video field as a video player.
 *
 * @uses wp_video_shortcode()
 *
 * @since 2.5
 *
 * @param string|array   $url   Can be a URL of the source file, or a Pods video field.
 * @param bool|array     $args  Optional. Additional arguments to pass to wp_video_shortcode()
 *
 * @return string
 */
function pods_video($url, $args = false)
{
    if (is_array($url)) {
        if (!is_null(pods_v('ID', $url))) {
            $id = pods_v('ID', $url);
            $url = wp_get_attachment_url($id);
        } else {
            return;
        }
    }
    $video_args = array('src' => $url);
    if (is_array($args)) {
        $video_args = array_merge($video_args, $args);
    }
    return wp_video_shortcode($video_args);
}
コード例 #13
0
 * @package pods_s
 */
pods_s_get_header();
?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main" role="main">

		<?php 
if (have_posts()) {
    //Build pods object for current item or return false if no Pod for this content type
    $pods = pods(null, get_the_ID(), true);
    //get name of pod
    if ($pods) {
        $pod_name = pods_s_get_content_type(true);
        $pod_name = pods_v('specific_type', $pod_name, false, true);
    }
    while (have_posts()) {
        the_post();
        //test if we have a valid Pods object.
        if ($pods and $pod_name) {
            //Output template of the same name as Pod, if such a template exists.
            //if it doesn't output template part
            $temp = $pods->template($pod_name);
            if (isset($temp)) {
                echo $temp;
            } else {
                pods_s_get_template_part('content', pods_s_part_by_post_type(), compact(array('pods')));
            }
        } else {
            pods_s_get_template_part('content', pods_s_part_by_post_type());
コード例 #14
0
ファイル: checkin.php プロジェクト: Ingothq/ingSL
 /**
  * Prepare data to be saved
  *
  * @param array $data
  */
 protected function prepare_data($data)
 {
     $details = pods_v_sanitized('details', $data, [], true);
     $this->data = ['datetime' => current_time('mysql'), 'license' => $this->get_license_id($data['license']), 'url' => pods_v_sanitized('url', $data, null), 'wp_ver' => pods_v_sanitized('wp_version', $details, 0), 'ingot_ver' => pods_v_sanitized('ingot_version', $details, 0), 'php_ver' => pods_v_sanitized('php_version', $details, 0), 'vertical' => pods_v_sanitized('ing_vertical', $details, 0), 'trial' => boolval(pods_v('trial', $data, false, true))];
 }
コード例 #15
0
        }
        $more = true;
        $extra = '';
        $max_length = (int) pods_var('maxlength', $field['options'], pods_var($field['type'] . '_max_length', $field['options'], 0), null, true);
        if (0 < $max_length) {
            $extra .= ' maxlength="' . esc_attr($max_length) . '"';
        }
        /**
         * Filter that lets you make the title field readonly
         *
         * @param Pods $pod Current Pods object.
         * @param PodsUI $obj Current PodsUI object.
         *
         * @since 2.5
         */
        if (pods_v('readonly', $field['options'], pods_v('readonly', $field, false)) || apply_filters('pods_ui_form_title_readonly', false, $pod, $obj)) {
            ?>
                                    <div id="titlediv">
                                        <div id="titlewrap">
                                            <h3><?php 
            echo esc_html($pod->index());
            ?>
</h3>
                                            <input type="hidden" name="pods_field_<?php 
            echo esc_attr($pod->pod_data['field_index']);
            ?>
" data-name-clean="pods-field-<?php 
            echo esc_attr($pod->pod_data['field_index']);
            ?>
" id="title" size="30" tabindex="1" value="<?php 
            echo esc_attr(htmlspecialchars($pod->index()));
コード例 #16
0
/**
 * Check if permissions are restricted
 *
 * @param array $options
 *
 * @return bool Whether the permissions are restricted
 *
 * @since 2.3.4
 */
function pods_has_permissions($options)
{
    $permission = false;
    if (isset($options['options'])) {
        $options = $options['options'];
    }
    if (1 == pods_v('restrict_role', $options, 0) || 1 == pods_v('restrict_capability', $options, 0) || 1 == pods_v('admin_only', $options, 0)) {
        return true;
    }
    return false;
}
コード例 #17
0
    $attachment['thumbnail'] = $thumb[0];
    $attachment['link'] = '';
    if ($linked) {
        $attachment['link'] = wp_get_attachment_url($attachment['ID']);
    }
    $attachment = apply_filters('pods_media_attachment', $attachment);
    echo $field_file->markup($attributes, $file_limit, $title_editable, $attachment['ID'], $attachment['thumbnail'], $attachment['post_title']);
}
?>
</ul>

    <a class="button pods-file-add pods-media-add" href="<?php 
echo esc_url(admin_url('media-upload.php?inlineId=pods_media_attachment' . $the_post_id . '&tab=' . $tab . '&TB_iframe=1&width=640&height=1500&pods_pod=' . $pod->pod . '&pods_pod_id=' . $pod->pod . '&pods_field=' . $options['name'] . '&pods_field_id=' . $options['id'] . '&pods_uri_hash=' . $uri_hash . '&pods_field_nonce=' . $field_nonce));
?>
"><?php 
echo pods_v($form_field_type . '_add_button', $options, __('Add File', 'pods'));
?>
</a>
</div>

<script type="text/x-handlebars" id="<?php 
echo $css_id;
?>
-handlebars">
    <?php 
echo $field_file->markup($attributes, $file_limit, $title_editable);
?>
</script>

<script type="text/javascript">
    jQuery( function ( $ ) {
コード例 #18
0
ファイル: PodsInit.php プロジェクト: benbrandt/pods
 /**
  * Add REST API support to post type and taxonomy objects.
  *
  * @uses "init"
  *
  * @since 2.5.6
  */
 public function add_rest_support()
 {
     static $rest_support_added;
     if (!function_exists('register_rest_field')) {
         return;
     }
     include_once PODS_DIR . 'classes/PodsRESTFields.php';
     include_once PODS_DIR . 'classes/PodsRESTHandlers.php';
     $rest_bases = pods_transient_get('pods_rest_bases');
     if (empty($rest_bases)) {
         $pods = pods_api()->load_pods();
         $rest_bases = array();
         if (!empty($pods) && is_array($pods)) {
             foreach ($pods as $pod) {
                 $type = $pod['type'];
                 if (in_array($type, array('post_type', 'taxonomy'))) {
                     if ($pod && PodsRESTHandlers::pod_extends_core_route($pod)) {
                         $rest_bases[$pod['name']] = array('type' => $type, 'base' => sanitize_title(pods_v('rest_base', $pod['options'], $pod['name'])));
                     }
                 }
             }
         }
         if (empty($rest_bases)) {
             $rest_bases = 'none';
         }
         pods_transient_set('pods_rest_bases', $rest_bases);
     }
     if (empty($rest_support_added) && !empty($rest_bases) && 'none' !== $rest_bases) {
         foreach ($rest_bases as $pod_name => $pod_info) {
             $pod_type = $pod_info['type'];
             $rest_base = $pod_info['base'];
             if ('post_type' == $pod_type) {
                 PodsRESTHandlers::post_type_rest_support($pod_name, $rest_base);
             } elseif ('taxonomy' == $pod_type) {
                 PodsRESTHandlers::taxonomy_rest_support($pod_name, $rest_base);
             }
             new PodsRESTFields($pod_name);
         }
         $rest_support_added = true;
     }
 }
<?php

/**
 * Get diffrent URL segment if in a local environment with a diffrent directory structure.
 *
 * In local wp-config set: define( 'LOCAL_ENV', true );
 */
$pod_name = pods_v(0, 'url');
$slug = pods_v(1, 'url');
if (defined('LOCAL_ENV') && LOCAL_ENV) {
    $pod_name = pods_v(1, 'url');
    $slug = pods_v(2, 'url');
}
$pods = pods($pod_name, $slug);
コード例 #20
0
 /**
  * Get all Pods with auto template enable and its settings
  *
  * @return array With info about auto template settings per post type
  *
  * @since 2.4.5
  */
 function auto_pods()
 {
     /**
      * Filter to override all settings for which templates are used.
      *
      * Note: If this filter does not return null, all back-end settings are ignored. To add to settings with a filter, use 'pods_pfat_auto_pods';
      *
      * @param array $auto_pods Array of parameters to use instead of those from settings.
      *
      * @return array Settings arrays for each post type.
      *
      * @since 2.4.5
      */
     $auto_pods = apply_filters('pods_pfat_auto_pods_override', null);
     if (!is_null($auto_pods)) {
         return $auto_pods;
     }
     //try to get cached results of this method
     $key = '_pods_pfat_auto_pods';
     $auto_pods = pods_transient_get($key);
     //check if we already have the results cached & use it if we can.
     if ($auto_pods === false) {
         //get possible pods
         $the_pods = $this->the_pods();
         //start output array empty
         $auto_pods = array();
         //get pods api class
         $api = pods_api();
         //loop through each to see if auto templates is enabled
         foreach ($the_pods as $the_pod => $the_pod_label) {
             //get this Pods' data.
             $pod_data = $api->load_pod(array('name' => $the_pod));
             //if auto template is enabled add info about Pod to array
             if (1 == pods_v('pfat_enable', $pod_data['options'])) {
                 //check if pfat_single and pfat_archive are set
                 $single = pods_v('pfat_single', $pod_data['options'], false, true);
                 $archive = pods_v('pfat_archive', $pod_data['options'], false, true);
                 $single_append = pods_v('pfat_append_single', $pod_data['options'], true, true);
                 $archive_append = pods_v('pfat_append_archive', $pod_data['options'], true, true);
                 $single_filter = pods_v('pfat_filter_single', $pod_data['options'], 'the_content', true);
                 $archive_filter = pods_v('pfat_filter_archive', $pod_data['options'], 'the_content', true);
                 $type = pods_v('type', $pod_data, false, true);
                 //check if it's a post type that has an arhive
                 if ($type === 'post_type' && $the_pod !== 'post' || $the_pod !== 'page') {
                     $has_archive = pods_v('has_archive', $pod_data['options'], false, true);
                 } else {
                     $has_archive = true;
                 }
                 if (empty($single_filter)) {
                     $single_filter = 'the_content';
                 }
                 if (empty($archive_filter)) {
                     $archive_filter = 'the_content';
                 }
                 //build output array
                 $auto_pods[$the_pod] = array('name' => $the_pod, 'label' => $the_pod_label, 'single' => $single, 'archive' => $archive, 'single_append' => $single_append, 'archive_append' => $archive_append, 'has_archive' => $has_archive, 'single_filter' => $single_filter, 'archive_filter' => $archive_filter, 'type' => $type);
             }
         }
         //endforeach
         //cache the results
         pods_transient_set($key, $auto_pods);
     }
     /**
      * Add to or change settings.
      *
      * Use this filter to change or add to the settings set in the back-end for this plugin. Has no effect if 'pods_pfat_auto_pods_override' filter is being used.
      *
      * @param array $auto_pods Array of parameters to use instead of those from settings.
      *
      * @return array Settings arrays for each post type.
      *
      * @since 2.4.5
      */
     $auto_pods = apply_filters('pods_pfat_auto_pods', $auto_pods);
     return $auto_pods;
 }
コード例 #21
0
ファイル: PodsAdmin.php プロジェクト: benbrandt/pods
 /**
  * Populate REST API tab.
  *
  * @since 0.1.0
  *
  * @param array $options
  * @param array $pod
  *
  * @return array
  */
 public function add_rest_settings_tab_fields($options, $pod)
 {
     if (!function_exists('register_rest_field')) {
         $options['rest-api'] = array('no_dependencies' => array('label' => __(sprintf('Pods REST API support requires WordPress 4.3.1 or later and the %s or later.', '<a href="http://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">WordPress REST API 2.0-beta9</a>'), 'pods'), 'help' => __(sprintf('See %s for more information.', '<a href="http://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">http://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/</a>'), 'pods'), 'type' => 'html'));
     } elseif ($this->restable_pod($pod)) {
         $options['rest-api'] = array('rest_enable' => array('label' => __('Enable', 'pods'), 'help' => __('Add REST API support for this Pod.', 'pods'), 'type' => 'boolean', 'default' => '', 'dependency' => true), 'rest_base' => array('label' => __('Rest Base', 'pods'), 'help' => __('This will form the url for the route.', 'pods'), 'type' => 'text', 'default' => pods_v('name', $pod), 'boolean_yes_label' => '', 'depends-on' => array('rest_enable' => true)), 'read_all' => array('label' => __('Show All Fields?', 'pods'), 'help' => __('Show all fields in REST API. If unchecked fields must be enabled on a field by field basis.', 'pods'), 'type' => 'boolean', 'default' => '', 'boolean_yes_label' => '', 'depends-on' => array('rest_enable' => true)), 'write_all' => array('label' => __('Allow All Fields To Be Updated?', 'pods'), 'help' => __('Allow all fields to be updated via the REST API. If unchecked fields must be enabled on a field by field basis.', 'pods'), 'type' => 'boolean', 'default' => pods_v('name', $pod), 'boolean_yes_label' => '', 'depends-on' => array('rest_enable' => true)));
     } else {
         $options['rest-api'] = array('not_restable' => array('label' => __('Pods REST API support covers post type, taxonomy and user Pods.', 'pods'), 'help' => __(sprintf('See %s for more information.', '<a href="http://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/" target="_blank">http://pods.io/docs/build/extending-core-wordpress-rest-api-routes-with-pods/"</a>'), 'pods'), 'type' => 'html'));
     }
     return $options;
 }
/**
 *
 * Template Name: Pods Single
 *
 * Use this as a page template for Pods Pages single item, to show a Pods template of the same name as the pod
 */
get_header();
?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">
			<?php 
//setup Pod object presuming permalink structure of example.com/pod-name/item-name
//get current item name
$slug = pods_v('last', 'url');
//get current pod name
$pod_name = pods_(0, 'url');
//get pods object
$pods = pods($pod_name, $slug);
?>
			<article>
				<?php 
//Output template of the same name as Pod, if such a template exists.
$temp = $pods->template($pod_name);
if (isset($temp)) {
    echo $temp;
}
?>
			</article><!-- #post -->
		</div><!-- #content -->
コード例 #23
0
 /**
  * Get find() params based on current UI action
  *
  * @param null|array $params
  * @param null|string $action
  */
 public function get_params($params = null, $action = null)
 {
     if (null === $action) {
         $action = $this->action;
     }
     $defaults = array('full' => false, 'flatten' => true, 'fields' => null, 'type' => '');
     if (!empty($params) && is_array($params)) {
         $params = (object) array_merge($defaults, $params);
     } else {
         $params = (object) $defaults;
     }
     if (!in_array($action, array('manage', 'reorder'))) {
         $action = 'manage';
     }
     $params_override = false;
     $orderby = array();
     $limit = $this->limit;
     $sql = null;
     if ('reorder' == $this->action) {
         if (!empty($this->reorder['orderby'])) {
             $orderby[$this->reorder['orderby']] = $this->reorder['orderby_dir'];
         } else {
             $orderby[$this->reorder['on']] = $this->reorder['orderby_dir'];
         }
         if (!empty($this->reorder['limit'])) {
             $limit = $this->reorder['limit'];
         }
         if (!empty($this->reorder['sql'])) {
             $sql = $this->reorder['sql'];
         }
     }
     if (!empty($this->orderby)) {
         $this->orderby = (array) $this->orderby;
         foreach ($this->orderby as $order) {
             if (false !== strpos($order, ' ')) {
                 $orderby[] = $order;
             } elseif (!isset($orderby[$order])) {
                 $orderby[$order] = $this->orderby_dir;
             }
         }
     }
     if (false !== $this->pod && is_object($this->pod) && ('Pods' == get_class($this->pod) || 'Pod' == get_class($this->pod))) {
         $find_params = array('where' => pods_v($action, $this->where, null, true), 'orderby' => $orderby, 'page' => (int) $this->page, 'pagination' => true, 'limit' => (int) $limit, 'search' => $this->searchable, 'search_query' => $this->search, 'search_across' => $this->search_across, 'search_across_picks' => $this->search_across_picks, 'filters' => $this->filters, 'sql' => $sql);
         $params_override = true;
     } else {
         $find_params = array('table' => $this->sql['table'], 'id' => $this->sql['field_id'], 'index' => $this->sql['field_index'], 'where' => pods_v($action, $this->where, null, true), 'orderby' => $orderby, 'page' => (int) $this->page, 'pagination' => true, 'limit' => (int) $limit, 'search' => $this->searchable, 'search_query' => $this->search, 'fields' => $this->fields['search'], 'sql' => $sql);
         if (!empty($this->sql['select'])) {
             $find_params['select'] = $this->sql['select'];
         }
     }
     if (empty($find_params['where']) && $this->restricted($this->action)) {
         $find_params['where'] = $this->pods_data->query_fields($this->restrict[$this->action], is_object($this->pod) ? $this->pod->pod_data : null);
     }
     if ($params_override) {
         $find_params = array_merge($find_params, (array) $this->params);
     }
     if ($params->full) {
         $find_params['limit'] = -1;
     }
     // Debug purposes
     if (1 == pods_v('pods_debug_params', 'get', 0) && pods_is_admin(array('pods'))) {
         pods_debug($find_params);
     }
     return $find_params;
 }
コード例 #24
0
    } elseif (isset($_POST['pods_reset'])) {
        $pods_init->reset();
        $pods_init->setup();
        pods_redirect(pods_var_update(array('pods_reset_success' => 1), array('page', 'tab')));
    } elseif (isset($_POST['pods_reset_deactivate'])) {
        $pods_init->reset();
        deactivate_plugins(PODS_DIR . 'init.php');
        pods_redirect('index.php');
    } elseif (1 == pods_v('pods_reset_success')) {
        pods_message('Pods 2.x settings and data have been reset.');
    } elseif (1 == pods_v('pods_cleanup_1x_success')) {
        pods_message('Pods 1.x data has been deleted.');
    }
}
// Monday Mode
$monday_mode = pods_v('pods_monday_mode', 'get', 0, true);
if (pods_var('pods_reset_weekend', 'post', pods_var('pods_reset_weekend', 'get', 0, null, true), null, true)) {
    if ($monday_mode) {
        $html = '<br /><br /><iframe width="480" height="360" src="http://www.youtube-nocookie.com/embed/QH2-TGUlwu4?autoplay=1" frameborder="0" allowfullscreen></iframe>';
        pods_message('The weekend has been reset and you have been sent back to Friday night. Unfortunately due to a tear in the fabric of time, you slipped back to Monday. We took video of the whole process and you can see it below..' . $html);
    } else {
        $html = '<br /><br /><iframe width="480" height="360" src="http://www.youtube-nocookie.com/embed/xhrBDcQq2DM?autoplay=1" frameborder="0" allowfullscreen></iframe>';
        pods_message('Oops, sorry! You can only reset the weekend on a Monday before the end of the work day. Somebody call the Waaambulance!' . $html, 'error');
    }
}
$old_version = get_option('pods_version');
if (!empty($old_version)) {
    ?>
    <h3><?php 
    _e('Delete Pods 1.x data', 'pods');
    ?>
コード例 #25
0
ファイル: general.php プロジェクト: pods-framework/pods
/**
 * A fork of get_page_by_title that excludes items unavailable via access rights (by status)
 *
 * @see get_page_by_title
 *
 * @param string $title Title of item to get
 * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
 * @param string $type Post Type
 * @param string|array $status Post statuses to include (default is what user has access to)
 *
 * @return WP_Post|null WP_Post on success or null on failure
 *
 * @since 2.3.4
 */
function pods_by_title($title, $output = OBJECT, $type = 'page', $status = null)
{
    // @todo support Pod item lookups, not just Post Types
    /**
     * @var $wpdb WPDB
     */
    global $wpdb;
    if (empty($status)) {
        $status = array('publish');
        if (current_user_can('read_private_' . $type . 's')) {
            $status[] = 'private';
        }
        if (current_user_can('edit_' . $type . 's')) {
            $status[] = 'draft';
        }
    }
    $status = (array) $status;
    $status_sql = ' AND `post_status` IN ( %s' . str_repeat(', %s', count($status) - 1) . ' )';
    $orderby_sql = ' ORDER BY ( `post_status` = %s ) DESC' . str_repeat(', ( `post_status` = %s ) DESC', count($status) - 1) . ', `ID` DESC';
    $prepared = array_merge(array($title, $type), $status, $status);
    // once for WHERE, once for ORDER BY
    $page = $wpdb->get_var($wpdb->prepare("SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_title` = %s AND `post_type` = %s" . $status_sql . $orderby_sql, $prepared));
    if ($page) {
        return get_post(pods_v($page, 'post_id'), $output);
    }
    return null;
}
コード例 #26
0
 /**
  * Reformat a number to the way the value of the field is displayed
  *
  * @param mixed $value
  * @param string $name
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @return string
  * @since 2.0
  */
 public function format($value = null, $name = null, $options = null, $pod = null, $id = null)
 {
     global $wp_locale;
     if (null === $value) {
         // Don't enforce a default value here
         return null;
     }
     if ('9.999,99' == pods_v(self::$type . '_format', $options)) {
         $thousands = '.';
         $dot = ',';
     } elseif ('9,999.99' == pods_v(self::$type . '_format', $options)) {
         $thousands = ',';
         $dot = '.';
     } elseif ('9\'999.99' == pods_v(self::$type . '_format', $options)) {
         $thousands = '\'';
         $dot = '.';
     } elseif ('9 999,99' == pods_v(self::$type . '_format', $options)) {
         $thousands = ' ';
         $dot = ',';
     } elseif ('9999.99' == pods_v(self::$type . '_format', $options)) {
         $thousands = '';
         $dot = '.';
     } elseif ('9999,99' == pods_v(self::$type . '_format', $options)) {
         $thousands = '';
         $dot = ',';
     } else {
         $thousands = $wp_locale->number_format['thousands_sep'];
         $dot = $wp_locale->number_format['decimal_point'];
     }
     $length = (int) pods_v(self::$type . '_max_length', $options, 12, true);
     if ($length < 1 || 64 < $length) {
         $length = 64;
     }
     $decimals = (int) pods_v(self::$type . '_decimals', $options, 2);
     if ($decimals < 1) {
         $decimals = 0;
     } elseif (30 < $decimals) {
         $decimals = 30;
     }
     if ($length < $decimals) {
         $decimals = $length;
     }
     if ('i18n' == pods_v(self::$type . '_format', $options)) {
         $value = number_format_i18n((double) $value, $decimals);
     } else {
         $value = number_format((double) $value, $decimals, $dot, $thousands);
     }
     return $value;
 }
コード例 #27
0
ファイル: PodsRESTHandlers.php プロジェクト: benbrandt/pods
 /**
  * Check if a Pod supports extending core REST response.
  *
  * @since 2.5.6
  *
  * @param array|Pods $pod Pod object or the pod_data array
  *
  * @return bool
  */
 public static function pod_extends_core_route($pod)
 {
     $enabled = false;
     if (is_object($pod)) {
         $pod = $pod->pod_data;
     }
     if (is_array($pod)) {
         $enabled = (bool) pods_v('rest_enable', $pod['options'], false);
     }
     return $enabled;
 }
コード例 #28
0
ファイル: PodsMeta.php プロジェクト: talentedunicorn/pods
 /**
  * @param $comment_id
  */
 public function save_comment($comment_id)
 {
     $groups = $this->groups_get('comment', 'comment');
     if (empty($groups)) {
         return $comment_id;
     } elseif (empty($_POST)) {
         return $comment_id;
     } elseif (!wp_verify_nonce(pods_v('pods_meta', 'post'), 'pods_meta_comment')) {
         return $comment_id;
     }
     $data = array();
     $id = $comment_id;
     $pod = null;
     foreach ($groups as $group) {
         if (empty($group['fields'])) {
             continue;
         }
         if (null === $pod || is_object($pod) && $pod->id() != $id) {
             if (!is_object(self::$current_pod) || self::$current_pod->pod != $group['pod']['name']) {
                 self::$current_pod = pods($group['pod']['name'], $id, true);
             } elseif (self::$current_pod->id() != $id) {
                 self::$current_pod->fetch($id);
             }
             $pod = self::$current_pod;
         }
         foreach ($group['fields'] as $field) {
             if (false === PodsForm::permission($field['type'], $field['name'], $field, $group['fields'], $pod, $id)) {
                 if (!pods_var('hidden', $field['options'], false)) {
                     continue;
                 }
             }
             $data[$field['name']] = '';
             if (isset($_POST['pods_meta_' . $field['name']])) {
                 $data[$field['name']] = $_POST['pods_meta_' . $field['name']];
             }
         }
     }
     do_action('pods_meta_save_pre_comment', $data, $pod, $id, $groups);
     if (!empty($pod)) {
         // Fix for Pods doing it's own sanitization
         $data = pods_unslash((array) $data);
         $pod->save($data);
     } elseif (!empty($id)) {
         pods_no_conflict_on('comment');
         foreach ($data as $field => $value) {
             update_comment_meta($id, $field, $value);
         }
         pods_no_conflict_off('comment');
     }
     do_action('pods_meta_save_comment', $data, $pod, $id, $groups);
     return $comment_id;
 }
コード例 #29
0
ファイル: PodsForm.php プロジェクト: erkmen/wpstartersetup
 /**
  * Parse the default the value
  *
  * @since 2.0
  */
 public static function default_value($value, $type = 'text', $name = null, $options = null, $pod = null, $id = null)
 {
     $default_value = pods_v('default_value', $options);
     if ('' === $default_value || null === $default_value) {
         $default_value = $value;
     }
     $default = pods_v('default', $options, $default_value, true);
     $default_value = str_replace(array('{@', '}'), '', trim($default));
     if ($default != $default_value && 1 == (int) pods_v('default_evaluate_tags', $options, 1)) {
         $default = pods_evaluate_tags($default);
     }
     $default = pods_var_raw(pods_v('default_value_parameter', $options), 'request', $default, null, true);
     if ($default != $value) {
         $value = $default;
     }
     if (is_array($value)) {
         $value = pods_serial_comma($value);
     }
     return apply_filters('pods_form_field_default_value', $value, $default, $type, $options, $pod, $id);
 }
コード例 #30
0
/**
 * Recurse list of items and make it hierarchical
 *
 * @param int $parent Parent ID
 * @param array|object $list List of items
 * @param array $args Array of parent, children, and id keys to use
 *
 * @return array|object
 * @since 2.3
 */
function pods_hierarchical_list_recurse($parent, $list, &$args)
{
    $new = array();
    $object = false;
    if (is_object($list)) {
        $object = true;
        $list = get_object_vars($list);
    }
    $args['current_depth']++;
    $depth = $args['current_depth'];
    if (0 == $depth) {
        $args['list'] = $list;
    }
    foreach ($list as $k => $list_item) {
        if (is_object($list_item) && isset($list_item->{$args['id']})) {
            $list_item->{$args['parent']} = (int) pods_v($args['parent'], $list_item);
            if (is_array($list_item->{$args['parent']}) && isset($list_item->{$args['parent']}[$args['id']]) && $parent == $list_item->{$args['parent']}[$args['id']]) {
                $list_item->{$args['children']} = pods_hierarchical_list_recurse($list_item->{$args['id']}, $list, $args);
            } elseif ($parent == $list_item->{$args['parent']} || 0 == $depth && $parent == $list_item->{$args['id']}) {
                $list_item->{$args['children']} = pods_hierarchical_list_recurse($list_item->{$args['id']}, $list, $args);
            } else {
                continue;
            }
            $args['found'][$k] = $list_item;
        } elseif (is_array($list_item) && isset($list_item[$args['id']])) {
            $list_item[$args['parent']] = (int) pods_v($args['parent'], $list_item);
            if (is_array($list_item[$args['parent']]) && isset($list_item[$args['parent']][$args['id']]) && $parent == $list_item[$args['parent']][$args['id']]) {
                $list_item[$args['children']] = pods_hierarchical_list_recurse($list_item[$args['id']], $list, $args);
            } elseif ($parent == $list_item[$args['parent']] || 0 == $depth && $parent == $list_item[$args['id']]) {
                $list_item[$args['children']] = pods_hierarchical_list_recurse($list_item[$args['id']], $list, $args);
            } else {
                continue;
            }
            $args['found'][$k] = $list_item;
        } else {
            continue;
        }
        $new[$k] = $list_item;
        $args['current_depth'] = $depth;
    }
    if (0 == $depth && empty($new) && !empty($list)) {
        $first = current(array_slice($list, 0, 1));
        $new_parent = 0;
        $args['current_depth'] = -1;
        if (is_object($first) && isset($first->{$args['parent']})) {
            $new_parent = (int) $first->{$args['parent']};
        } elseif (is_array($first) && isset($first[$args['parent']])) {
            $new_parent = (int) $first[$args['parent']];
        }
        if (!empty($new_parent)) {
            $new = pods_hierarchical_list_recurse($new_parent, $list, $args);
        }
    }
    if (0 == $depth) {
        $orphans = array();
        foreach ($args['list'] as $k => $list_item) {
            if (!isset($args['found'][$k])) {
                $orphans[$k] = $list_item;
            }
        }
        if (!empty($orphans)) {
            foreach ($orphans as $orphan) {
                $new[] = $orphan;
            }
        }
    }
    if ($object) {
        $new = (object) $new;
    }
    return $new;
}