function _set_option_defaults() { $defaults = array(); $post_type_descriptions = array('post' => __('Individual blog posts', 'it-l10n-Builder-Cohen'), 'page' => __('Individual pages', 'it-l10n-Builder-Cohen'), 'attachment' => __('When you upload images, they get their own Media page that shows the image. This option controls whether or not comments are enabled on these Media pages.', 'it-l10n-Builder-Cohen'), '' => __('Custom post type', 'it-l10n-Builder-Cohen')); $comment_post_types = array(); if (function_exists('get_post_types') && function_exists('post_type_supports')) { $post_types = get_post_types(array(), 'objects'); foreach ((array) $post_types as $post_type => $post_object) { $post_type_var = str_replace(' ', '_', $post_type); if (post_type_supports($post_type, 'comments')) { $comment_post_types[$post_type_var] = array('name' => $post_object->labels->name); } } } else { $comment_post_types = array('post' => array('name' => 'Post'), 'page' => array('name' => 'Page')); } foreach (array_keys($comment_post_types) as $post_type) { if (isset($post_type_descriptions[$post_type])) { $comment_post_types[$post_type]['description'] = $post_type_descriptions[$post_type]; } else { $comment_post_types[$post_type]['description'] = $post_type_descriptions['']; } } $comment_post_types = ITUtility::sort_array($comment_post_types, 'name'); if (!is_array($comment_post_types)) { $comment_post_types = array(); } foreach (array_keys($comment_post_types) as $post_type) { $defaults["enable_comments_{$post_type}"] = 1; } $this->_comment_post_types = $comment_post_types; $defaults['favicon_option'] = 'preset'; $defaults['dashboard_favicon'] = 'on'; $this->_options = array_merge($defaults, $this->_options); }
function _modify_views() { $available_views = apply_filters('builder_get_available_views', array()); $views = array(); foreach (array_keys((array) $this->_options['views']) as $view_id) { $view = $this->_get_view_data($view_id); if (empty($view)) { continue; } $views[$view_id] = $view; } $views = ITUtility::sort_array($views, 'name'); if (builder_theme_supports('builder-extensions')) { $extensions = apply_filters('builder_get_extensions_with_names', array()); } $layout_rules = array('//INHERIT//' => __('Use this View\'s Active Layout', 'it-l10n-Builder-Paige'), '' => __('Use the site\'s Default Layout', 'it-l10n-Builder-Paige')); $extension_rules = array('' => __('Use the Active Extension', 'it-l10n-Builder-Paige'), '//DISABLE_EXTENSION//' => __('Disable the Active Extension', 'it-l10n-Builder-Paige')); $form = new ITForm(); $add_link = ITDialog::get_link("{$this->_self_link}&modify_view_screen=1", "modal=true"); ?> <div class="wrap"> <?php $form->start_form(); ?> <?php ITUtility::screen_icon(); ?> <?php $this->_print_tabs(); ?> <p><?php _e('Views allow you to apply specific Layouts to specific parts of your site. For details, click the "Help" button at the top-right.', 'it-l10n-Builder-Paige'); ?> </p> <div id="no-views-container"> <br /> <p><?php _e('Your site currently does not have any Views configured. Please click the "Add View" button below to apply a specific Layout to a site View.', 'it-l10n-Builder-Paige'); ?> </p> <a href="<?php echo $add_link; ?> " class="it-dialog button-secondary link-secondary"><?php _e('Add View', 'it-l10n-Builder-Paige'); ?> </a> </div> <div id="views-container"> <div class="tablenav"> <div class="alignleft actions"> <a href="<?php echo $add_link; ?> " class="it-dialog button-secondary link-secondary"><?php _e('Add View', 'it-l10n-Builder-Paige'); ?> </a> </div> <br class="clear" /> </div> <br class="clear" /> <table id="views-table" class="widefat fixed"> <thead> <tr class="thead"> <th><?php _e('Site View', 'it-l10n-Builder-Paige'); ?> </th> <th><?php _e('Site View Description', 'it-l10n-Builder-Paige'); ?> </th> <th title=""><?php _e('Layout', 'it-l10n-Builder-Paige'); ?> </th> <?php if (builder_theme_supports('builder-extensions')) { ?> <th><?php _e('Extension', 'it-l10n-Builder-Paige'); ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr class="thead"> <th><?php _e('Site View', 'it-l10n-Builder-Paige'); ?> </th> <th><?php _e('Site View Description', 'it-l10n-Builder-Paige'); ?> </th> <th title=""><?php _e('Layout', 'it-l10n-Builder-Paige'); ?> </th> <?php if (builder_theme_supports('builder-extensions')) { ?> <th><?php _e('Extension', 'it-l10n-Builder-Paige'); ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php $class = ' alternate'; ?> <?php foreach ((array) $views as $view_id => $view) { ?> <tr class="view-entry" id="view-<?php echo $this->_parse_view_id($view_id); ?> "<?php echo $class; ?> > <td> <strong><a class="view-name it-dialog" href="<?php echo ITDialog::get_link("{$this->_self_link}&modify_view_screen=1&original_view={$view_id}", "modal=true&max-width=400"); ?> " title="<?php _e('Modify View', 'it-l10n-Builder-Paige'); ?> "><?php echo $view['name']; ?> </a></strong><br /> <div class="row-actions"> <span class="edit"><a href="<?php echo ITDialog::get_link("{$this->_self_link}&modify_view_screen=1&original_view={$view_id}", "modal=true&max-width=400"); ?> " class="it-dialog" title="Modify View"><?php _e('Edit', 'it-l10n-Builder-Paige'); ?> </a> | </span> <span class="delete"><a href="<?php echo ITDialog::get_link("{$this->_self_link}&delete_view_screen={$view_id}"); ?> " class="it-dialog" title="Remove View Customization"><?php _e('Remove', 'it-l10n-Builder-Paige'); ?> </a></span> </div> </td> <td><?php echo $view['description']; ?> </td> <td class="view-layout"> <?php if (isset($this->_options['layouts'][$view['layout']])) { ?> <a href="<?php echo $this->_tabless_self_link; ?> &editor_tab=layouts&layout=<?php echo $view['layout']; ?> " title="<?php _e('Modify Layout', 'it-l10n-Builder-Paige'); ?> "> <?php echo $this->_options['layouts'][$view['layout']]['description']; ?> </a> <?php } elseif (isset($layout_rules[$view['layout']])) { ?> <?php echo $layout_rules[$view['layout']]; ?> <?php } ?> </td> <?php if (builder_theme_supports('builder-extensions')) { ?> <td> <?php if (isset($view['extension']) && isset($extensions[$view['extension']])) { ?> <?php echo $extensions[$view['extension']]; ?> <?php } elseif (isset($extension_rules[$view['extension']])) { ?> <?php echo $extension_rules[$view['extension']]; ?> <?php } ?> </td> <?php } ?> </tr> <?php $class = $class == '' ? ' alternate' : ''; ?> <?php } ?> </tbody> </table> <br class="clear" /> <div class="tablenav"> <div class="alignleft actions"> <a href="<?php echo $add_link; ?> " class="button-secondary link-secondary it-dialog"><?php _e('Add View', 'it-l10n-Builder-Paige'); ?> </a> </div> <br class="clear" /> </div> </div> <div id="new-view-container" style="display:none;"> <table> <tr class="view-entry" id="view-%parsed_view_id%" style="display:none;"> <td> <strong><a class="view-name it-dialog" href="<?php echo ITDialog::get_link("{$this->_self_link}&modify_view_screen=1&original_view=%view_id%", "modal=true"); ?> " title="<?php _e('Modify View', 'it-l10n-Builder-Paige'); ?> ">%view_name%</a></strong><br /> <div class="row-actions"> <span class="edit"><a href="<?php echo ITDialog::get_link("{$this->_self_link}&modify_view_screen=1&original_view=%view_id%", "modal=true"); ?> " class="it-dialog" title="Modify View"><?php _e('Edit', 'it-l10n-Builder-Paige'); ?> </a> | </span> <span class="delete"><a href="<?php echo ITDialog::get_link("{$this->_self_link}&delete_view_screen=%view_id%"); ?> " class="it-dialog" title="Remove View Customization"><?php _e('Remove', 'it-l10n-Builder-Paige'); ?> </a></span> </div> </td> <td>%view_description%</td> <td class="" title=""> <a href="<?php echo $this->_self_link; ?> &layout=%layout%" title="<?php _e('Modify Layout', 'it-l10n-Builder-Paige'); ?> "> %layout_description% </a> </td> <?php if (builder_theme_supports('builder-extensions')) { ?> <td>%extension%</td> <?php } ?> </tr> </table> </div> <div id="js-vars" style="display:none;"> <?php foreach ((array) $available_views as $view => $data) { ?> <div id="view-name-<?php echo $this->_parse_view_id($view); ?> "><?php echo $data['name']; ?> </div> <div id="view-description-<?php echo $this->_parse_view_id($view); ?> "><?php echo $data['description']; ?> </div> <?php } ?> <?php foreach ((array) $this->_options['layouts'] as $layout => $data) { ?> <div id="layout-description-<?php echo $layout; ?> "><?php echo $data['description']; ?> </div> <div id="layout-link-href-<?php echo $layout; ?> "><?php echo $this->_self_link; ?> &layout=<?php echo $layout; ?> </div> <?php } ?> </div> <?php $form->end_form(); ?> </div> <script type="text/javascript"> init_modify_views(); </script> <?php }
function show_import_process($form, $info, $data, $post_data) { $meta = $data['meta']; $data = $data['data']; $layout_settings = $this->get_layout_settings(); $updated_layout_settings = $this->_get_updated_layout_settings($layout_settings, $data, $post_data, $meta); $final_layout_settings = $updated_layout_settings['info']['layouts']; $final_layout_settings['data'] = $updated_layout_settings['data']['layouts']; $final_view_settings = $updated_layout_settings['info']['views']; $final_view_settings['data'] = $updated_layout_settings['data']['views']; if (!empty($final_layout_settings['actions']['kept'])) { echo '<h4>' . __('Keeping Site Layouts', 'it-l10n-Builder-Cohen') . "</h4>\n"; echo "<div style='margin-left:20px;'>\n"; echo "<p>" . __('The following Layouts on the site will be kept:', 'it-l10n-Builder-Cohen') . "</p>\n"; echo "<ul>\n"; foreach ((array) $final_layout_settings['actions']['kept'] as $guid) { echo "<li>{$final_layout_settings['data'][$guid]['description']}</li>\n"; } echo "</ul>\n"; echo "</div>\n"; } if (!empty($final_layout_settings['actions']['imported'])) { echo '<h4>' . __('Importing Layouts', 'it-l10n-Builder-Cohen') . "</h4>\n"; echo "<div style='margin-left:20px;'>\n"; echo "<p>" . __('The following Layouts from the export file will be imported:', 'it-l10n-Builder-Cohen') . "</p>\n"; echo "<ul>\n"; foreach ((array) $final_layout_settings['actions']['imported'] as $guid) { $renamed = ''; if (isset($final_layout_settings['actions']['renamed'][$guid])) { $renamed = ' <i>' . sprintf(__('(renamed from "%s")', 'it-l10n-Builder-Cohen'), $final_layout_settings['actions']['renamed'][$guid]) . '</i>'; } echo "<li>{$final_layout_settings['data'][$guid]['description']}{$renamed}</li>\n"; } echo "</ul>\n"; echo "</div>\n"; } if (!empty($final_layout_settings['actions']['removed'])) { echo '<h4>' . __('Removing Site Layouts', 'it-l10n-Builder-Cohen') . "</h4>\n"; echo "<div style='margin-left:20px;'>\n"; echo "<p>" . __('The following Layouts on the site will be removed:', 'it-l10n-Builder-Cohen') . "</p>\n"; echo "<ul>\n"; $layout_settings['layouts'] = ITUtility::sort_array($layout_settings['layouts'], 'description'); foreach ((array) array_keys($layout_settings['layouts']) as $guid) { if (in_array($guid, $final_layout_settings['actions']['removed'])) { echo "<li>{$layout_settings['layouts'][$guid]['description']}</li>\n"; } } echo "</ul>\n"; echo "</div>\n"; } /* if ( ! empty( $final_layout_settings['actions']['skipped'] ) ) { echo '<h4>'. __( 'Skipping Imported Layouts', 'it-l10n-Builder-Cohen' ) . "</h4>\n"; echo "<div style='margin-left:20px;'>\n"; echo "<p>" . __( 'The following Layouts from the export file will not be imported:', 'it-l10n-Builder-Cohen' ) . "</p>\n"; echo "<ul>\n"; foreach ( (array) $final_layout_settings['actions']['skipped'] as $guid ) echo "<li>{$data['layouts'][$guid]['description']}</li>\n"; echo "</ul>\n"; echo "</div>\n"; }*/ if ('add' !== $post_data['method'] && !empty($final_view_settings['data'])) { echo '<h4>' . __('Final View Settings', 'it-l10n-Builder-Cohen') . "</h4>\n"; echo "<div style='margin-left:20px;'>\n"; echo "<p>" . __('The site will use the following Views:', 'it-l10n-Builder-Cohen') . "</p>\n"; echo "<ul>\n"; $temp_layout_settings = $layout_settings; $temp_layout_settings['layouts'] = $final_layout_settings['data']; $temp_layout_settings['views'] = $final_view_settings['data']; foreach ((array) $final_view_settings['data'] as $id => $guid) { $description = $this->_get_view_description($id, $temp_layout_settings); $description = sprintf(__('<strong>%1$s</strong> uses the "%2$s" layout', 'it-l10n-Builder-Cohen'), $description['description'], $description['layout']); echo "<li>{$description}</li>\n"; } echo "</ul>\n"; echo "</div>\n"; } if ('add' !== $post_data['method']) { echo '<h4>' . __('Default Layout', 'it-l10n-Builder-Cohen') . "</h4>\n"; echo "<div style='margin-left:20px;'>\n"; echo $final_layout_settings['data'][$updated_layout_settings['data']['default']]['description']; echo "</div>\n"; } }
function get_extensions_data($extensions = array()) { $raw_extensions = apply_filters('builder_get_extensions', array()); foreach ($raw_extensions as $extension => $path) { $data = apply_filters('builder_get_extension_data', array(), $path); if (is_array($data)) { $extensions[$extension] = $data; } } $extensions = ITUtility::sort_array($extensions, 'name'); return $extensions; }