/** * Add pods specific capabilities. * * @param $capabilities List of extra capabilities to add * * @return array */ public function admin_capabilities($capabilities) { foreach ($this->components as $component => $component_data) { if (!empty($component_data['Hide'])) { continue; } if (true === (bool) pods_var('DeveloperMode', $component_data, false) && !pods_developer()) { continue; } if (true === (bool) pods_var('TablelessMode', $component_data, false) && !pods_developer()) { continue; } if (empty($component_data['MenuPage']) && (!isset($component_data['object']) || !method_exists($component_data['object'], 'admin'))) { continue; } $capability = 'pods_component_' . str_replace('-', '_', sanitize_title(str_replace(' and ', ' ', strip_tags($component_data['Name'])))); if (0 < strlen($component_data['Capability'])) { $capability = $component_data['Capability']; } if (!in_array($capability, $capabilities)) { $capabilities[] = $capability; } } return $capabilities; }
/** * Toggle a component on or off * * @param PodsUI $ui * * @return bool */ public function admin_components_toggle(PodsUI $ui) { $component = $_GET['id']; if (!empty(PodsInit::$components->components[$component]['PluginDependency'])) { $dependency = explode('|', PodsInit::$components->components[$component]['PluginDependency']); if (!pods_is_plugin_active($dependency[1])) { $website = 'http://wordpress.org/extend/plugins/' . dirname($dependency[1]) . '/'; if (isset($dependency[2])) { $website = $dependency[2]; } if (!empty($website)) { $website = ' ' . sprintf(__('You can find it at %s', 'pods'), '<a href="' . $website . '" target="_blank">' . $website . '</a>'); } $message = sprintf(__('The %s component requires that you have the <strong>%s</strong> plugin installed and activated.', 'pods'), PodsInit::$components->components[$component]['Name'], $dependency[0]) . $website; $ui->error($message); $ui->manage(); return; } } if (!empty(PodsInit::$components->components[$component]['ThemeDependency'])) { $dependency = explode('|', PodsInit::$components->components[$component]['ThemeDependency']); if (strtolower($dependency[1]) != strtolower(get_template()) && strtolower($dependency[1]) != strtolower(get_stylesheet())) { $website = ''; if (isset($dependency[2])) { $website = ' ' . sprintf(__('You can find it at %s', 'pods'), '<a href="' . $dependency[2] . '" target="_blank">' . $dependency[2] . '</a>'); } $message = sprintf(__('The %s component requires that you have the <strong>%s</strong> theme installed and activated.', 'pods'), PodsInit::$components->components[$component]['Name'], $dependency[0]) . $website; $ui->error($message); $ui->manage(); return; } } if (!empty(PodsInit::$components->components[$component]['MustUse'])) { $message = sprintf(__('The %s component can not be disabled from here. You must deactivate the plugin or theme that added it.', 'pods'), PodsInit::$components->components[$component]['Name']); $ui->error($message); $ui->manage(); return; } if (1 == pods_var('toggled')) { $toggle = PodsInit::$components->toggle($component); if (true === $toggle) { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component enabled', 'pods')); } elseif (false === $toggle) { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component disabled', 'pods')); } $components = PodsInit::$components->components; foreach ($components as $component => &$component_data) { $toggle = 0; if (isset(PodsInit::$components->settings['components'][$component_data['ID']])) { if (0 != PodsInit::$components->settings['components'][$component_data['ID']]) { $toggle = 1; } } if (true === $component_data['DeveloperMode']) { if (!pods_developer()) { unset($components[$component]); continue; } } $component_data = array('id' => $component_data['ID'], 'name' => $component_data['Name'], 'description' => make_clickable($component_data['Description']), 'version' => $component_data['Version'], 'author' => $component_data['Author'], 'toggle' => $toggle); } $ui->data = $components; pods_transient_clear('pods_components'); $url = pods_var_update(array('toggled' => null)); pods_redirect($url); } elseif (1 == pods_var('toggle')) { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component enabled', 'pods')); } else { $ui->message(PodsInit::$components->components[$component]['Name'] . ' ' . __('Component disabled', 'pods')); } $ui->manage(); }
/** * Add options and set defaults to * * @return array * * @since 2.0 */ public function options() { $options = array(self::$type . '_format_type' => array('label' => __('Selection Type', 'pods'), 'help' => __('help', 'pods'), 'default' => 'single', 'type' => 'pick', 'data' => array('single' => __('Single Select', 'pods'), 'multi' => __('Multiple Select', 'pods')), 'dependency' => true), self::$type . '_format_single' => array('label' => __('Format', 'pods'), 'help' => __('help', 'pods'), 'depends-on' => array(self::$type . '_format_type' => 'single'), 'default' => 'dropdown', 'type' => 'pick', 'data' => apply_filters('pods_form_ui_field_pick_format_single_options', array('dropdown' => __('Drop Down', 'pods'), 'radio' => __('Radio Buttons', 'pods'), 'autocomplete' => __('Autocomplete', 'pods')) + (pods_developer() && 1 == 0 ? array('flexible' => __('Flexible', 'pods')) : array())), 'dependency' => true), self::$type . '_format_multi' => array('label' => __('Format', 'pods'), 'help' => __('help', 'pods'), 'depends-on' => array(self::$type . '_format_type' => 'multi'), 'default' => 'checkbox', 'type' => 'pick', 'data' => apply_filters('pods_form_ui_field_pick_format_multi_options', array('checkbox' => __('Checkboxes', 'pods'), 'multiselect' => __('Multi Select', 'pods'), 'autocomplete' => __('Autocomplete', 'pods')) + (pods_developer() && 1 == 0 ? array('flexible' => __('Flexible', 'pods')) : array())), 'dependency' => true), self::$type . '_taggable' => array('label' => __('Taggable', 'pods'), 'help' => __('Allow new values to be inserted when using an Autocomplete field', 'pods'), 'excludes-on' => array(self::$type . '_format_single' => array('dropdown', 'radio'), self::$type . '_format_multi' => array('checkbox', 'multiselect'), self::$type . '_object' => array_merge(array('site', 'network'), self::simple_objects())), 'type' => 'boolean', 'default' => 0), self::$type . '_select_text' => array('label' => __('Default Select Text', 'pods'), 'help' => __('This is the text use for the default "no selection" dropdown item, if empty, it will default to "-- Select One --"', 'pods'), 'depends-on' => array(self::$type . '_format_type' => 'single', self::$type . '_format_single' => 'dropdown'), 'default' => '', 'type' => 'text'), self::$type . '_limit' => array('label' => __('Selection Limit', 'pods'), 'help' => __('help', 'pods'), 'depends-on' => array(self::$type . '_format_type' => 'multi'), 'default' => 0, 'type' => 'number'), self::$type . '_allow_html' => array('label' => __('Allow HTML', 'pods'), 'type' => 'boolean', 'default' => 0), self::$type . '_table_id' => array('label' => __('Table ID Column', 'pods'), 'help' => __('You must provide the ID column name for the table, this will be used to keep track of the relationship', 'pods'), 'depends-on' => array(self::$type . '_object' => 'table'), 'required' => 1, 'default' => '', 'type' => 'text'), self::$type . '_table_index' => array('label' => __('Table Index Column', 'pods'), 'help' => __('You must provide the index column name for the table, this may optionally also be the ID column name', 'pods'), 'depends-on' => array(self::$type . '_object' => 'table'), 'required' => 1, 'default' => '', 'type' => 'text'), self::$type . '_display' => array('label' => __('Display Field in Selection List', 'pods'), 'help' => __('Provide the name of a field on the related object to reference, example: {@post_title}', 'pods'), 'excludes-on' => array(self::$type . '_object' => array_merge(array('site', 'network'), self::simple_objects())), 'default' => '', 'type' => 'text'), self::$type . '_user_role' => array('label' => __('Limit list to Role(s)', 'pods'), 'help' => __('help', 'pods'), 'depends-on' => array(self::$type . '_object' => 'user'), 'default' => '', 'type' => 'pick', 'pick_object' => 'role', 'pick_format_type' => 'multi'), self::$type . '_where' => array('label' => __('Customized <em>WHERE</em>', 'pods'), 'help' => __('help', 'pods'), 'excludes-on' => array(self::$type . '_object' => array_merge(array('site', 'network'), self::simple_objects())), 'default' => '', 'type' => 'text'), self::$type . '_orderby' => array('label' => __('Customized <em>ORDER BY</em>', 'pods'), 'help' => __('help', 'pods'), 'excludes-on' => array(self::$type . '_object' => array_merge(array('site', 'network'), self::simple_objects())), 'default' => '', 'type' => 'text'), self::$type . '_groupby' => array('label' => __('Customized <em>GROUP BY</em>', 'pods'), 'help' => __('help', 'pods'), 'excludes-on' => array(self::$type . '_object' => array_merge(array('site', 'network'), self::simple_objects())), 'default' => '', 'type' => 'text')); /*if ( !is_multisite() ) unset( $options[ self::$type . '_user_site' ] );*/ return $options; }
/** * Get a list of all available field types and include * * @return array Registered Field Types data * * @since 2.3 */ public static function field_types() { $field_types = array('text', 'website', 'phone', 'email', 'password', 'paragraph', 'wysiwyg', 'code', 'datetime', 'date', 'time', 'number', 'currency', 'file', 'avatar', 'pick', 'boolean', 'color', 'slug'); if (pods_developer()) { $field_types[] = 'html'; } $field_types = array_merge($field_types, array_keys(self::$field_types)); $field_types = array_filter(array_unique($field_types)); $types = apply_filters('pods_api_field_types', $field_types); $field_types = pods_transient_get('pods_field_types'); if (empty($field_types) || count($types) != count($field_types)) { $field_types = array(); foreach ($types as $field_type) { $file = null; if (isset(self::$field_types[$field_type])) { $file = self::$field_types[$field_type]['file']; } self::field_loader($field_type, $file); if (!isset(self::$loaded[$field_type]) || !is_object(self::$loaded[$field_type])) { continue; } $class_vars = get_class_vars(get_class(self::$loaded[$field_type])); // PHP 5.2.x workaround $field_types[$field_type] = $class_vars; $field_types[$field_type]['file'] = $file; } self::$field_types = $field_types; pods_transient_set('pods_field_types', self::$field_types); } else { self::$field_types = array_merge($field_types, self::$field_types); } return self::$field_types; }
<?php $depends_on = false; foreach ($field_options as $field_name => $field_option) { if (false !== strpos($field_name, 'helper') && !class_exists('Pods_Helpers')) { continue; } elseif ($field_option['developer_mode'] && !pods_developer()) { continue; } $field_option = (array) $field_option; $depends = PodsForm::dependencies($field_option, !isset($pods_tab_form) ? 'field-data-' : ''); if ((!empty($depends_on) || !empty($depends)) && $depends_on != $depends) { if (!empty($depends_on)) { ?> </div> <?php } if (!empty($depends)) { ?> <div class="pods-field-option-container <?php echo esc_attr($depends); ?> "> <?php } } if (!is_array($field_option['group'])) { $row_name = $field_name; if (!isset($pods_tab_form)) { $row_name = 'field_data[' . $pods_i . '][' . $field_name . ']'; }