function deleteProject() { $projid = $_POST['projid']; $pod = pods('project'); $pod->delete($projid); exit; }
/** * Function, with caching, to export all items of a Pod as a serialized php array or JSON object * * @param string $pod_name * @param bool $json * * @return bool|mixed|null|string|void */ function export_pod($pod_name, $json = true) { //be sure to set your Pod's name here //name the transient we are caching in for the Pod. $transient_name = "all_{$pod_name}_export"; //check if we already have this data cached, if not continue if (false === ($export = pods_transient_get($transient_name))) { //build Pods object, get all items $pods = pods($pod_name, array('limit' => -1), true); //if we have items, loop through them, adding each item's complete row to the array if ($pods && $pods->total() > 0) { while ($pods->fetch()) { $export[$pods->id()] = $pods->row(); } } if ($json) { $export = json_encode($export); } else { $export = serialize($export); } //cache for next time pods_transient_set($transient_name, $export); } return $export; }
/** * Note that by setting the second arg to true in pods::ui() these new settings override existing values, but all other values set in Pods Admin remain. */ function slug_cpt_ui() { $pods = pods('cpt'); $override_options['fields'] = array('post_title', 'post_date', 'custom_field'); $override_options['actions_disabled'] = array('edit', 'delete'); return $pods->ui($override_options, true); }
public static function notification_count() { global $current_user; $yesterday = date('Y-m-d', strtotime("-1 days")); $jomiz_dms_data_notifications = pods("jomiz_dms_data_notifications", array("where" => "owner.ID = {$current_user->ID} AND created > '{$yesterday}'", "limit" => -1, "orderby" => "created DESC")); //echo "<pre>$jomiz_dms_data_notifications->sql</pre>"; return $jomiz_dms_data_notifications->total_found(); }
function slug_pets_content_filter($content) { if (get_post_type() == 'pets') { $obj = pods('pets', get_the_id()); return $obj->template('pets') . $content; } return $content; }
/** * Always check if it is a fundraiser page. */ function slug_fundraiser_content_filter($content) { if (get_post_type() == 'fundraiser') { $obj = pods('fundraiser', get_the_id()); return $obj->template('Fundraiser Single') . $content; } return $content; }
function pq_tunnel_pod_field($fields, $prefix = null) { $out = array(); // return out if fields are empty if (empty($fields)) { return $out; } foreach ($fields as $name => $field) { $out[] = $prefix . $name; if ($field['type'] === 'file' && $field['options']['file_uploader'] == 'attachment') { $out[] = $prefix . $name . '._src'; $out[] = $prefix . $name . '._img'; $sizes = get_intermediate_image_sizes(); foreach ($sizes as &$size) { $out[] = $prefix . $name . '._src.' . $size; } if ('multi' != $field['options']['file_format_type']) { foreach ($sizes as &$size) { $out[] = $prefix . $name . '._src_relative.' . $size; } foreach ($sizes as &$size) { $out[] = $prefix . $name . '._src_schemeless.' . $size; } } foreach ($sizes as &$size) { $out[] = $prefix . $name . '._img.' . $size; } } if (!empty($field['table_info'])) { if (!empty($field['table_info']['pod'])) { if (false === strpos($prefix, $name . '.')) { $pod = pods($field['table_info']['pod']['name']); // only tunnel in if there are object fields if (!empty($field['table_info']['object_fields'])) { $out = array_merge($out, pq_tunnel_pod_field($field['table_info']['object_fields'], $prefix . $name . '.')); } if (post_type_supports($field['table_info']['pod']['name'], 'thumbnail')) { $out[] = 'post_thumbnail'; $out[] = 'post_thumbnail_url'; $sizes = get_intermediate_image_sizes(); foreach ($sizes as &$size) { $out[] = 'post_thumbnail.' . $size; $out[] = 'post_thumbnail_url.' . $size; } } $pod_fields = $pod->fields(); $out = array_merge($out, pq_tunnel_pod_field($pod_fields, $prefix . $name . '.')); } } else { if (!empty($field['table_info']['object_fields'])) { $out = array_merge($out, pq_tunnel_pod_field($field['table_info']['object_fields'], $prefix . $name . '.')); } } } } return $out; }
public static function add_notification($owner, $link, $text) { $data = array(); $data['target_url'] = $link; $data['name'] = $text; $data['owner'] = $owner; $the_fucken_pod = pods("jomiz_dms_data_notifications"); $the_fucken_pod->add($data); }
/** * Get Pod object * * @since 2.5.6 * * @param $pod_name * @param $id * * @return bool|Pods */ protected static function get_pod($pod_name, $id) { if (!self::$pod || self::$pod->pod != $pod_name) { self::$pod = pods($pod_name, $id, true); } if (self::$pod && self::$pod->id != $id) { self::$pod->fetch($id); } return self::$pod; }
function addEventToCalandar() { global $current_user; get_currentuserinfo(); $eventId = $_POST['eventId']; $calPod = pods('calandar'); $data = array('author' => $current_user->ID, 'event' => $eventId); $newCalItemId = $calPod->add($data); echo $newCalItemId; exit; }
/** * Add a new applicant * Real life example of a function to create a new "applicant" record using data submitted from a form. * * IMPORTANT: Always sanitize data from forms. */ function add_new_applicant() { // Get field values from form submission $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $telephone = $_POST['telephone']; $email = $_POST['email']; $fields = array('first_name' => $first_name, 'last_name' => $last_name, 'telephone' => $telephone, 'email' => $email); $new_id = pods('applicant')->add($fields); return $new_id; }
function slug_act_img_rel($pieces) { //get value of 'img' field $img = $pieces['fields']['img']['value']; //if it has a value save the value of the permalink field in extended media if ($img !== '') { $pods = pods('media', $img); $data = array('act_permalink' => $pieces['fields']['permalink']['value']); $pods->save($data); } }
public static function surveys($evaluation_id) { $evals = pods('survey', ['limit' => -1, 'where' => 'evaluation.ID = ' . $evaluation_id]); $ret = []; if ($evals->total()) { $all_evals = $evals->data(); foreach ($all_evals as $key => $eval) { $ret[] = $eval; } } return $ret; }
public function evaluate_duplicated($fieldname) { $fieldvalue = $this->current_pod->field($fieldname); if ($fieldvalue == "") { return "no-duplication"; } $duplicated_pods = pods($this->podname, array("where" => "t.{$fieldname} = '{$fieldvalue}'")); if ($duplicated_pods->total() > 1) { return "duplicated-found"; } return "no-duplication"; }
/** * Set the Pods object * * @since 2.5.6 * * @access protected * * @param string|Pods $pod Pods object or name of Pods object */ private function set_pod($pod) { if (is_string($pod)) { $this->set_pod(pods($pod, null, true)); } else { $type = $pod->pod_data['type']; if (in_array($type, array('post_type', 'user', 'taxonomy'))) { $this->pod = $pod; } else { $this->pod = false; } } }
public static function add_database_message($message, $title, $originator) { global $jomiz_dms_settings; if (!$jomiz_dms_settings->debug_mode) { return; } $data = array(); $data['name'] = $title; $data['originator'] = $originator; $data['message'] = $message; $debug_pod = pods("dms_data_debug"); $debug_pod->add($data); }
public static function surveys($user_id) { error_log('user model surveys - user id ' . $user_id); $user_surveys = pods('survey', ['limit' => -1, 'where' => 'user.ID = ' . $user_id]); $ret = []; if ($user_surveys->total()) { $all_user_surveys = $user_surveys->data(); error_log('user surveys ' . json_encode($all_user_surveys)); foreach ($all_user_surveys as $key => $user_survey) { $ret[] = $user_survey; } } return $ret; }
/** * setup pods */ function sdm_pods_init_action() { if (!function_exists('pods')) { return; } $settingsPod = pods('kc_settings'); if ($settingsPod) { KC::$copyright = $settingsPod->field('copyright'); KC::$author_slug = $settingsPod->field('authors_slug'); KC::$default_header_image = PodUtils::getImgUrl($settingsPod, 'default_header_image', 'full'); } // SCHEMA $schemaPod = pods('schema'); if ($schemaPod) { KC::$schemaOrg = new SchemaOrg($schemaPod); } }
function execute_actions($type, $podname, $pieces, $is_new_item, $id) { $actions_on_pod = pods("jomiz_dms_actions", array("where" => "t.pod_name = '{$podname}' AND t.status = 'active' AND t.action_type = '{$type}'", "orderby" => "execution_order")); if ($actions_on_pod->total() > 0) { while ($actions_on_pod->fetch()) { $arguments = array(); $arguments["is_new_item"] = $is_new_item; $arguments["record_id"] = $id; $arguments["podname"] = $podname; $arguments["custom_php"] = $actions_on_pod->field("custom_php"); $arguments["stop_on_error_messages"] = $actions_on_pod->field("stop_on_error_messages"); //dms_debug::add_database_message(var_export($arguments, TRUE), "Action Found", "pods-actions"); $actions = new dms_action($arguments); $actions->perform(); } } }
public function init() { if ($this->init_done) { return; } $settings_pod = pods("jomiz_dms_settings"); $this->debug_mode = $settings_pod->field("debug_mode"); $this->groups_members_field_id = $settings_pod->field("groups_members_field_id"); $this->groups_managers_field_id = $settings_pod->field("groups_managers_field_id"); $this->dms_workflow_groups_field_id = $settings_pod->field("dms_workflow_groups_field_id"); $this->login_logo = $settings_pod->field("login_logo"); $this->top_logo = $settings_pod->field("top_logo._src"); $this->organization_url = $settings_pod->field("organization_url"); $this->login_logo = $this->login_logo["guid"]; //$this -> top_logo = $this -> top_logo["guid"]; $this->init_done = TRUE; }
function load_pod_data($obj = array(), $webhook_type, $pieces) { global $wpdb; $pod_data = array(); if ($webhook_type == 'PODS') { $fields = array(); foreach ($pieces['fields'] as $field_name => $field_data) { $fields[$field_name] = $field_data['value']; } $pod = pods($pieces['params']->pod, $pieces['params']->id); $post_fileds = array_keys($pieces['object_fields']); foreach ($post_fileds as $i => $field_name) { $pod_data[$field_name] = $pod->display($field_name); } $pod_data = array_merge($fields, $pod_data); } return array_merge($obj, $pod_data); }
/** * Saves (inserts or updates) a Survey POD. This function is also triggered indirectly, for instance when saving a user to check * the relations and add necessary Survey POD and information to LimeSurvey. See LimesurveyModel.php * @param integer $user_id user_id of a WordPress user * @param integer $evaluation_id [description] * @param string $token_180 [description] * @param integer $limesurvey_id_180 [description] * @param string $token_360 Optional: * @param integer $limesurvey_id_360 Optional: * @return boolean true on succesfull insert or update, false on error */ public static function save($user_id, $evaluation_id, $survey_args) { $evaluation_pod = pods('evaluation', $evaluation_id); if (!$evaluation_pod->exists()) { error_log('Relationship not found during save of Survey'); } $user = UserModel::findByID($user_id); if ($user) { // check if a token already exists; $existing_surveys = self::getByUserAndRelation($user_id, $evaluation_id); if ($existing_surveys === false) { $survey_pod = pods('survey'); $extra_args = ['post_title' => $evaluation_pod->field('name') . ' (' . $user->data->user_nicename . ')', 'post_status' => 'publish']; $args = array_merge($survey_args, $extra_args); $survey_pod->save($args); } } }
function cio_mmc_display_section($post_type, $section, $v, $id) { $pod = pods($post_type, $id); if (!$pod->exists()) { return; } if (!isset($v['fields']) or empty($v['fields'])) { return; } /* $op = $pod->fields($section); if (false==$this->cio_pods_is_show_section ($section, null, 'pick', $op, $pod, $id ) ) return; */ $html = '<div class="cio-display cio-display-' . str_replace('_', '-', $section) . '">'; foreach ($v['fields'] as $field => $fv) { //$options = $pod->fields($field); $html .= '<div class="cio-display-start-new-row"> </div>'; if (!$pod->display($field)) { continue; } if ('file' == $fv['type'][0]) { if ('single' == $fv['file_format_type'][0]) { if ('images' == $fv['file_type'][0]) { $html .= '<div class="cio-label cio-label-' . str_replace('_', '-', $field) . '">' . $fv['post_title'] . '</div>'; $html .= '<div class="cio-field cio-field-' . str_replace('_', '-', $field) . '"><a href="' . $pod->display($field) . ' "><img class="cio-mmc-image" src="' . $pod->display($field) . '"> </a></div>'; //$html .= '<div class="cio-desc cio-desc-' . str_replace('_', '-', $field).'">' . $fv['description'] . '</div>'; } } else { //free version supports displaying single image only. premium version supports multiple files. continue; } } else { $html .= '<div class="cio-label cio-label-' . str_replace('_', '-', $field) . '">' . $fv['post_title'] . '</div>'; $html .= '<div class="cio-field cio-field-' . str_replace('_', '-', $field) . '">' . $pod->display($field) . '</div>'; //$html .= '<div class="cio-desc cio-desc-' . str_replace('_', '-', $field).'">' . $fv['description'] . '</div>'; } } $html .= '</div>'; return $html; }
/** * 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); } }
/** * setup pods */ function init_action() { if (!function_exists('pods')) { return; } $settingsPod = pods('kc_settings'); if ($settingsPod) { KC::$copyright = $settingsPod->field('copyright'); KC::$author_slug = $settingsPod->field('authors_slug'); KC::$default_header_image = PodUtils::getImgUrl($settingsPod, 'default_header_image', 'full'); } else { KC::debug('no kc_settings pod'); } $schemaPod = pods('schema'); if ($schemaPod) { $data = new SchemaData(); $data->url = get_site_url(); $data->type = $schemaPod->field('type'); // get_bloginfo(); $data->name = $schemaPod->field('name'); // get_bloginfo(); $data->logo = PodUtils::getImgUrl($schemaPod, 'logo', 'full'); //get_site_url() . "/wp-content/themes/kauaicreative.com/site-assets/logo.png"; $data->streetAddress = $schemaPod->field('street_address'); $data->addressLocality = $schemaPod->field('address_locality'); $data->addressRegion = $schemaPod->field('address_region'); $data->postalCode = $schemaPod->field('postal_code'); $data->contactType = $schemaPod->field('contact_type'); // customer service $data->telephone = $schemaPod->field('telephone'); $data->email = $schemaPod->field('email'); $data->hours = $schemaPod->field('hours'); $schemaOrg = new SchemaOrg($data); KC::$schemaOrg = $schemaOrg; } else { KC::debug('no schema pod'); } //if (!KC::$default_header_image) KC::$default_header_image = get_site_url() . "/wp-content/themes/kauaicreative.com/site-assets/default-bg.jpg"; //KC::debug($data); // $schemaOrg->schemaData }
function pods_addon_import_free($post_id, $data, $import_options) { global $vipp_addon_free, $wpdb, $my_fields; //$my_pod_name = $data['vipp_my_pod_name']; $my_pod_name = $import_options->options['custom_type']; //echo '<br>' . $my_pod_name; $vipp_addon_free->log('- Processing custom fields of pods custom type name: `' . $my_pod_name . '`'); $save = array(); //echo '<pre>'; //print_r($data); //print_r($my_fields[$my_pod_name]); //echo '</pre>'; $vipp_addon_free->log('- Some fields may be skipped as per your import setting. Please change import setting when you need to import to the skipped fields.'); foreach ($my_fields[$my_pod_name] as $k => $v) { if ($vipp_addon_free->can_update_meta($k, $import_options)) { $save[$k] = $data['vippfree' . $my_pod_name . $k]; } else { //$vipp_addon_free->log( '- Skipped field `' . $k. '` as per import setting. ' ); } } $result = pods($my_pod_name)->save($save, null, $post_id); $vipp_addon_free->log('- Successfully saved custom fields to pods custom type: `' . $my_pod_name . '`. ID ' . $post_id); //print_r($save); }
*/ $action_id = isset($_GET['do']) ? $_GET['do'] : -1; $record_id = isset($_GET['on']) ? $_GET['on'] : -1; $return_url = isset($_GET['return-to']) ? urldecode($_GET['return-to']) : get_home_url(); //dms_debug::add_database_message("1", "Action Exectiopn", "ACTION API PAGE"); if ($action_id < 0 || $action_id == "") { echo core_utilities::get_error_message("No Action"); return; } //dms_debug::add_database_message("2", "Action Exectiopn", "ACTION API PAGE"); if ($record_id < 0 || $record_id == "") { echo core_utilities::get_error_message("No Record"); return; } //dms_debug::add_database_message("3", "Action Exectiopn", "ACTION API PAGE"); $action_on_pod = pods("jomiz_dms_actions", array('where' => "t.id = {$action_id}")); //dms_debug::add_database_message(var_export($action_on_pod, TRUE), "Action Exectiopn", "ACTION API PAGE"); if ($action_on_pod->total() == 0) { echo core_utilities::get_error_message("The Action Is Not Registered"); return; } if (dms_data::is_record_sealed($action_on_pod->field("pod_name"), $record_id)) { // Record Is Sealed //wp_redirect($return_url); //return; } $arguments = array(); $arguments["record_id"] = $record_id; $arguments["podname"] = $action_on_pod->field("pod_name"); $arguments["built_in_action"] = ""; $arguments["built_in_parameters"] = "";
/** * @param int $user_id * @return bool */ public static function remove_token($user_id = 0) { if (!$user_id) { return false; } $pod = pods('jwt_user_token'); $records = $pod->find(null, -1, "author.ID = {$user_id}"); while ($records->fetch()) { $records->delete(); } }
/** * Get a field raw value from a Pod * * @param string $pod The pod name * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run 'find' * @param string|array $name The field name, or an associative array of parameters * @param boolean $single (optional) For tableless fields, to return the whole array or the just the first item * * @return mixed Field value * * @since 2.1 */ function pods_field_raw($pod, $id = false, $name = null, $single = false) { // allow for pods_field_raw( 'field_name' ); if (null === $name) { $name = $pod; $single = (bool) $id; $pod = get_post_type(); $id = get_the_ID(); } return pods($pod, $id)->raw($name, $single); }
/** * Export data from a Pod * * @param string|object $pod The pod name or Pods object * @param array $params An associative array of parameters * * @return array Data arrays of all exported pod items * @since 1.7.1 */ public function export($pod = null, $params = null) { if (empty($pod)) { $pod = $this->pod; } $find = array('limit' => -1, 'search' => false, 'pagination' => false); if (!empty($params) && isset($params['params'])) { $find = array_merge($find, (array) $params['params']); unset($params['params']); $pod = pods($pod, $find); } elseif (!is_object($pod)) { $pod = pods($pod, $find); } $data = array(); while ($pod->fetch()) { $data[$pod->id()] = $this->export_pod_item($params, $pod); } $data = $this->do_hook('export', $data, $pod->pod, $pod); return $data; }