Ejemplo n.º 1
0
function pp_vantage_panels_panels_row_attributes($attr, $row)
{
    if (!empty($row['style']['no_margin'])) {
        if (empty($attr['style'])) {
            $attr['style'] = '';
        }
        $attr['style'] .= 'margin-bottom: 0px;';
    } else {
        if (empty($attr['style'])) {
            $attr['style'] = '';
        }
        if (!empty($row['style']['col_gutter']) || '0' === $row['style']['col_gutter']) {
            $attr['style'] .= 'margin-left: -' . $row['style']['col_gutter'] / 2 . 'px;';
            $attr['style'] .= 'margin-right: -' . $row['style']['col_gutter'] / 2 . 'px;';
        }
        $marginBottom = pootle_pb_settings('margin-bottom');
        if (!empty($row['style']['margin_bottom']) || '0' === $row['style']['margin_bottom']) {
            $attr['style'] .= "margin-bottom: {$row['style']['margin_bottom']}px;";
        } elseif ($marginBottom) {
            $attr['style'] .= "margin-bottom: {$marginBottom}px;";
        } else {
            $attr['style'] .= 'margin-bottom: 0;';
        }
    }
    if (isset($row['style']['id']) && !empty($row['style']['id'])) {
        $attr['id'] = $row['style']['id'];
    }
    return $attr;
}
Ejemplo n.º 2
0
/**
 * Handles creating the preview.
 */
function siteorigin_panels_preview()
{
    if (isset($_GET['siteorigin_panels_preview']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'ppb-panels-preview')) {
        global $siteorigin_panels_is_preview;
        $siteorigin_panels_is_preview = true;
        // Set the panels home state to true
        $post_id = filter_input(INPUT_POST, 'post_id');
        if (empty($post_id)) {
            $GLOBALS['siteorigin_panels_is_panels_home'] = true;
        }
        add_action('option_siteorigin_panels_home_page', 'siteorigin_panels_preview_load_data');
        locate_template(pootle_pb_settings('home-template'), true);
        exit;
    }
}
Ejemplo n.º 3
0
 /**
  * Filter the content of the panel, adding all the widgets.
  * @param string $content Post content
  * @return string Pootle page builder post content
  * @filter the_content
  */
 function content_filter($content)
 {
     $postID = get_the_ID();
     $isWooCommerceInstalled = function_exists('is_shop') && function_exists('wc_get_page_id');
     if ($isWooCommerceInstalled) {
         // prevent Page Builder overwrite taxonomy description with widget content
         if (is_tax(array('product_cat', 'product_tag')) && get_query_var('paged') == 0 || is_post_type_archive() && !is_shop()) {
             return $content;
         }
         if (is_shop()) {
             $postID = wc_get_page_id('shop');
         }
     } else {
         if (is_post_type_archive()) {
             return $content;
         }
     }
     //If product done once set $postID to Tabs Post ID
     if (isset($GLOBALS['canvasPB_ProductDoneOnce'])) {
         global $wpdb;
         $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE " . "post_content LIKE '" . esc_sql($content) . "'" . " AND post_type LIKE 'wc_product_tab'" . " AND post_status LIKE 'publish'");
         foreach ($results as $id) {
             $postID = $id->ID;
         }
     }
     //If its product set canvasPB_ProductDoneOnce to skip this for TAB
     if (function_exists('is_product')) {
         if (is_single() && is_product()) {
             $GLOBALS['canvasPB_ProductDoneOnce'] = true;
         }
     }
     $post = get_post($postID);
     if (empty($post)) {
         return $content;
     }
     if (in_array($post->post_type, pootle_pb_settings('post-types'))) {
         $panel_content = $this->panels_render($post->ID);
         if (!empty($panel_content)) {
             $content = $panel_content;
         }
     }
     return $content;
 }
Ejemplo n.º 4
0
    /**
     * Output settings field
     * @param array $args
     * @param string $groupName
     */
    public function options_field_generic($args, $groupName = 'siteorigin_panels_display')
    {
        $settings = pootle_pb_settings();
        switch ($args['type']) {
            case 'responsive':
                ?>
<label><input type="checkbox"
				                name="<?php 
                echo $groupName;
                ?>
[<?php 
                echo esc_attr($args['type']);
                ?>
]" <?php 
                checked($settings[$args['type']]);
                ?>
				                value="1"/> <?php 
                _e('Enabled', 'ppb-panels');
                ?>
</label><?php 
                break;
            case 'mobile-width':
                ?>
<input type="text" name="<?php 
                echo $groupName;
                ?>
[<?php 
                echo esc_attr($args['type']);
                ?>
]"
				         value="<?php 
                echo esc_attr($settings[$args['type']]);
                ?>
"
				         class="small-text" /> <?php 
                _e('px', 'ppb-panels');
                break;
        }
        if (!empty($args['description'])) {
            ?>
<p class="description"><?php 
            echo esc_html($args['description']);
            ?>
</p><?php 
        }
    }
Ejemplo n.º 5
0
 /**
  * Generate the actual CSS.
  *
  * @param int|string $post_id
  * @param array $panels_data
  * @return string Css styles
  */
 function panels_generate_css($post_id, $panels_data)
 {
     // Exit if we don't have panels data
     if (empty($panels_data) || empty($panels_data['grids'])) {
         return;
     }
     $settings = pootle_pb_settings();
     $panels_mobile_width = $settings['mobile-width'];
     $panels_margin_bottom = $settings['margin-bottom'];
     $css = array();
     $css[1920] = array();
     $css[$panels_mobile_width] = array();
     // This is a mobile resolution
     // Add the grid sizing
     $ci = 0;
     foreach ($panels_data['grids'] as $gi => $grid) {
         $cell_count = intval($grid['cells']);
         for ($i = 0; $i < $cell_count; $i++) {
             $cell = $panels_data['grid_cells'][$ci++];
             if ($cell_count > 1) {
                 $css_new = 'width:' . round($cell['weight'] * 100, 3) . '%';
                 if (empty($css[1920][$css_new])) {
                     $css[1920][$css_new] = array();
                 }
                 $css[1920][$css_new][] = '#pgc-' . $post_id . '-' . $gi . '-' . $i;
             }
         }
         // Add the bottom margin to any grids that aren't the last
         if ($gi != count($panels_data['grids']) - 1) {
             $css[1920]['margin-bottom: ' . $panels_margin_bottom . 'px'][] = '#pg-' . $post_id . '-' . $gi;
         }
         if ($settings['responsive']) {
             // Mobile Responsive
             $mobile_css = array('float:none', 'width:auto');
             foreach ($mobile_css as $c) {
                 if (empty($css[$panels_mobile_width][$c])) {
                     $css[$panels_mobile_width][$c] = array();
                 }
                 $css[$panels_mobile_width][$c][] = '#pg-' . $post_id . '-' . $gi . ' .panel-grid-cell';
             }
             for ($i = 0; $i < $cell_count; $i++) {
                 if ($i != $cell_count - 1) {
                     $css_new = 'margin-bottom:' . $panels_margin_bottom . 'px';
                     if (empty($css[$panels_mobile_width][$css_new])) {
                         $css[$panels_mobile_width][$css_new] = array();
                     }
                     $css[$panels_mobile_width][$css_new][] = '#pgc-' . $post_id . '-' . $gi . '-' . $i;
                 }
             }
         }
     }
     if ($settings['responsive']) {
         // Add CSS to prevent overflow on mobile resolution.
         $panel_grid_css = 'margin-left: 0 !important; margin-right: 0 !important;';
         $panel_grid_cell_css = 'padding: 0 !important; width: 100% !important;';
         // TODO copy changes back to folio
         if (empty($css[$panels_mobile_width][$panel_grid_css])) {
             $css[$panels_mobile_width][$panel_grid_css] = array();
         }
         if (empty($css[$panels_mobile_width][$panel_grid_cell_css])) {
             $css[$panels_mobile_width][$panel_grid_cell_css] = array();
         }
         $css[$panels_mobile_width][$panel_grid_css][] = '.panel-grid';
         $css[$panels_mobile_width][$panel_grid_cell_css][] = '.panel-grid-cell';
     } else {
         // TODO Copy changes back to Folio
         $panel_grid_cell_css = 'display: inline-block !important; vertical-align: top !important;';
         if (empty($css[$panels_mobile_width][$panel_grid_cell_css])) {
             $css[$panels_mobile_width][$panel_grid_cell_css] = array();
         }
         $css[$panels_mobile_width][$panel_grid_cell_css][] = '.panel-grid-cell';
     }
     // Add the bottom margin
     $bottom_margin = 'margin-bottom: ' . $panels_margin_bottom . 'px';
     $bottom_margin_last = 'margin-bottom: 0 !important';
     if (empty($css[1920][$bottom_margin])) {
         $css[1920][$bottom_margin] = array();
     }
     if (empty($css[1920][$bottom_margin_last])) {
         $css[1920][$bottom_margin_last] = array();
     }
     $css[1920][$bottom_margin][] = '.panel-grid-cell .panel';
     $css[1920][$bottom_margin_last][] = '.panel-grid-cell .panel:last-child';
     // This is for the side margins
     $magin_half = $settings['margin-sides'] / 2;
     $side_margins = "margin: 0 -{$magin_half}px 0";
     $side_paddings = "padding: 0 {$magin_half}px 0";
     if (empty($css[1920][$side_margins])) {
         $css[1920][$side_margins] = array();
     }
     if (empty($css[1920][$side_paddings])) {
         $css[1920][$side_paddings] = array();
     }
     $css[1920][$side_margins][] = '.panel-grid';
     $css[1920][$side_paddings][] = '.panel-grid-cell';
     if (!defined('POOTLEPAGE_OLD_V')) {
         $css[1920]['padding: 10px'][] = '.panel';
         $css[768]['padding: 5px'][] = '.panel';
     }
     /**
      * Filter the unprocessed CSS array
      */
     $css = apply_filters('siteorigin_panels_css', $css);
     // Build the CSS
     $css_text = '';
     krsort($css);
     foreach ($css as $res => $def) {
         if (empty($def)) {
             continue;
         }
         if ($res < 1920) {
             $css_text .= '@media ( max-width:' . $res . 'px )';
             $css_text .= ' { ';
         }
         foreach ($def as $property => $selector) {
             $selector = array_unique($selector);
             $css_text .= implode(' , ', $selector) . ' { ' . $property . ' } ';
         }
         if ($res < 1920) {
             $css_text .= ' } ';
         }
     }
     return $css_text;
 }
Ejemplo n.º 6
0
 /**
  * Enqueue the panels admin scripts
  *
  * @action admin_print_scripts-post-new.php
  * @action admin_print_scripts-post.php
  * @uses Pootle_Page_Builder_Admin_UI::enqueue_color_picker()
  * @since 1.0.0
  */
 public function enqueue_scripts()
 {
     $screen = get_current_screen();
     if ($screen->base == 'post' && in_array($screen->id, pootle_pb_settings('post-types'))) {
         wp_enqueue_script('jquery-ui-resizable');
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_script('jquery-ui-slider');
         wp_enqueue_script('jquery-ui-dialog');
         wp_enqueue_script('jquery-ui-button');
         wp_enqueue_script('so-undomanager', POOTLEPAGE_URL . 'js/undomanager.min.js', array(), 'fb30d7f');
         wp_enqueue_script('ppb-chosen', POOTLEPAGE_URL . 'js/chosen/chosen.jquery.min.min.js', array('jquery'), POOTLEPAGE_VERSION);
         $deps = array('jquery', 'jquery-ui-resizable', 'jquery-ui-sortable', 'jquery-ui-slider', 'jquery-ui-dialog', 'jquery-ui-button', 'jquery-ui-tabs');
         wp_enqueue_script('so-panels-admin', POOTLEPAGE_URL . 'js/panels.admin.js', $deps, POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-sticky', POOTLEPAGE_URL . 'js/panels.admin.sticky.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-panels', POOTLEPAGE_URL . 'js/panels.admin.panels.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-grid', POOTLEPAGE_URL . 'js/panels.admin.grid.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-prebuilt', POOTLEPAGE_URL . 'js/panels.admin.prebuilt.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-tooltip', POOTLEPAGE_URL . 'js/panels.admin.tooltip.min.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-media', POOTLEPAGE_URL . 'js/panels.admin.media.min.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('so-panels-admin-styles', POOTLEPAGE_URL . 'js/panels.admin.styles.js', array('jquery'), POOTLEPAGE_VERSION);
         wp_enqueue_script('row-options', POOTLEPAGE_URL . 'js/row.options.admin.js', array('jquery'));
         wp_localize_script('so-panels-admin', 'panels', array('previewUrl' => wp_nonce_url(add_query_arg('siteorigin_panels_preview', 'true', get_home_url()), 'ppb-panels-preview'), 'i10n' => array('buttons' => array('insert' => __('Insert', 'ppb-panels'), 'cancel' => __('cancel', 'ppb-panels'), 'delete' => __('Delete', 'ppb-panels'), 'duplicate' => __('Duplicate', 'ppb-panels'), 'style' => __('Style', 'ppb-panels'), 'edit' => __('Edit', 'ppb-panels'), 'done' => __('Done', 'ppb-panels'), 'undo' => __('Want to undo?', 'ppb-panels'), 'add' => __('Add', 'ppb-panels')), 'messages' => array('deleteColumns' => __('Columns deleted', 'ppb-panels'), 'deleteWidget' => __('Content deleted', 'ppb-panels'), 'confirmLayout' => __('Are you sure you want to load this layout? It will overwrite your current page.', 'ppb-panels'), 'editWidget' => __('Edit %s Widget', 'ppb-panels'), 'styleWidget' => __('Style Widget', 'ppb-panels')))));
         // this is the data of the widget and row that have been setup
         $panels_data = $this->get_current_admin_panels_data();
         // Add in the forms
         if (count($panels_data) > 0) {
             // load all data even if no widget inside, so row styling will be loaded
             wp_localize_script('so-panels-admin', 'panelsData', $panels_data);
         }
         // Set up the row styles
         wp_localize_script('so-panels-admin', 'panelsStyleFields', siteorigin_panels_style_get_fields());
         $this->enqueue_color_picker();
         wp_localize_script('pp-pb-color-picker', 'wpColorPickerL10n', array('clear' => __('Clear'), 'defaultString' => __('Default'), 'pick' => __('Select Color'), 'current' => __('Current Color')));
         wp_enqueue_style('wp-color-picker');
         // This gives panels a chance to enqueue scripts too, without having to check the screen ID.
         do_action('ppb_enqueue_admin_scripts');
         do_action('sidebar_admin_setup');
     }
 }