コード例 #1
0
 /**
  * Gets the content of a post, its excerpt as well as its title and returns it as an array
  *
  * @param string $content_type
  * @param string $excerpt_type
  * @param int    $trid
  * @param string $lang
  *
  * @return array containing all the fields information
  */
 public static function copy_from_original_fields($content_type, $excerpt_type, $trid, $lang)
 {
     global $wpdb;
     $post_id = $wpdb->get_var($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND language_code=%s", $trid, $lang));
     $post = get_post($post_id);
     $fields_to_copy = array('content' => 'post_content', 'title' => 'post_title', 'excerpt' => 'post_excerpt');
     $fields_contents = array();
     if (!empty($post)) {
         foreach ($fields_to_copy as $editor_key => $editor_field) {
             //loops over the three fields to be inserted into the array
             if ($editor_key === 'content' || $editor_key === 'excerpt') {
                 //
                 $editor_var = 'rich';
                 if ($editor_key === 'content') {
                     $editor_var = $content_type;
                     //these variables are supplied by a javascript call in scripts.js icl_copy_from_original(lang, trid)
                 } elseif ($editor_key === 'excerpt') {
                     $editor_var = $excerpt_type;
                 }
                 if (function_exists('format_for_editor')) {
                     // WordPress 4.3 uses format_for_editor
                     $html_pre = $post->{$editor_field};
                     if ($editor_var == 'rich') {
                         $html_pre = convert_chars($html_pre);
                         $html_pre = wpautop($html_pre);
                     }
                     $html_pre = format_for_editor($html_pre, $editor_var);
                 } else {
                     // Backwards compatible for WordPress < 4.3
                     if ($editor_var === 'rich') {
                         $html_pre = wp_richedit_pre($post->{$editor_field});
                     } else {
                         $html_pre = wp_htmledit_pre($post->{$editor_field});
                     }
                 }
                 $fields_contents[$editor_key] = htmlspecialchars_decode($html_pre);
             } elseif ($editor_key === 'title') {
                 $fields_contents[$editor_key] = strip_tags($post->{$editor_field});
             }
         }
         $fields_contents['customfields'] = apply_filters('wpml_copy_from_original_custom_fields', self::copy_from_original_custom_fields($post));
     } else {
         $fields_contents['error'] = __('Post not found', 'sitepress');
     }
     do_action('icl_copy_from_original', $post_id);
     return $fields_contents;
 }
コード例 #2
0
    /**
     * 投稿画面にフィールドを表示
     *
     * @param int $index インデックス番号
     * @param mixed $value 保存されている値(check のときだけ配列)
     * @return string html
     */
    public function get_field($index, $value)
    {
        $name = $this->get_field_name_in_editor($index);
        $disabled = $this->get_disable_attribute($index);
        if (function_exists('format_for_editor')) {
            $value = format_for_editor($value);
        } else {
            $value = wp_richedit_pre($value);
        }
        return sprintf('<div class="wp-editor-wrap">
				<div class="wp-editor-tools hide-if-no-js">
					<div class="wp-media-buttons">%s</div>
				</div>
				<div class="wp-editor-container">
					<textarea name="%s" rows="8" class="widefat smart-cf-wp-editor" %s>%s</textarea>
				</div>
			</div>', $this->media_buttons(), esc_attr($name), disabled(true, $disabled, false), $value);
    }
コード例 #3
0
 function filter_excerpt_field_content_copy($elements)
 {
     if ($elements['post_type'] == 'product') {
         $elements['excerpt']['editor_type'] = 'editor';
     }
     if (function_exists('format_for_editor')) {
         // WordPress 4.3 uses format_for_editor
         $elements['excerpt']['value'] = htmlspecialchars_decode(format_for_editor($elements['excerpt']['value'], $_POST['excerpt_type']));
     } else {
         // Backwards compatible for WordPress < 4.3
         if ($_POST['excerpt_type'] == 'rich') {
             $elements['excerpt']['value'] = htmlspecialchars_decode(wp_richedit_pre($elements['excerpt']['value']));
         } else {
             $elements['excerpt']['value'] = htmlspecialchars_decode(wp_htmledit_pre($elements['excerpt']['value']));
         }
     }
     return $elements;
 }
コード例 #4
0
 /**
  *
  *
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function display_setting($args = array(), $options)
 {
     extract($args);
     if (empty($widget)) {
         echo '<div style="display:none;">';
     }
     $do_return = false;
     switch ($type) {
         case 'heading':
             if (!empty($desc)) {
                 echo '<h3>' . $desc . '</h3>';
             }
             $do_return = true;
             break;
         case 'expand_all':
             if (!empty($desc)) {
                 echo '<h3>' . $desc . '</h3>';
             }
             echo '<a id="' . $this->get_field_id($id) . '-expand" style="cursor:pointer;" onclick="jQuery( \'.af-collapsible-control\' ).slideToggle(); jQuery( \'.af-collapsible\' ).slideToggle(); jQuery( this ).hide(); jQuery( \'#' . $this->get_field_id($id) . '-collapse\' ).show();">&raquo; ' . esc_html__('Expand All Options') . '</a>';
             echo '<a id="' . $this->get_field_id($id) . '-collapse" style="cursor:pointer; display: none;" onclick="jQuery( \'.af-collapsible-control\' ).slideToggle(); jQuery( \'.af-collapsible\' ).slideToggle(); jQuery( this ).hide(); jQuery( \'#' . $this->get_field_id($id) . '-expand\' ).show();">&laquo; ' . esc_html__('Collapse All Options') . '</a>';
             $do_return = true;
             break;
         case 'expand_begin':
             if (!empty($desc)) {
                 echo '<h3>' . $desc . '</h3>';
             }
             echo '<span class="af-collapsible-control">';
             echo '<a id="' . $this->get_field_id($id) . '-expand" style="cursor:pointer;" onclick="jQuery( \'div#' . $this->get_field_id($id) . '\' ).slideToggle(); jQuery( this ).hide(); jQuery( \'#' . $this->get_field_id($id) . '-collapse\' ).show();">&raquo; ' . esc_html__('Expand') . '</a>';
             echo '<a id="' . $this->get_field_id($id) . '-collapse" style="cursor:pointer; display: none;" onclick="jQuery( \'div#' . $this->get_field_id($id) . '\' ).slideToggle(); jQuery( this ).hide(); jQuery( \'#' . $this->get_field_id($id) . '-expand\' ).show();">&laquo; ' . esc_html__('Collapse') . '</a>';
             echo '</span>';
             echo '<div id="' . $this->get_field_id($id) . '" style="display:none" class="af-collapsible">';
             $do_return = true;
             break;
         case 'expand_end':
             echo '</div>';
             $do_return = true;
             break;
         default:
             break;
     }
     if ($do_return) {
         if (empty($widget)) {
             echo '</div>';
         }
         return;
     }
     if (!isset($options[$id]) && 'checkbox' != $type) {
         $options[$id] = $std;
     } elseif (!isset($options[$id])) {
         $options[$id] = 0;
     }
     $field_class = '';
     if (!empty($class)) {
         $field_class = ' ' . $class;
     }
     echo '<p>';
     switch ($type) {
         case 'checkbox':
             echo '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $this->get_field_id($id) . '" name="' . $this->get_field_name($id) . '" value="1" ' . checked($options[$id], 1, false) . ' /> ';
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             break;
         case 'select':
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             echo '<select id="' . $this->get_field_id($id) . '"class="select' . $field_class . '" name="' . $this->get_field_name($id) . '">';
             foreach ($choices as $value => $label) {
                 echo '<option value="' . esc_attr($value) . '"' . selected($options[$id], $value, false) . '>' . $label . '</option>';
             }
             echo '</select>';
             break;
         case 'radio':
             $i = 0;
             $count_options = count($options) - 1;
             foreach ($choices as $value => $label) {
                 echo '<input class="radio' . $field_class . '" type="radio" name="' . $this->get_field_name($id) . '" id="' . $this->get_field_name($id . $i) . '" value="' . esc_attr($value) . '" ' . checked($options[$id], $value, false) . '> <label for="' . $this->get_field_name($id . $i) . '">' . $label . '</label>';
                 if ($i < $count_options) {
                     echo '<br />';
                 }
                 $i++;
             }
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             break;
         case 'textarea':
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             if (function_exists('format_for_editor')) {
                 echo '<textarea class="widefat' . $field_class . '" id="' . $this->get_field_id($id) . '" name="' . $this->get_field_name($id) . '" placeholder="' . $std . '" rows="5" cols="30">' . format_for_editor($options[$id]) . '</textarea>';
             } else {
                 echo '<textarea class="widefat' . $field_class . '" id="' . $this->get_field_id($id) . '" name="' . $this->get_field_name($id) . '" placeholder="' . $std . '" rows="5" cols="30">' . wp_htmledit_pre($options[$id]) . '</textarea>';
             }
             break;
         case 'password':
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             echo '<input class="widefat' . $field_class . '" type="password" id="' . $this->get_field_id($id) . '" name="' . $this->get_field_name($id) . '" value="' . esc_attr($options[$id]) . '" />';
             break;
         case 'readonly':
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             echo '<input class="widefat' . $field_class . '" type="text" id="' . $this->get_field_id($id) . '" name="' . $this->get_field_name($id) . '" value="' . esc_attr($options[$id]) . '" readonly="readonly" />';
             break;
         case 'text':
             echo '<label for="' . $this->get_field_id($id) . '">' . $title . '</label>';
             $suggest_id = 'suggest_' . self::$suggest_id++;
             echo '<input class="widefat' . $field_class . ' ' . $suggest_id . '" type="text" id="' . $this->get_field_id($id) . '" name="' . $this->get_field_name($id) . '" placeholder="' . $std . '" value="' . esc_attr($options[$id]) . '" />';
             if ($suggest) {
                 echo static::get_suggest($id, $suggest_id);
             }
             break;
         default:
             break;
     }
     if (!empty($desc)) {
         echo '<br /><span class="setting-description"><small>' . $desc . '</small></span>';
     }
     echo '</p>';
     if (empty($widget)) {
         echo '</div>';
     }
 }
コード例 #5
0
 function format_value_for_input($value, $field = null)
 {
     if (version_compare(get_bloginfo('version'), '4.3', '>=')) {
         return format_for_editor($value);
     } else {
         return wp_richedit_pre($value);
     }
 }
コード例 #6
0
ファイル: icit-spots.php プロジェクト: sevir/toffy-lite
        function form($instance)
        {
            global $wp_version;
            extract(wp_parse_args((array) $instance, array('title' => '', 'id' => '', 'template' => '')), EXTR_SKIP);
            if (!empty($id) && intval($id) > 0) {
                $spot_post = get_post($id);
            }
            $spots = get_posts(array('numberposts' => -1, 'post_type' => SPOTS_POST_TYPE));
            ?>
			<p>
				<label for="<?php 
            echo $this->get_field_id('title');
            ?>
"><?php 
            _e('Title:', SPOTS_DOM);
            ?>
					<input class="widefat title-field" id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" type="text" value="<?php 
            echo esc_attr($title);
            ?>
" />
				</label>
			</p> <?php 
            // once a spot is chosen or created the widget is inexorably bound to that spot - simplifies the UI greatly.
            if (empty($id) || $id == 0) {
                ?>
				<p>
					<a class="button create-spot" href="#"><?php 
                _e('Create a new spot', SPOTS_DOM);
                ?>
</a>
					<span class="description"><?php 
                _e('(You must enter a title first)', SPOTS_DOM);
                ?>
</span>
				</p> <?php 
            } else {
                ?>

				<input class="spot-id" type="hidden" name="<?php 
                echo $this->get_field_name('id');
                ?>
" value="<?php 
                echo esc_attr($id);
                ?>
" /> <?php 
            }
            if (count($spots) && (empty($id) || $id == 0)) {
                ?>
				<p>
					<label for="<?php 
                echo $this->get_field_id('id');
                ?>
"><?php 
                if (empty($id)) {
                    _e('Or select an existing ', SPOTS_DOM);
                }
                _e('Spot:', SPOTS_DOM);
                ?>
						<select name="<?php 
                echo $this->get_field_name('id');
                ?>
" id="<?php 
                echo $this->get_field_id('id');
                ?>
" class="widefat spot-select"> <?php 
                printf('<option value="">%s</option>', __('None', SPOTS_DOM));
                foreach ($spots as $spot) {
                    printf('<option value="%s"%s>%s</option>', esc_attr($spot->ID), selected($spot->ID, (int) $id, false), esc_html(!empty($spot->post_title) ? $spot->post_title : $spot->ID));
                }
                ?>
						</select>
					</label>
				</p> <?php 
            }
            if (isset($spot_post)) {
                ?>
				<div class="code-toggle hide-if-no-js">
					<a href="#" class="button visual" data-id="<?php 
                echo $this->get_field_id('content');
                ?>
" ><?php 
                _e('Visual', SPOTS_DOM);
                ?>
</a>
					<a href="#" class="button text" data-id="<?php 
                echo $this->get_field_id('content');
                ?>
"><?php 
                _e('Text', SPOTS_DOM);
                ?>
</a>
				</div>

				<div class="editorcontainer wp-editor-wrap">
					<textarea cols="40" rows="10" class="widefat mceme" id="<?php 
                echo $this->get_field_id('content');
                ?>
" name="<?php 
                echo $this->get_field_name('content');
                ?>
">
						<?php 
                if (version_compare($wp_version, '4.3', '>=')) {
                    echo format_for_editor($spot_post->post_content);
                } else {
                    echo wp_richedit_pre($spot_post->post_content);
                }
                ?>
					</textarea>
				</div>

				<?php 
                if (version_compare($wp_version, '3.5', '<')) {
                    ?>

				<div class="spot-featured-image">
				<?php 
                    // show featured image if set
                    if (current_theme_supports('post-thumbnails')) {
                        echo $this->_wp_post_thumbnail_html(null, $spot_post->ID);
                    }
                    ?>
				</div>
				<?php 
                }
            }
            $templates = icit_spots::$instance_spots->get_templates();
            if ($templates) {
                ?>

				<p>
					<label for="<?php 
                echo $this->get_field_id('template');
                ?>
"><?php 
                _e('Template', SPOTS_DOM);
                ?>
</label>
					<select class="widefat" name="<?php 
                echo $this->get_field_name('template');
                ?>
" id="<?php 
                echo $this->get_field_id('template');
                ?>
">
						<option value=""><?php 
                _e('Default Template', SPOTS_DOM);
                ?>
</option> <?php 
                foreach ($templates as $i => $name) {
                    printf('<option value="%s" %s>%s</option>', esc_attr($name), selected($name, $template, false), esc_html(ucfirst($name)));
                }
                ?>
					</select>
				</p> <?php 
            }
            ?>

			<p><a class="edit-spot-link"<?php 
            echo intval($id) ? '' : ' style="display:none;"';
            ?>
 target="_parent" href="./post.php?post=<?php 
            echo $id;
            ?>
&amp;post_type=<?php 
            echo SPOTS_POST_TYPE;
            ?>
&amp;action=edit"><?php 
            _e('Go to the full editor for this spot', SPOTS_DOM);
            ?>
</a></p> <?php 
        }
コード例 #7
0
ファイル: wpeditor.php プロジェクト: jasmith93/cnws
<?php

if (!$is_compact) {
    echo VP_View::instance()->load('control/template_control_head', $head_info);
}
?>

<?php 
// prepare value for tinyMCE editor
$value = html_entity_decode($value, ENT_COMPAT, 'UTF-8');
if (has_filter('the_editor_content')) {
    $value = apply_filters('the_editor_content', $value);
} else {
    $value = format_for_editor($value);
}
?>
<div class="customEditor">
	<div class="wp-editor-tools">
		<div class="custom_upload_buttons hide-if-no-js wp-media-buttons"><?php 
do_action('media_buttons');
?>
</div>
	</div>
	<textarea class="vp-input vp-js-wpeditor" id="<?php 
echo $name . '_ce';
?>
" data-vp-opt="<?php 
echo $opt;
?>
" rows="10" cols="50" name="<?php 
echo $name;
コード例 #8
0
    public function display_setting($args = array())
    {
        extract($args);
        $options = get_option('truwriter_options');
        if (!isset($options[$id]) && $type != 'checkbox') {
            $options[$id] = $std;
        } elseif (!isset($options[$id])) {
            $options[$id] = 0;
        }
        $options['new_types'] = 'New Type Name';
        // always reset
        $field_class = '';
        if ($class != '') {
            $field_class = ' ' . $class;
        }
        switch ($type) {
            case 'heading':
                echo '</td></tr><tr valign="top"><td colspan="2"><h4 style="margin-bottom:0;">' . $desc . '</h4><p style="margin-top:0">' . $std . '</p>';
                break;
            case 'checkbox':
                echo '<input class="checkbox' . $field_class . '" type="checkbox" id="' . $id . '" name="truwriter_options[' . $id . ']" value="1" ' . checked($options[$id], 1, false) . ' /> <label for="' . $id . '">' . $desc . '</label>';
                break;
            case 'select':
                echo '<select class="select' . $field_class . '" name="truwriter_options[' . $id . ']">';
                foreach ($choices as $value => $label) {
                    echo '<option value="' . esc_attr($value) . '"' . selected($options[$id], $value, false) . '>' . $label . '</option>';
                }
                echo '</select>';
                if ($desc != '') {
                    echo '<br /><span class="description">' . $desc . '</span>';
                }
                break;
            case 'radio':
                $i = 0;
                foreach ($choices as $value => $label) {
                    echo '<input class="radio' . $field_class . '" type="radio" name="truwriter_options[' . $id . ']" id="' . $id . $i . '" value="' . esc_attr($value) . '" ' . checked($options[$id], $value, false) . '> <label for="' . $id . $i . '">' . $label . '</label>';
                    if ($i < count($options) - 1) {
                        echo '<br />';
                    }
                    $i++;
                }
                if ($desc != '') {
                    echo '<br /><span class="description">' . $desc . '</span>';
                }
                break;
            case 'textarea':
                echo '<textarea class="' . $field_class . '" id="' . $id . '" name="truwriter_options[' . $id . ']" placeholder="' . $std . '" rows="10" cols="80">' . format_for_editor($options[$id]) . '</textarea>';
                if ($desc != '') {
                    echo '<br /><span class="description">' . $desc . '</span>';
                }
                break;
            case 'medialoader':
                echo '<div id="uploader_' . $id . '">';
                if ($options[$id]) {
                    $front_img = wp_get_attachment_image_src($options[$id], 'radcliffe');
                    echo '<img id="previewimage_' . $id . '" src="' . $front_img[0] . '" width="640" height="300" alt="default thumbnail" />';
                } else {
                    echo '<img id="previewimage_' . $id . '" src="http://placehold.it/640x300" alt="default header image" />';
                }
                echo '<input type="hidden" name="truwriter_options[' . $id . ']" id="' . $id . '" value="' . $options[$id] . '" />
  <br /><input type="button" class="upload_image_button button-primary" name="_truwriter_button' . $id . '" id="_truwriter_button' . $id . '" data-options_id="' . $id . '" data-uploader_title="Set Default Header Image" data-uploader_button_text="Select Image" value="Set/Change Image" />
</div><!-- uploader -->';
                if ($desc != '') {
                    echo '<br /><span class="description">' . $desc . '</span>';
                }
                break;
            case 'password':
                echo '<input class="regular-text' . $field_class . '" type="password" id="' . $id . '" name="truwriter_options[' . $id . ']" value="' . esc_attr($options[$id]) . '" />';
                if ($desc != '') {
                    echo '<br /><span class="description">' . $desc . '</span>';
                }
                break;
            case 'text':
            default:
                echo '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="truwriter_options[' . $id . ']" placeholder="' . $std . '" value="' . esc_attr($options[$id]) . '" />';
                if ($desc != '') {
                    if ($id == 'def_thumb') {
                        $desc .= '<br /><a href="' . $options[$id] . '" target="_blank"><img src="' . $options[$id] . '" style="overflow: hidden;" width="' . $options["index_thumb_w"] . '"></a>';
                    }
                    echo '<br /><span class="description">' . $desc . '</span>';
                }
                break;
        }
    }
コード例 #9
0
 /**
  * Save the form
  *
  * @access public
  * @since 2.8.1
  * @return void
  */
 public function save_update_form()
 {
     global $wpdb;
     if (!isset($_POST['action']) || !isset($_GET['page'])) {
         return;
     }
     if ('visual-form-builder' !== $_GET['page']) {
         return;
     }
     if ('update_form' !== $_POST['action']) {
         return;
     }
     check_admin_referer('vfb_update_form');
     $form_id = absint($_POST['form_id']);
     $form_key = sanitize_title($_POST['form_title'], $form_id);
     $form_title = $_POST['form_title'];
     $form_subject = $_POST['form_email_subject'];
     $form_to = serialize(array_map('sanitize_email', $_POST['form_email_to']));
     $form_from = sanitize_email($_POST['form_email_from']);
     $form_from_name = $_POST['form_email_from_name'];
     $form_from_override = isset($_POST['form_email_from_override']) ? $_POST['form_email_from_override'] : '';
     $form_from_name_override = isset($_POST['form_email_from_name_override']) ? $_POST['form_email_from_name_override'] : '';
     $form_success_type = $_POST['form_success_type'];
     $form_notification_setting = isset($_POST['form_notification_setting']) ? $_POST['form_notification_setting'] : '';
     $form_notification_email_name = isset($_POST['form_notification_email_name']) ? $_POST['form_notification_email_name'] : '';
     $form_notification_email_from = isset($_POST['form_notification_email_from']) ? sanitize_email($_POST['form_notification_email_from']) : '';
     $form_notification_email = isset($_POST['form_notification_email']) ? $_POST['form_notification_email'] : '';
     $form_notification_subject = isset($_POST['form_notification_subject']) ? $_POST['form_notification_subject'] : '';
     $form_notification_message = isset($_POST['form_notification_message']) ? format_for_editor($_POST['form_notification_message']) : '';
     $form_notification_entry = isset($_POST['form_notification_entry']) ? $_POST['form_notification_entry'] : '';
     $form_label_alignment = $_POST['form_label_alignment'];
     // Add confirmation based on which type was selected
     switch ($form_success_type) {
         case 'text':
             $form_success_message = format_for_editor($_POST['form_success_message_text']);
             break;
         case 'page':
             $form_success_message = $_POST['form_success_message_page'];
             break;
         case 'redirect':
             $form_success_message = $_POST['form_success_message_redirect'];
             break;
     }
     $newdata = array('form_key' => $form_key, 'form_title' => $form_title, 'form_email_subject' => $form_subject, 'form_email_to' => $form_to, 'form_email_from' => $form_from, 'form_email_from_name' => $form_from_name, 'form_email_from_override' => $form_from_override, 'form_email_from_name_override' => $form_from_name_override, 'form_success_type' => $form_success_type, 'form_success_message' => $form_success_message, 'form_notification_setting' => $form_notification_setting, 'form_notification_email_name' => $form_notification_email_name, 'form_notification_email_from' => $form_notification_email_from, 'form_notification_email' => $form_notification_email, 'form_notification_subject' => $form_notification_subject, 'form_notification_message' => $form_notification_message, 'form_notification_entry' => $form_notification_entry, 'form_label_alignment' => $form_label_alignment);
     $where = array('form_id' => $form_id);
     // Update form details
     $wpdb->update($this->form_table_name, $newdata, $where);
     $field_ids = array();
     // Get max post vars, if available. Otherwise set to 1000
     $max_post_vars = ini_get('max_input_vars') ? intval(ini_get('max_input_vars')) : 1000;
     // Set a message to be displayed if we've reached a limit
     if (count($_POST, COUNT_RECURSIVE) > $max_post_vars) {
         $this->post_max_vars = true;
     }
     foreach ($_POST['field_id'] as $fields) {
         $field_ids[] = $fields;
     }
     // Initialize field sequence
     $field_sequence = 0;
     // Loop through each field and update
     foreach ($field_ids as $id) {
         $id = absint($id);
         $field_name = isset($_POST['field_name-' . $id]) ? trim($_POST['field_name-' . $id]) : '';
         $field_key = sanitize_key(sanitize_title($field_name, $id));
         $field_desc = isset($_POST['field_description-' . $id]) ? trim($_POST['field_description-' . $id]) : '';
         $field_options = isset($_POST['field_options-' . $id]) ? serialize(array_map('trim', $_POST['field_options-' . $id])) : '';
         $field_validation = isset($_POST['field_validation-' . $id]) ? $_POST['field_validation-' . $id] : '';
         $field_required = isset($_POST['field_required-' . $id]) ? $_POST['field_required-' . $id] : '';
         $field_size = isset($_POST['field_size-' . $id]) ? $_POST['field_size-' . $id] : '';
         $field_css = isset($_POST['field_css-' . $id]) ? $_POST['field_css-' . $id] : '';
         $field_layout = isset($_POST['field_layout-' . $id]) ? $_POST['field_layout-' . $id] : '';
         $field_default = isset($_POST['field_default-' . $id]) ? trim($_POST['field_default-' . $id]) : '';
         $field_data = array('field_key' => $field_key, 'field_name' => $field_name, 'field_description' => $field_desc, 'field_options' => $field_options, 'field_validation' => $field_validation, 'field_required' => $field_required, 'field_size' => $field_size, 'field_css' => $field_css, 'field_layout' => $field_layout, 'field_sequence' => $field_sequence, 'field_default' => $field_default);
         $where = array('form_id' => $form_id, 'field_id' => $id);
         // Update all fields
         $wpdb->update($this->field_table_name, $field_data, $where);
         $field_sequence++;
     }
 }
 public function test_editor_mode_conflicts()
 {
     $args = array('name' => 'test_richtextarea_1', 'default_value' => '<p>some <strong>html</strong> content</p>', 'editor_settings' => array('default_editor' => 'html'));
     $fm = new Fieldmanager_RichTextArea($args);
     ob_start();
     $fm->add_meta_box('Test RichTextArea', 'post')->render_meta_box($this->post, array());
     $html_1 = ob_get_clean();
     $args['name'] = 'test_richtextarea_2';
     $args['editor_settings']['default_editor'] = 'tinymce';
     $fm = new Fieldmanager_RichTextArea($args);
     ob_start();
     $fm->add_meta_box('Test RichTextArea', 'post')->render_meta_box($this->post, array());
     $html_2 = ob_get_clean();
     $args['name'] = 'test_richtextarea_3';
     $args['editor_settings']['default_editor'] = 'html';
     $fm = new Fieldmanager_RichTextArea($args);
     ob_start();
     $fm->add_meta_box('Test RichTextArea', 'post')->render_meta_box($this->post, array());
     $html_3 = ob_get_clean();
     if (_fm_phpunit_is_wp_at_least(3.9)) {
         $this->assertContains('html-active', $html_1);
         $this->assertNotContains('tmce-active', $html_1);
         $this->assertContains('tmce-active', $html_2);
         $this->assertNotContains('html-active', $html_2);
         $this->assertContains('html-active', $html_3);
         $this->assertNotContains('tmce-active', $html_3);
     } else {
         $this->_skip_tests_because_version(3.9);
     }
     if (_fm_phpunit_is_wp_at_least(4.3)) {
         $this->assertContains(format_for_editor($args['default_value']), $html_1);
         $this->assertContains(format_for_editor($args['default_value']), $html_2);
         $this->assertContains(format_for_editor($args['default_value']), $html_3);
     } elseif (_fm_phpunit_is_wp_at_least(3.9)) {
         $this->assertContains(wp_htmledit_pre($args['default_value']), $html_1);
         $this->assertContains(wp_richedit_pre($args['default_value']), $html_2);
         $this->assertContains(wp_htmledit_pre($args['default_value']), $html_3);
     } else {
         $this->_skip_tests_because_version(3.9);
     }
 }
コード例 #11
0
    function render()
    {
        $val = $this->get_value();
        $id = 'wysiwyg-' . $this->get_name();
        ?>
		<div id="wp-<?php 
        echo $id;
        ?>
-wrap" class="carbon-wysiwyg wp-editor-wrap tmce-active" data-toolbar="full">
			<div id="wp-<?php 
        echo $id;
        ?>
-editor-tools" class="wp-editor-tools">
				<div id="wp-<?php 
        echo $id;
        ?>
-media-buttons" class="hide-if-no-js wp-media-buttons">
					<?php 
        do_action('media_buttons');
        ?>
				</div>
			</div>
			<div class="wp-editor-tabs">
				<a class="wp-switch-editor switch-html">Text</a>
				<a class="wp-switch-editor switch-tmce">Visual</a>
			</div>

			<div id="wp-<?php 
        echo $id;
        ?>
-editor-container" class="wp-editor-container">
				<textarea id="<?php 
        echo $id;
        ?>
" class="wp-editor-area" name="<?php 
        echo $this->get_name();
        ?>
" <?php 
        echo $this->required ? 'data-carbon-required="true"' : '';
        ?>
><?php 
        echo format_for_editor($val);
        ?>
</textarea>
			</div>
		</div>
		<?php 
    }
コード例 #12
0
ファイル: wysiwyg.php プロジェクト: arfianadam/arfianadam.com
    function create_field($field)
    {
        global $wp_version;
        // vars
        $id = 'wysiwyg-' . $field['id'] . '-' . uniqid();
        ?>
		<div id="wp-<?php 
        echo $id;
        ?>
-wrap" class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php 
        echo $field['toolbar'];
        ?>
" data-upload="<?php 
        echo $field['media_upload'];
        ?>
">
			<?php 
        if (user_can_richedit() && $field['media_upload'] == 'yes') {
            ?>
				<?php 
            if (version_compare($wp_version, '3.3', '<')) {
                ?>
					<div id="editor-toolbar">
						<div id="media-buttons" class="hide-if-no-js">
							<?php 
                do_action('media_buttons');
                ?>
						</div>
					</div>
				<?php 
            } else {
                ?>
					<div id="wp-<?php 
                echo $id;
                ?>
-editor-tools" class="wp-editor-tools">
						<div id="wp-<?php 
                echo $id;
                ?>
-media-buttons" class="hide-if-no-js wp-media-buttons">
							<?php 
                do_action('media_buttons');
                ?>
						</div>
					</div>
				<?php 
            }
            ?>
			<?php 
        }
        ?>
			<div id="wp-<?php 
        echo $id;
        ?>
-editor-container" class="wp-editor-container">
				<textarea id="<?php 
        echo $id;
        ?>
" class="wp-editor-area" name="<?php 
        echo $field['name'];
        ?>
" ><?php 
        if (user_can_richedit()) {
            echo format_for_editor($field['value']);
        } else {
            echo format_for_editor($field['value']);
        }
        ?>
</textarea>
			</div>
		</div>
		
		<?php 
    }