function so_panels_bootstrap_admin_enqueue_scripts($prefix = '', $force = false)
{
    $screen = get_current_screen();
    if ($force || siteorigin_panels_is_admin_page()) {
        wp_enqueue_media();
        //wp_enqueue_script( 'so-panels-bootstrap-admin', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array( 'jquery', 'jquery-ui-resizable', 'jquery-ui-sortable', 'jquery-ui-draggable', 'underscore', 'backbone', 'plupload', 'plupload-all' ), SITEORIGIN_PANELS_VERSION, true );
        wp_enqueue_script('so-panels-bootstrap-admin', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-sortable', 'jquery-ui-draggable', 'underscore', 'backbone', 'plupload', 'plupload-all'), SITEORIGIN_PANELS_VERSION, true);
        wp_enqueue_script('so-panels-bootstrap-admin-utils', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap-utils' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', null, SITEORIGIN_PANELS_VERSION, true);
        wp_enqueue_script('so-panels-bootstrap-admin-utils', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap-utils' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', null, SITEORIGIN_PANELS_VERSION, true);
        wp_enqueue_script('so-panels-bootstrap-admin-styles', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap-styles' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array('jquery', 'underscore', 'backbone', 'wp-color-picker'), SITEORIGIN_PANELS_VERSION, true);
        if ($screen->base != 'widgets' && $screen->base != 'customize') {
            // We don't use the history browser and live editor in the widgets interface
            wp_enqueue_script('so-panels-bootstrap-admin-history', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap-history' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array('so-panels-bootstrap-admin', 'jquery', 'underscore', 'backbone'), SITEORIGIN_PANELS_VERSION, true);
            wp_enqueue_script('so-panels-bootstrap-admin-live-editor', plugin_dir_url(__FILE__) . 'assets/js/so-panels-bootstrap-admin-live-editor' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array('so-panels-bootstrap-admin', 'jquery', 'underscore', 'backbone'), SITEORIGIN_PANELS_VERSION, true);
        }
        add_action('admin_footer', 'siteorigin_panels_js_templates');
        $widgets = siteorigin_panels_get_widgets();
        $directory_enabled = get_user_meta(get_current_user_id(), 'so_panels_directory_enabled', true);
        wp_localize_script('so-panels-bootstrap-admin', 'soPanelsOptions', array('ajaxurl' => wp_nonce_url(admin_url('admin-ajax.php'), 'panels_action', '_panelsnonce'), 'widgets' => $widgets, 'widget_dialog_tabs' => apply_filters('siteorigin_panels_widget_dialog_tabs', array(0 => array('title' => __('All Widgets', 'siteorigin-panels'), 'filter' => array('installed' => true, 'groups' => '')))), 'row_layouts' => apply_filters('siteorigin_panels_row_layouts', array()), 'directory_enabled' => !empty($directory_enabled), 'contextual' => array('default_widgets' => apply_filters('siteorigin_panels_contextual_default_widgets', array('SiteOrigin_Widget_Editor_Widget', 'SiteOrigin_Widget_Button_Widget', 'SiteOrigin_Widget_Image_Widget', 'SiteOrigin_Panels_Widgets_Layout'))), 'loc' => array('missing_widget' => array('title' => __('Missing Widget', 'siteorigin-panels'), 'description' => __("Page Builder doesn't know about this widget.", 'siteorigin-panels')), 'time' => array('seconds' => __('%d seconds', 'siteorigin-panels'), 'minutes' => __('%d minutes', 'siteorigin-panels'), 'hours' => __('%d hours', 'siteorigin-panels'), 'second' => __('%d second', 'siteorigin-panels'), 'minute' => __('%d minute', 'siteorigin-panels'), 'hour' => __('%d hour', 'siteorigin-panels'), 'ago' => __('%s before', 'siteorigin-panels'), 'now' => __('Now', 'siteorigin-panels')), 'history' => array('current' => __('Current', 'siteorigin-panels'), 'revert' => __('Original', 'siteorigin-panels'), 'restore' => __('Version restored', 'siteorigin-panels'), 'back_to_editor' => __('Converted to editor', 'siteorigin-panels'), 'widget_deleted' => __('Widget deleted', 'siteorigin-panels'), 'widget_added' => __('Widget added', 'siteorigin-panels'), 'widget_edited' => __('Widget edited', 'siteorigin-panels'), 'widget_duplicated' => __('Widget duplicated', 'siteorigin-panels'), 'widget_moved' => __('Widget moved', 'siteorigin-panels'), 'row_deleted' => __('Row deleted', 'siteorigin-panels'), 'row_added' => __('Row added', 'siteorigin-panels'), 'row_edited' => __('Row edited', 'siteorigin-panels'), 'row_moved' => __('Row moved', 'siteorigin-panels'), 'row_duplicated' => __('Row duplicated', 'siteorigin-panels'), 'cell_resized' => __('Cell resized', 'siteorigin-panels'), 'prebuilt_loaded' => __('Prebuilt layout loaded', 'siteorigin-panels')), 'prebuilt_confirm' => __('Are you sure you want to overwrite your current content? This can be undone in the builder history.', 'siteorigin-panels'), 'prebuilt_loading' => __('Loading prebuilt layout', 'siteorigin-panels'), 'confirm_use_builder' => __("Would you like to copy this editor's existing content to Page Builder?", 'siteorigin-panels'), 'confirm_stop_builder' => __("Would you like to clear your Page Builder content and revert to using the standard visual editor?", 'siteorigin-panels'), 'layout_widget' => __('Layout Builder Widget', 'siteorigin-panels'), 'dropdown_confirm' => __('Are you sure?', 'siteorigin-panels'), 'search_results_header' => __('Search Results For: ', 'siteorigin-panels'), 'contextual' => array('add_widget_below' => __('Add Widget Below', 'siteorigin-panels'), 'add_widget_cell' => __('Add Widget to Cell', 'siteorigin-panels'), 'search_widgets' => __('Search Widgets', 'siteorigin-panels'), 'add_row' => __('Add Row', 'siteorigin-panels'), 'column' => __('Column', 'siteorigin-panels'))), 'plupload' => array('max_file_size' => wp_max_upload_size() . 'b', 'url' => wp_nonce_url(admin_url('admin-ajax.php'), 'panels_action', '_panelsnonce'), 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filter_title' => __('Page Builder layouts', 'siteorigin-panels'), 'error_message' => __('Error uploading or importing file.', 'siteorigin-panels')), 'wpColorPickerOptions' => apply_filters('siteorigin_panels_wpcolorpicker_options', array())));
    }
}
Esempio n. 2
0
/**
 * Render a widget form with all the Page Builder specific fields
 *
 * @param string $widget The class of the widget
 * @param array $instance Widget values
 * @param bool $raw
 * @param string $widget_number
 * @return mixed|string The form
 */
function siteorigin_panels_render_form($widget, $instance = array(), $raw = false, $widget_number = '{$id}')
{
    global $wp_widget_factory;
    // This is a chance for plugins to replace missing widgets
    $the_widget = !empty($wp_widget_factory->widgets[$widget]) ? $wp_widget_factory->widgets[$widget] : false;
    $the_widget = apply_filters('siteorigin_panels_widget_object', $the_widget, $widget);
    if (empty($the_widget) || !is_a($the_widget, 'WP_Widget')) {
        $widgets = siteorigin_panels_get_widgets();
        if (!empty($widgets[$widget]) && !empty($widgets[$widget]['plugin'])) {
            // We know about this widget, show a form about installing it.
            $install_url = siteorigin_panels_plugin_activation_install_url($widgets[$widget]['plugin']['slug'], $widgets[$widget]['plugin']['name']);
            $form = '<div class="panels-missing-widget-form">' . '<p>' . preg_replace(array('/1\\{ *(.*?) *\\}/', '/2\\{ *(.*?) *\\}/'), array('<a href="' . $install_url . '" target="_blank">$1</a>', '<strong>$1</strong>'), sprintf(__('You need to install 1{%1$s} to use the widget 2{%2$s}.', 'siteorigin-panels'), $widgets[$widget]['plugin']['name'], $widget)) . '</p>' . '<p>' . __("Save and reload this page to start using the widget after you've installed it.", 'siteorigin-panels') . '</p>' . '</div>';
        } else {
            // This widget is missing, so show a missing widgets form.
            $form = '<div class="panels-missing-widget-form"><p>' . preg_replace(array('/1\\{ *(.*?) *\\}/', '/2\\{ *(.*?) *\\}/'), array('<strong>$1</strong>', '<a href="https://siteorigin.com/thread/" target="_blank">$1</a>'), sprintf(__('The widget 1{%1$s} is not available. Please try locate and install the missing plugin. Post on the 2{support forums} if you need help.', 'siteorigin-panels'), esc_html($widget))) . '</p></div>';
        }
        // Allow other themes and plugins to change the missing widget form
        return apply_filters('siteorigin_panels_missing_widget_form', $form, $widget, $instance);
    }
    if ($raw) {
        $instance = $the_widget->update($instance, $instance);
    }
    $the_widget->id = 'temp';
    $the_widget->number = $widget_number;
    ob_start();
    $return = $the_widget->form($instance);
    do_action_ref_array('in_widget_form', array(&$the_widget, &$return, $instance));
    $form = ob_get_clean();
    // Convert the widget field naming into ones that Page Builder uses
    $exp = preg_quote($the_widget->get_field_name('____'));
    $exp = str_replace('____', '(.*?)', $exp);
    $form = preg_replace('/' . $exp . '/', 'widgets[' . preg_replace('/\\$(\\d)/', '\\\\$$1', $widget_number) . '][$1]', $form);
    $form = apply_filters('siteorigin_panels_widget_form', $form, $widget, $instance);
    // Add all the information fields
    return $form;
}
/**
 * Render a widget form with all the Page Builder specific fields
 *
 * @param string $widget The class of the widget
 * @param array $instance Widget values
 * @param bool $raw
 * @return mixed|string The form
 */
function siteorigin_panels_render_form($widget, $instance = array(), $raw = false)
{
    global $wp_widget_factory;
    // This is a chance for plugins to replace missing widgets
    $the_widget = !empty($wp_widget_factory->widgets[$widget]) ? $wp_widget_factory->widgets[$widget] : false;
    $the_widget = apply_filters('siteorigin_panels_widget_object', $the_widget, $widget);
    if (empty($the_widget) || !is_a($the_widget, 'WP_Widget')) {
        $widgets = siteorigin_panels_get_widgets();
        if (!empty($widgets[$widget]) && !empty($widgets[$widget]['plugin'])) {
            // We know about this widget, show a form about installing it.
            $install_url = siteorigin_panels_plugin_activation_install_url($widgets[$widget]['plugin']['slug'], $widgets[$widget]['plugin']['name']);
            $form = '<div class="panels-missing-widget-form">' . '<p>' . sprintf(__("You need to <a href='%s' target='_blank'>install %s</a> to use the widget <strong>%s</strong>. It's a free plugin available off the official WordPress plugin directory.", 'siteorigin-panels'), $install_url, $widgets[$widget]['plugin']['name'], $widget) . '</p>' . '<p>' . __("Save and reload this page to start using the widget after you've installed it.") . '</p>' . '</div>';
        } else {
            // This widget is missing, so show a missing widgets form.
            $form = '<div class="panels-missing-widget-form"><p>' . sprintf(__('The widget <strong>%s</strong> is not available. Please try locate and install the missing plugin. Post on the <a href="%s" target="_blank">support forums</a> if you need help.', 'siteorigin-panels'), esc_html($widget), 'http://siteorigin.com/thread/') . '</p></div>';
        }
        // Allow other themes and plugins to change the missing widget form
        return apply_filters('siteorigin_panels_missing_widget_form', $form, $widget, $instance);
    }
    if ($raw) {
        $instance = $the_widget->update($instance, $instance);
    }
    $the_widget->id = 'temp';
    $the_widget->number = '{$id}';
    ob_start();
    $the_widget->form($instance);
    $form = ob_get_clean();
    // Convert the widget field naming into ones that Page Builder uses
    $exp = preg_quote($the_widget->get_field_name('____'));
    $exp = str_replace('____', '(.*?)', $exp);
    $form = preg_replace('/' . $exp . '/', 'widgets[{$id}][$1]', $form);
    $form = apply_filters('siteorigin_panels_widget_form', $form, $widget, $instance);
    // Add all the information fields
    return $form;
}