public function getCustomField($get, $post)
 {
     $popup_close = 'false';
     $fm = CRED_Loader::get('MODEL/Fields');
     $fields = $fm->getTypesDefaultFields(true);
     if (isset($post['field']) && is_array($post['field'])) {
         $fm = CRED_Loader::get('MODEL/Fields');
         $fm->setCustomField($post['field']);
         $popup_close = 'true';
     }
     if (isset($get['field_name'])) {
         $field_name = $get['field_name'];
         $post_type = isset($get['post_type']) ? $get['post_type'] : 'post';
         if (isset($get['_reset_']) && '1' == $get['_reset_']) {
             $fm->ignoreCustomFields($post_type, array($field_name), 'reset');
             $popup_close = 'true';
             $data = array();
             $field_type = '';
             //__('Not Set','wp-cred');
         } else {
             $data = $fm->getCustomField($post_type, $field_name);
             if (isset($get['field'])) {
                 $field_type = $get['field'];
                 if (isset($data['type']) && $data['type'] != $field_type) {
                     $data = array();
                 }
             } else {
                 $field_type = isset($data['type']) ? $data['type'] : 'textfield';
             }
         }
         echo CRED_Loader::renderTemplate('custom-field-setup', array('field' => $fields[$field_type], 'data' => $data, 'popup_close' => $popup_close, 'field_name' => $field_name, 'post_type' => $post_type, 'url' => cred_route('/Generic_Fields/getCustomField?post_type=' . $post_type . '&field_name=' . $field_name), 'fields' => $fields));
     }
     die;
 }
Beispiel #2
0
 public static function addFormsButton($context, $text_area = 'textarea#content')
 {
     global $wp_version, $post;
     //static $add_only_once=0;
     if (!isset($post) || empty($post)) {
         return '';
     }
     if ($post->post_type == CRED_FORMS_CUSTOM_POST_NAME) {
         // WP 3.3 changes ($context arg is actually a editor ID now)
         if (version_compare($wp_version, '3.1.4', '>') && !empty($context)) {
             $text_area = $context;
         }
         $addon_buttons = array();
         $shortcode_but = '';
         $shortcode_but = CRED_Loader::renderTemplate('insert-field-shortcode-button', array('help' => self::$help, 'help_target' => self::$help_link_target));
         $shortcode2_but = '';
         $fm = CRED_Loader::get('MODEL/Fields');
         $shortcode2_but = CRED_Loader::renderTemplate('insert-generic-field-shortcode-button', array('gfields' => $fm->getTypesDefaultFields(), 'url' => cred_route('/Generic_Fields/getField'), 'help' => self::$help, 'help_target' => self::$help_link_target));
         $forms_model = CRED_Loader::get('MODEL/Forms');
         $settings = $forms_model->getFormCustomField($post->ID, 'form_settings');
         $scaffold_but = '';
         $scaffold_but = CRED_Loader::renderTemplate('scaffold-button', array('include_captcha_scaffold' => isset($settings['include_captcha_scaffold']) ? $settings['include_captcha_scaffold'] : false, 'include_wpml_scaffold' => isset($settings['include_wpml_scaffold']) ? $settings['include_wpml_scaffold'] : false, 'help' => self::$help, 'help_target' => self::$help_link_target));
         $preview_but = '';
         $preview_but = CRED_Loader::renderTemplate('preview-form-button');
         //$syntax_highlight_but='';
         //$syntax_highlight_but = CRED_Loader::renderTemplate('syntax-highlight-button');
         //$addon_buttons[] = $syntax_highlight_but;
         $addon_buttons[] = $scaffold_but;
         $addon_buttons[] = $shortcode_but;
         $addon_buttons[] = $shortcode2_but;
         $addon_buttons[] = $preview_but;
         $addon_buttons = implode(' ', $addon_buttons);
         $out = $addon_buttons;
         // WP 3.3 changes
         if (version_compare($wp_version, '3.1.4', '>')) {
             echo $out;
         } else {
             return $context . $out;
         }
     } else {
         if (is_string($context) && 'content' != $context) {
             $out = '';
             //self::addCREDButton('', $context);
             // WP 3.3 changes
             if (version_compare($wp_version, '3.1.4', '>')) {
                 echo $out;
                 return;
             } else {
                 return $context . $out;
             }
         }
         $fm = CRED_Loader::get('MODEL/Forms');
         $forms = $fm->getFormsForTable(0, -1);
         // WP 3.3 changes ($context arg is actually a editor ID now)
         if (version_compare($wp_version, '3.1.4', '>') && !empty($context)) {
             $text_area = $context;
         }
         $addon_buttons = array();
         $shortcode_but = '';
         $shortcode_but = CRED_Loader::renderTemplate('insert-form-shortcode-button', array('forms' => $forms, 'help' => self::$help, 'help_target' => self::$help_link_target));
         $addon_buttons[] = $shortcode_but;
         $addon_buttons = implode(' ', $addon_buttons);
         $out = $addon_buttons;
         // WP 3.3 changes
         if (version_compare($wp_version, '3.1.4', '>')) {
             echo $out;
         } else {
             return $context . $out;
         }
     }
 }