Ejemplo n.º 1
0
 /**
  * Load activated components and init component
  *
  * @since 2.0
  */
 public function load()
 {
     do_action('pods_components_load');
     foreach ((array) $this->components as $component => $component_data) {
         $component_data['MustUse'] = apply_filters('pods_component_require_' . $component_data['ID'], $component_data['MustUse'], $component_data);
         if (false === $component_data['MustUse'] && (!isset($this->settings['components'][$component]) || 0 == $this->settings['components'][$component])) {
             continue;
         }
         if (!empty($component_data['PluginDependency'])) {
             $dependency = explode('|', $component_data['PluginDependency']);
             if (!pods_is_plugin_active($dependency[1])) {
                 continue;
             }
         }
         if (!empty($component_data['ThemeDependency'])) {
             $dependency = explode('|', $component_data['ThemeDependency']);
             if (strtolower($dependency[1]) != strtolower(get_template()) && strtolower($dependency[1]) != strtolower(get_stylesheet())) {
                 continue;
             }
         }
         if (false === $component_data['External']) {
             $component_data['File'] = realpath($this->components_dir . $component_data['File']);
         }
         if (empty($component_data['File'])) {
             pods_transient_clear('pods_components');
             continue;
         }
         if (!file_exists($component_data['File'])) {
             pods_message('Pods Component not found: ' . $component_data['File']);
             pods_transient_clear('pods_components');
             continue;
         }
         include_once $component_data['File'];
         if (!empty($component_data['Class']) && class_exists($component_data['Class']) || isset($component_data['object'])) {
             if (!isset($this->components[$component]['object'])) {
                 $this->components[$component]['object'] = new $component_data['Class']();
             }
             if (method_exists($this->components[$component]['object'], 'options')) {
                 if (isset($this->settings['components'][$component])) {
                     $this->components[$component]['options'] = $this->components[$component]['object']->options($this->settings['components'][$component]);
                 } else {
                     $this->components[$component]['options'] = $this->components[$component]['object']->options(array());
                 }
                 $this->options($component, $this->components[$component]['options']);
             } else {
                 $this->options($component, array());
             }
             if (method_exists($this->components[$component]['object'], 'handler')) {
                 $this->components[$component]['object']->handler($this->settings['components'][$component]);
             }
         }
     }
 }
<?php

if (!empty($_POST)) {
    if (isset($_POST['clearcache'])) {
        $api = pods_api();
        $api->cache_flush_pods();
        if (defined('PODS_PRELOAD_CONFIG_AFTER_FLUSH') && PODS_PRELOAD_CONFIG_AFTER_FLUSH) {
            $api->load_pods();
        }
        pods_redirect(pods_query_arg(array('pods_clearcache' => 1), array('page', 'tab')));
    }
} elseif (1 == pods_var('pods_clearcache')) {
    pods_message('Pods transients and cache have been cleared.');
}
?>

<h3><?php 
_e('Clear Pods Cache', 'pods');
?>
</h3>

<p><?php 
_e('This tool will clear all of the transients/cache that are used by Pods. ', 'pods');
?>
</p>

<p class="submit">
    <input type="submit" class="button button-primary" name="clearcache" value="<?php 
esc_attr_e('Clear Pods Cache', 'pods');
?>
" />
Ejemplo n.º 3
0
<?php

global $pods_i;
$api = pods_api();
$pod = $api->load_pod(array('id' => $obj->id));
if ('taxonomy' == $pod['type'] && 'none' == $pod['storage'] && 1 == pods_var('enable_extra_fields', 'get')) {
    $api->save_pod(array('id' => $obj->id, 'storage' => 'table'));
    $pod = $api->load_pod(array('id' => $obj->id));
    unset($_GET['enable_extra_fields']);
    pods_message(__('Extra fields were successfully enabled for this Custom Taxonomy.', 'pods'));
}
$field_types = PodsForm::field_types();
$field_types_select = array();
foreach ($field_types as $type => $field_type_data) {
    /**
     * @var $field_type PodsField
     */
    $field_type = PodsForm::field_loader($type, $field_type_data['file']);
    $field_type_vars = get_class_vars(get_class($field_type));
    if (!isset($field_type_vars['pod_types'])) {
        $field_type_vars['pod_types'] = true;
    }
    // Only show supported field types
    if (true !== $field_type_vars['pod_types']) {
        if (empty($field_type_vars['pod_types'])) {
            continue;
        } elseif (is_array($field_type_vars['pod_types']) && !in_array(pods_var('type', $pod), $field_type_vars['pod_types'])) {
            continue;
        } elseif (!is_array($field_type_vars['pod_types']) && pods_var('type', $pod) != $field_type_vars['pod_types']) {
            continue;
        }
Ejemplo n.º 4
0
    pods_redirect(pods_var_update(array('pods_reset' => 1), array('page', 'tab')));
} elseif (isset($_POST['reset_deactivate'])) {
    $pods_init->reset();
    deactivate_plugins(PODS_DIR . 'init.php');
    pods_redirect('index.php');
} elseif (1 == pods_var('pods_reset')) {
    pods_message('Pods 2.x settings and data have been reset.');
} elseif (1 == pods_var('pods_cleanup_1x')) {
    pods_message('Pods 1.x data has been deleted.');
} elseif (pods_var('reset_weekend', 'post', pods_var('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');
    ?>
</h3>

    <p><?php 
    _e('This will delete all of your Pods 1.x data, it\'s only recommended if you\'ve verified your data has been properly migrated into Pods 2.x.', 'pods');
    ?>
</p>
    /**
     * @param bool $reorder
     *
     * @return mixed|null
     */
    public function manage($reorder = false)
    {
        if (false !== $this->callback_action('manage', $reorder)) {
            return null;
        }
        if (!empty($this->action_bulk) && !empty($this->actions_bulk) && isset($this->actions_bulk[$this->action_bulk]) && !in_array($this->action_bulk, $this->actions_disabled) && !empty($this->bulk)) {
            if (empty($_REQUEST['_wpnonce' . $this->num]) || false === wp_verify_nonce($_REQUEST['_wpnonce' . $this->num], 'pods-ui-action-bulk')) {
                pods_message(__('Invalid bulk request, please try again.', 'pods'));
            } elseif (false !== $this->callback_bulk($this->action_bulk, $this->bulk)) {
                return null;
            } elseif ('delete' == $this->action_bulk) {
                return $this->delete_bulk();
            }
        }
        $this->screen_meta();
        if (true === $reorder) {
            wp_enqueue_script('jquery-ui-sortable');
        }
        ?>
    <div class="wrap pods-admin 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 esc_url($this->icon);
            ?>
);"<?php 
        }
        ?>
><br /></div>
        <h2>
            <?php 
        if (true === $reorder) {
            echo $this->header['reorder'];
            $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'];
            }
            ?>
                <small>(<a href="<?php 
            echo esc_url($link);
            ?>
">&laquo; <?php 
            echo sprintf(__('Back to %s', 'pods'), $this->heading['manage']);
            ?>
</a>)</small>
                <?php 
        } else {
            echo $this->header['manage'];
        }
        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 esc_url($link);
            ?>
" class="add-new-h2"><?php 
            echo $this->label['add_new'];
            ?>
</a>
                <?php 
        }
        if (!in_array('reorder', $this->actions_disabled) && !in_array('reorder', $this->actions_hidden) && false !== $this->reorder['on']) {
            $link = pods_query_arg(array('action' . $this->num => 'reorder'), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['reorder'])) {
                $link = $this->action_links['reorder'];
            }
            ?>
                <a href="<?php 
            echo esc_url($link);
            ?>
" class="add-new-h2"><?php 
            echo $this->label['reorder'];
            ?>
</a>
                <?php 
        }
        ?>
        </h2>

		<form id="posts-filter" action="" method="get">
        	<?php 
        $excluded_filters = array('search' . $this->num, 'pg' . $this->num, 'action' . $this->num, 'action_bulk' . $this->num, 'action_bulk_ids' . $this->num, '_wpnonce' . $this->num);
        $filters = $this->filters;
        foreach ($filters as $k => $filter) {
            if (isset($this->pod->fields[$filter])) {
                $filter_field = $this->pod->fields[$filter];
            } elseif (isset($this->fields['manage'][$filter])) {
                $filter_field = $this->fields['manage'][$filter];
            } else {
                unset($filters[$k]);
                continue;
            }
            if (in_array($filter_field['type'], array('date', 'datetime', 'time'))) {
                if ('' == pods_var_raw('filter_' . $filter . '_start', 'get', '', null, true) && '' == pods_var_raw('filter_' . $filter . '_end', 'get', '', null, true)) {
                    unset($filters[$k]);
                    continue;
                }
            } elseif ('' === pods_var_raw('filter_' . $filter, 'get', '')) {
                unset($filters[$k]);
                continue;
            }
            $excluded_filters[] = 'filter_' . $filter . '_start';
            $excluded_filters[] = 'filter_' . $filter . '_end';
            $excluded_filters[] = 'filter_' . $filter;
        }
        $get = $_GET;
        foreach ($get as $k => $v) {
            if (is_array($v) || in_array($k, $excluded_filters) || strlen($v) < 1) {
                continue;
            }
            ?>
				<input type="hidden" name="<?php 
            echo esc_attr($k);
            ?>
" value="<?php 
            echo esc_attr($v);
            ?>
" />
			<?php 
        }
        if (false !== $this->callback('header', $reorder)) {
            return null;
        }
        if (false === $this->data) {
            $this->get_data();
        } elseif ($this->sortable) {
            // we have the data already as an array
            $this->sort_data();
        }
        if (!in_array('export', $this->actions_disabled) && 'export' == $this->action) {
            $this->export();
        }
        if ((!empty($this->data) || false !== $this->search || $this->filters_enhanced && !empty($this->views)) && ($this->filters_enhanced && !empty($this->views) || false !== $this->searchable)) {
            if ($this->filters_enhanced) {
                $this->filters();
            } else {
                ?>
                <p class="search-box" align="right">
                    <?php 
                $excluded_filters = array('search' . $this->num, 'pg' . $this->num);
                foreach ($this->filters as $filter) {
                    $excluded_filters[] = 'filter_' . $filter . '_start';
                    $excluded_filters[] = 'filter_' . $filter . '_end';
                    $excluded_filters[] = 'filter_' . $filter;
                }
                $this->hidden_vars($excluded_filters);
                foreach ($this->filters as $filter) {
                    if (isset($this->pod->fields[$filter])) {
                        $filter_field = $this->pod->fields[$filter];
                    } elseif (isset($this->fields['manage'][$filter])) {
                        $filter_field = $this->fields['manage'][$filter];
                    } else {
                        continue;
                    }
                    if (in_array($filter_field['type'], array('date', 'datetime', 'time'))) {
                        $start = pods_var_raw('filter_' . $filter . '_start', 'get', pods_var_raw('filter_default', $filter_field, '', null, true), null, true);
                        $end = pods_var_raw('filter_' . $filter . '_end', 'get', pods_var_raw('filter_ongoing_default', $filter_field, '', null, true), null, true);
                        // override default value
                        $filter_field['options']['default_value'] = '';
                        $filter_field['options'][$filter_field['type'] . '_allow_empty'] = 1;
                        if (!empty($start) && !in_array($start, array('0000-00-00', '0000-00-00 00:00:00', '00:00:00'))) {
                            $start = PodsForm::field_method($filter_field['type'], 'convert_date', $start, 'n/j/Y');
                        }
                        if (!empty($end) && !in_array($end, array('0000-00-00', '0000-00-00 00:00:00', '00:00:00'))) {
                            $end = PodsForm::field_method($filter_field['type'], 'convert_date', $end, 'n/j/Y');
                        }
                        ?>
                        <label for="pods-form-ui-filter-<?php 
                        echo esc_attr($filter);
                        ?>
_start">
                            <?php 
                        echo $filter_field['label'];
                        ?>
                        </label>
                        <?php 
                        echo PodsForm::field('filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field);
                        ?>

                        <label for="pods-form-ui-filter-<?php 
                        echo esc_attr($filter);
                        ?>
_end">
                            to
                        </label>
                    <?php 
                        echo PodsForm::field('filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field);
                    } elseif ('pick' == $filter_field['type']) {
                        $value = pods_var_raw('filter_' . $filter, 'get');
                        if (strlen($value) < 1) {
                            $value = pods_var_raw('filter_default', $filter_field);
                        }
                        // override default value
                        $filter_field['options']['default_value'] = '';
                        $filter_field['options']['pick_format_type'] = 'single';
                        $filter_field['options']['pick_format_single'] = 'dropdown';
                        $filter_field['options']['input_helper'] = pods_var_raw('ui_input_helper', pods_var_raw('options', pods_var_raw($filter, $this->fields['search'], array(), null, true), array(), null, true), '', null, true);
                        $filter_field['options']['input_helper'] = pods_var_raw('ui_input_helper', $filter_field['options'], $filter_field['options']['input_helper'], null, true);
                        $options = array_merge($filter_field, $filter_field['options']);
                        ?>
                        <label for="pods-form-ui-filter-<?php 
                        echo esc_attr($filter);
                        ?>
">
                            <?php 
                        echo $filter_field['label'];
                        ?>
                        </label>
                    <?php 
                        echo PodsForm::field('filter_' . $filter, $value, 'pick', $options);
                    } elseif ('boolean' == $filter_field['type']) {
                        $value = pods_var_raw('filter_' . $filter, 'get', '');
                        if (strlen($value) < 1) {
                            $value = pods_var_raw('filter_default', $filter_field);
                        }
                        // override default value
                        $filter_field['options']['default_value'] = '';
                        $filter_field['options']['pick_format_type'] = 'single';
                        $filter_field['options']['pick_format_single'] = 'dropdown';
                        $filter_field['options']['pick_object'] = 'custom-simple';
                        $filter_field['options']['pick_custom'] = array('1' => pods_var_raw('boolean_yes_label', $filter_field['options'], __('Yes', 'pods'), null, true), '0' => pods_var_raw('boolean_no_label', $filter_field['options'], __('No', 'pods'), null, true));
                        $filter_field['options']['input_helper'] = pods_var_raw('ui_input_helper', pods_var_raw('options', pods_var_raw($filter, $this->fields['search'], array(), null, true), array(), null, true), '', null, true);
                        $filter_field['options']['input_helper'] = pods_var_raw('ui_input_helper', $filter_field['options'], $filter_field['options']['input_helper'], null, true);
                        $options = array_merge($filter_field, $filter_field['options']);
                        ?>
                        <label for="pods-form-ui-filter-<?php 
                        echo esc_attr($filter);
                        ?>
">
                            <?php 
                        echo $filter_field['label'];
                        ?>
                        </label>
                    <?php 
                        echo PodsForm::field('filter_' . $filter, $value, 'pick', $options);
                    } else {
                        $value = pods_var_raw('filter_' . $filter, 'get');
                        if (strlen($value) < 1) {
                            $value = pods_var_raw('filter_default', $filter_field);
                        }
                        // override default value
                        $filter_field['options']['default_value'] = '';
                        $options = array();
                        $options['input_helper'] = pods_var_raw('ui_input_helper', pods_var_raw('options', pods_var_raw($filter, $this->fields['search'], array(), null, true), array(), null, true), '', null, true);
                        $options['input_helper'] = pods_var_raw('ui_input_helper', $options, $options['input_helper'], null, true);
                        ?>
                        <label for="pods-form-ui-filter-<?php 
                        echo esc_attr($filter);
                        ?>
">
                            <?php 
                        echo $filter_field['label'];
                        ?>
                        </label>
                    <?php 
                        echo PodsForm::field('filter_' . $filter, $value, 'text', $options);
                    }
                }
                if (false !== $this->do_hook('filters_show_search', true)) {
                    ?>
						&nbsp;&nbsp; <label<?php 
                    echo empty($this->filters) ? ' class="screen-reader-text"' : '';
                    ?>
 for="page-search<?php 
                    echo esc_attr($this->num);
                    ?>
-input"><?php 
                    _e('Search', 'pods');
                    ?>
:</label>
						<?php 
                    echo PodsForm::field('search' . $this->num, $this->search, 'text', array('attributes' => array('id' => 'page-search' . $this->num . '-input')));
                    ?>
					<?php 
                } else {
                    echo PodsForm::field('search' . $this->num, '', 'hidden');
                }
                ?>
                    <?php 
                echo PodsForm::submit_button($this->header['search'], 'button', false, false, array('id' => 'search' . $this->num . '-submit'));
                ?>
                    <?php 
                if (0 < strlen($this->search)) {
                    $clear_filters = array('search' . $this->num => false);
                    foreach ($this->filters as $filter) {
                        $clear_filters['filter_' . $filter . '_start'] = false;
                        $clear_filters['filter_' . $filter . '_end'] = false;
                        $clear_filters['filter_' . $filter] = false;
                    }
                    ?>
                        <br class="clear" />
                        <small>[<a href="<?php 
                    echo esc_url(pods_query_arg($clear_filters, array('orderby' . $this->num, 'orderby_dir' . $this->num, 'limit' . $this->num, 'page'), $this->exclusion()));
                    ?>
"><?php 
                    _e('Reset Filters', 'pods');
                    ?>
</a>]</small>
                        <br class="clear" />
                        <?php 
                }
                ?>
                </p>
                <?php 
            }
        } else {
            ?>
                <br class="clear" />
                <?php 
        }
        if (!empty($this->data) && (false !== $this->pagination_total || false !== $this->pagination || true === $reorder) || !in_array('export', $this->actions_disabled) && !in_array('export', $this->actions_hidden) || !empty($this->actions_disabled)) {
            ?>
                <div class="tablenav">
                    <?php 
            if (!empty($this->data) && !empty($this->actions_bulk)) {
                ?>
                    <div class="alignleft actions">
	                    <?php 
                wp_nonce_field('pods-ui-action-bulk', '_wpnonce' . $this->num, false);
                ?>

                        <select name="action_bulk<?php 
                echo esc_attr($this->num);
                ?>
">
                            <option value="-1" selected="selected"><?php 
                _e('Bulk Actions', 'pods');
                ?>
</option>

                            <?php 
                foreach ($this->actions_bulk as $action => $action_data) {
                    if (in_array($action, $this->actions_hidden) || in_array($action, $this->actions_hidden)) {
                        continue;
                    }
                    if (!isset($action_data['label'])) {
                        $action_data['label'] = ucwords(str_replace('_', ' ', $action));
                    }
                    ?>
                                <option value="<?php 
                    echo esc_attr($action);
                    ?>
"><?php 
                    echo esc_html($action_data['label']);
                    ?>
</option>
                            <?php 
                }
                ?>
                        </select>

                        <input type="submit" id="doaction_bulk<?php 
                echo esc_attr($this->num);
                ?>
" class="button-secondary action" value="<?php 
                esc_attr_e('Apply', 'pods');
                ?>
">
                    </div>
                <?php 
            }
            if (true !== $reorder && (false !== $this->pagination_total || false !== $this->pagination)) {
                ?>
                        <div class="tablenav-pages<?php 
                echo esc_attr($this->limit < $this->total_found || 1 < $this->page ? '' : ' one-page');
                ?>
">
                            <?php 
                $this->pagination(1);
                ?>
                        </div>
                        <?php 
            }
            if (true === $reorder) {
                $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'];
                }
                ?>
                        <input type="button" value="<?php 
                esc_attr_e('Update Order', 'pods');
                ?>
" class="button" onclick="jQuery('form.admin_ui_reorder_form').submit();" />
                        <input type="button" value="<?php 
                esc_attr_e('Cancel', 'pods');
                ?>
" class="button" onclick="document.location='<?php 
                echo esc_js($link);
                ?>
';" />
                    </form>
				<?php 
            } elseif (!in_array('export', $this->actions_disabled) && !in_array('export', $this->actions_hidden)) {
                ?>
                        <div class="alignleft actions">
                            <strong><?php 
                _e('Export', 'pods');
                ?>
:</strong>
                            <?php 
                foreach ($this->export['formats'] as $format => $separator) {
                    ?>
                                <input type="button" value=" <?php 
                    echo esc_attr(strtoupper($format));
                    ?>
 " class="button" onclick="document.location='<?php 
                    echo pods_slash(pods_query_arg(array('action' . $this->num => 'export', 'export_type' . $this->num => $format, '_wpnonce' => wp_create_nonce('pods-ui-action-export')), self::$allowed, $this->exclusion()));
                    ?>
';" />
                                <?php 
                }
                ?>
                        </div>
                        <?php 
            }
            ?>
                    <br class="clear" />
                </div>
                <?php 
        } else {
            ?>
                <br class="clear" />
                <?php 
        }
        ?>
            <div class="clear"></div>
            <?php 
        if (empty($this->data) && false !== $this->default_none && false === $this->search) {
            ?>
                <p><?php 
            _e('Please use the search filter(s) above to display data', 'pods');
            if ($this->export) {
                ?>
, <?php 
                _e('or click on an Export to download a full copy of the data', 'pods');
            }
            ?>
.</p>
                <?php 
        } else {
            $this->table($reorder);
        }
        if (!empty($this->data)) {
            if (true !== $reorder && (false !== $this->pagination_total || false !== $this->pagination)) {
                ?>
                    <div class="tablenav">
                        <div class="tablenav-pages<?php 
                echo esc_attr($this->limit < $this->total_found || 1 < $this->page ? '' : ' one-page');
                ?>
">
                            <?php 
                $this->pagination(0);
                ?>
                            <br class="clear" />
                        </div>
                    </div>
                    <?php 
            }
        }
        ?>
        </form>
    </div>
    <?php 
        if ($this->filters_enhanced) {
            $this->filters_popup();
        }
    }
Ejemplo n.º 6
0
 /**
  * Handle main Pods Setup area for managing Pods and Fields
  */
 public function admin_setup()
 {
     $pods = pods_api()->load_pods(array('fields' => false));
     $view = pods_var('view', 'get', 'all', null, true);
     if (empty($pods) && !isset($_GET['action'])) {
         $_GET['action'] = 'add';
     }
     if ('pods-add-new' == $_GET['page']) {
         if (isset($_GET['action']) && 'add' != $_GET['action']) {
             pods_redirect(pods_var_update(array('page' => 'pods', 'action' => $_GET['action'])));
         } else {
             $_GET['action'] = 'add';
         }
     } elseif (isset($_GET['action']) && 'add' == $_GET['action']) {
         pods_redirect(pods_var_update(array('page' => 'pods-add-new', 'action' => '')));
     }
     $types = array('post_type' => __('Post Type (extended)', 'pods'), 'taxonomy' => __('Taxonomy (extended)', 'pods'), 'cpt' => __('Custom Post Type', 'pods'), 'ct' => __('Custom Taxonomy', 'pods'), 'user' => __('User (extended)', 'pods'), 'media' => __('Media (extended)', 'pods'), 'comment' => __('Comments (extended)', 'pods'), 'pod' => __('Advanced Content Type', 'pods'), 'settings' => __('Custom Settings Page', 'pods'));
     $row = false;
     $pod_types_found = array();
     $fields = array('label' => array('label' => __('Label', 'pods')), 'name' => array('label' => __('Name', 'pods')), 'type' => array('label' => __('Type', 'pods')), 'storage' => array('label' => __('Storage Type', 'pods'), 'width' => '10%'), 'field_count' => array('label' => __('Number of Fields', 'pods'), 'width' => '8%'));
     $total_fields = 0;
     foreach ($pods as $k => $pod) {
         if (isset($types[$pod['type']])) {
             if (in_array($pod['type'], array('post_type', 'taxonomy'))) {
                 if (empty($pod['object'])) {
                     if ('post_type' == $pod['type']) {
                         $pod['type'] = 'cpt';
                     } else {
                         $pod['type'] = 'ct';
                     }
                 }
             }
             if (!isset($pod_types_found[$pod['type']])) {
                 $pod_types_found[$pod['type']] = 1;
             } else {
                 $pod_types_found[$pod['type']]++;
             }
             if ('all' != $view && $view != $pod['type']) {
                 unset($pods[$k]);
                 continue;
             }
             $pod['real_type'] = $pod['type'];
             $pod['type'] = $types[$pod['type']];
         } elseif ('all' != $view) {
             continue;
         }
         $pod['storage'] = ucwords($pod['storage']);
         if ($pod['id'] == pods_var('id') && 'delete' != pods_var('action')) {
             $row = $pod;
         }
         $pod = array('id' => $pod['id'], 'label' => pods_var_raw('label', $pod), 'name' => pods_var_raw('name', $pod), 'object' => pods_var_raw('object', $pod), 'type' => pods_var_raw('type', $pod), 'real_type' => pods_var_raw('real_type', $pod), 'storage' => pods_var_raw('storage', $pod), 'field_count' => count($pod['fields']));
         $total_fields += $pod['field_count'];
         $pods[$k] = $pod;
     }
     if (false === $row && 0 < pods_var('id') && 'delete' != pods_var('action')) {
         pods_message('Pod not found', 'error');
         unset($_GET['id']);
         unset($_GET['action']);
     }
     $ui = array('data' => $pods, 'row' => $row, 'total' => count($pods), 'total_found' => count($pods), 'icon' => PODS_URL . 'ui/images/icon32.png', 'items' => 'Pods', 'item' => 'Pod', 'fields' => array('manage' => $fields), 'actions_disabled' => array('view', 'export'), 'actions_custom' => array('add' => array($this, 'admin_setup_add'), 'edit' => array($this, 'admin_setup_edit'), 'duplicate' => array('callback' => array($this, 'admin_setup_duplicate'), 'restrict_callback' => array($this, 'admin_setup_duplicate_restrict')), 'reset' => array('label' => __('Delete All Items', 'pods'), 'confirm' => __('Are you sure you want to delete all items from this Pod? If this is an extended Pod, it will remove the original items extended too.', 'pods'), 'callback' => array($this, 'admin_setup_reset'), 'restrict_callback' => array($this, 'admin_setup_reset_restrict')), 'delete' => array($this, 'admin_setup_delete')), 'action_links' => array('add' => pods_var_update(array('page' => 'pods-add-new', 'action' => '', 'id' => '', 'do' => ''))), 'search' => false, 'searchable' => false, 'sortable' => true, 'pagination' => false, 'extra' => array('total' => ', ' . number_format_i18n($total_fields) . ' ' . _n('field', 'fields', $total_fields, 'pods')));
     if (1 < count($pod_types_found)) {
         $ui['views'] = array('all' => __('All', 'pods'));
         $ui['view'] = $view;
         $ui['heading'] = array('views' => __('Type', 'pods'));
         $ui['filters_enhanced'] = true;
         foreach ($pod_types_found as $pod_type => $number_found) {
             $ui['views'][$pod_type] = $types[$pod_type];
         }
     }
     pods_ui($ui);
 }
Ejemplo n.º 7
0
/**
 * Output an error in the WP Dashboard UI
 *
 * @param string $message
 *
 * @return bool
 *
 * @since 1.12
 * @deprcated 2.3
 */
function pods_ui_error($message)
{
    pods_deprecated("pods_message", '2.3');
    pods_message($message, 'error');
}
Ejemplo n.º 8
0
?>
            <?php 
echo PodsForm::field('_wpnonce', wp_create_nonce('pods-component-' . $component . '-settings'), 'hidden');
?>

            <h2><?php 
_e('Settings', 'pods');
?>
: <?php 
echo $component_label;
?>
</h2>

            <?php 
if (isset($_GET['do'])) {
    pods_message(__('Settings saved successfully.', 'pods'));
}
?>

            <table class="form-table pods-manage-field">
                <?php 
$depends_on = false;
foreach ($options as $field_name => $field_option) {
    $field_option = PodsForm::field_setup($field_option, null, $field_option['type']);
    $depends = PodsForm::dependencies($field_option);
    if ((!empty($depends_on) || !empty($depends)) && $depends_on != $depends) {
        if (!empty($depends_on)) {
            ?>
                    </tbody>
                <?php 
        }
 /**
  * Handle AJAX processing of jobs
  *
  * @param array<string> $ids
  */
 public static function admin_page_process_jobs_ajax($ids)
 {
     /**
      * @var $wpdb wpdb
      */
     global $wpdb;
     $ids = array_map('absint', $ids);
     $pods_jobs_queue = array();
     foreach ($ids as $id) {
         // Build nonce action from request
         $nonce_action = 'pods-jobs-queue-' . $id . '/process';
         // Build nonce from action
         $nonce = wp_create_nonce($nonce_action);
         // Setup object to push for processing
         $pods_jobs_queue[] = array('job_id' => $id, 'nonce' => $nonce);
     }
     // Enqueue Pods Jobs Queue JS
     wp_enqueue_script('pods-jobs-queue');
     // Queue view to be included via AJAX
     echo '<script>' . "\n" . 'var pods_jobs_queue = ' . json_encode($pods_jobs_queue) . ';' . "\n" . '</script>' . "\n";
     // Enqueue jQuery UI Progressbar
     wp_enqueue_script('jquery-ui-progressbar');
     $message = '<span id="pods-jobs-queue-progress-status">%s</span>' . '<div id="pods-jobs-queue-progress-indicator" style="position:relative;max-width:300px;display:none;">' . '<div id="pods-jobs-queue-progress-label" style="position:absolute;left:45%%;top:6px;font-weight:bold;text-shadow:1px 1px 0 #FFF;font-size:12px;">%s</div>' . '</div>';
     $message = sprintf($message, _n('Processing Job', 'Processing Jobs', count($pods_jobs_queue), 'pods-jobs-queue'), __('Loading...', 'pods-jobs-queue'));
     pods_message($message);
 }