/** * Loads the correct fields for the selected actions under Profile > Actions. * * @since 1.0.0 * @param $data str. The type of action being requested. * @return html. The fields. */ function bbconnect_get_post_to_edit() { if (!wp_verify_nonce($_POST['bbconnect_admin_nonce'], 'bbconnect-admin-nonce')) { die(__('Terribly sorry.', 'bbconnect')); } if (isset($_POST['data'])) { $cid = $_POST['cid']; $type = $_POST['type']; $post_val = array(); global $post; // WE'RE EDITING AN EXISTING FILE if (false !== strpos($_POST['data'], 'edit-')) { $post_id = (int) substr($_POST['data'], 5); $post = get_post($post_id); $post_author = $post->post_author; $post_type = $post->post_type; $action = 'edit'; if ($post_type == 'bb_note') { $note_types = wp_get_post_terms($post_id, 'bb_note_type'); foreach ($note_types as $note_type) { if ($note_type->parent == 0) { $parent_term = $note_type; } else { $child_term = $note_type; } } } } else { if ('user' == $type) { $bbconnect_actions = bbconnect_get_user_actions(); $post_type = 'bb_note'; if (empty($_POST['data'])) { echo ''; die; } } else { $bbconnect_actions = bbconnect_get_post_actions(); $post_type = false; $post_type = $_POST['data']; if (false == $post_type) { echo ''; die; } } $post = get_default_post_to_edit($post_type, true); $post_author = $_POST['uid']; $action = $_POST['actung']; } // SET THE NONCE if ('user' == $type) { bbconnect_user_actions_nonce_field(); } else { bbconnect_post_actions_nonce_field(); } $post_fields = array(array('meta' => array('source' => 'wpr', 'meta_key' => 'post_title', 'name' => __('Title', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'text', 'req' => true, 'public' => false, 'choices' => false))), array('meta' => array('source' => 'wpr', 'meta_key' => 'post_date', 'name' => __('Date', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'date', 'req' => true, 'public' => false, 'choices' => false)))); if ('user' == $type) { if (!empty($parent_term)) { // Editing existing note $post_fields[] = array('post_val' => $parent_term->slug, 'meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type_parent', 'name' => __('Type', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => true, 'public' => true, 'choices' => array($parent_term->slug => $parent_term->name)))); $post_fields[] = array('post_val' => $child_term->slug, 'meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type', 'name' => __('', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => false, 'public' => true, 'choices' => array($child_term->slug => $child_term->name)))); } else { // New note $parent_term = get_term_by('slug', $_POST['data'], 'bb_note_type'); $terms = get_terms('bb_note_type', array('hide_empty' => false, 'parent' => $parent_term->term_id)); $choices = array(); foreach ($terms as $term) { $choices[$term->slug] = $term->name; } $post_fields[] = array('meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type', 'name' => __('Type', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => true, 'public' => false, 'choices' => $choices))); $post_fields[] = array('meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type_parent', 'name' => __('', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'hidden', 'req' => false, 'public' => false, 'choices' => $parent_term->slug))); } } foreach ($post_fields as $field) { $meta_key = $field['meta']['meta_key']; $field['type'] = 'post'; $field['action'] = $action; $field['id'] = $post->ID; $field['swap_name'] = $meta_key; if (isset($post->{$meta_key})) { $field['post_val'] = $post->{$meta_key}; } echo '<p><ul style="display: block; float: none;">'; bbconnect_get_field($field); echo '</ul></p>'; } if ('bulk-edit' == $action) { echo '<ul><li class="meta-item"><span class="bbconnect-label">'; echo '<a class="rui off" title="' . $cid . 'bulk-edit">Enable Text</a>'; echo '</span><span class="bbconnect-field">'; } echo '<div style="width: 90%;padding: .3em;margin: .2em 0;"> </div>'; //echo '<p>'. __( 'Title', 'bbconnect' ) .'<br /><input type="text" name="post_title" class="regular-text" value="'.$post->post_title.'" /></p>'; //echo '<p>'. __( 'Date', 'bbconnect' ) .'<br /><input type="text" class="bbconnect-date" name="post_date" class="regular-text" value="'.$post->post_date.'" /></p>'; if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) { wp_editor(stripslashes($post->post_content), $cid, array('tinymce' => false, 'textarea_name' => 'post_content', 'teeny' => true, 'quicktags' => true)); } else { wp_editor(stripslashes($post->post_content), $cid, array('tinymce' => true, 'textarea_name' => 'post_content', 'teeny' => false, 'quicktags' => true)); } if ('bulk-edit' == $action) { echo '</span></li></ul>'; } // SET THE META if ('user' == $type) { bbconnect_user_actions_meta_fields(array('post_id' => $post->ID, 'fields' => bbconnect_get_user_actions_meta(), 'action' => $action, 'post_val' => $post_val)); } else { bbconnect_post_actions_meta_fields(array('post_id' => $post->ID, 'fields' => bbconnect_get_post_actions_meta(), 'action' => $action, 'post_val' => $post_val)); } ?> <input type="hidden" name="post_ID" value="<?php echo $post->ID; ?> " /> <input type="hidden" name="post_status" value="publish" /> <input type="hidden" name="post_author" value="<?php echo $post_author; ?> " /> <input type="hidden" name="post_type" value="<?php echo $post_type; ?> " /> <?php $inline_button = apply_filters('bbconnect_inline_do_action_button', array('<input type="submit" class="bbconnect-actions-save button-primary ' . $type . '" name="save" value="' . __('Save', 'bbconnect') . '" />'), $post_type, $type, $action); echo '<div class="tright">'; echo implode(' ', $inline_button); echo '</div>'; } else { echo 'error'; } if ('3.9' <= get_bloginfo('version')) { _WP_Editors::enqueue_scripts(); //print_footer_scripts(); _WP_Editors::editor_js(); echo '<script src="' . admin_url('js/editor.js') . '" />'; } die; }
} ?> <?php } ?> </td> <?php } ?> </tr> <?php } ?> </tbody> </table> </div> </div> <?php if (!$woocommerce_wpml->settings['first_editor_call']) { //load editor js if (class_exists('_WP_Editors')) { _WP_Editors::editor_js(); } $woocommerce_wpml->settings['first_editor_call'] = true; $woocommerce_wpml->update_settings(); } ?> </td> </tr>
function hrm_tinymce($element) { if (!isset($element['content']) || !isset($element['editor_id'])) { return; } if (empty($element['editor_id'])) { return; } ob_start(); $settings = isset($element['settings']) && is_array($element['settings']) ? $element['settings'] : array(); $id = isset($element['id']) ? esc_attr($element['id']) : ''; $desc = isset($element['desc']) ? esc_attr($element['desc']) : ''; $wrap_class = isset($element['wrap_class']) ? $element['wrap_class'] : ''; $wrap_tag = isset($element['wrap_tag']) ? $element['wrap_tag'] : 'div'; $extra = isset($element['extra']) ? $element['extra'] : array(); $required = isset($extra['data-hrm_required']) && $extra['data-hrm_required'] === true ? '*' : ''; $label = isset($element['label']) ? esc_attr($element['label']) : ''; echo $this->multiple_field_inside_this_wrap($element); printf('<%1$s class="hrm-form-field %2$s">', $wrap_tag, $wrap_class); printf('<%1$s class="hrm-form-field %2$s">', $wrap_tag, $wrap_class); printf('<label for="%1s">%2s<em>%3s</em></label>', $id, $label, $required); wp_editor($element['content'], $element['editor_id'], $settings); printf('<span class="hrm-clear"></span><span class="description">%s</span>', $desc); printf('</%s>', $wrap_tag); echo $this->multiple_field_inside_this_wrap_close($element); _WP_Editors::editor_js(); return ob_get_clean(); }
function wp_editors() { if (function_exists('wp_editor')) { $init_str = ''; ob_start(); _WP_Editors::editor_js(); $js = ob_get_contents(); ob_end_clean(); $js = explode('tinyMCEPreInit = {', $js); if (count($js) > 0) { $js[1] = explode('};', $js[1]); if (count($js[1]) > 0) { if (preg_match('/mceInit\\s*:(.*?),\\s*qtInit/is', $js[1][0], $matches)) { $init_str = $matches[1]; $js[1][0] = preg_replace('/mceInit\\s*:(.*?),\\s*qtInit/is', 'qtInit', $js[1][0]); } } $js[1] = implode('};', $js[1]); } if ($init_str != '') { echo ' <script type="text/javascript"> var OP_tinyMCE = ' . $init_str . '; </script>'; } $js = implode('tinyMCEPreInit = {', $js); echo $js; } }
/** * Add form item. Returns form item with selected arguments. * * @since 4.0.0 * @param array $args Input argument name => argument value */ public function add_form_item($args = array()) { $default = array('class' => '', 'inline_style' => '', 'type' => '', 'value' => '', 'multiple' => false, 'max_value' => '100', 'min_value' => '0', 'step_value' => '1', 'default_value' => '', 'options' => '', 'placeholder' => '', 'upload_button_text' => __('Choose Media', 'cherry'), 'remove_button_text' => __('Remove Media', 'cherry'), 'return_data_type' => 'id', 'multi_upload' => true, 'display_image' => true, 'display_input' => true, 'library_type' => '', 'label' => '', 'title' => '', 'description' => '', 'hint' => '', 'toggle' => array('true_toggle' => __('On', 'cherry'), 'false_toggle' => __('Off', 'cherry'))); extract(array_merge($default, $args)); $value = $value == '' || $value == false && $value != 0 ? $default_value : $value; $item_id = $id; $name = $this->generate_field_name($id); $id = $this->generate_field_id($id); $item_inline_style = $inline_style ? 'style="' . $inline_style . '"' : ''; $output = ''; if (is_array($this->options['hidden_items']) && in_array($item_id, $this->options['hidden_items'])) { return; } switch ($type) { case 'submit': // $output .= '<input ' . $item_inline_style . ' class="' . $class . ' '.$this->options['class']['submit'].'" id="' . $id . '" name="' . $name . '" type="'.$type.'" value="' . esc_html( $value ) . '" >'; $type .= ' ' . $class; $item_inline_style .= ' id=' . $id; $output .= get_submit_button($value, $type, $name, false, $item_inline_style); break; case 'reset': $output .= '<input ' . $item_inline_style . ' class="' . $class . ' ' . $this->options['class']['submit'] . '" id="' . $id . '" name="' . $name . '" type="reset" value="' . esc_html($value) . '" >'; break; case 'text': $ui_text = new UI_Text(array('id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'class' => $class)); $output .= $ui_text->render(); break; case 'textarea': $ui_textarea = new UI_Textarea(array('id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'class' => $class)); $output .= $ui_textarea->render(); break; case 'select': $ui_select = new UI_Select(array('id' => $id, 'name' => $name, 'multiple' => $multiple, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_select->render(); break; case 'checkbox': $ui_checkbox = new UI_Checkbox(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_checkbox->render(); break; case 'radio': $ui_radio = new UI_Radio(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_radio->render(); break; case 'switcher': $ui_switcher = new UI_Switcher(array('id' => $id, 'name' => $name, 'value' => $value, 'toggle' => $toggle, 'class' => $class)); $output .= $ui_switcher->render(); break; case 'stepper': $ui_stepper = new UI_Stepper(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class)); $output .= $ui_stepper->render(); break; case 'slider': $ui_slider = new UI_Slider(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class)); $output .= $ui_slider->render(); break; case 'rangeslider': $ui_range_slider = new UI_Range_Slider(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class)); $output .= $ui_range_slider->render(); break; case 'colorpicker': $ui_colorpicker = new UI_Colorpicker(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_colorpicker->render(); break; case 'media': $ui_media = new UI_Media(array('id' => $id, 'name' => $name, 'value' => $value, 'multi_upload' => $multi_upload, 'library_type' => $library_type, 'class' => $class)); $output .= $ui_media->render(); break; case 'background': $ui_background = new UI_Background(array('id' => $id, 'name' => $name, 'value' => $value, 'multi_upload' => $multi_upload, 'library_type' => $library_type, 'class' => $class)); $output .= $ui_background->render(); break; case 'typography': $ui_typography = new UI_Typography(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_typography->render(); break; case 'ace-editor': $ui_ace_editor = new UI_Ace_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_ace_editor->render(); break; case 'repeater': $ui_repeater = new UI_Repeater(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_repeater->render(); break; case 'static_area_editor': $ui_statics = new UI_Static_Area_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_statics->render(); break; case 'layouteditor': $ui_layout_editor = new UI_Layout_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_layout_editor->render(); break; case 'editor': //$wrap = false; ob_start(); $settings = array('textarea_name' => $name, 'media_buttons' => 1, 'teeny' => 0, 'textarea_rows' => 10, 'tinymce' => array('setup' => 'function(ed) { ed.onChange.add(function(ed) { tinyMCE.triggerSave(); }); }')); wp_editor($value, $id, $settings); $output .= ob_get_clean(); _WP_Editors::editor_js(); _WP_Editors::enqueue_scripts(); break; } return $this->wrap_item($output, $id, 'cherry-section cherry-' . $type . ' ' . $this->options['class']['section'], $title, $label, $description, $hint); }
function enqueue_controls_css() { include_once ReduxFramework::$_dir . 'core/enqueue.php'; $enqueue = new reduxCoreEnqueue($this->parent); $enqueue->get_warnings_and_errors_array(); $enqueue->init(); wp_enqueue_style('redux-extension-advanced-customizer', $this->_extension_url . 'extension_advanced_customizer.css'); wp_enqueue_script('redux-extension-advanced-customizer', $this->_extension_url . 'extension_advanced_customizer.js', array('jquery'), ReduxFramework_extension_advanced_customizer::$version . '4', true); require_once ABSPATH . '/wp-includes/class-wp-editor.php'; _WP_Editors::enqueue_scripts(); _WP_Editors::editor_js(); }
/** * @internal **/ public function _action_print_wp_editor() { if (!class_exists('_WP_Editors')) { require ABSPATH . WPINC . '/class-wp-editor.php'; $id = 'fw-wp-editor-option-type'; $set = _WP_Editors::parse_settings($id, array('teeny' => true, 'media_buttons' => true, 'tinymce' => true, 'editor_css' => true, 'quicktags' => true)); _WP_Editors::editor_settings($id, $set); _WP_Editors::enqueue_scripts(); _WP_Editors::editor_js(); } }
/** * Query Maker Engine */ function rad_query_listener() { global $post, $super_options, $helper, $ioa_meta_data; $type = $_REQUEST["type"]; if ($type == "rad-live-save") { if (!isset($_POST['data'])) { return 0; } $post_ID = $_POST['id']; $the_post = array('ID' => $post_ID, 'post_content' => $_POST['data']); // Update the post into the database wp_update_post($the_post); $ioa_options = get_post_meta($post_ID, 'ioa_options', true); $ioa_options['ioa_template_mode'] = 'rad-builder'; update_post_meta($post_ID, 'ioa_options', $ioa_options); update_post_meta($post_ID, '_style_keys', $_POST['styles']); update_post_meta($post_ID, 'rad_version', RAD_Version); echo 1; } elseif ($type == 'rad-live-preview') { global $radunits, $helper; $widget = array(); $widget['data'] = $_POST['data']; $widget['id'] = $_POST['id']; $widget['type'] = $_POST['key']; $widget['layout'] = 'full'; $widget['data']['id'] = $_POST['id']; $widget['data']['type'] = $_POST['key']; if (isset($widget['data']['inputs'])) { $widget['data'] = $widget['data']['inputs']; } $widget['data'] = $helper->getAssocMap($widget['data'], 'value'); $ioa_meta_data['widget'] = $widget; $ioa_meta_data['widget_classes'] = ' w_layout_element '; $ioa_meta_data['widget_classes'] .= ' w_full '; $ioa_meta_data['rad_type'] = $widget['type']; get_template_part("templates/rad/" . $radunits[str_replace('-', '_', $widget['type'])]->data['template']); } elseif ($type == "rad-builder-data") { global $radunits, $post, $ioa_portfolio_slug; $settings = array(); foreach ($radunits as $key => $widget) { if ($widget->getCommonKey() != "") { $settings[$widget->getCommonKey()] = $widget->mapSettingsOverlay(); } else { $settings[$key] = $widget->mapSettingsOverlay(); } } array_unique($settings); foreach ($settings as $key => $setting) { echo $setting; } } elseif ($type == "rad_wp_editor") { $settings = array('wpautop' => true, 'media_buttons' => true, 'textarea_name' => 'rad_wp_editor', 'textarea_rows' => 15, 'textarea_columns' => 4, 'tinymce' => array('theme_advanced_buttons1' => 'bold,italic,underline,blockquote,|,bullist ,numlist , link,unlink, ioabutton', 'theme_advanced_buttons2' => '', 'theme_advanced_buttons3' => '', 'theme_advanced_buttons4' => '', 'content_css' => get_stylesheet_directory_uri() . '/sprites/stylesheets/custom-editor-style.css'), 'tabindex' => '', 'editor_class' => " rad-editor", 'teeny' => false, 'dfw' => false, 'quicktags' => true); wp_editor('', 'rad_wp_editor', $settings); if (!class_exists('_WP_Editors')) { require ABSPATH . WPINC . '/class-wp-editor.php'; } _WP_Editors::editor_js(); } elseif ($type == "RAD") { $data = array(); if (isset($_POST['data'])) { $data = $_POST['data']; } echo update_post_meta($_POST['id'], 'rad_data', $data); } elseif ($type == "RAD-Template-Export") { $tdata = array(); if (isset($_POST['data'])) { $tdata = $_POST['data']; } $title = 'Page_Template'; if (isset($_POST['title'])) { $title = str_replace(' ', '_', $_POST['title']); } echo set_transient('TEMP_RAD_TEMPLATE', $tdata, 60 * 60); echo set_transient('TEMP_RAD_TEMPLATE_TITLE', $title, 60 * 60); } elseif ($type == "RAD-Template") { $data = array(); if (get_option('RAD_TEMPLATES')) { $data = get_option('RAD_TEMPLATES'); } $tdata = array(); if (isset($_POST['data'])) { $tdata = $_POST['data']; } $title = $_POST['title']; $id = 'RT' . uniqid(); $data[$id] = array('post_id' => $_POST['id'], 'data' => $tdata, 'title' => $title); update_option('RAD_TEMPLATES', $data); } elseif ($type == "RAD-Template-Section") { $data = array(); if (get_option('RAD_TEMPLATES_SECTION')) { $data = get_option('RAD_TEMPLATES_SECTION'); } $tdata = array(); if (isset($_POST['data'])) { $tdata = $_POST['data']; } $title = $_POST['title']; $id = 'ST' . uniqid(); $data[$id] = array('post_id' => $_POST['id'], 'data' => $tdata, 'title' => $title); update_option('RAD_TEMPLATES_SECTION', $data); } elseif ($type == 'RAD-Revision-Import') { $post_id = $_POST['post_id']; $revisions = get_post_meta($post_id, 'rad_revisions', true); $revision = $revisions[$_POST['key']]; $template = $revision['data']; foreach ($template as $key => $section) { $d = $section['data']; $d = radAssocMap($d, 'value'); $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } RADMarkup::generateRADSection($d, $section['id'], $containers, false, $section['data']); } } elseif ($type == "RAD-Revision") { $tdata = $_POST['data']; $title = $_POST['title']; $rev_id = 'RT' . uniqid(); $post_id = $_POST['id']; $length = 5; $revisions = get_post_meta($post_id, 'rad_revisions', true); if ($revisions == "") { $revisions = array(); } $revisions[$rev_id] = array('title' => $title, 'post_id' => $post_id, 'data' => json_decode(stripslashes($tdata), true)); if (count($revisions) > $length) { array_shift($revisions); } echo update_post_meta($post_id, 'rad_revisions', $revisions); } elseif ($type == "RAD-Template-Delete") { $data = array(); if (get_option('RAD_TEMPLATES')) { $data = get_option('RAD_TEMPLATES'); } $id = $_POST['key']; unset($data[$id]); update_option('RAD_TEMPLATES', $data); } elseif ($type == "RAD-Section-Delete") { $data = array(); if (get_option('RAD_TEMPLATES_SECTION')) { $data = get_option('RAD_TEMPLATES_SECTION'); } $id = $_POST['key']; unset($data[$id]); update_option('RAD_TEMPLATES_SECTION', $data); } elseif ($type == "RAD-Page-Import") { $data = array(); $data = base64_decode($_POST['data']); $template = json_decode(stripslashes($data), true); foreach ($template as $key => $section) { $d = $section['data']; $d = radAssocMap($d, 'value'); $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } RADMarkup::generateRADSection($d, $section['id'], $containers, false, $section['data']); } } elseif ($type == 'RAD-OldBackup') { $data = array(); $pid = $_POST['pid']; $old_backup = get_post_meta($pid, 'rad_data', true); if (!is_array($old_backup)) { $old_backup = json_decode(stripslashes(base64_decode($old_backup)), true); } foreach ($old_backup as $key => $section) { $d = array(); if (isset($section['data'])) { $d = $section['data']; } $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } foreach ($containers as $container) { $data = array(); if (gettype($container['data']) == "string") { $container['data'] = json_decode($container['data'], true); } foreach ($container['data'] as $key => $value) { if ($key != 'id' && $key != 'layout' && $key != 'first' && $key != 'top' && $key != 'last') { $data[] = array("name" => $key, "value" => $value); } } if (isset($data[0]['value']) && is_array($data[0]['value'])) { $data = $container['data']; $data[] = array("name" => 'id', "value" => $container['id']); } if (isset($container['id'])) { $container['data']['id'] = $container['id']; } $widgets = array(); if (isset($container['widgets'])) { $widgets = $container['widgets']; } foreach ($widgets as $key => $w) { $data = array(); foreach ($w as $key => $value) { if ($key != 'id' && $key != 'layout' && $key != 'first' && $key != 'top' && $key != 'last') { $v = $value; if ($key == 'text_data') { $v = str_replace('\\', '', $v); // remove unecessary text data slashes } $v = str_replace(array('&squot;', '&quot;', '&sqstart;', '&sqend;', '<'), array('\'', '"', '[', ']', '<'), $v); $data[] = array("name" => $key, "value" => $v); } } if (isset($w['data'])) { if (gettype($w['data']) == "string") { $data = json_decode($w['data'], true); } } if (isset($w['type'])) { $data[] = array("name" => "type", "value" => str_replace('-', '_', $w['type'])); } if (isset($w['id'])) { $data[] = array("name" => "id", "value" => str_replace('-', '_', $w['id'])); } if (isset($data[0]['value']) && is_array($data[0]['value'])) { $type = $data[1]; $data = $data[0]['value']; $data[] = $type; $new_data = array(); foreach ($data as $key => $r) { $new_data[] = array("name" => $r['name'], "value" => stripslashes($r['value'])); } $data = $new_data; } } } $id = 'rps' . uniqid(); if (isset($d['id'])) { $id = $d['id']; } $data = array(); if (gettype($section['data']) == "string") { $section['data'] = json_decode($section['data'], true); } foreach ($section['data'] as $key => $value) { if ($key != 'id' && $key != 'first' && $key != 'top' && $key != 'last') { $data[] = array("name" => $key, "value" => $value); } if (isset($section['id'])) { $section['data']['id'] = $section['id']; } } if (isset($section['data'][0]['name'])) { $data = array(); foreach ($section['data'] as $key => $value) { if ($key != "id") { $data[] = array("name" => $value['name'], "value" => $value['value']); } } if (isset($section['id'])) { $data[] = array("name" => "id", "value" => $section['id']); } $id = $section['id']; } RADMarkup::generateRADSection($data, $id, $containers, false, $data); } } elseif ($type == "RAD-Live-Page-Import") { global $ioa_meta_data; $data = array(); $data = base64_decode($_POST['data']); $template = json_decode(stripslashes($data), true); $ioa_meta_data['rad_data'] = $template; get_template_part('templates/rad/construct'); } elseif ($type == "RAD-Import") { $data = array(); if (get_option('RAD_TEMPLATES')) { $data = get_option('RAD_TEMPLATES'); } $tkey = $_POST['key']; $template = json_decode(stripslashes($data[$tkey]['data']), true); foreach ($template as $key => $section) { $d = $section['data']; $d = radAssocMap($d, 'value'); $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } RADMarkup::generateRADSection($d, $section['id'], $containers, false, $section['data']); } } elseif ($type == "RAD-Import-Section") { $data = array(); if (get_option('RAD_TEMPLATES_SECTION')) { $data = get_option('RAD_TEMPLATES_SECTION'); } $tkey = $_POST['key']; $template = json_decode(stripslashes($data[$tkey]['data']), true); foreach ($template as $key => $section) { $d = $section['data']; $d = radAssocMap($d, 'value'); $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } RADMarkup::generateRADSection($d, $section['id'], $containers, false, $section['data']); } } elseif ($type == 'RAD-Sidebar') { global $radunits; ?> <div class="settings-bar"> <div class="top-bar clearfix"> <a href="" class="save-settings"><?php _e('Save', 'ioa'); ?> </a> <a href="" class="preview-trigger"><?php _e('Preview', 'ioa'); ?> <span></span></a> <a href="" class="cancel-settings"><i class="ioa-front-icon cancel-2icon-"></i></a> </div> <div class="settings-body"> <div class="inner-settings-body clearfix"> <?php $settings = array(); foreach ($radunits as $key => $widget) { if ($widget->getCommonKey() != "") { $settings[$widget->getCommonKey()] = $widget->mapSettingsOverlay(array('noeditor' => false, 'switcher' => true)); } else { $settings[$key] = $widget->mapSettingsOverlay(array('noeditor' => false, 'switcher' => true)); } } array_unique($settings); foreach ($settings as $key => $setting) { echo $setting; } ?> </div> </div> </div> <?php } elseif ($type == "RAD-InstaImport") { $ins_path = get_template_directory() . "/sprites/templates/" . $_POST['key']; $fh = fopen($ins_path, 'r'); $super_query = fread($fh, filesize($ins_path)); $data = base64_decode($super_query); $template = json_decode(stripslashes($data), true); foreach ($template as $key => $section) { $d = $section['data']; $d = radAssocMap($d, 'value'); $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } RADMarkup::generateRADSection($d, $section['id'], $containers, false, $section['data']); } } elseif ($type == "RAD-InstaImport-Section") { $ins_path = get_template_directory() . "/sprites/rad_sections/" . $_POST['key']; $fh = fopen($ins_path, 'r'); $super_query = fread($fh, filesize($ins_path)); $data = base64_decode($super_query); $template = json_decode(stripslashes($data), true); foreach ($template as $key => $section) { $d = $section['data']; $d = radAssocMap($d, 'value'); $containers = array(); if (isset($section['containers'])) { $containers = $section['containers']; } RADMarkup::generateRADSection($d, $section['id'], $containers, false, $section['data']); } } die; }
function admin_print_footer_scripts() { if (!$this->is_valid($this->current_source)) { return false; } if (!class_exists('_WP_Editors')) { require ABSPATH . WPINC . '/class-wp-editor.php'; } /** * TODO: Make this not so hacky :) * * To get things setup so we can actually have TinyMCE loaded for use in the * individual slide source editors, we need to get TinyMCE loaded on the page first. * Unfortunately TinyMCE is not a registered script for WordPress yet, so its * not as easy as using wp_enqueue_script() to get it in there. TinyMCE is however * hard coded for output with the wp_editor() script. All we need to do is run it * once to get it scheduled for loading and the _WP_Editors class takes care of * the rest to get it loaded when we actually call the _WP_Editors::editor_js() */ ob_start(); wp_editor("", $this->namespace, apply_filters("{$this->namespace}_wp_editor_settings", $this->wp_editor_settings)); ob_end_clean(); _WP_Editors::editor_js(); }
/** * This feature is deprecated, but we still try to support it. */ public function test_init_options() { $value = rand_str(); $value_2 = rand_str(); $css_url = 'http://example.org/' . rand_str() . '.css'; $css_url_2 = 'http://example.org/' . rand_str() . '.css'; $fm = new Fieldmanager_RichTextArea(array('name' => 'test_richtextarea', 'init_options' => array('fm_test' => $value, 'content_css' => $css_url))); ob_start(); $fm->add_meta_box('Test RichTextArea', 'post')->render_meta_box($this->post, array()); ob_end_clean(); ob_start(); _WP_Editors::editor_js(); $js = ob_get_clean(); $this->assertContains('fm_test:"' . $value . '"', $js); $this->assertContains($css_url, $js); // Now test that `editor_settings` and `stylesheet` take precedence $fm = new Fieldmanager_RichTextArea(array('name' => 'test_richtextarea', 'init_options' => array('fm_test' => $value, 'content_css' => $css_url), 'stylesheet' => $css_url_2, 'editor_settings' => array('tinymce' => array('fm_test' => $value_2)))); ob_start(); $fm->add_meta_box('Test RichTextArea', 'post')->render_meta_box($this->post, array()); ob_end_clean(); ob_start(); _WP_Editors::editor_js(); $js = ob_get_clean(); $this->assertNotContains('fm_test:"' . $value . '"', $js); $this->assertNotContains($css_url, $js); $this->assertContains('fm_test:"' . $value_2 . '"', $js); $this->assertContains($css_url_2, $js); }