コード例 #1
0
    /**
     * 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);
    }
コード例 #2
0
/**
 * 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;">&nbsp;</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;
}
コード例 #3
0
 public static function enqueue_footer_js()
 {
     global $frm_vars, $frm_input_masks;
     if (empty($frm_vars['forms_loaded'])) {
         return;
     }
     FrmFormsController::register_pro_scripts();
     if (!FrmAppHelper::doing_ajax()) {
         wp_enqueue_script('formidable');
     }
     if (isset($frm_vars['tinymce_loaded']) && $frm_vars['tinymce_loaded']) {
         _WP_Editors::enqueue_scripts();
     }
     // trigger jQuery UI to be loaded on every page
     self::add_js();
     if (isset($frm_vars['datepicker_loaded']) && !empty($frm_vars['datepicker_loaded'])) {
         if (is_array($frm_vars['datepicker_loaded'])) {
             foreach ($frm_vars['datepicker_loaded'] as $fid => $o) {
                 if (!$o) {
                     unset($frm_vars['datepicker_loaded'][$fid]);
                 }
                 unset($fid, $o);
             }
         }
         if (!empty($frm_vars['datepicker_loaded'])) {
             wp_enqueue_script('jquery-ui-datepicker');
             FrmStylesHelper::enqueue_jquery_css();
         }
     }
     if (isset($frm_vars['chosen_loaded']) && $frm_vars['chosen_loaded']) {
         wp_enqueue_script('jquery-chosen');
     }
     if (isset($frm_vars['star_loaded']) && !empty($frm_vars['star_loaded'])) {
         wp_enqueue_script('jquery-frm-rating');
         wp_enqueue_style('dashicons');
         FrmStylesController::enqueue_style();
     }
     $frm_input_masks = apply_filters('frm_input_masks', $frm_input_masks, $frm_vars['forms_loaded']);
     foreach ((array) $frm_input_masks as $fid => $o) {
         if (!$o) {
             unset($frm_input_masks[$fid]);
         }
         unset($fid, $o);
     }
     if (!empty($frm_input_masks)) {
         wp_enqueue_script('jquery-maskedinput');
     }
     if (isset($frm_vars['google_graphs']) && !empty($frm_vars['google_graphs'])) {
         wp_enqueue_script('google_jsapi', 'https://www.google.com/jsapi');
     }
 }
コード例 #4
0
 public static function enqueue_footer_js()
 {
     global $frm_vars, $frm_input_masks;
     if (empty($frm_vars['forms_loaded'])) {
         return;
     }
     $scripts = array();
     if (!defined('DOING_AJAX') or isset($frm_vars['preview']) and $frm_vars['preview']) {
         $scripts[] = 'formidable';
     }
     if (isset($frm_vars['recap_script']) and $frm_vars['recap_script']) {
         $scripts[] = 'recaptcha-ajax';
     }
     $styles = array();
     if (isset($frm_vars['rte_loaded']) && !empty($frm_vars['rte_loaded'])) {
         $scripts[] = 'nicedit';
     }
     if (isset($frm_vars['tinymce_loaded']) && $frm_vars['tinymce_loaded']) {
         _WP_Editors::enqueue_scripts();
     }
     if (isset($frm_vars['datepicker_loaded']) and !empty($frm_vars['datepicker_loaded'])) {
         if (is_array($frm_vars['datepicker_loaded'])) {
             foreach ($frm_vars['datepicker_loaded'] as $fid => $o) {
                 if (!$o) {
                     unset($frm_vars['datepicker_loaded'][$fid]);
                 }
                 unset($fid);
                 unset($o);
             }
         }
         if (!empty($frm_vars['datepicker_loaded'])) {
             $scripts[] = 'jquery-ui-datepicker';
             $styles[] = 'jquery-theme';
         }
     }
     if (isset($frm_vars['chosen_loaded']) and $frm_vars['chosen_loaded']) {
         $scripts[] = 'jquery-chosen';
     }
     if (isset($frm_vars['star_loaded']) and !empty($frm_vars['star_loaded'])) {
         $scripts[] = 'jquery-frm-rating';
         wp_enqueue_style('dashicons');
         global $frm_settings;
         if ((!isset($frm_vars['css_loaded']) || !$frm_vars['css_loaded']) && $frm_settings->load_style != 'none') {
             $styles[] = 'formidable';
             $frm_vars['css_loaded'] = true;
         }
     }
     $frm_input_masks = apply_filters('frm_input_masks', $frm_input_masks, $frm_vars['forms_loaded']);
     foreach ((array) $frm_input_masks as $fid => $o) {
         if (!$o) {
             unset($frm_input_masks[$fid]);
         }
         unset($fid);
         unset($o);
     }
     if (!empty($frm_input_masks)) {
         $scripts[] = 'jquery-maskedinput';
     }
     if (!empty($scripts)) {
         FrmAppHelper::load_scripts($scripts);
     }
     if (!empty($styles)) {
         FrmAppHelper::load_styles($styles);
     }
     unset($scripts);
 }
 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();
 }
コード例 #6
0
 /**
  * @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();
     }
 }
コード例 #7
0
        /**
         * Action: customize_controls_print_footer_scripts
         */
        public function customize_controls_print_footer_scripts()
        {

            // Because of https://core.trac.wordpress.org/ticket/27853
            // Which was fixed in 3.9.1 so we only need this on earlier versions
            $wp_version = get_bloginfo('version');
            if (version_compare($wp_version, '3.9.1', '<') && class_exists('_WP_Editors')) {
                _WP_Editors::enqueue_scripts();
            }

        } // END customize_controls_print_footer_scripts