/** * Handles creating the preview. * @since 0.1.0 */ function pootlepb_preview() { if (null !== filter_input(INPUT_GET, 'pootlepb_preview') && wp_verify_nonce(filter_input(INPUT_GET, '_wpnonce'), 'ppb-panels-preview')) { global $pootlepb_is_preview; $pootlepb_is_preview = true; // Set the panels home state to true $post_id = filter_input(INPUT_POST, 'post_id'); if (empty($post_id)) { $GLOBALS['pootlepb_is_panels_home'] = true; } locate_template(pootlepb_settings('home-template'), true); exit; } }
/** * Filter the content of the panel, adding all the content blocks. * * @param string $content Post content * * @return string Pootle page builder post content * @filter the_content * @since 0.1.0 */ public function content_filter($content) { $postID = apply_filters('pootlepb_the_content_id', get_the_ID()); $pass = apply_filters('pootlepb_the_content_pass', in_array(get_post_type(), pootlepb_settings('post-types'))); if (!$pass) { return $content; } $post = get_post($postID); $panel_content = $this->panels_render($post->ID); if (!empty($panel_content)) { $content = $panel_content; } return $content; }
/** * Generate the actual CSS. * * @param int|string $post_id * @param array $panels_data * * @return string|null CSS to output * @since 0.1.0 */ public function panels_generate_css($post_id, $panels_data) { // Exit if we don't have panels data if (empty($panels_data['grids'])) { return null; } $settings = pootlepb_settings(); // Pootle page builder settings // Add the grid sizing $this->grid_styles($settings, $panels_data, $post_id); //Margin and padding $this->grid_elements_margin_padding($settings); /** * Filter the unprocessed CSS array * @since 0.1.0 */ $this->styles = apply_filters('pootlepb_css', $this->styles); // Build the CSS return $this->grid_build_css(); }
$enabled_modules = get_option('ppb_enabled_addons', array('hero-section', 'image', 'pootle-slider', 'photo-gallery', 'unsplash', 'pbtn', 'blog-posts', 'wc-products', 'ninja_forms-form', 'metaslider-slider')); $disabled_modules = get_option('ppb_disabled_addons', array()); $enabled_modules = apply_filters('pootlepb_enabled_addons', $enabled_modules); $disabled_modules = apply_filters('pootlepb_disabled_addons', $disabled_modules); // Removing disabled modules foreach ($disabled_modules as $id) { unset($ppb_modules[$id]); } // Prioritizing active modules foreach ($enabled_modules as $i => $id) { if (!empty($ppb_modules[$id])) { $ppb_modules[$id]['priority'] = $i * 2 + 1; } } if ($enabled_modules) { $side = pootlepb_settings('modules-position'); ?> <div id="pootlepb-modules-wrap" class="position-<?php echo $side; ?> "> <div class="dashicons dashicons-screenoptions" onclick="jQuery(this).parent().toggleClass('toggle')"></div> <div id="pootlepb-modules"> <?php pootlepb_prioritize_array($ppb_modules); foreach ($ppb_modules as $module) { $id = $module['id']; $module = wp_parse_args($module, array('label' => 'Unlabeled Module', 'icon_class' => 'dashicons dashicons-star-filled', 'icon_html' => '')); $classes = "mod-{$id}"; $attr = ""; if (!empty($module['callback'])) {
/** * Output settings field * * @param array $args * @param string $groupName * * @since 0.1.0 */ public function options_field_generic($args, $groupName = 'pootlepb_display') { $settings = pootlepb_settings(); $name = 'name="' . esc_attr($groupName) . '[' . esc_attr($args['type']) . ']"'; $value = isset($settings[$args['type']]) ? $settings[$args['type']] : ''; switch ($args['type']) { case 'hard-uninstall': ?> <label><input type="checkbox" name="pootlepb-hard-uninstall" id="pootlepb-hard-uninstall" <?php checked(get_option('pootlepb-hard-uninstall')); ?> value="1"/> <?php _e('Enabled', 'ppb-panels'); ?> </label> <?php break; case 'responsive': ?> <label><input type="checkbox" <?php echo $name; ?> <?php checked($value); ?> value="1"/> <?php _e('Enabled', 'ppb-panels'); ?> </label><?php break; case 'modules-position': ?> <label> <input type="radio" <?php echo $name; ?> <?php checked('left', $value); ?> value="left"/> <?php _e('Left', 'ppb-panels'); ?> </label> <label> <input type="radio" <?php echo $name; ?> <?php checked('right', $value); ?> value="right"/> <?php _e('Right', 'ppb-panels'); ?> </label> <?php break; case 'mobile-width': ?> <input type="text" <?php echo $name; ?> value="<?php echo esc_attr($value); ?> " class="small-text" /> <?php _e('px', 'ppb-panels'); break; } if (!empty($args['description'])) { ?> <p class="description"><?php echo esc_html($args['description']); ?> </p><?php } }
/** * Add current pages as cloneable pages * * @param $layouts * * @return mixed * @since 0.1.0 */ public function cloned_page_layouts($layouts) { $pages = get_posts(array('post_type' => pootlepb_settings('post-types'), 'post_status' => array('publish', 'draft'), 'numberposts' => 250)); foreach ($pages as $page) { $panels_data = apply_filters('pootlepb_data', get_post_meta($page->ID, 'panels_data', true), $page->ID); if (!empty($panels_data)) { $this->get_layout_from_post($page, $panels_data, $layouts); } } return $layouts; }
/** * Outputs content editor panel * @since 0.1.0 */ public function ppb_tmce_dialog() { $screen = get_current_screen(); if (in_array($screen->id, pootlepb_settings('post-types'))) { ?> <div id="ppb-editor-container" style="display:none;position:absolute;right:25px;left:auto;" class="panels-admin-dialog ppb-dialog ppb-add-content-panel ppb-cool-panel-container ppb-helper-clearfix" tabindex="-1" role="dialog" aria-describedby="ppb-id-7" aria-labelledby="ppb-id-8"> <div class="ppb-dialog-titlebar ppb-widget-header ppb-corner-all ppb-helper-clearfix ui-draggable-handle"> <span id="ppb-id-8" class="ppb-dialog-title"> Editor </span> <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ppb-dialog-titlebar-close" title="Close" type="button"><span class= "ui-button-icon-primary ui-icon ppb-icon-closethick"></span><span class="ui-button-text">Close</span></button> </div> <div class="panel-dialog dialog-form widget-dialog-pootle_pb_content_block ppb-dialog-content ppb-widget-content" id="ppb-id-7"> <?php require POOTLEPB_DIR . 'tpl/content-block-panel.php'; ?> </div> <div class="ppb-dialog-buttonpane ppb-widget-content ppb-helper-clearfix"> <div class="ppb-dialog-buttonset"> <button type="button" class="button pootle stop ppb-button ppb-widget ppb-state-default ppb-corner-all ppb-button-text-only" role="button"> <span class="ppb-button-text">Done</span> </button> </div> </div> </div> <?php } }
/** * Return Query with all posts using ppb * @return WP_Query * @since 0.3.0 */ public function ppb_posts() { if (empty($this->ppb_posts)) { //Get all posts using page builder $args = array('post_type' => pootlepb_settings('post-types'), 'posts_per_page' => -1, 'meta_query' => array(array('key' => 'panels_data', 'compare' => 'EXISTS'))); $this->ppb_posts = new WP_Query($args); } return $this->ppb_posts; }