Example #1
0
/**
 * Enqueue all the admin scripts for Black Studio TinyMCE compatibility with Page Builder.
 *
 * @param $page
 */
function pp_page_builder_pootle_text_widget_admin_enqueue($page)
{
    $screen = get_current_screen();
    if ($screen->base == 'post' && in_array($screen->id, siteorigin_panels_setting('post-types')) || $screen->base == 'appearance_page_so_panels_home_page') {
        global $pootle_text_widget_version;
        if (!isset($pootle_text_widget_version)) {
            //			if ( function_exists( 'black_studio_tinymce_get_version' ) ) {
            //				$pootle_text_widget_version = black_studio_tinymce_get_version();
            //}
            $pootle_text_widget_version = '1.0.0';
        }
        //		if ( version_compare( $pootle_text_widget_version, '1.3.3', '<=' ) ) {
        //			// Use the old compatibility file.
        // pootle-text-widget is based on black-studio 1.3.3
        wp_enqueue_script('pootle-text-widget-pp-page-builder', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/compat/pootle-text-widget/pootle-text-widget-pp-page-builder.old.js', array('jquery'), POOTLEPAGE_VERSION);
        //		}
        //		else {
        // Use the new compatibility file
        //			wp_enqueue_script( 'pootle-text-widget-pp-page-builder', plugin_dir_url( POOTLEPAGE_BASE_FILE ) . 'widgets/compat/pootle-text-widget/pootle-text-widget-pp-page-builder.min.js', array( 'jquery' ), POOTLEPAGE_VERSION );
        //		}
        wp_enqueue_style('pootle-text-widget-pp-page-builder', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/compat/pootle-text-widget/pootle-text-widget-pp-page-builder.css', array(), POOTLEPAGE_VERSION);
        //		if ( version_compare( $pootle_text_widget_version, '1.2.0', '<=' ) ) {
        //			// We also need a modified javascript for older versions of Black Studio TinyMCE
        //			wp_enqueue_script( 'black-studio-tinymce-widget', plugin_dir_url( POOTLEPAGE_BASE_FILE ) . 'widgets/compat/pootle-text-widget/pootle-text-widget.min.js', array( 'jquery' ), POOTLEPAGE_VERSION );
        //		}
    }
}
/**
 * Enqueue all the admin scripts for Black Studio TinyMCE compatibility with Page Builder.
 *
 * @param $page
 */
function siteorigin_panels_black_studio_tinymce_admin_enqueue($page)
{
    $screen = get_current_screen();
    if ($screen->base == 'post' && in_array($screen->id, siteorigin_panels_setting('post-types')) || $screen->base == 'appearance_page_so_panels_home_page') {
        wp_enqueue_script('black-studio-tinymce-widget-siteorigin-panels', plugin_dir_url(SITEORIGIN_PANELS_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget-siteorigin-panels.min.js', array('jquery'), SITEORIGIN_PANELS_VERSION);
        wp_enqueue_style('black-studio-tinymce-widget-siteorigin-panels', plugin_dir_url(SITEORIGIN_PANELS_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget-siteorigin-panels.css', array(), SITEORIGIN_PANELS_VERSION);
        global $black_studio_tinymce_widget_version;
        if (version_compare($black_studio_tinymce_widget_version, '1.2.0', '<=')) {
            // We also need a modified javascript for older versions of Black Studio TinyMCE
            wp_enqueue_script('black-studio-tinymce-widget', plugin_dir_url(SITEORIGIN_PANELS_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget.min.js', array('jquery'), SITEORIGIN_PANELS_VERSION);
        }
    }
}
/**
 * Register the custom styles scripts
 */
function siteorigin_panels_default_styles_register_scripts()
{
    wp_register_script('siteorigin-panels-front-styles', plugin_dir_url(SITEORIGIN_PANELS_BASE_FILE) . 'js/styling' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array('jquery'), SITEORIGIN_PANELS_VERSION);
    wp_localize_script('siteorigin-panels-front-styles', 'panelsStyles', array('fullContainer' => apply_filters('siteorigin_panels_full_width_container', siteorigin_panels_setting('full-width-container'))));
    // Check if we need to enqueue the front styles
    if (is_singular() && get_post_meta(get_the_ID(), 'panels_data', true) != '') {
        $panels_data = get_post_meta(get_the_ID(), 'panels_data', true);
        if (!empty($panels_data['grids'])) {
            foreach ($panels_data['grids'] as $grid) {
                if (empty($grid['style']['row_stretch'])) {
                    continue;
                }
                wp_enqueue_script('siteorigin-panels-front-styles');
                break;
            }
        }
    }
}
Example #4
0
/**
 * Add some default recommended widgets.
 *
 * @param $widgets
 *
 * @return array
 */
function siteorigin_panels_add_recommended_widgets($widgets)
{
    if (empty($widgets['WP_Widget_Black_Studio_TinyMCE'])) {
        if (siteorigin_panels_setting('recommended-widgets')) {
            $widgets['WP_Widget_Black_Studio_TinyMCE'] = array('class' => 'WP_Widget_Black_Studio_TinyMCE', 'title' => __('Visual Editor', 'siteorigin-panels'), 'description' => __('Arbitrary text or HTML with visual editor', 'siteorigin-panels'), 'installed' => false, 'plugin' => array('name' => __('Black Studio TinyMCE', 'siteorigin-panels'), 'slug' => 'black-studio-tinymce-widget'), 'groups' => array('recommended'), 'icon' => 'dashicons dashicons-edit');
        }
    } else {
        $widgets['WP_Widget_Black_Studio_TinyMCE']['groups'] = array('recommended');
        $widgets['WP_Widget_Black_Studio_TinyMCE']['icon'] = 'dashicons dashicons-edit';
    }
    if (siteorigin_panels_setting('recommended-widgets')) {
        // Add in all the widgets bundle widgets
        $widgets = wp_parse_args($widgets, include plugin_dir_path(__FILE__) . '/widgets-bundle.php');
    }
    foreach ($widgets as $class => $data) {
        if (strpos($class, 'SiteOrigin_Panels_Widgets_') === 0 || strpos($class, 'SiteOrigin_Panels_Widget_') === 0) {
            $widgets[$class]['groups'] = array('panels');
        }
    }
    $widgets['SiteOrigin_Panels_Widgets_Layout']['icon'] = 'dashicons dashicons-analytics';
    $wordpress_widgets = array('WP_Widget_Pages', 'WP_Widget_Links', 'WP_Widget_Search', 'WP_Widget_Archives', 'WP_Widget_Meta', 'WP_Widget_Calendar', 'WP_Widget_Text', 'WP_Widget_Categories', 'WP_Widget_Recent_Posts', 'WP_Widget_Recent_Comments', 'WP_Widget_RSS', 'WP_Widget_Tag_Cloud', 'WP_Nav_Menu_Widget');
    foreach ($wordpress_widgets as $wordpress_widget) {
        if (isset($widgets[$wordpress_widget])) {
            $widgets[$wordpress_widget]['groups'] = array('wordpress');
            $widgets[$wordpress_widget]['icon'] = 'dashicons dashicons-wordpress';
        }
    }
    // Third-party plugins dettection.
    foreach ($widgets as $widget_id => &$widget) {
        if (strpos($widget_id, 'WC_') === 0 || strpos($widget_id, 'WooCommerce') !== FALSE) {
            $widget['groups'][] = 'woocommerce';
        }
        if (strpos($widget_id, 'BBP_') === 0 || strpos($widget_id, 'BBPress') !== FALSE) {
            $widget['groups'][] = 'bbpress';
        }
        if (strpos($widget_id, 'Jetpack') !== FALSE || strpos($widget['title'], 'Jetpack') !== FALSE) {
            $widget['groups'][] = 'jetpack';
        }
    }
    return $widgets;
}
Example #5
0
/**
 * Filter content before we save it.
 *
 * @param $content
 * @return array|mixed|string
 * @filter content_save_pre
 */
function siteorigin_panels_content_save_pre($content)
{
    global $post;
    if (!siteorigin_panels_setting('copy-content')) {
        return $content;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $content;
    }
    if (empty($_POST['_sopanels_nonce']) || !wp_verify_nonce($_POST['_sopanels_nonce'], 'save')) {
        return $content;
    }
    if (empty($_POST['panels_js_complete'])) {
        return $content;
    }
    if (empty($post) || !current_user_can('edit_post', $post->ID)) {
        return $content;
    }
    if (empty($_POST['grids']) || empty($_POST['grid_cells']) || empty($_POST['widgets']) || empty($_POST['panel_order'])) {
        return $content;
    }
    $data['grids'] = $_POST['grids'];
    $data['grid_cells'] = $_POST['grid_cells'];
    $data['widgets'] = $_POST['widgets'];
    $data['panel_order'] = $_POST['panel_order'];
    $data['action'] = 'siteorigin_panels_get_post_content';
    $data['post_id'] = (string) $post->ID;
    $data['widgets'] = array_map('stripslashes_deep', $data['widgets']);
    $data['_signature'] = sha1(NONCE_SALT . serialize($data));
    // This can cause a fatal error, so handle in a separate request.
    $request = wp_remote_post(admin_url('admin-ajax.php?action=siteorigin_panels_get_post_content'), array('method' => 'POST', 'timeout' => 5, 'redirection' => 0, 'body' => $data));
    if (!is_wp_error($request) && $request['response']['code'] == 200 && !empty($request['body'])) {
        $content = $request['body'];
    }
    return $content;
}
Example #6
0
/**
 * Transfer theme data into new settings
 */
function siteorigin_panels_transfer_home_page()
{
    if (get_option('siteorigin_panels_home_page', false) === false && get_theme_mod('panels_home_page', false) !== false) {
        // Transfer settings from theme mods into settings
        update_option('siteorigin_panels_home_page', get_theme_mod('panels_home_page', false));
        update_option('siteorigin_panels_home_page_enabled', get_theme_mod('panels_home_page_enabled', false));
        // Remove the theme mod data
        remove_theme_mod('panels_home_page');
        remove_theme_mod('panels_home_page_enabled');
    }
    // Transfer the home page setting to a page
    if (!get_option('siteorigin_panels_home_page_id') && get_option('siteorigin_panels_home_page') && siteorigin_panels_setting('home-page')) {
        // Lets create a new page
        $page_id = wp_insert_post(array('post_title' => __('Home', 'siteorigin-panels'), 'post_status' => get_option('siteorigin_panels_home_page_enabled') ? 'publish' : 'draft', 'post_type' => 'page', 'comment_status' => 'closed'));
        update_post_meta($page_id, 'panels_data', get_option('siteorigin_panels_home_page'));
        update_post_meta($page_id, '_wp_page_template', siteorigin_panels_setting('home-template'));
        update_option('siteorigin_panels_home_page_id', $page_id);
        if (get_option('siteorigin_panels_home_page_enabled')) {
            // Lets make this page the home page
            update_option('show_on_front', 'page');
            update_option('page_on_front', $page_id);
        }
    }
}
/**
 * Enqueue all the admin scripts for Black Studio TinyMCE compatibility with Page Builder.
 *
 * @param $page
 */
function siteorigin_panels_black_studio_tinymce_admin_enqueue($page)
{
    $screen = get_current_screen();
    if ($screen->base == 'post' && in_array($screen->id, siteorigin_panels_setting('post-types')) || $screen->base == 'appearance_page_so_panels_home_page') {
        global $black_studio_tinymce_widget_version;
        if (!isset($black_studio_tinymce_widget_version)) {
            if (function_exists('black_studio_tinymce_get_version')) {
                $black_studio_tinymce_widget_version = black_studio_tinymce_get_version();
            }
        }
        if (version_compare($black_studio_tinymce_widget_version, '1.3.3', '<=')) {
            // Use the old compatibility file.
            wp_enqueue_script('black-studio-tinymce-widget-siteorigin-panels', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget-siteorigin-panels.old.min.js', array('jquery'), POOTLEPAGE_VERSION);
        } else {
            // Use the new compatibility file
            wp_enqueue_script('black-studio-tinymce-widget-siteorigin-panels', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget-siteorigin-panels.min.js', array('jquery'), POOTLEPAGE_VERSION);
        }
        wp_enqueue_style('black-studio-tinymce-widget-siteorigin-panels', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget-siteorigin-panels.css', array(), POOTLEPAGE_VERSION);
        if (version_compare($black_studio_tinymce_widget_version, '1.2.0', '<=')) {
            // We also need a modified javascript for older versions of Black Studio TinyMCE
            wp_enqueue_script('black-studio-tinymce-widget', plugin_dir_url(POOTLEPAGE_BASE_FILE) . 'widgets/compat/black-studio-tinymce/black-studio-tinymce-widget.min.js', array('jquery'), POOTLEPAGE_VERSION);
        }
    }
}
    ?>
</a></li>
				<?php 
}
?>

				<li><a href="#directory"><?php 
_e('Layouts Directory', 'siteorigin-panels');
?>
</a></li>
				<li><a href="#import"><?php 
_e('Import/Export', 'siteorigin-panels');
?>
</a></li>
				<?php 
$post_types = siteorigin_panels_setting('post-types');
foreach ($post_types as $post_type) {
    $type = get_post_type_object($post_type);
    if (empty($type)) {
        continue;
    }
    ?>
<li><a href="#<?php 
    echo 'clone_' . $post_type;
    ?>
"><?php 
    printf(__('Clone: %s', 'siteorigin-panels'), $type->labels->name);
    ?>
</a></li><?php 
}
?>
Example #9
0
<?php

global $wp_widget_factory;
$layouts = apply_filters('siteorigin_panels_prebuilt_layouts', array());
?>

<div id="panels" data-animations="<?php 
echo siteorigin_panels_setting('animations') ? 'true' : 'false';
?>
">

	<?php 
do_action('siteorigin_panels_before_interface');
?>

	<div id="panels-container">
	</div>
	
	<div id="add-to-panels">
		<button class="panels-add" data-tooltip="<?php 
esc_attr_e('Add Widget', 'siteorigin-panels');
?>
"><?php 
_e('Add Widget', 'siteorigin-panels');
?>
</button>
		<button class="grid-add" data-tooltip="<?php 
esc_attr_e('Add Row', 'siteorigin-panels');
?>
"><?php 
_e('Add Row', 'siteorigin-panels');
/**
 * Display one of the premium or contribution teasers
 */
function siteorigin_panels_display_premium_teaser()
{
    if (siteorigin_panels_setting('display-teaser') && apply_filters('siteorigin_premium_upgrade_teaser', true) && !defined('SITEORIGIN_PREMIUM_VERSION')) {
        $links = array(array(__('Page Builder Addons', 'siteorigin-panels'), __('Addons', 'siteorigin-panels'), siteorigin_panels_premium_url()), array(__('Contribute to Page Builder', 'siteorigin-panels'), __('Contribute', 'siteorigin-panels'), 'http://siteorigin.com/downloads/contribution/'));
        $i = floor(time() / (30 * 60)) % count($links);
        if (!empty($links[$i])) {
            ?>
			<a class="so-tool-button so-siteorigin-premium" title="<?php 
            echo esc_attr($links[$i][0]);
            ?>
" href="<?php 
            echo esc_url($links[$i][2]);
            ?>
" target="_blank">
				<span class="so-panels-icon so-panels-icon-plus"></span>
				<span class="so-button-text"><?php 
            echo esc_html($links[$i][1]);
            ?>
</span>
			</a>
			<?php 
        }
    }
}
Example #11
0
function siteorigin_panels_live_edit_link($wp_admin_bar)
{
    // Add a Live Edit link if this is a Page Builder page that the user can edit
    if (siteorigin_panels_setting('live-editor-quick-link') && is_singular() && current_user_can('edit_post', get_the_ID()) && get_post_meta(get_the_ID(), 'panels_data', true)) {
        $wp_admin_bar->add_node(array('id' => 'so_live_editor', 'title' => __('Live Editor', 'siteorigin-panels'), 'href' => add_query_arg('so_live_editor', 1, get_edit_post_link(get_the_ID())), 'meta' => array('class' => 'live-edit-page')));
    }
}
Example #12
0
/**
 * Add the Edit Home Page item to the admin bar.
 *
 * @param WP_Admin_Bar $admin_bar
 * @return WP_Admin_Bar
 */
function siteorigin_panels_admin_bar_menu($admin_bar)
{
    // Ignore this unless the theme is using the home page feature.
    if (!siteorigin_panels_setting('home-page')) {
        return $admin_bar;
    }
    if (!current_user_can('edit_theme_options')) {
        return $admin_bar;
    }
    if (is_home() || is_front_page()) {
        if (is_page() && get_post_meta(get_the_ID(), 'panels_data', true) !== '' || !is_page()) {
            $admin_bar->add_node(array('id' => 'edit-home-page', 'title' => __('Edit Home Page', 'siteorigin-panels'), 'href' => admin_url('themes.php?page=so_panels_home_page')));
            if (is_page()) {
                // Remove the standard edit button
                $admin_bar->remove_node('edit');
            }
        }
    }
    return $admin_bar;
}
Example #13
0
    /**
     * Display a settings field
     *
     * @param $field_id
     * @param $field
     */
    function display_field($field_id, $field)
    {
        $value = siteorigin_panels_setting($field_id);
        $field_name = 'panels_setting[' . $field_id . ']';
        switch ($field['type']) {
            case 'text':
                ?>
<input name="<?php 
                echo esc_attr($field_name);
                ?>
" class="panels-setting-<?php 
                echo esc_attr($field['type']);
                ?>
" type="text" value="<?php 
                echo esc_attr($value);
                ?>
" /> <?php 
                break;
            case 'number':
                ?>
				<input name="<?php 
                echo esc_attr($field_name);
                ?>
" type="number" class="panels-setting-<?php 
                echo esc_attr($field['type']);
                ?>
" value="<?php 
                echo esc_attr($value);
                ?>
" />
				<?php 
                if (!empty($field['unit'])) {
                    echo esc_html($field['unit']);
                }
                break;
            case 'html':
                ?>
<textarea name="<?php 
                echo esc_attr($field_name);
                ?>
" class="panels-setting-<?php 
                echo esc_attr($field['type']);
                ?>
 widefat" rows="<?php 
                echo !empty($field['rows']) ? intval($field['rows']) : 2;
                ?>
"><?php 
                echo esc_textarea($value);
                ?>
</textarea> <?php 
                break;
            case 'checkbox':
                ?>
				<label class="widefat">
					<input name="<?php 
                echo esc_attr($field_name);
                ?>
" type="checkbox" <?php 
                checked(!empty($value));
                ?>
 />
					<?php 
                echo !empty($field['checkbox_text']) ? esc_html($field['checkbox_text']) : __('Enabled', 'siteorigin-panels');
                ?>
				</label>
				<?php 
                break;
            case 'select':
                ?>
				<select name="<?php 
                echo esc_attr($field_name);
                ?>
">
					<?php 
                foreach ($field['options'] as $option_id => $option) {
                    ?>
						<option value="<?php 
                    echo esc_attr($option_id);
                    ?>
" <?php 
                    selected($option_id, $value);
                    ?>
><?php 
                    echo esc_html($option);
                    ?>
</option>
					<?php 
                }
                ?>
				</select>
				<?php 
                break;
            case 'select_multi':
                foreach ($field['options'] as $option_id => $option) {
                    ?>
					<label class="widefat">
						<input name="<?php 
                    echo esc_attr($field_name);
                    ?>
[<?php 
                    echo esc_attr($option_id);
                    ?>
]" type="checkbox" <?php 
                    checked(in_array($option_id, $value));
                    ?>
 />
						<?php 
                    echo esc_html($option);
                    ?>
					</label>
					<?php 
                }
                break;
        }
    }
function so_panels_bootstrap_css_object($css, $panels_data = null, $post_id = null)
{
    $settings = siteorigin_panels_setting();
    $panels_mobile_width = $settings['mobile-width'];
    $panels_margin_bottom = $settings['margin-bottom'];
    $css = new SiteOrigin_Panels_Css_Builder();
    foreach ($panels_data['grids'] as $gi => $grid) {
        $cell_count = intval($grid['cells']);
        if ($gi != count($panels_data['grids']) - 1) {
            // Filter the bottom margin for this row with the arguments
            $css->add_row_css($post_id, $gi, '', array('margin-bottom' => apply_filters('siteorigin_panels_css_row_margin_bottom', $panels_margin_bottom . 'px', $grid, $gi, $panels_data, $post_id)));
        }
        if ($cell_count > 1) {
            $css->add_cell_css($post_id, $gi, false, '', array('float' => !is_rtl() ? 'left' : 'right'));
        }
        if ($settings['responsive']) {
            for ($i = 0; $i < $cell_count; $i++) {
                if ($i != $cell_count - 1) {
                    $css->add_cell_css($post_id, $gi, $i, '', array('margin-bottom' => $panels_margin_bottom . 'px'), $panels_mobile_width);
                }
            }
        }
    }
    // Add the bottom margins
    $css->add_cell_css($post_id, false, false, '.so-panel', array('margin-bottom' => apply_filters('siteorigin_panels_css_cell_margin_bottom', $panels_margin_bottom . 'px', $grid, $gi, $panels_data, $post_id)));
    $css->add_cell_css($post_id, false, false, '.so-panel:last-child', array('margin-bottom' => apply_filters('siteorigin_panels_css_cell_last_margin_bottom', '0px', $grid, $gi, $panels_data, $post_id)));
    foreach ($panels_data['grids'] as $gi => $grid) {
        // Rows with only one cell don't need gutters
        if ($grid['cells'] <= 1) {
            continue;
        }
        // Let other themes and plugins change the gutter.
        $gutter = apply_filters('siteorigin_panels_css_row_gutter', $settings['margin-sides'] . 'px', $grid, $gi, $panels_data);
        if (!empty($gutter)) {
            // We actually need to find half the gutter.
            preg_match('/([0-9\\.,]+)(.*)/', $gutter, $match);
            if (!empty($match[1])) {
                $margin_half = floatval($match[1]) / 2 . $match[2];
                $css->add_row_css($post_id, $gi, '', array('margin-left' => '-' . $margin_half, 'margin-right' => '-' . $margin_half));
                $css->add_cell_css($post_id, $gi, false, '', array('padding-left' => $margin_half, 'padding-right' => $margin_half));
            }
        }
    }
    // Let other plugins and components filter the CSS object.
    $css = apply_filters('so_panels_bootstrap_css_object', $css, $panels_data, $post_id);
    return $css;
}
function siteorigin_premium_display_teaser()
{
    return siteorigin_panels_setting('display-teaser') && apply_filters('siteorigin_premium_upgrade_teaser', true) && !defined('SITEORIGIN_PREMIUM_VERSION');
}
Example #16
0
    /**
     * Dynamically generates CSS for for SiteOrigin_Panels_Widget::widget
     *
     * @param $style
     * @param $preset
     * @param object $class The widget class
     */
    function widget_dynamically_generate_css($style, $preset, $instance, $class)
    {
        if (!empty($instance['origin_style'])) {
            $filename = $class->origin_id . '-' . $style . '-' . $preset;
            if (siteorigin_panels_setting('inline-css')) {
                static $inlined_css = array();
                if (empty($inlined_css[$filename])) {
                    $inlined_css[$filename] = true;
                    ?>
<style type = "text/css" media = "all"><?php 
                    echo origin_widgets_generate_css(get_class($class), $style, $preset);
                    ?>
</style><?php 
                }
            } else {
                wp_enqueue_style('origin-widget-' . $filename, add_query_arg(array('class' => get_class($class), 'style' => $style, 'preset' => $preset), site_url('?action = origin_widgets_css')), array(), POOTLEPAGE_VERSION);
            }
        }
    }
Example #17
0
/**
 * Display the fields for the other settings.
 *
 * @param $args
 */
function siteorigin_panels_options_field_display($args)
{
    $settings = siteorigin_panels_setting();
    switch ($args['type']) {
        case 'responsive':
        case 'copy-content':
        case 'animations':
        case 'inline-css':
        case 'bundled-widgets':
            ?>
<label><input type="checkbox" name="siteorigin_panels_display[<?php 
            echo esc_attr($args['type']);
            ?>
]" <?php 
            checked($settings[$args['type']]);
            ?>
 /> <?php 
            _e('Enabled', 'siteorigin-panels');
            ?>
</label><?php 
            break;
        case 'margin-bottom':
        case 'margin-sides':
        case 'mobile-width':
            ?>
<input type="text" name="siteorigin_panels_display[<?php 
            echo esc_attr($args['type']);
            ?>
]" value="<?php 
            echo esc_attr($settings[$args['type']]);
            ?>
" class="small-text" /> <?php 
            _e('px', 'siteorigin-panels');
            break;
    }
    if (!empty($args['description'])) {
        ?>
<p class="description"><?php 
        echo esc_html($args['description']);
        ?>
</p><?php 
    }
}
 static function row_style_attributes($attributes, $args)
 {
     if (!empty($args['row_stretch'])) {
         $attributes['class'][] = 'siteorigin-panels-stretch';
         $attributes['data-stretch-type'] = $args['row_stretch'];
         wp_enqueue_script('siteorigin-panels-front-styles');
     }
     if (!empty($args['class'])) {
         $attributes['class'] = array_merge($attributes['class'], explode(' ', $args['class']));
     }
     if (!empty($args['row_css'])) {
         preg_match_all('/^(.+?):(.+?);?$/m', $args['row_css'], $matches);
         if (!empty($matches[0])) {
             for ($i = 0; $i < count($matches[0]); $i++) {
                 $attributes['style'] .= $matches[1][$i] . ':' . $matches[2][$i] . ';';
             }
         }
     }
     if (!empty($args['padding'])) {
         $attributes['style'] .= 'padding: ' . esc_attr($args['padding']) . ';';
     }
     if (!empty($args['background'])) {
         $attributes['style'] .= 'background-color:' . $args['background'] . ';';
     }
     if (!empty($args['background_display']) && !empty($args['background_image_attachment'])) {
         if ($args['background_display'] == 'parallax' || $args['background_display'] == 'parallax-original') {
             wp_enqueue_script('siteorigin-panels-front-styles');
         }
         $url = wp_get_attachment_image_src($args['background_image_attachment'], 'full');
         if (!empty($url)) {
             if ($args['background_display'] == 'parallax' || $args['background_display'] == 'parallax-original') {
                 wp_enqueue_script('siteorigin-parallax');
                 $parallax_args = array('backgroundUrl' => $url[0], 'backgroundSize' => array($url[1], $url[2]), 'backgroundSizing' => $args['background_display'] == 'parallax-original' ? 'original' : 'scaled', 'limitMotion' => siteorigin_panels_setting('parallax-motion') ? floatval(siteorigin_panels_setting('parallax-motion')) : 'auto');
                 $attributes['data-siteorigin-parallax'] = json_encode($parallax_args);
                 $attributes['style'] .= 'background-image: url(' . $url[0] . '); background-position: center center; background-repeat: no-repeat;';
             } else {
                 $attributes['style'] .= 'background-image: url(' . $url[0] . ');';
                 switch ($args['background_display']) {
                     case 'tile':
                         $attributes['style'] .= 'background-repeat: repeat;';
                         break;
                     case 'cover':
                         $attributes['style'] .= 'background-size: cover;';
                         break;
                     case 'center':
                         $attributes['style'] .= 'background-position: center center; background-repeat: no-repeat;';
                         break;
                     case 'fixed':
                         $attributes['style'] .= 'background-attachment: fixed; background-size: cover;';
                         break;
                 }
             }
         }
     }
     if (!empty($args['border_color'])) {
         $attributes['style'] .= 'border: 1px solid ' . $args['border_color'] . ';';
     }
     return $attributes;
 }
Example #19
0
    /**
     * Render the widget.
     *
     * @param array $args
     * @param array $instance
     * @return bool|void
     */
    function widget($args, $instance)
    {
        // Set up defaults for all the widget args
        foreach ($this->form_args as $field_id => $field_args) {
            if (isset($field_args['default']) && !isset($instance[$field_id])) {
                $instance[$field_id] = $field_args['default'];
            }
            if (!isset($instance[$field_id])) {
                $instance[$field_id] = false;
            }
        }
        // Filter the title
        if (!empty($instance['title'])) {
            $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        }
        if (!empty($instance['origin_style'])) {
            list($style, $preset) = explode(':', $instance['origin_style']);
            $style = sanitize_file_name($style);
            $preset = sanitize_file_name($preset);
            $data = $this->get_style_data($style);
            $template = $data['Template'];
        } else {
            $style = 'default';
            $preset = 'default';
        }
        if (empty($template)) {
            $template = 'default';
        }
        $template_file = false;
        $paths = $this->get_widget_paths();
        foreach ($paths as $path) {
            if (file_exists($path . '/' . $this->origin_id . '/tpl/' . $template . '.php')) {
                $template_file = $path . '/' . $this->origin_id . '/tpl/' . $template . '.php';
                break;
            }
        }
        if (empty($template_file)) {
            echo $args['before_widget'];
            echo 'Template not found';
            echo $args['after_widget'];
            return false;
        }
        // Dynamically generate the CSS
        if (!empty($instance['origin_style'])) {
            $filename = $this->origin_id . '-' . $style . '-' . $preset;
            if (siteorigin_panels_setting('inline-css')) {
                static $inlined_css = array();
                if (empty($inlined_css[$filename])) {
                    $inlined_css[$filename] = true;
                    ?>
<style type="text/css" media="all"><?php 
                    echo origin_widgets_generate_css(get_class($this), $style, $preset);
                    ?>
</style><?php 
                }
            } else {
                wp_enqueue_style('origin-widget-' . $filename, add_query_arg(array('class' => get_class($this), 'style' => $style, 'preset' => $preset), site_url('?action=origin_widgets_css')), array(), SITEORIGIN_PANELS_VERSION);
            }
        }
        if (method_exists($this, 'enqueue_scripts')) {
            $this->enqueue_scripts();
        }
        $widget_classes = apply_filters('siteorigin_widgets_classes', array('origin-widget', 'origin-widget-' . $this->origin_id, 'origin-widget-' . $this->origin_id . '-' . $style . '-' . $preset), $instance);
        if (method_exists($this, 'widget_classes')) {
            $widget_classes = $this->widget_classes(array('origin-widget', 'origin-widget-' . $this->origin_id, 'origin-widget-' . $this->origin_id . '-' . $style . '-' . $preset), $instance);
        }
        echo $args['before_widget'];
        echo '<div class="' . esc_attr(implode(' ', $widget_classes)) . '">';
        include $template_file;
        echo '</div>';
        echo $args['after_widget'];
    }
 public function localize_scripts()
 {
     $panels_mobile_width = 780;
     // default
     if (function_exists('siteorigin_panels_setting')) {
         $settings = siteorigin_panels_setting();
         $panels_mobile_width = $settings['mobile-width'];
     }
     $custom_css = lsow_get_option('lsow_custom_css', '');
     wp_localize_script('lsow-frontend-scripts', 'lsow_settings', array('mobile_width' => $panels_mobile_width, 'custom_css' => $custom_css));
 }
Example #21
0
/**
 * Register the custom styles scripts
 */
function siteorigin_panels_default_styles_register_scripts()
{
    wp_register_script('siteorigin-panels-front-styles', plugin_dir_url(SITEORIGIN_PANELS_BASE_FILE) . 'js/styling' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array('jquery'), SITEORIGIN_PANELS_VERSION);
    wp_register_script('siteorigin-panels-front-parallax', plugin_dir_url(SITEORIGIN_PANELS_BASE_FILE) . 'js/jquery.stellar' . SITEORIGIN_PANELS_JS_SUFFIX . '.js', array('jquery'), SITEORIGIN_PANELS_VERSION);
    wp_localize_script('siteorigin-panels-front-styles', 'panelsStyles', array('fullContainer' => apply_filters('siteorigin_panels_full_width_container', siteorigin_panels_setting('full-width-container'))));
}
/**
 * Handles creating the preview.
 */
function siteorigin_panels_preview()
{
    if (isset($_GET['siteorigin_panels_preview']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'siteorigin-panels-preview')) {
        global $siteorigin_panels_is_preview;
        $siteorigin_panels_is_preview = true;
        // Set the panels home state to true
        if (empty($_POST['post_id'])) {
            $GLOBALS['siteorigin_panels_is_panels_home'] = true;
        }
        add_action('option_siteorigin_panels_home_page', 'siteorigin_panels_preview_load_data');
        locate_template(siteorigin_panels_setting('home-template'), true);
        exit;
    }
}
Example #23
0
<?php

$settings = siteorigin_panels_setting();
?>

<div class="wrap" id="panels-home-page" data-post-id="<?php 
echo get_the_ID();
?>
">
	<form action="<?php 
echo add_query_arg('page', 'so_panels_home_page');
?>
" class="hide-if-no-js siteorigin-panels-builder-form" method="post" id="panels-home-page-form" data-type="custom_home_page">
		<div id="icon-index" class="icon32"><br></div>
		<h2>
			<label class="switch">
				<input class="switch-input" type="checkbox" <?php 
checked(get_option('siteorigin_panels_home_page_id') && get_option('siteorigin_panels_home_page_id') == get_option('page_on_front') && get_option('show_on_front') == 'page');
?>
 name="siteorigin_panels_home_enabled">
				<span class="switch-label" data-on="<?php 
_e('On', 'siteorigin-panels');
?>
" data-off="<?php 
_e('Off', 'siteorigin-panels');
?>
"></span>
				<span class="switch-handle"></span>
			</label>

			<?php 
function pp_pb_option_css()
{
    $output = '';
    // Widget Styling
    $widget_font_title = get_option('page_builder_widget_font_title', array('size' => '14', 'unit' => 'px', 'face' => 'Helvetica, Arial, sans-serif', 'style' => 'bold', 'color' => '#555555'));
    $widget_font_text = get_option('page_builder_widget_font_text', array('size' => '13', 'unit' => 'px', 'face' => 'Helvetica, Arial, sans-serif', 'style' => 'thin', 'color' => '#555555'));
    $widget_padding_tb = get_option('page_builder_widget_padding_tb', '0');
    $widget_padding_lr = get_option('page_builder_widget_padding_lr', '0');
    $widget_bg = get_option('page_builder_widget_bg', 'transparent');
    $widget_border = get_option('page_builder_widget_border', array('width' => '0', 'style' => 'solid', 'color' => '#dbdbdb'));
    $widget_title_border = get_option('page_builder_widget_title_border', array('width' => '1', 'style' => 'solid', 'color' => '#e6e6e6'));
    $widget_border_radius = get_option('page_builder_widget_border_radius', '0px');
    // in Visual Editor, dont set underline for h3
    $output .= '.widget_pootle-text-widget > .textwidget h3 { border-bottom: none !important; }';
    $widget_title_css = '';
    if ($widget_font_title) {
        $widget_title_css .= 'font:' . $widget_font_title["style"] . ' ' . $widget_font_title["size"] . $widget_font_title["unit"] . '/1.2em ' . stripslashes($widget_font_title["face"]) . ';color:' . $widget_font_title["color"] . ';';
    }
    if ($widget_title_border) {
        $widget_title_css .= 'border-bottom:' . $widget_title_border["width"] . 'px ' . $widget_title_border["style"] . ' ' . $widget_title_border["color"] . ' !important;';
    }
    if (isset($widget_title_border["width"]) and $widget_title_border["width"] == 0) {
        $widget_title_css .= 'margin-bottom:0 !important;';
    }
    if ($widget_title_css != '') {
        $output .= '.panel-grid-cell .widget h3.widget-title {' . $widget_title_css . '}' . "\n";
    }
    if ($widget_title_border) {
        $output .= '.panel-grid-cell .widget_recent_comments li{ border-color: ' . $widget_title_border["color"] . ';}' . "\n";
    }
    if ($widget_font_text) {
        $output .= '.panel-grid-cell .widget p, .panel-grid-cell .widget .textwidget { ' . pp_pb_generate_font_css($widget_font_text, 1.5) . ' }' . "\n";
    }
    $widget_css = '';
    if ($widget_font_text) {
        $widget_css .= 'font:' . $widget_font_text["style"] . ' ' . $widget_font_text["size"] . $widget_font_text["unit"] . '/1.5em ' . stripslashes($widget_font_text["face"]) . ';color:' . $widget_font_text["color"] . ';';
    }
    if (!$widget_padding_lr) {
        $widget_css .= 'padding-left: 0; padding-right: 0;';
    } else {
        $widget_css .= 'padding-left: ' . $widget_padding_lr . 'px ; padding-right: ' . $widget_padding_lr . 'px;';
    }
    if (!$widget_padding_tb) {
        $widget_css .= 'padding-top: 0; padding-bottom: 0;';
    } else {
        $widget_css .= 'padding-top: ' . $widget_padding_tb . 'px ; padding-bottom: ' . $widget_padding_tb . 'px;';
    }
    if ($widget_bg) {
        $widget_css .= 'background-color:' . $widget_bg . ';';
    } else {
        $widget_css .= 'background-color: transparent;';
    }
    if ($widget_border["width"] > 0) {
        $widget_css .= 'border:' . $widget_border["width"] . 'px ' . $widget_border["style"] . ' ' . $widget_border["color"] . ';';
    }
    if ($widget_border_radius) {
        $widget_css .= 'border-radius:' . $widget_border_radius . ';-moz-border-radius:' . $widget_border_radius . ';-webkit-border-radius:' . $widget_border_radius . ';';
    }
    if ($widget_css != '') {
        $output .= '.panel-grid-cell .widget {' . $widget_css . '}' . "\n";
    }
    if ($widget_border["width"] > 0) {
        $output .= '.panel-grid-cell #tabs {border:' . $widget_border["width"] . 'px ' . $widget_border["style"] . ' ' . $widget_border["color"] . ';}' . "\n";
    }
    // Tabs Widget
    $widget_tabs_bg = get_option('page_builder_widget_tabs_bg', 'transparent');
    $widget_tabs_bg_inside = get_option('page_builder_widget_tabs_bg_inside', '');
    $widget_tabs_font = get_option('page_builder_widget_tabs_font', array('size' => '12', 'unit' => 'px', 'face' => 'Helvetica, Arial, sans-serif', 'style' => 'bold', 'color' => '#555555'));
    $widget_tabs_font_meta = get_option('page_builder_widget_tabs_font_meta', array('size' => '11', 'unit' => 'px', 'face' => 'Helvetica, Arial, sans-serif', 'style' => 'thin', 'color' => ''));
    if ($widget_tabs_bg) {
        $output .= '.panel-grid-cell #tabs, .panel-grid-cell .widget_woodojo_tabs .tabbable {background-color:' . $widget_tabs_bg . ';}' . "\n";
    } else {
        $output .= '.panel-grid-cell #tabs, .panel-grid-cell .widget_woodojo_tabs .tabbable {background-color: transparent;}' . "\n";
    }
    if ($widget_tabs_bg_inside) {
        $output .= '.panel-grid-cell #tabs .inside, .panel-grid-cell #tabs ul.wooTabs li a.selected, .panel-grid-cell #tabs ul.wooTabs li a:hover {background-color:' . $widget_tabs_bg_inside . ';}' . "\n";
    } else {
        //$output .= '.panel-grid-cell #tabs .inside, .panel-grid-cell #tabs ul.wooTabs li a.selected, .panel-grid-cell #tabs ul.wooTabs li a:hover {background-color: transparent; }' . "\n";
    }
    if ($widget_tabs_font) {
        $output .= '.panel-grid-cell #tabs .inside li a, .panel-grid-cell .widget_woodojo_tabs .tabbable .tab-pane li a { ' . pp_pb_generate_font_css($widget_tabs_font, 1.5) . ' }' . "\n";
    }
    if ($widget_tabs_font_meta) {
        $output .= '.panel-grid-cell #tabs .inside li span.meta, .panel-grid-cell .widget_woodojo_tabs .tabbable .tab-pane li span.meta { ' . pp_pb_generate_font_css($widget_tabs_font_meta, 1.5) . ' }' . "\n";
    }
    $output .= '.panel-grid-cell #tabs ul.wooTabs li a, .panel-grid-cell .widget_woodojo_tabs .tabbable .nav-tabs li a { ' . pp_pb_generate_font_css($widget_tabs_font_meta, 2) . ' }' . "\n";
    //	global $siteorigin_panels_inline_css;
    //	if ( !empty( $siteorigin_panels_inline_css ) ) {
    //		$output .= $siteorigin_panels_inline_css;
    //	}
    $removeListSetting = siteorigin_panels_setting('remove-list-padding');
    if ($removeListSetting == true) {
        $output .= ".entry .panel-grid .widget ul, .entry .panel-grid .widget ol { padding-left: 0; }\n";
    }
    echo "<style>\n" . $output . "\n" . "</style>\n";
}