function builder_add_responsive_stylesheets() { $template_dir = get_template_directory(); $template_url = get_template_directory_uri(); $stylesheet_dir = get_stylesheet_directory(); $stylesheet_url = get_stylesheet_directory_uri(); $files = array('style-responsive.css' => 'tablet-width', 'style-tablet.css' => array('mobile-width', 'tablet-width'), 'style-mobile.css' => 'mobile-width'); $files = apply_filters('builder_get_responsive_stylesheet_files', $files); $stylesheets = array(); $use_template = false; if ($template_dir != $stylesheet_dir && !defined('BUILDER_DISABLE_PARENT_RESPONSIVE_STYLESHEETS')) { $use_template = true; } foreach (array_keys($files) as $file) { if (file_exists("{$stylesheet_dir}/{$file}")) { $stylesheets[$file] = "{$stylesheet_url}/{$file}"; } else { if ($use_template && file_exists("{$template_dir}/{$file}")) { $stylesheets[$file] = "{$template_url}/{$file}"; } } } if (empty($stylesheets)) { return; } $size_widths = array('tablet-width' => builder_theme_supports('builder-responsive', 'tablet-width'), 'mobile-width' => builder_theme_supports('builder-responsive', 'mobile-width'), 'layout-width' => apply_filters('builder_get_layout_width', '')); foreach ($stylesheets as $file => $stylesheet) { $widths = $files[$file]; if (is_array($widths)) { $min_width = $widths[0]; $max_width = $widths[1]; } else { $min_width = ''; $max_width = $widths; } if (!empty($min_width) && isset($size_widths[$min_width])) { $min_width = $size_widths[$min_width]; } if (!empty($min_width) && isset($size_widths[$min_width])) { $min_width = $size_widths[$min_width]; } if (is_numeric($min_width)) { $min_width .= 'px'; } if (!empty($size_widths[$max_width])) { $max_width = $size_widths[$max_width]; } if (!empty($size_widths[$max_width])) { $max_width = $size_widths[$max_width]; } if (is_numeric($max_width)) { $max_width .= 'px'; } if (empty($min_width)) { echo "<link rel=\"stylesheet\" href=\"{$stylesheet}\" type=\"text/css\" media=\"only screen and (max-width: {$max_width})\" />\n"; } else { echo "<link rel=\"stylesheet\" href=\"{$stylesheet}\" type=\"text/css\" media=\"only screen and (min-width: {$min_width}) and (max-width: {$max_width})\" />\n"; } } }
function builder_widget_content_load() { if (!builder_theme_supports('builder-widget-widget-content')) { return; } require_once dirname(__FILE__) . '/widget.php'; require_once dirname(__FILE__) . '/post-types/content.php'; }
function it_builder_configure_editor_features() { builder_add_settings_editor_box(__('Menu Builder', 'it-l10n-Builder-Paige'), null, array('var' => 'menu_builder', '_builtin' => true)); builder_add_settings_editor_box(__('Analytics and JavaScript Code', 'it-l10n-Builder-Paige'), null, array('var' => 'analytics', '_builtin' => true)); builder_add_settings_editor_box(__('Favicon', 'it-l10n-Builder-Paige'), null, array('var' => 'favicon', '_builtin' => true)); builder_add_settings_editor_box(__('Identify Widget Areas', 'it-l10n-Builder-Paige'), null, array('var' => 'widgets', '_builtin' => true)); builder_add_settings_editor_box(__('Comments', 'it-l10n-Builder-Paige'), null, array('var' => 'comments', '_builtin' => true)); if (builder_theme_supports('builder-gallery-shortcode')) { builder_add_settings_editor_box(__('Gallery Shortcode', 'it-l10n-Builder-Paige'), null, array('var' => 'gallery_shortcode', '_builtin' => true)); } // builder_add_settings_editor_box( __( 'Theme Activation', 'it-l10n-Builder-Paige' ), null, array( 'var' => 'activation', '_builtin' => true, 'priority' => 'low' ) ); builder_add_settings_editor_box(__('Theme Features', 'it-l10n-Builder-Paige'), null, array('var' => 'theme_features', '_builtin' => true, 'priority' => 'low')); }
function get_current_stylesheet_version() { $version = $this->generator_version; if (empty($this->layout['version'])) { $version .= ',1'; } else { $version .= ',' . $this->layout['version']; } $version .= ',' . get_stylesheet(); if (builder_theme_supports('builder-full-width-modules-legacy') && !isset($GLOBALS['builder_theme_supports_defaults']['builder-full-width-modules-legacy'])) { $GLOBALS['builder_theme_supports_defaults']['builder-full-width-modules-legacy'] = false; } foreach ($GLOBALS['builder_theme_supports_defaults'] as $feature => $args) { $support = builder_theme_supports($feature); if (!$support) { continue; } $version .= ',{' . $feature . ':'; $data = array(); if (!empty($args) && $support) { foreach ($args as $arg => $value) { $arg_support = builder_theme_supports($feature, $arg); if ($arg_support) { $data[] = $arg . '=' . (string) $arg_support; } } } else { $data[] = (string) $support; } $version .= implode(',', $data); $version .= '}'; } $modules = array(); foreach ($this->layout['modules'] as $module) { $modules[] = $module['guid']; } $version .= ',{modules:' . implode(',', $modules) . '}'; $version = apply_filters('builder_get_layout_stylesheet_version', $version); return $version; }
function _get_defaults($defaults) { $new_defaults = array('type' => 'pages', 'style' => ''); if (builder_theme_supports('builder-navigation-module-sidebars')) { $new_defaults['sidebar'] = ''; } return array_merge($defaults, $new_defaults); }
function _modify_layout() { $defaults = array('guid' => '', 'description' => '', 'width' => '960', 'hide_widths' => 'no'); $defaults = apply_filters('builder_filter_layout_editor_default_values', $defaults); $layout_widths = array('600' => __('Narrow (600 pixels)', 'it-l10n-Builder-Paige'), '780' => __('Medium (780 pixels)', 'it-l10n-Builder-Paige'), '960' => __('Wide (960 pixels)', 'it-l10n-Builder-Paige')); $layout_widths = apply_filters('builder_filter_layout_editor_width_options', $layout_widths); foreach ((array) $layout_widths as $width => $description) { if ((string) intval($width) != (string) $width) { unset($layout_widths[$width]); } } $layout_widths['custom'] = __('Custom...', 'it-l10n-Builder-Paige'); if (builder_theme_supports('builder-extensions')) { $extensions_data = apply_filters('builder_get_extensions_data', array()); $extensions = array('' => __('-- No Extension --', 'it-l10n-Builder-Paige')); $extension_descriptions = array(); foreach ((array) $extensions_data as $extension => $extension_data) { $extensions[$extension] = $extension_data['name']; $description = $extension_data['description']; if (!empty($description)) { $description = "<p>{$description}</p>"; } if ($extension_data['disable_theme_style']) { $description .= __('<p><strong>Notice:</strong> This Extension replaces theme styling with its own.</p>', 'it-l10n-Builder-Paige'); } $extension_descriptions[] = '"' . str_replace('"', '\\"', $extension) . '": "' . str_replace('"', '\\"', $description) . '"'; } } /* $layouts = array(); foreach ( (array) $this->_options['layouts'] as $layout_id => $layout_data ) { if ( isset( $_REQUEST['layout'] ) && ( $layout_id == $_REQUEST['layout'] ) ) continue; $layouts[$layout_id] = $layout_data['description']; } sort( $layouts );*/ $layout = array(); if (isset($this->_cached_layout) && is_array($this->_cached_layout)) { $layout = $this->_cached_layout; } else { if (isset($_REQUEST['layout']) && isset($this->_options['layouts'][$_REQUEST['layout']])) { $layout = $this->_options['layouts'][$_REQUEST['layout']]; } } $layout = ITUtility::merge_defaults($layout, $defaults); if (isset($layout['width']) && (string) intval($layout['width']) == (string) $layout['width'] && !isset($layout_widths[$layout['width']])) { $layout['custom_width'] = $layout['width']; $layout['width'] = 'custom'; } if (!empty($layout['extension']) && false !== strpos($layout['extension'], '%WP_CONTENT_DIR%')) { $layout['extension'] = basename($layout['extension']); } $form = new ITForm($layout); ?> <div class="wrap"> <?php ITUtility::screen_icon(); ?> <?php if (!empty($_REQUEST['layout'])) { ?> <h2><?php _e('Edit Layout', $this->_var); ?> </h2> <?php } else { ?> <h2><?php _e('Add New Layout', $this->_var); ?> </h2> <?php } ?> <?php $form->start_form(); ?> <h3 class="title"><?php _e('Settings', 'it-l10n-Builder-Paige'); ?> </h3> <table class="form-table"> <tr><th scope="row"><label for="description"><?php _e('Name', 'it-l10n-Builder-Paige'); ?> </label></th> <td> <?php $form->add_text_box('description', array('size' => '15', 'maxlength' => '15')); ?> <?php ITUtility::add_tooltip(__('The name helps identify this Layout\'s widget areas. Choose a descriptive, short name.', 'it-l10n-Builder-Paige')); ?> </td> </tr> <tr><th scope="row"><label for="width"><?php _e('Width', 'it-l10n-Builder-Paige'); ?> </label></th> <td> <?php $form->add_drop_down('width', $layout_widths); ?> <?php ITUtility::add_tooltip(__('The width determines how wide the Layout is. Typically, a wider width is better for more complex Layouts that have multiple sidebars while a more narrow width is better for minimalistic Layouts such as one that does not use any sidebars.')); ?> <div id="layout-width-custom" style="display:none;"> <label> <?php _e('Custom Width', 'it-l10n-Builder-Paige'); ?> <?php $form->add_text_box('custom_width', array('size' => '4', 'maxlength' => '5')); ?> <?php _e('pixels', 'it-l10n-Builder-Paige'); ?> </label> </div> </td> </tr> <?php if (builder_theme_supports('builder-extensions')) { ?> <tr><th scope="row"><label for="extension"><?php _e('Extension', 'it-l10n-Builder-Paige'); ?> </label></th> <td> <?php $form->add_drop_down('extension', $extensions); ?> <?php ITUtility::add_tooltip(__('Extensions can provide additional code that changes the content, provides additional features, or modifies the styling of the Layout.<br /><br />You can find Extensions in your theme\'s directory inside a directory named "extensions".', 'it-l10n-Builder-Paige')); ?> <div id="extension-details"></div> </td> </tr> <?php } ?> <tr><th scope="row"><label for="hide_widgets"><?php _e('Hide Widget Areas', 'it-l10n-Builder-Paige'); ?> </label></th> <td> <?php $form->add_drop_down('hide_widgets', array('no' => __('No', 'it-l10n-Builder-Paige'), 'yes' => __('Yes', 'it-l10n-Builder-Paige'))); ?> <?php ITUtility::add_tooltip(__('Use this option to hide this Layout\'s widget areas from the <strong>Appearance > Widgets</strong> editor. This makes it easier to work with other Layout\'s widget areas.', 'it-l10n-Builder-Paige')); ?> </td> </tr> <?php do_action('builder_editor_add_custom_settings', $layout); ?> </table> <h3 class="title">Design</h3> <table class="form-table layout-modules"> <tr class="add-module-help"><td colspan="2"><?php _e('In order to start building your layout, please click the Add Module link below.', 'it-l10n-Builder-Paige'); ?> </td></tr> <?php $position = 1; $max_id = 0; if (isset($layout['modules'])) { foreach ((array) $layout['modules'] as $id => $module) { if (false !== $this->_add_module_fields($module, $id, $position)) { $position++; } if ($id > $max_id) { $max_id = $id; } } } ?> </table> <p class="submit"> <?php $form->add_submit('save', array('value' => __('Save Layout', 'it-l10n-Builder-Paige'), 'class' => 'button-primary')); ?> <?php $form->add_submit('save_and_continue', array('value' => __('Save Layout and Continue Editing', 'it-l10n-Builder-Paige'), 'class' => 'button-secondary')); ?> <?php $form->add_submit('cancel', array('value' => __('Cancel', 'it-l10n-Builder-Paige'), 'class' => 'button-secondary cancel')); ?> </p> <input type="hidden" name="next-position" value="<?php echo $position; ?> " /> <input type="hidden" name="current-position" value="0" /> <input type="hidden" name="next-id" value="<?php echo $max_id + 1; ?> " /> <?php $form->add_hidden('self-link', $this->_self_link); ?> <?php if (isset($_REQUEST['layout'])) { $form->add_hidden('layout', $_REQUEST['layout']); } ?> <?php if (isset($_REQUEST['layout'])) { $form->add_hidden('layout-guid', $layout['guid']); } ?> <?php if (isset($_REQUEST['add_layout'])) { $form->add_hidden('add_layout', $_REQUEST['add_layout']); } ?> <?php $form->add_hidden('base_url', "{$this->_plugin_url}"); ?> <?php $form->end_form(); ?> </div> <?php foreach ((array) $this->_modules as $var => $module) { echo "<table id=\"module-editor-{$var}\" style=\"display:none;\">"; $this->_add_module_fields(array('module' => $var, 'data' => array()), '%id%', '%position%'); echo '</table>'; $form->add_hidden("module-name-{$var}", $module->_name); $form->add_hidden("module-editable-{$var}", method_exists($module, 'edit') ? '1' : '0'); $form->add_hidden("module-max-{$var}", $module->_max); } $module_image_paths = array(); if (is_dir("{$this->_plugin_path}/modules") && ($readdir = opendir("{$this->_plugin_path}/modules"))) { while (($module = readdir($readdir)) !== false) { if (preg_match('/^\\.{1,2}$/', $module)) { continue; } if (is_dir("{$this->_plugin_path}/modules/{$module}") && is_dir("{$this->_plugin_path}/modules/{$module}/images")) { $module_image_paths[] = "modules/{$module}/images"; } } } echo "<div class=\"preload-images\">\n"; foreach ((array) $module_image_paths as $path) { if ($readdir = opendir("{$this->_plugin_path}/{$path}")) { while (($image = readdir($readdir)) !== false) { if (is_file("{$this->_plugin_path}/{$path}/{$image}") && preg_match('/\\.(png|jpg|jpeg|gif)$/i', $image)) { echo "<img src=\"{$this->_plugin_url}/{$path}/{$image}\" alt=\"preload image\" />\n"; } } } } echo "</div>\n"; ?> <script type="text/javascript"> <?php if (isset($extension_descriptions)) { ?> var builder_extension_details = {<?php echo implode(",\n", $extension_descriptions); ?> }; <?php } ?> init_layout_editor(); </script> <?php }
Added filter to push to builder_get_default_layouts Updated layout-settings data version to 1.6 2.4.1 - 2011-10-06 - Chris Jean Minor performance improvements 2.5.0 - 2012-08-23 - Chris Jean Changed require_once to require. Changed require for modules.php to module-loader.php. Replaced frequent dirname requests with a variable. 2.6.0 - 2012-10-12 - Chris Jean Added require for style-generator.php. */ builder_set_data_version('layout-settings', '1.6'); $layout_engine_dir = dirname(__FILE__); require $layout_engine_dir . '/functions.php'; require $layout_engine_dir . '/available-views.php'; require $layout_engine_dir . '/module-loader.php'; require $layout_engine_dir . '/sidebars.php'; require $layout_engine_dir . '/style-generator.php'; if (builder_theme_supports('builder-default-layouts')) { add_filter('it_storage_filter_load_layout_settings', 'builder_get_default_layouts', 0); } if (is_admin()) { if (current_theme_supports('builder-my-theme-menu')) { require $layout_engine_dir . '/editor.php'; } require $layout_engine_dir . '/add-layout-screen-options.php'; builder_add_import_export_data_source('BuilderDataSourceLayoutsViews', $layout_engine_dir . '/data-source-layouts-views.php'); } else { require $layout_engine_dir . '/layout-selector.php'; require $layout_engine_dir . '/layout-engine.php'; }
<?php /* Code responsible for loading the title functionality Written by Chris Jean for iThemes.com Version 1.1.0 Version History 1.0.0 - 2012-08-03 - Chris Jean Initial version 1.1.0 - 2013-02-15 - Chris Jean Moved wp_title filter to be conditional on support for builder-title-tag. */ require_once dirname(__FILE__) . '/functions.php'; add_action('builder_add_title', 'builder_add_title'); if (builder_theme_supports('builder-title-tag')) { add_filter('wp_title', 'builder_filter_wp_title', 20, 3); }
function get_columns_styling($fields, $type) { $columns = $fields[$type]; if ('columns' == $type) { $full_width = $fields['widths']['container_width']; } else { $full_width = $fields['widths']['full_sidebar_width']; } $style = ''; if (1 == count($columns)) { if (builder_theme_supports('builder-percentage-widths')) { $width = '100%'; } else { $width = $full_width . 'px'; } $selectors = array_keys($columns); $style .= "{$selectors[0]} {\n"; $style .= "\twidth: {$width};\n"; $style .= "}\n"; return $style; } $total_width = array_sum($columns); if (builder_theme_supports('builder-percentage-widths')) { $column_widths = builder_get_percent_widths($columns); $width_unit = '%'; } else { $column_widths = $columns; $width_unit = 'px'; } if (builder_theme_supports('builder-responsive')) { $selectors = array_keys($columns); $offset = 0; $media_rules = ''; foreach ($column_widths as $selector => $width) { $style .= "{$selector} {\n"; $style .= "\tfloat: left !important;\n"; $style .= "\twidth: {$width}%;\n"; $style .= "\tmargin-left: {$offset}%;\n"; $style .= "\tmargin-right: -100%;\n"; $style .= "}\n"; $offset += $width; } if (builder_theme_supports('builder-responsive', 'enable-breakpoints') && !empty($fields['column_min_width'])) { $break_point_width = $fields['widths']['container_width'] * $fields['column_min_width'] / min($columns); $break_point_width = min($fields['widths']['container_width'], $break_point_width); $style .= "@media screen and (max-width: {$break_point_width}px) {\n"; $style .= "\t" . implode(",\n\t", $selectors) . " {\n"; $style .= "\t\tfloat: none !important;\n"; $style .= "\t\twidth: auto;\n"; $style .= "\t\tmargin: 0;\n"; $style .= "\t}\n"; $style .= "\t" . implode(" .builder-module-block,\n\t", $selectors) . " .builder-module-block,\n"; $style .= "\t" . implode(" .widget,\n\t", $selectors) . " .widget {\n"; $style .= "\t\tmargin: 0;\n"; $style .= "\t}\n"; $style .= "}\n"; } } else { foreach ($column_widths as $selector => $width) { $style .= "{$selector} {\n"; $style .= "\twidth: {$width}{$width_unit};\n"; $style .= "\tmax-width: {$width}{$width_unit};\n"; $style .= "}\n"; } } return $style; }
function it_builder_load_theme_features() { global $wp_version; $path = dirname(dirname(__FILE__)); it_classes_load('it-cache.php'); require $path . '/import-export/init.php'; require $path . '/widgets/init.php'; require $path . '/data/init.php'; require $path . '/theme-settings/init.php'; require $path . '/layout-engine/init.php'; require $path . '/title/init.php'; $file_cache = builder_theme_supports('builder-file-cache') ? true : false; $GLOBALS['builder_cache'] = new ITCache('builder-core', array('enable_file_cache' => $file_cache)); $GLOBALS['builder_cache']->add_content_type('javascript-footer', 'javascript-footer.js', 'text/javascript', array('async_load' => true)); $GLOBALS['builder_cache']->add_content_filter('javascript', 'builder_filter_javascript_content'); $GLOBALS['builder_cache']->add_content_filter('javascript-footer', 'builder_filter_javascript_footer_content'); $GLOBALS['builder_cache']->add_content_filter('css', 'builder_filter_css_content'); if (builder_theme_supports('builder-my-theme-menu')) { require $path . '/tutorials/init.php'; } // Compatibility check for pre-3.0 automatic-feed-links support if (version_compare($wp_version, '2.9.7', '<=') && builder_theme_supports('automatic-feed-links') && function_exists('automatic_feed_links')) { automatic_feed_links(); } if (builder_theme_supports('builder-extensions')) { require $path . '/extensions/init.php'; } if (builder_theme_supports('builder-admin-bar')) { require $path . '/admin-bar/init.php'; } if (builder_theme_supports('builder-plugin-features')) { require $path . '/plugin-features/init.php'; } if (builder_theme_supports('builder-3.0')) { add_theme_support('loop-standard'); } if (builder_theme_supports('loop-standard')) { require $path . '/loop-standard/functions.php'; } if (builder_theme_supports('builder-responsive')) { add_theme_support('builder-percentage-widths'); add_theme_support('builder-responsive-ready'); require $path . '/responsive/init.php'; } if (builder_theme_supports('builder-gallery-shortcode')) { require $path . '/gallery-shortcode/init.php'; } if ('on' == builder_get_theme_setting('dashboard_favicon')) { add_action('admin_enqueue_scripts', 'builder_add_favicon', 0); } do_action('builder_theme_features_loaded'); }
function print_body_tag($render_data) { // Figure out if output buffering is enabled or not. // The flush should be bypassed if the page is being output buffered. $output_buffering_level = ob_get_level(); $is_buffered = $output_buffering_level > 1 || !@ini_get('output_buffering') && $output_buffering_level > 0; if (!$is_buffered && builder_theme_supports('builder-header-flush') && (!defined('BUILDER_DISABLE_FLUSH') || false === BUILDER_DISABLE_FLUSH)) { flush(); } $attributes = array('id' => array("builder-layout-{$this->_layout['guid']}")); if (builder_theme_supports('builder-responsive')) { $class = 'builder-responsive'; } else { $class = 'builder-static'; } $attributes['class'] = get_body_class($class); $attributes = apply_filters('builder_filter_body_attributes', $attributes); ITUtility::print_open_tag('body', $attributes); }