public static function generate($inputs, $table_class = 'form-table') { echo '<table class="' . $table_class . '">'; $row_count = 0; foreach ($inputs as $input) { $row_count++; if (!method_exists(__CLASS__, 'input_' . $input['type'])) { continue; } $tooltip = isset($input['tooltip']) && $input['tooltip'] ? '<span class="label-tooltip" title="' . htmlspecialchars($input['tooltip']) . '"></span>' : null; $description = isset($input['description']) && $input['description'] ? '<p class="description">' . $input['description'] . '</p>' : null; $suffix = isset($input['suffix']) && $input['suffix'] ? $input['suffix'] : null; $id = isset($input['id']) ? $input['id'] : null; $row_class = $row_count == count($inputs) ? ' class="no-bottom-border"' : null; if (headway_get('value', $input) && !is_int(headway_get('value', $input))) { $input['value'] = stripslashes(htmlspecialchars($input['value'])); } echo '<tr valign="top"' . $row_class . '> <th scope="row"> <label for="' . $id . '">' . $input['label'] . $tooltip . '</label> </th> <td>'; call_user_func(array(__CLASS__, 'input_' . $input['type']), $input); echo $suffix . $description; echo '</td> </tr>'; } echo '</table>'; }
/** * Over time, there may be issues to be corrected between updates or naming conventions to be changed between updates. * All of that will be processed here. **/ public static function db_upgrade($db_version) { /* Pre-3.0.3 */ if (version_compare($db_version, '3.0.3', '<')) { self::fix_serialization_in_db(); self::repair_blocks(); } /** * Pre-3.2.3 * * Change the old wrapper-horizontal-padding and wrapper-vertical-padding to design editor values **/ if (version_compare($db_version, '3.2.3', '<')) { $horizontal_padding = HeadwayOption::get('wrapper-horizontal-padding', 'general', 15); $vertical_padding = HeadwayOption::get('wrapper-vertical-padding', 'general', 15); HeadwayElementsData::set_property('structure', 'wrapper', 'padding-top', $vertical_padding); HeadwayElementsData::set_property('structure', 'wrapper', 'padding-bottom', $vertical_padding); HeadwayElementsData::set_property('structure', 'wrapper', 'padding-left', $horizontal_padding); HeadwayElementsData::set_property('structure', 'wrapper', 'padding-right', $horizontal_padding); } /** * Pre-3.4 * * - Change block and wrapper margins to Design Editor values * - Convert Media blocks to Slider or Embed blocks **/ if (version_compare($db_version, '3.4', '<')) { /* Change block and wrapper margins to Design Editor values */ HeadwayElementsData::set_property('structure', 'wrapper', 'margin-top', HeadwayOption::get('wrapper-top-margin', 'general', 30)); HeadwayElementsData::set_property('structure', 'wrapper', 'margin-bottom', HeadwayOption::get('wrapper-bottom-margin', 'general', 30)); HeadwayElementsData::set_property('default-elements', 'default-block', 'margin-bottom', HeadwayOption::get('block-bottom-margin', 'general', 10)); /* Convert Media blocks to Slider or Embed blocks */ $media_blocks = HeadwayBlocksData::get_blocks_by_type('media'); if (is_array($media_blocks) && count($media_blocks)) { foreach ($media_blocks as $media_block_id => $media_block_layout_id) { $media_block = HeadwayBlocksData::get_block($media_block_id); $media_block_mode = headway_get('mode', $media_block['settings'], 'embed'); switch ($media_block_mode) { case 'embed': HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'embed')); break; case 'image-rotator': $slider_images = array(); foreach (headway_get('images', $media_block['settings'], array()) as $media_block_image) { $slider_images[] = array('image' => $media_block_image, 'image-description' => null, 'image-hyperlink' => null); } HeadwayBlocksData::update_block($media_block['layout'], $media_block['id'], array('type' => 'slider', 'settings' => array('images' => $slider_images))); break; } } } } /* Add action to flush caches */ do_action('headway_db_upgrade'); /* Update the version here. */ $headway_settings = get_option('headway', array('version' => 0)); $headway_settings['version'] = HEADWAY_VERSION; update_option('headway', $headway_settings); return true; }
public static function init() { self::check_option_groups(); if (headway_get('ve-preview') && HeadwayCapabilities::can_user_visually_edit()) { HeadwayOption::$group_suffix = '_preview'; } }
public function get_wrappers_select_options_for_mirroring() { $wrappers = HeadwayWrappers::get_all_wrappers(); $options = array('' => '– Do Not Mirror –'); //If there are no blocks, then just return the Do Not Mirror option. if (empty($wrappers) || !is_array($wrappers)) { return $options; } foreach ($wrappers as $wrapper_id => $wrapper_settings) { /* If we can't get a name for the layout, then things probably aren't looking good. Just skip this wrapper. */ if (!($layout_name = HeadwayLayout::get_name($wrapper_settings['layout']))) { continue; } /* Check for mirroring here */ if (HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) { continue; } $current_layout_suffix = $this->wrapper['layout'] == $wrapper_settings['layout'] ? ' (Warning: Same Layout)' : null; $wrapper_alias = headway_get('alias', $wrapper_settings) ? ' – ' . headway_get('alias', $wrapper_settings) : null; //Get alias if it exists, otherwise use the default name $options[$wrapper_id] = 'Wrapper #' . HeadwayWrappers::format_wrapper_id($wrapper_id) . $wrapper_alias . ' – ' . $layout_name . $current_layout_suffix; } //Remove the current wrapper from the list unset($options[$this->wrapper['id']]); return $options; }
function content($block) { $images = parent::get_setting($block, 'images', array()); $block_width = HeadwayBlocksData::get_block_width($block); $block_height = HeadwayBlocksData::get_block_height($block); $has_images = false; foreach ($images as $image) { if ($image['image']) { $has_images = true; break; } } if (!$has_images) { echo '<div class="alert alert-yellow"><p>There are no images to display.</p></div>'; return; } $no_slide_class = count($images) === 1 ? ' flexslider-no-slide' : ''; echo '<div class="flexslider' . $no_slide_class . '">'; /* Put in viewport div for sliders that only have 1 image and don't slide */ if (count($images) === 1) { echo '<div class="flex-viewport">'; } echo '<ul class="slides">'; foreach ($images as $image) { if (!$image['image']) { continue; } $output = array('image' => array('src' => parent::get_setting($block, 'crop-resize-images', true) ? headway_resize_image($image['image'], $block_width, $block_height) : $image['image'], 'alt' => headway_fix_data_type(headway_get('image-alt', $image)), 'title' => headway_fix_data_type(headway_get('image-title', $image)), 'caption' => headway_fix_data_type(headway_get('image-description', $image))), 'hyperlink' => array('href' => headway_fix_data_type(headway_get('image-hyperlink', $image)), 'target' => headway_fix_data_type(headway_get('image-open-link-in-new-window', $image, false)) ? ' target="_blank"' : null)); echo '<li>'; /* Open hyperlink if user added one for image */ if ($output['hyperlink']['href']) { echo '<a href="' . $output['hyperlink']['href'] . '"' . $output['hyperlink']['target'] . '>'; } /* Don't forget to display the ACTUAL IMAGE */ echo '<img src="' . $output['image']['src'] . '" alt="' . $output['image']['alt'] . '" title="' . $output['image']['title'] . '" />'; /* Closing tag for hyperlink */ if ($output['hyperlink']['href']) { echo '</a>'; } /* Caption */ if (!empty($output['image']['caption'])) { echo '<p class="flex-caption">' . $output['image']['caption'] . '</p>'; } echo '</li>'; } echo '</ul>'; /* Put in viewport div for sliders that only have 1 image and don't slide */ if (count($images) === 1) { echo '</div><!-- .flex-viewport -->'; } echo '</div><!-- .flexslider -->'; }
public static function cookie_baker() { /* If headers were already sent, then don't follow through with this function or it will err. */ if (headers_sent()) { return false; } if (headway_get('full-site') == 'true') { return setcookie('headway-full-site', 1, time() + 60 * 60 * 24 * 7, '/'); } if (headway_get('full-site') == 'false') { return setcookie('headway-full-site', false, time() - 3600, '/'); } return false; }
/** * Traverses up the hierarchy tree to figure out which layout is being used. * * @return mixed **/ public static function get_current_in_use() { //If the user is viewing the site through the iframe and the mode is set to Layout, then display that exact layout. if (headway_get('ve-layout') && (HeadwayRoute::is_visual_editor_iframe() || HeadwayRoute::is_visual_editor())) { return headway_get('ve-layout'); } //Get hierarchy $hierarchy = array_reverse(self::get_current_hierarchy()); //Loop through entire hierarchy to find which one is customized or has a template foreach ($hierarchy as $layout) { $status = self::get_status($layout); //If the layout isn't customized or using a template, skip to next, otherwise we return the current layout in the next line. if ($status['customized'] === false && $status['template'] === false) { continue; } //If the layout has a template assigned to it, use the template. Templates will take precedence over customized status. if ($status['template']) { return 'template-' . $status['template']; } //If it's a customized layout, then use the layout itself after making sure there are blocks on the layout if ($status['customized'] && count(HeadwayBlocksData::get_blocks_by_layout($layout)) > 0) { return $layout; } } //If there's still not a customized layout, loop through the top-level layouts and find the first one that's customized. $top_level_layouts = array('index', 'single', 'archive', 'four04'); if (get_option('show_on_front') == 'page') { $top_level_layouts[] = 'front_page'; } foreach ($top_level_layouts as $top_level_layout) { $status = self::get_status($top_level_layout); if ($status['customized'] === false && $status['template'] === false) { continue; } //If the layout has a template assigned to it, use the template. Templates will take precedence over customized status. if ($status['template']) { return 'template-' . $status['template']; } //If it's a customized layout and the layout has blocks, then use the layout itself if ($status['customized'] && count(HeadwayBlocksData::get_blocks_by_layout($top_level_layout)) > 0) { return $top_level_layout; } } //If there STILL isn't a customized layout, just return the top level of the current layout. return end($hierarchy); }
public static function register_element_instance($args) { if (!is_array($args)) { return new WP_Error('hw_elements_register_element_instance_args_not_array', __('Error: Arguments must be an array for this element instance.', 'headway'), $args); } $defaults = array('group' => null, 'grandparent' => null, 'element' => null, 'id' => null, 'name' => null, 'selector' => null, 'layout' => null, 'state-of' => null); $item = array_merge($defaults, $args); //If requirements are not met, throw errors if (!$item['id']) { return new WP_Error('hw_elements_register_element_instance_no_id', __('Error: An ID is required for this element instance.', 'headway'), $item); } if (!$item['name']) { return new WP_Error('hw_elements_register_element_instance_no_name', __('Error: A name is required for this element instance.', 'headway'), $item); } if ($item['group'] === null) { return new WP_Error('hw_elements_register_element_instance_no_group', __('Error: A group is required for this element instance.', 'headway'), $item); } if ($item['element'] === null) { return new WP_Error('hw_elements_register_element_instance_no_parent', __('Error: A parent element is required for this element instance.', 'headway'), $item); } if ($item['selector'] === null) { return new WP_Error('hw_elements_register_element_instance_no_selector', __('Error: A CSS selector is required for this element instance.', 'headway'), $item); } //If layout is set, then set layout-name as well if ($item['layout']) { $item['layout-name'] = HeadwayLayout::get_name($item['layout']); } //Figure out where the element will go in the elements array if ($item['grandparent'] !== null && isset(self::$elements[$item['group']][$item['grandparent']]['children'][$item['element']])) { $destination =& self::$elements[$item['group']][$item['grandparent']]['children'][$item['element']]; } else { if (isset(self::$elements[$item['group']][$item['element']])) { $destination =& self::$elements[$item['group']][$item['element']]; } else { return false; } } //Make sure that the element supports instances if (!headway_get('supports-instances', $destination)) { return false; } $destination =& $destination['instances'][$item['id']]; //Add the guts $destination = $item; //Add the instance to element paths so we can look the parent, grandparent and group up self::$element_paths[$item['id']] = array('group' => $item['group'], 'parent' => $item['element'], 'grandparent' => $item['grandparent']); //Remove the extra options unset($destination['element']); unset($destination['grandparent']); unset($destination['group']); //The element instance is now registered! return $destination; }
public function display() { if (!$this->blocks) { return $this->display_no_blocks_message(); } foreach ($this->wrappers as $wrapper_id => $wrapper_settings) { $wrapper_id_for_blocks = $wrapper_id; /* Check if mirroring. If mirroring, change wrapper ID to the wrapper being mirrored and preserve original ID for a later class */ if ($wrapper_being_mirrored = HeadwayWrappers::get_wrapper_mirror($wrapper_settings)) { $mirrored_wrapper_id = $wrapper_being_mirrored['id']; $wrapper_id_for_blocks = $mirrored_wrapper_id; foreach (HeadwayBlocksData::get_blocks_by_wrapper($wrapper_being_mirrored['layout'], $mirrored_wrapper_id) as $block_from_mirrored_wrapper) { $this->blocks[$block_from_mirrored_wrapper['id']] = $block_from_mirrored_wrapper; } } /* Grab blocks belonging to this wrapper */ $wrapper_blocks = array(); foreach ($this->blocks as $block_id => $block) { if (headway_get('wrapper', $block, HeadwayWrappers::$default_wrapper_id) === $wrapper_id_for_blocks) { $wrapper_blocks[$block_id] = $block; } /* If there's only one wrapper and the block does not have a proper ID or is default, move it to that wrapper */ if (count($this->wrappers) === 1 && (headway_get('wrapper', $block) === null || headway_get('wrapper', $block) == 'wrapper-default' || !isset($this->wrappers[headway_get('wrapper', $block)]))) { $wrapper_blocks[$block_id] = $block; } } /* Setup wrapper classes */ $wrapper_column_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('column-width', $wrapper_settings) : HeadwayOption::get('column-width', false, HeadwayWrappers::$default_column_width); $wrapper_gutter_width = headway_get('use-independent-grid', $wrapper_settings) ? headway_get('gutter-width', $wrapper_settings) : HeadwayOption::get('gutter-width', false, HeadwayWrappers::$default_gutter_width); $wrapper_classes = array('wrapper'); $wrapper_classes[] = $wrapper_settings['fluid'] ? 'wrapper-fluid' : 'wrapper-fixed'; $wrapper_classes[] = HeadwayResponsiveGrid::is_active() ? 'responsive-grid' : null; $wrapper_classes[] = headway_get('use-independent-grid', $wrapper_settings) ? 'independent-grid' : null; $wrapper_classes[] = 'grid-' . ($wrapper_settings['fluid-grid'] || HeadwayResponsiveGrid::is_enabled() ? 'fluid' : 'fixed') . '-' . $wrapper_settings['columns'] . '-' . $wrapper_column_width . '-' . $wrapper_gutter_width; $wrapper_classes[] = $wrapper_being_mirrored ? 'wrapper-mirroring-' . HeadwayWrappers::format_wrapper_id($mirrored_wrapper_id) : null; $last_wrapper_id = array_slice(array_keys($this->wrappers), -1, 1); $last_wrapper_id = $last_wrapper_id[0]; $first_wrapper_id = array_keys($this->wrappers); $first_wrapper_id = $first_wrapper_id[0]; if ($last_wrapper_id == $wrapper_id) { $wrapper_classes[] = 'wrapper-last'; } else { if ($first_wrapper_id == $wrapper_id) { $wrapper_classes[] = 'wrapper-first'; } } /* Custom wrapper classes */ $custom_css_classes = explode(' ', str_replace(' ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags(headway_get('css-classes', $wrapper_settings, '')))))); $wrapper_classes = array_merge($wrapper_classes, $custom_css_classes); /* Display the wrapper */ do_action('headway_before_wrapper'); echo '<div id="' . $wrapper_id . '" class="' . implode(' ', array_unique(array_filter($wrapper_classes))) . '">' . "\n\n"; do_action('headway_wrapper_open'); $wrapper = new HeadwayGridRenderer($wrapper_blocks, $wrapper_settings); $wrapper->render_grid(); do_action('headway_wrapper_close'); echo '</div><!-- .wrapper -->' . "\n\n"; do_action('headway_after_wrapper'); /* End displaying wrapper */ } }
function setup_query() { //If the query mode is default, just use $wp_query global and do what WordPress would normally do. //ALSO: if a block is brand new and just created in the visual editor (and hasn't been saved), then we'll force it into //custom query. if ($this->get_setting('mode', 'default') == 'default' && !headway_get('ve-live-content-query', $this->block, false)) { global $wp_query; $this->query = $wp_query; //The mode is custom query so we have to set it all up. } else { /* Setup Query Options */ $query_options = array(); if ($this->get_setting('mode', 'default') == 'custom-query') { //If we're just fetching a page, we can simply do that. Otherwise, we have to use all of the query filters. if ($this->get_setting('fetch-page-content', false)) { $query_options['page_id'] = $this->get_setting('fetch-page-content', false); } else { //Categories if ($this->get_setting('categories-mode', 'include') == 'include') { $query_options['category__in'] = $this->get_setting('categories', array()); } if ($this->get_setting('categories-mode', 'include') == 'exclude') { $query_options['category__not_in'] = $this->get_setting('categories', array()); } //Categories $query_options['post_type'] = $this->get_setting('post-type', false); //Post Limit $query_options['posts_per_page'] = $this->get_setting('number-of-posts', 10); //End Post Limit if (is_array($this->get_setting('author'))) { $query_options['author'] = trim(implode(',', $this->get_setting('author')), ', '); } //Order by $query_options['orderby'] = $this->get_setting('order-by', 'date'); $query_options['order'] = $this->get_setting('order', 'desc'); //End order by $query_options['offset'] = $this->get_setting('offset', 0); if ($this->get_setting('paginate', true)) { $query_options['paged'] = $this->paged; if ($this->get_setting('offset', 0) >= 1 && $query_options['paged'] > 1) { $query_options['offset'] = $this->get_setting('offset', 0) + $this->get_setting('number-of-posts', 10) * ($query_options['paged'] - 1); } } } //End else conditional for either page fetching or custom query filters //End if conditional checking that the mode is custom query. //If the mode isn't a custom query, then this is a ve-live-content-query so we can just simulate $wp_query. } else { $query_options = array('showposts' => 10, 'posts_per_page' => 10); } //Initiate query instance $this->query = new WP_Query($query_options); } }
/** * Used for when a user clicks View Site in the Visual Editor **/ public static function redirect_to_layout() { remove_filter('wp_redirect', '__return_false', 12); if (headway_get('debug') && HeadwayCapabilities::can_user_visually_edit()) { wp_die(HeadwayLayout::get_url(headway_get('layout'))); } return wp_safe_redirect(HeadwayLayout::get_url(headway_get('layout'))); }
<h3 class="title" id="seo-templates-title">SEO Templates</h3> <div id="seo-templates"> <div id="seo-templates-hidden-inputs"> <?php /* SETUP THE TYPES OF SEO TEMPLATE INPUTS */ $seo_template_inputs = array('title', 'description', 'noindex', 'nofollow', 'noarchive', 'nosnippet', 'noodp', 'noydir'); /* GENERATE HIDDEN INPUTS */ $seo_options = HeadwayOption::get('seo-templates', 'general', array()); foreach (HeadwaySEO::output_layouts_and_defaults() as $page => $defaults) { foreach ($seo_template_inputs as $input) { $name_attr = 'name="headway-admin-input[seo-templates][' . $page . '][' . $input . ']"'; $default = isset($defaults[$input]) ? $defaults[$input] : null; $page_options = headway_get($page, $seo_options, array()); $value = headway_get($input, $page_options, $default); echo '<input type="hidden" id="seo-' . $page . '-' . $input . '"' . $name_attr . ' value="' . stripslashes(htmlspecialchars($value)) . '" />'; } } ?> </div> <div id="seo-templates-header"> <span>Select a Template:</span> <select> <option value="index">Blog Index</option> <?php if (get_option('show_on_front') == 'page') { echo '<option value="front_page">Front Page</option>'; }
public static function get_addon_info($api, $action, $args) { if (!$api && headway_get('headway')) { /* Output */ $addon_info_request = wp_remote_post(add_query_arg(array('action' => 'addon-info'), HEADWAY_EXTEND_DATA_URL), array('body' => array('slug' => headway_get('slug'), 'license_key' => headway_get_license_key()))); $addon_info = wp_remote_retrieve_body($addon_info_request); if (!is_serialized($addon_info) || $addon_info_request['response']['code'] != 200) { return false; } $addon_info = maybe_unserialize($addon_info); $api = new stdClass(); $api->name = $addon_info['name']; $api->version = $addon_info['version']; $api->download_link = str_replace('{KEY}', headway_get_license_key(), $addon_info['download_url']); } return $api; }
public static function get_seo_templates($layout = false) { $seo_templates_query = HeadwayOption::get('seo-templates', 'general', self::output_layouts_and_defaults()); if ($layout) { return headway_get(self::current_seo_layout(), $seo_templates_query, array()); } else { return $seo_templates_query; } }
protected function input_select($input) { echo ' <tr> <td> <select id="' . $input['attr-id'] . '" name="' . $input['attr-name'] . '">'; if (headway_get('blank-option', $input)) { echo '<option value="">' . headway_get('blank-option', $input) . '</option>'; } foreach ($input['options'] as $value => $text) { $selected = $input['value'] === $value ? ' selected' : null; echo '<option value="' . $value . '"' . $selected . '>' . $text . '</option>'; } echo ' </select> </td> </tr>'; }
/** * Convert base64 encoded image into a file and move it to proper WP uploads directory. **/ public static function decode_image_to_uploads($base64_string) { /* Make sure user has permissions to edit in the Visual Editor */ if (!HeadwayCapabilities::can_user_visually_edit()) { return; } /* Create a temporary file and decode the base64 encoded image into it */ $temporary_file = wp_tempnam(); file_put_contents($temporary_file, base64_decode($base64_string)); /* Use wp_check_filetype_and_ext() to figure out the real mimetype of the image. Provide a bogus extension and then we'll use the 'proper_filename' later. */ $filename = 'headway-imported-image.jpg'; $file_information = wp_check_filetype_and_ext($temporary_file, $filename); /* Construct $file array which is similar to a PHP $_FILES array. This array must be a variable since wp_handle_sideload() requires a variable reference argument. */ if (headway_get('proper_filename', $file_information)) { $filename = $file_information['proper_filename']; } $file = array('name' => $filename, 'tmp_name' => $temporary_file); /* Let WordPress move the image and spit out the file path, URL, etc. Set test_form to false that way it doesn't verify $_POST['action'] */ $upload = wp_handle_sideload($file, array('test_form' => false)); /* If there's an error, be sure to unlink/delete the temporary file in case wp_handle_sideload() doesn't. */ if (isset($upload['error'])) { @unlink($temporary_file); } return $upload; }
public function display_plugin_changelog() { if (headway_get('plugin') != $this->slug || !($update_info = $this->retrieve_update_info())) { return; } $changelog_request = wp_remote_get(str_replace('{KEY}', headway_get_license_key(), $update_info['changelog_url'])); $changelog = wp_remote_retrieve_body($changelog_request); echo $changelog; die; }
public function list_fonts($sortby = false) { if (headway_post('sortby')) { $sortby = headway_post('sortby'); } if (!($fonts = $this->retrieve_fonts($sortby))) { echo '<p class="error">Unable to retrieve fonts at this time.</p>'; return; } /* Display possible error */ if (isset($fonts['error'])) { echo '<p class="error">' . $fonts['error'] . '</p>'; return; } /* Output the fonts */ foreach ($fonts as $font) { echo ' <li data-value="' . $font['id'] . '" style="font-family:' . $font['stack'] . ';" data-variants="' . htmlspecialchars(json_encode(headway_get('variants', $font, array()))) . '"> <span class="font-family">' . $font['name'] . '</span> <span class="font-preview-text">The quick brown fox jumps over the lazy dog.</span> <span title="Use Font" class="use-font action"></span> <span title="Preview Font" class="preview-font action"></span> </li> '; } return true; }
Debug Mode: <?php echo HeadwayOption::get('debug-mode', false, false) ? 'Enabled' . "\n" : 'Disabled' . "\n"; ?> Show On Front: <?php echo get_option('show_on_front') . "\n"; ?> Page On Front: <?php echo get_option('page_on_front') . "\n"; ?> Page For Posts: <?php echo get_option('page_for_posts') . "\n"; ?> <?php if (!headway_get('exclude-counts')) { ?> Amount of Posts: ~<?php echo $post_count->publish . "\n"; ?> Amount of Pages: ~<?php echo $page_count->publish . "\n"; ?> Amount of Blocks: ~<?php echo count(HeadwayBlocksData::get_all_blocks()) . "\n"; ?> <?php } ?> Responsive Grid: <?php
/** * Assembles the classes for the body element. **/ public static function body_class($c) { global $wp_query, $authordata; $c[] = 'custom'; /* User Agents */ if (!HeadwayCompiler::is_plugin_caching()) { $user_agent = $_SERVER['HTTP_USER_AGENT']; /* IE */ if ($ie_version = headway_is_ie()) { $c[] = 'ie'; $c[] = 'ie' . $ie_version; } /* Modern Browsers */ if (stripos($user_agent, 'Safari') !== false) { $c[] = 'safari'; } elseif (stripos($user_agent, 'Firefox') !== false) { $c[] = 'firefox'; } elseif (stripos($user_agent, 'Chrome') !== false) { $c[] = 'chrome'; } elseif (stripos($user_agent, 'Opera') !== false) { $c[] = 'opera'; } /* Rendering Engines */ if (stripos($user_agent, 'WebKit') !== false) { $c[] = 'webkit'; } elseif (stripos($user_agent, 'Gecko') !== false) { $c[] = 'gecko'; } /* Mobile */ if (stripos($user_agent, 'iPhone') !== false) { $c[] = 'iphone'; } elseif (stripos($user_agent, 'iPod') !== false) { $c[] = 'ipod'; } elseif (stripos($user_agent, 'iPad') !== false) { $c[] = 'ipad'; } elseif (stripos($user_agent, 'Android') !== false) { $c[] = 'android'; } } /* End User Agents */ /* Responsive Grid */ if (HeadwayResponsiveGrid::is_enabled()) { $c[] = 'responsive-grid-enabled'; } if (HeadwayResponsiveGrid::is_active()) { $c[] = 'responsive-grid-active'; } /* Pages */ if (is_page() && isset($wp_query->post) && isset($wp_query->post->ID)) { $c[] = 'pageid-' . $wp_query->post->ID; $c[] = 'page-slug-' . $wp_query->post->post_name; } /* Posts & Pages */ if (is_singular() && isset($wp_query->post) && isset($wp_query->post->ID)) { //Add the custom classes from the meta box if ($custom_css_class = HeadwayLayoutOption::get($wp_query->post->ID, 'css-class', null)) { $custom_css_classes = str_replace(' ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags($custom_css_class)))); $c = array_merge($c, array_filter(explode(' ', $custom_css_classes))); } } /* Layout IDs, etc */ $c[] = 'layout-' . HeadwayLayout::get_current(); $c[] = 'layout-using-' . HeadwayLayout::get_current_in_use(); if (HeadwayRoute::is_visual_editor_iframe()) { $c[] = 've-iframe'; } if (headway_get('ve-iframe-mode') && HeadwayRoute::is_visual_editor_iframe()) { $c[] = 'visual-editor-mode-' . headway_get('ve-iframe-mode'); } if (!current_theme_supports('headway-design-editor')) { $c[] = 'design-editor-disabled'; } $c = array_unique(array_filter($c)); return $c; }
function input_integer($options, $id) { $unit = headway_get('unit', $options) ? '<span class="unit">' . headway_get('unit', $options) . '</span>' : null; echo '<input type="text" value="' . $options['value'] . '" />' . $unit; }
public function input_text($input) { $readonly = isset($input['readonly']) && $input['readonly'] === true ? ' disabled' : null; echo ' <div class="input-left"> <label>' . $input['label'] . '</label> </div> <div class="input-right"> <input type="text" ' . $input['attributes'] . ' placeholder="' . stripslashes(htmlspecialchars(headway_get('placeholder', $input))) . '" value="' . stripslashes(htmlspecialchars($input['value'])) . '" class="text"' . $readonly . ' />'; if (isset($input['suffix'])) { echo '<span class="suffix">' . $input['suffix'] . '</span>'; } echo ' </div> '; }
public static function complex_property_shadow($args) { extract($args); $shadow_type = strpos($property_id, 'box-shadow') !== false ? 'box-shadow' : 'text-shadow'; global $headway_complex_property_check; //If the complex property check isn't even set, make it an empty array. if (!is_array($headway_complex_property_check)) { $headway_complex_property_check = array($shadow_type => array()); } //Since the complex property is a combination of a bunch of properties, we only want it to output once. if (isset($headway_complex_property_check[$shadow_type][$selector]) && $headway_complex_property_check[$shadow_type][$selector] == true) { return; } $headway_complex_property_check[$shadow_type][$selector] = true; if (!isset($properties[$shadow_type . '-color'])) { return null; } $shadow_color = headway_format_color($properties[$shadow_type . '-color']); if ($shadow_color == 'transparent') { return null; } $shadow_hoffset = isset($properties[$shadow_type . '-horizontal-offset']) ? $properties[$shadow_type . '-horizontal-offset'] : '0'; $shadow_voffset = isset($properties[$shadow_type . '-vertical-offset']) ? $properties[$shadow_type . '-vertical-offset'] : '0'; $shadow_blur = isset($properties[$shadow_type . '-blur']) ? $properties[$shadow_type . '-blur'] : '0'; $shadow_inset = headway_get($shadow_type . '-position', $properties, 'outside') == 'inset' ? ' inset' : null; return $shadow_type . ': ' . $shadow_color . ' ' . $shadow_hoffset . 'px ' . $shadow_voffset . 'px ' . $shadow_blur . 'px' . $shadow_inset . ';'; }
public static function is_mode($mode) { if (self::get_current_mode() === strtolower($mode)) { return true; } if (!headway_get('visual-editor-mode') && strtolower($mode) === strtolower(self::$default_mode)) { return true; } return false; }
static function live_css() { if (headway_get('visual-editor-open')) { return null; } return HeadwayOption::get('live-css'); }
/** * @return bool **/ public static function flush_cache($hard = false) { //Flush Headway cache if it is active. if (self::can_cache()) { //Delete the Headway cache option if hard flush otherwise delete the ones that aren't set to stay with soft flush if ($hard) { HeadwayOption::delete('cache'); } else { $cache = HeadwayOption::get('cache'); foreach ($cache as $cached_file_id => $cached_file) { if (!headway_get('require-hard-flush', $cached_file, false)) { unset($cache[$cached_file_id]); } } HeadwayOption::set('cache', $cache); } //Set do not delete list $no_delete = array('..', '.'); if ($handle = opendir(HEADWAY_CACHE_DIR)) { while (false !== ($file = readdir($handle))) { if (in_array($file, $no_delete) || strpos($file, 'hard-cache') !== false && !$hard) { continue; } @unlink(HEADWAY_CACHE_DIR . '/' . $file); } closedir($handle); } } //Flush plugin caches self::flush_plugin_caches(); return true; }
static function clone_pages_select_walker($pages, $depth = 0) { $return = ''; foreach ($pages as $id => $children) { $layout_id_fragments = explode('-', $id); $status = HeadwayLayout::get_status($id); /* Take care of layouts that are the front page or blog index */ if (get_option('show_on_front') === 'page' && (isset($layout_id_fragments[1]) && $layout_id_fragments[1] == 'page')) { /* If the page is set as the static homepage or blog page, hide it if they don't have children. */ if (end($layout_id_fragments) == get_option('page_on_front') || end($layout_id_fragments) == get_option('page_for_posts')) { /* Layout has children--add the no edit class and has children class. */ if (is_array($children) && count($children) !== 0) { $disabled = true; } else { continue; } } } /* Handle layouts that aren't customized or have a template */ if (headway_get('customized', $status, false) === false || headway_get('template', $status, false) !== false) { /* If there ARE customized children, add the no-edit class */ if (is_array($children) && count($children) !== 0) { /* Check if the children are customized. */ if (HeadwayVisualEditorDisplay::is_any_layout_child_customized($children)) { $disabled = true; } else { continue; } /* If there aren't any children, do not display the node at all */ } else { continue; } } /* If the current layout is selected, then make it disabled. */ if (headway_post('layout') == $id) { $disabled = true; } /* Output Stuff */ $depth_display = str_repeat(' ', $depth); $disabled = isset($disabled) && $disabled === true ? ' disabled="disabled"' : null; $return .= '<option value="' . $id . '"' . $disabled . '>' . $depth_display . HeadwayLayout::get_name($id) . '</option>'; if (is_array($children) && count($children) !== 0) { $return .= self::clone_pages_select_walker($children, $depth + 1); } } return $return; }
public static function block_type_nice($type) { $block_types = self::get_block_types(); return headway_get('name', headway_get($type, $block_types)); }
public function get_blocks_select_options_for_mirroring() { $block_type = $this->block['type']; $blocks = HeadwayBlocksData::get_blocks_by_type($block_type); $options = array('' => '– Do Not Mirror –'); //If there are no blocks, then just return the Do Not Mirror option. if (!isset($blocks) || !is_array($blocks)) { return $options; } foreach ($blocks as $block_id => $layout_id) { //Get the block instance $block = HeadwayBlocksData::get_block($block_id); //If the block is mirrored, skip it if (HeadwayBlocksData::is_block_mirrored($block)) { continue; } /* Do not show block that's in a mirrored wrapper */ if (HeadwayWrappers::get_wrapper_mirror(HeadwayWrappers::get_wrapper(headway_get('wrapper', $block)))) { continue; } //Create the default name by using the block type and ID $default_name = HeadwayBlocks::block_type_nice($block['type']) . ' #' . $block['id']; //If we can't get a name for the layout, then things probably aren't looking good. Just skip this block. if (!($layout_name = HeadwayLayout::get_name($layout_id))) { continue; } //Make sure the block exists if (!HeadwayBlocksData::block_exists($block['id'])) { continue; } $current_layout_suffix = $this->block['layout'] == $layout_id ? ' (Warning: Same Layout)' : null; //Get alias if it exists, otherwise use the default name $options[$block['id']] = headway_get('alias', $block['settings'], $default_name) . ' – ' . $layout_name . $current_layout_suffix; } //Remove the current block from the list unset($options[$this->block['id']]); return $options; }
public static function home_link_filter($menu) { $block = self::$block; if (parent::get_setting($block, 'hide-home-link')) { return $menu; } if (get_option('show_on_front') == 'posts') { $current = is_home() || is_front_page() ? ' current_page_item' : null; $home_text = parent::get_setting($block, 'home-link-text') ? parent::get_setting($block, 'home-link-text') : 'Home'; /* If it's not the grid, then do not add the extra <span>'s */ if (!HeadwayRoute::is_grid() && !headway_get('ve-live-content-query', $block)) { $home_link = '<li class="menu-item-home headway-home-link' . $current . '"><a href="' . home_url() . '">' . $home_text . '</a></li>'; } else { $home_link = '<li class="menu-item-home headway-home-link' . $current . '"><a href="' . home_url() . '"><span>' . $home_text . '</span></a></li>'; } } else { $home_link = null; } return $home_link . $menu; }