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));
    }
}
<?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
global $pods_init;
$monday_mode = pods_var('monday_mode', 'get', 0, null, true);
if (1 == date_i18n('N') && (int) date_i18n('G') < 15) {
    $monday_mode = 1;
}
if (isset($_POST['cleanup_1x'])) {
    pods_upgrade('2.0.0')->cleanup();
    pods_redirect(pods_var_update(array('pods_cleanup_1x' => 1), array('page', 'tab')));
} elseif (isset($_POST['reset'])) {
    $pods_init->reset();
    $pods_init->setup();
    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)) {
Ejemplo n.º 4
0
 /**
  * Process a Pod-based form
  *
  * @param mixed $params
  * @param object $obj Pod object
  * @param array $fields Fields being submitted in form ( key => settings )
  * @param string $thank_you URL to send to upon success
  *
  * @return mixed
  *
  * @since 2.0
  */
 public function process_form($params, $obj = null, $fields = null, $thank_you = null)
 {
     $this->display_errors = false;
     $form = null;
     $nonce = pods_var('_pods_nonce', $params);
     $pod = pods_var('_pods_pod', $params);
     $id = pods_var('_pods_id', $params);
     $uri = pods_var('_pods_uri', $params);
     $form = pods_var('_pods_form', $params);
     $location = pods_var('_pods_location', $params);
     if (is_object($obj)) {
         $pod = $obj->pod;
         $id = $obj->id();
     }
     if (!empty($fields)) {
         $fields = array_keys($fields);
         $form = implode(',', $fields);
     } else {
         $fields = explode(',', $form);
     }
     if (empty($nonce) || empty($pod) || empty($uri) || empty($fields)) {
         return pods_error(__('Invalid submission', 'pods'), $this);
     }
     $uid = @session_id();
     if (is_user_logged_in()) {
         $uid = 'user_' . get_current_user_id();
     }
     $field_hash = wp_create_nonce('pods_fields_' . $form);
     $action = 'pods_form_' . $pod . '_' . $uid . '_' . $id . '_' . $uri . '_' . $field_hash;
     if (empty($uid)) {
         return pods_error(__('Access denied for your session, please refresh and try again.', 'pods'), $this);
     }
     if (false === wp_verify_nonce($nonce, $action)) {
         return pods_error(__('Access denied, please refresh and try again.', 'pods'), $this);
     }
     $data = array();
     foreach ($fields as $field) {
         $data[$field] = pods_var_raw('pods_field_' . $field, $params, '');
     }
     $params = array('pod' => $pod, 'id' => $id, 'data' => $data, 'from' => 'process_form', 'location' => $location);
     $id = $this->save_pod_item($params);
     if (0 < $id && !empty($thank_you)) {
         $thank_you = str_replace('X_ID_X', $id, $thank_you);
         pods_redirect($thank_you);
     }
     return $id;
 }
 /**
  * @param null $id
  *
  * @return bool|mixed
  */
 public function delete_bulk()
 {
     $this->do_hook('pre_delete_bulk');
     if (1 != pods_var('deleted_bulk', 'get', 0)) {
         $ids = $this->bulk;
         $success = false;
         if (!empty($ids)) {
             $ids = (array) $ids;
             foreach ($ids as $id) {
                 $id = pods_absint($id);
                 if (empty($id)) {
                     continue;
                 }
                 if ($callback = $this->callback('delete', $id)) {
                     $check = $callback;
                 } elseif (is_object($this->pod)) {
                     $check = $this->pod->delete($id);
                 } else {
                     $check = $this->pods_data->delete($this->sql['table'], array($this->sql['field_id'] => $id));
                 }
                 if ($check) {
                     $success = true;
                 }
             }
         }
         if ($success) {
             pods_redirect(pods_query_arg(array('action_bulk' => 'delete', 'deleted_bulk' => 1), array('page', 'lang', 'action', 'id')));
         } else {
             $this->error(sprintf(__("<strong>Error:</strong> %s has not been deleted.", 'pods'), $this->item));
         }
     } else {
         $this->message(sprintf(__("<strong>Deleted:</strong> %s have been deleted.", 'pods'), $this->items));
         unset($_GET['deleted_bulk']);
     }
     $this->action_bulk = false;
     unset($_GET['action_bulk']);
     $this->do_hook('post_delete_bulk');
     $this->manage();
 }
Ejemplo n.º 6
0
 /**
  * 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();
 }
Ejemplo n.º 7
0
<?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_var_update(array('pods_clearcache' => 1), array('page', 'tab')));
    }
} elseif (1 == pods_var('pods_clearcache')) {
    pods_message('Pods transients and cache have been cleared.');
}
if (PODS_GITHUB_UPDATE) {
    ?>

<h3><?php 
    _e('Force an update of this beta from GitHub', 'pods');
    ?>
</h3>

<p><?php 
    _e('This tool lets you update your Pods installation to the latest alpha/beta/release candidate, usually only when you\'ve been instructed to do so.', 'pods');
    ?>
</p>

<?php 
    $update = admin_url('update-core.php?pods_force_refresh=1');
    if (is_multisite()) {
        $update = network_admin_url('update-core.php?pods_force_refresh=1');
Ejemplo n.º 8
0
 /**
  * @param null $id
  *
  * @return bool|mixed
  */
 public function delete_bulk()
 {
     $this->do_hook('pre_delete_bulk');
     if (1 != pods_var('deleted_bulk', 'get', 0)) {
         $ids = $this->bulk;
         $success = false;
         if (!empty($ids)) {
             $ids = (array) $ids;
             foreach ($ids as $id) {
                 $id = pods_absint($id);
                 if (empty($id)) {
                     continue;
                 }
                 if (isset($this->actions_custom['delete']) && is_callable($this->actions_custom['delete'])) {
                     $check = call_user_func_array($this->actions_custom['delete'], array($id, &$this));
                     if (false !== $check) {
                         $check = true;
                     }
                 } elseif (is_object($this->pod)) {
                     $check = $this->pod->delete($id);
                 } else {
                     $check = $this->pods_data->delete($this->table, array($this->data->field_id => $id));
                 }
                 if ($check) {
                     $success = true;
                 }
             }
         }
         if ($success) {
             pods_redirect(pods_var_update(array('action_bulk' => 'delete', 'deleted_bulk' => 1), array('page', 'lang', 'action', 'id')));
         } else {
             $this->error(__("<strong>Error:</strong> {$this->item} has not been deleted.", 'pods'));
         }
     } else {
         $this->message(__("<strong>Deleted:</strong> {$this->items} have been deleted.", 'pods'));
         unset($_GET['deleted_bulk']);
     }
     $this->action_bulk = false;
     unset($_GET['action_bulk']);
     $this->do_hook('post_delete_bulk');
     $this->manage();
 }