Exemplo n.º 1
0
function pods_ui_demo_init()
{
    pods_ui_demo_validate_plugin();
    $installed = get_option('pods_ui_demo');
    if (empty($installed)) {
        if (false === pods_ui_demo_validate_plugin()) {
            return false;
        }
        // Activate the Pods UI Demo package, this is an export of the Pods,
        // and whatever else you may need for the plugin. Not every plugin
        // needs this, you can remove this function.
        $api = new PodAPI();
        $package = file_get_contents(dirname(__FILE__) . '/package.txt');
        $package = addslashes(trim($package));
        /* validate if you need to
           $validate = $api->validate_package($package);
           if (!is_bool($validate)) {
               pods_ui_message('Package failed validation: '.$validate, 2);
               return false;
           }*/
        $imported = $api->import_package($package, true);
        delete_option('pods_ui_demo');
        update_option('pods_ui_demo', true === $imported ? '1' : '0');
        return true === $imported ? true : false;
    }
    return true;
}
Exemplo n.º 2
0
 /**
  * Drop a single pod item
  *
  * $params['pod_id'] int The item's ID from the wp_pod table
  * $params['tbl_row_id'] int (optional) The item's ID from the wp_pod_tbl_* table (used with datatype parameter)
  * $params['datatype'] string (optional) The datatype name (used with tbl_row_id parameter)
  * $params['datatype_id'] int (optional) The datatype ID (used with tbl_row_id parameter)
  *
  * @param array $params An associative array of parameters
  * @since 1.7.9
  */
 function drop_pod_item($params)
 {
     if (defined('PODS_STRICT_MODE') && PODS_STRICT_MODE) {
         $params = pods_sanitize($params);
     }
     $params = (object) $params;
     if (isset($params->tbl_row_id)) {
         if (!empty($params->tbl_row_id) && is_array($params->tbl_row_id)) {
             $new_params = $params;
             foreach ($params->tbl_row_id as $tbl_row_id) {
                 $new_params->tbl_row_id = $tbl_row_id;
                 $this->drop_pod_item($new_params);
             }
             return;
         }
         if (isset($params->datatype_id)) {
             $select_dt = "p.datatype = '{$params->datatype_id}'";
         } else {
             $select_dt = "t.name = '{$params->datatype}'";
         }
         $sql = "\n            SELECT\n                p.id AS pod_id, p.tbl_row_id, t.id, t.name\n            FROM\n                @wp_pod p\n            INNER JOIN\n                @wp_pod_types t ON t.id = p.datatype\n            WHERE\n                p.tbl_row_id = {$params->tbl_row_id} AND\n                {$select_dt}\n            LIMIT\n                1\n            ";
     } else {
         $sql = "\n            SELECT\n                p.id AS pod_id, p.tbl_row_id, t.id, t.name\n            FROM\n                @wp_pod p\n            INNER JOIN\n                @wp_pod_types t ON t.id = p.datatype\n            WHERE\n                p.id = {$params->pod_id}\n            LIMIT\n                1\n            ";
     }
     $result = pod_query($sql);
     $row = mysql_fetch_assoc($result);
     $params->datatype_id = $row['id'];
     $params->datatype = $row['name'];
     $params->pod_id = $row['pod_id'];
     $params->tbl_row_id = $row['tbl_row_id'];
     // Get helper code
     $result = pod_query("SELECT pre_drop_helpers, post_drop_helpers FROM @wp_pod_types WHERE id = {$params->datatype_id}");
     $row = mysql_fetch_assoc($result);
     $params->pre_drop_helpers = explode(',', $row['pre_drop_helpers']);
     $params->post_drop_helpers = explode(',', $row['post_drop_helpers']);
     // Plugin hook
     do_action('pods_pre_drop_pod_item', $params);
     // Pre-drop helpers
     if (0 < count($params->pre_drop_helpers)) {
         foreach ($params->pre_drop_helpers as $helper) {
             $function_or_file = $helper;
             $check_function = $function_or_file;
             if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_HELPER_FUNCTIONS') || !PODS_HELPER_FUNCTIONS)) {
                 $check_function = false;
             }
             $check_file = null;
             if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_HELPER_FILES') || !PODS_HELPER_FILES)) {
                 $check_file = false;
             }
             if (false !== $check_function && false !== $check_file) {
                 $function_or_file = pods_function_or_file($function_or_file, $check_function, 'helper', $check_file);
             } else {
                 $function_or_file = false;
             }
             $content = false;
             if (!$function_or_file) {
                 $api = new PodAPI();
                 $params_helper = array('name' => $helper, 'type' => 'pre_drop');
                 if (!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) {
                     $params_helper = pods_sanitize($params_helper);
                 }
                 $content = $api->load_helper($params_helper);
                 if (false !== $content && 0 < strlen(trim($content['phpcode']))) {
                     $content = $content['phpcode'];
                 } else {
                     $content = false;
                 }
             }
             if (false === $content && false !== $function_or_file && isset($function_or_file['function'])) {
                 $function_or_file['function']($params, $this);
             } elseif (false === $content && false !== $function_or_file && isset($function_or_file['file'])) {
                 locate_template($function_or_file['file'], true, true);
             } elseif (false !== $content) {
                 if (!defined('PODS_DISABLE_EVAL') || PODS_DISABLE_EVAL) {
                     eval("?>{$content}");
                 } else {
                     echo $content;
                 }
             }
         }
     }
     pod_query("DELETE FROM `@wp_pod_tbl_{$params->datatype}` WHERE id = {$params->tbl_row_id} LIMIT 1");
     pod_query("UPDATE @wp_pod_rel SET sister_pod_id = NULL WHERE sister_pod_id = {$params->pod_id}");
     pod_query("DELETE FROM @wp_pod WHERE id = {$params->pod_id} LIMIT 1");
     pod_query("DELETE FROM @wp_pod_rel WHERE pod_id = {$params->pod_id}");
     // Plugin hook
     do_action('pods_post_drop_pod_item', $params);
     // Post-drop helpers
     if (0 < count($params->post_drop_helpers)) {
         foreach ($params->post_drop_helpers as $helper) {
             $function_or_file = $helper;
             $check_function = $function_or_file;
             if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_HELPER_FUNCTIONS') || !PODS_HELPER_FUNCTIONS)) {
                 $check_function = false;
             }
             $check_file = null;
             if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_HELPER_FILES') || !PODS_HELPER_FILES)) {
                 $check_file = false;
             }
             if (false !== $check_function && false !== $check_file) {
                 $function_or_file = pods_function_or_file($function_or_file, $check_function, 'helper', $check_file);
             } else {
                 $function_or_file = false;
             }
             $content = false;
             if (!$function_or_file) {
                 $api = new PodAPI();
                 $params_helper = array('name' => $helper, 'type' => 'post_drop');
                 if (!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) {
                     $params_helper = pods_sanitize($params_helper);
                 }
                 $content = $api->load_helper($params_helper);
                 if (false !== $content && 0 < strlen(trim($content['phpcode']))) {
                     $content = $content['phpcode'];
                 } else {
                     $content = false;
                 }
             }
             if (false === $content && false !== $function_or_file && isset($function_or_file['function'])) {
                 $function_or_file['function']($params, $this);
             } elseif (false === $content && false !== $function_or_file && isset($function_or_file['file'])) {
                 locate_template($function_or_file['file'], true, true);
             } elseif (false !== $content) {
                 if (!defined('PODS_DISABLE_EVAL') || PODS_DISABLE_EVAL) {
                     eval("?>{$content}");
                 } else {
                     echo $content;
                 }
             }
         }
     }
 }
            $missing_fields = true;
            $missing_error .= '<p style="font-weight: bold; color: red;">Please enter a valid email address.</p>';
        }
        // check and validate recaptcha
        $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
            $missing_fields = true;
            $missing_error .= '<p style="font-weight: bold; color: red;">Image Verification failed! (reCAPTCHA said: ' . $resp->error . ')</p>';
        }
    }
}
if ($_POST['submitted'] == "1" && !$missing_fields) {
    // ************************************************************************
    // SAVING DATA
    // ************************************************************************
    $api = new PodAPI();
    // all of the values to save and options to use
    $reg_data = array('name' => addslashes($txt_name), 'email' => addslashes($txt_email), 'address' => addslashes($txt_address), 'city' => addslashes($txt_city), 'state' => strtoupper(addslashes($txt_state)), 'zipcode' => addslashes($txt_zip), 'phone' => addslashes($txt_phone), 'event_date' => addslashes($txt_date), 'interests' => addslashes($txt_service_interest), 'interest_weddings' => $txt_interest_weddings, 'interest_social' => $txt_interest_social, 'interest_corporate' => $txt_interest_corporate, 'interest_mitzvahs' => $txt_interest_mitzvahs, 'interest_parties' => $txt_interest_parties, 'referral' => addslashes($txt_referral), 'notes' => addslashes($txt_comments), 'inquire_date' => date("Y-m-d H:i:s"));
    pods_sanitize($reg_data);
    $params = array('datatype' => 'user_profiles', 'columns' => $reg_data);
    // create the item
    $api->save_pod_item($params);
    // ************************************************************************
    // MAILCHIMP INSERTION
    // ************************************************************************
    // grab an API Key from http://admin.mailchimp.com/account/api/
    $api = new MCAPI('e7c8035acf9e6541b2a1e0c27ccd2dfd-us1');
    // grab your List's Unique Id by going to http://admin.mailchimp.com/lists/
    // Click the "settings" link for the list - the Unique Id is at the bottom of that page.
    $list_id = 'da7db994ec';
    if ($api->listSubscribe($list_id, $txt_email, '', '', false) === true) {
Exemplo n.º 4
0
 $check_function = $function_or_file;
 if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_HELPER_FUNCTIONS') || !PODS_HELPER_FUNCTIONS)) {
     $check_function = false;
 }
 $check_file = null;
 if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_HELPER_FILES') || !PODS_HELPER_FILES)) {
     $check_file = false;
 }
 if (false !== $check_function && false !== $check_file) {
     $function_or_file = pods_function_or_file($function_or_file, $check_function, 'helper', $check_file);
 } else {
     $function_or_file = false;
 }
 $content = false;
 if (!$function_or_file) {
     $api = new PodAPI();
     $params = array('name' => $input_helper, 'type' => 'input');
     if (!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) {
         $params = pods_sanitize($params);
     }
     $content = $api->load_helper($params);
     if (false !== $content && 0 < strlen(trim($content['phpcode']))) {
         $content = $content['phpcode'];
     } else {
         $content = false;
     }
 }
 if (false === $content && false !== $function_or_file && isset($function_or_file['function'])) {
     echo $function_or_file['function']($coltype, $field, $css_id, $css_classes, $value, $this);
 } elseif (false === $content && false !== $function_or_file && isset($function_or_file['file'])) {
     locate_template($function_or_file['file'], true, true);
Exemplo n.º 5
0
 /**
  * Display the page template
  */
 function showTemplate($template, $code = null)
 {
     ob_start();
     //pre-template hooks
     do_action('pods_pre_showtemplate', $template, $code, $this);
     do_action("pods_pre_showtemplate_{$template}", $template, $code, $this);
     if (!empty($code)) {
         $function_or_file = false;
     } else {
         $function_or_file = $template;
         $check_function = false;
         $check_file = null;
         if ((!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) && (!defined('PODS_TEMPLATE_FILES') || !PODS_TEMPLATE_FILES)) {
             $check_file = false;
         }
         if (false !== $check_function && false !== $check_file) {
             $function_or_file = pods_function_or_file($function_or_file, $check_function, 'template', $check_file);
         } else {
             $function_or_file = false;
         }
         if (!$function_or_file) {
             $api = new PodAPI();
             $params = array('name' => $template);
             if (!defined('PODS_STRICT_MODE') || !PODS_STRICT_MODE) {
                 $params = pods_sanitize($params);
             }
             $code = $api->load_template($params);
             if (false !== $code && 0 < strlen(trim($code['code']))) {
                 $code = $code['code'];
             } else {
                 $code = false;
             }
         }
     }
     if (empty($code) && false !== $function_or_file && isset($function_or_file['file'])) {
         // Only detail templates need $this->id
         if (empty($this->id)) {
             while ($this->fetchRecord()) {
                 locate_template($function_or_file['file'], true, true);
             }
         } else {
             locate_template($function_or_file['file'], true, true);
         }
     } elseif (!empty($code)) {
         // Only detail templates need $this->id
         if (empty($this->id)) {
             while ($this->fetchRecord()) {
                 echo $this->parse_template_string($code);
             }
         } else {
             echo $this->parse_template_string($code);
         }
     }
     //post-template hooks
     do_action('pods_post_showtemplate', $template, $code, $this);
     do_action("pods_post_showtemplate_{$template}", $template, $code, $this);
     return apply_filters('pods_showtemplate', ob_get_clean(), $template, $code, $this);
 }
Exemplo n.º 6
0
 function pods_ui_import_package($package)
 {
     $api = new PodAPI();
     $validate = $api->validate_package($package);
     if (!is_bool($validate)) {
         pods_ui_message('Package failed validation: ' . $validate, 2);
         return false;
     }
     return $api->import_package($package);
 }