Example #1
0
 public static function getForm($form, $post_id = null, $preview = false)
 {
     self::initVars();
     ++self::$form_count;
     //add_filter('cred_form_validate',array($this,'check_hooks'),10);
     if (is_string($form) && !is_numeric($form)) {
         $form_p = get_page_by_title($form, OBJECT, CRED_FORMS_CUSTOM_POST_NAME);
         if ($form_p && is_object($form_p)) {
             $form = $form_p->ID;
         } else {
             return '';
         }
     }
     if (!array_key_exists($form . '_' . self::$form_count, self::$form_cache)) {
         // parse and cache form
         $fb = new CRED_Form_Builder($form, $post_id, $preview);
         self::$form_cache[$form . '_' . self::$form_count] = array('form' => $fb->form(), 'form_count' => self::$form_count, 'hide_comments' => $fb->getHideComments(), 'css_to_use' => $fb->css_to_use, 'extra' => $fb->getExtra(), 'form_js' => $fb->getFormJS(), 'hasRecaptcha' => $fb->hasRecaptcha);
     }
     // add filter to hide comments (new method)
     if (self::$form_cache[$form . '_' . self::$form_count]['hide_comments']) {
         self::hideComments();
     }
     return self::$form_cache[$form . '_' . self::$form_count]['form'];
 }