├── .editorconfig ├── composer.json ├── CONTRIBUTING.md ├── LICENSE.md ├── ruleset.xml ├── README.md ├── sagextras.php └── modules ├── gallery.php └── nav-walker.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "storm2k/sagextras", 3 | "type": "wordpress-plugin", 4 | "license": "MIT", 5 | "description": "A WordPress plugin to restore some Bootstrap specific functionality to the Sage theme.", 6 | "homepage": "https://github.com/storm2k/sagextras", 7 | "authors": [ 8 | { 9 | "name": "Michael Romero", 10 | "email": "romero@dimensionsixdesign.com", 11 | "homepage": "https://github.com/storm2k" 12 | } 13 | ], 14 | "keywords": [ 15 | "wordpress", 16 | "sage" 17 | ], 18 | "support": { 19 | "issues": "https://github.com/storm2k/sagextras/issues" 20 | }, 21 | "require": { 22 | "php": ">=5.4.0", 23 | "composer/installers": "~1.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | I welcome all contributions to this plugin that will help make it better and more useful for everyone who uses it. Please follow a couple of guidelines when coding as outlined below. 4 | 5 | ## Coding Standards 6 | 7 | For convenience coding standard rules, compatible with Roots guidelines are provided, along with proper .editorconfig file. 8 | 9 | You can check if your contribution passes the styleguide by installing [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) and running the following in your project directory: 10 | 11 | ```bash 12 | phpcs --standard=ruleset.xml --extensions=php -n -s . 13 | ``` 14 | 15 | ## Additonal code rules 16 | 17 | * Use `Sagextras\` namespace 18 | * Use short array syntax 19 | * Use short echo syntax 20 | 21 | ## Pull Requests 22 | 23 | Please make sure your pull requests contain a clear decription of the changes you've made before submitting. Thanks! -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) Michael Romero 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Roots Coding Standards 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sagextras 2 | 3 | A tiny WordPress plugin that restores some Bootstrap specific functionality to the [Sage](https://roots.io/sage) theme. This plugin is modularlized just like Soil, so you only need to load the things you actually need. Add the neccessary lines to your lib/setup.php and the functionality will be there. 4 | 5 | ## Modules 6 | 7 | * **Restore the Roots Bootstrap Navwalker**
8 | `add_theme_support('se-nav-walker');` 9 | 10 | **REMINDER!!!** You need to go into `templates/header.php` and replace the menu code with the code contained in [this Gist](https://gist.github.com/johnny-bit/cc8840f148da01c2af52) so the menu works properly. 11 | 12 | ~~ * **Bootstrap friendly Gallery code**
13 | `add_theme_support('se-gallery');`~~ 14 | **Please Note:** With the release of Sage 8.3.0, this doesn't work anymore because Sage now uses WordPress's standard HTML5 gallery codes. 15 | 16 | ## Support 17 | 18 | Please feel free to open an [issue](https://github.com/storm2k/sagextras/issues) if you run into problems. 19 | 20 | ## Contributions 21 | 22 | I welcome all ideas and support on how to make this better for everyone. [Pull requests](https://github.com/storm2k/sagextras/pulls) are more than welcome. Please take a look at the [contributing](https://github.com/storm2k/sagextras/blob/master/CONTRIBUTING.md) file for coding standards and some testing. 23 | 24 | (A big thanks to everyone who has contributed thusfar, especially [johnny-bit](https://github.com/johnny-bit), who has done a lot of work cleaning up the code and bringing it up to par for standards!) 25 | 26 | ## ToDo 27 | 28 | - NavWalker uses code from Sage release 8.1.1. Looking forward to modularizing utils it uses. 29 | - Gallery is now namespaced, looking forward to modularizing any utils it uses. 30 | 31 | -------------------------------------------------------------------------------- /sagextras.php: -------------------------------------------------------------------------------- 1 | options; 39 | } 40 | if (substr($module, 0, 5) !== 'se-') { 41 | return self::get('se-' . $module); 42 | } 43 | return []; 44 | } 45 | 46 | protected function __construct($options) { 47 | $this->set($options); 48 | } 49 | 50 | public function set($options) { 51 | $this->options = $options; 52 | } 53 | } 54 | 55 | function load_modules() { 56 | global $_wp_theme_features; 57 | foreach (glob(__DIR__ . '/modules/*.php') as $file) { 58 | $feature = 'se-' . basename($file, '.php'); 59 | $soil_feature = 'soil-' . basename($file, '.php'); 60 | if (isset($_wp_theme_features[$feature])) { 61 | 62 | if (isset($_wp_theme_features[$soil_feature])) { 63 | unset($_wp_theme_features[$soil_feature]); 64 | } 65 | 66 | Options::init($feature, $_wp_theme_features[$feature]); 67 | require_once $file; 68 | } 69 | } 70 | } 71 | 72 | add_action('after_setup_theme', __NAMESPACE__ . '\\load_modules', 100); 73 | -------------------------------------------------------------------------------- /modules/gallery.php: -------------------------------------------------------------------------------- 1 | 'ASC', 41 | 'orderby' => 'menu_order ID', 42 | 'id' => $post->ID, 43 | 'itemtag' => '', 44 | 'icontag' => '', 45 | 'captiontag' => '', 46 | 'columns' => 4, 47 | 'size' => 'thumbnail', 48 | 'include' => '', 49 | 'exclude' => '', 50 | 'link' => '' 51 | ], $attr)); 52 | 53 | $id = intval($id); 54 | $columns = (12 % $columns == 0) ? $columns : 4; 55 | $grid = sprintf('col-sm-%1$s col-lg-%1$s', 12 / $columns); 56 | 57 | if ($order === 'RAND') { 58 | $orderby = 'none'; 59 | } 60 | 61 | if (!empty($include)) { 62 | $_attachments = get_posts(['include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]); 63 | 64 | $attachments = []; 65 | foreach ($_attachments as $key => $val) { 66 | $attachments[$val->ID] = $_attachments[$key]; 67 | } 68 | } elseif (!empty($exclude)) { 69 | $attachments = get_children(['post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]); 70 | } else { 71 | $attachments = get_children(['post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]); 72 | } 73 | 74 | if (empty($attachments)) { 75 | return ''; 76 | } 77 | 78 | if (is_feed()) { 79 | $output = "\n"; 80 | foreach ($attachments as $att_id => $attachment) { 81 | $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; 82 | } 83 | return $output; 84 | } 85 | 86 | $unique = (get_query_var('page')) ? $instance . '-p' . get_query_var('page') : $instance; 87 | $output = '' : ''; 115 | $output .= ''; 116 | 117 | return $output; 118 | } 119 | 120 | if (current_theme_supports('se-gallery')) { 121 | remove_shortcode('gallery'); 122 | add_shortcode('gallery', __NAMESPACE__ . '\\gallery'); 123 | add_filter('use_default_gallery_style', '__return_null'); 124 | } 125 | 126 | /** 127 | * Add class="thumbnail img-thumbnail" to attachment items 128 | */ 129 | function attachment_link_class($html) { 130 | $html = str_replace('Home 10 | *
  • Sample PageHome
  • 14 | * 15 | */ 16 | class NavWalker extends \Walker_Nav_Menu { 17 | 18 | private $cpt; // Boolean, is current post a custom post type 19 | private $archive; // Stores the archive page for current URL 20 | 21 | public function __construct() { 22 | add_filter('nav_menu_css_class', array($this, 'cssClasses'), 10, 2); 23 | add_filter('nav_menu_item_id', '__return_null'); 24 | $cpt = get_post_type(); 25 | $this->cpt = in_array($cpt, get_post_types(array('_builtin' => false))); 26 | $this->archive = get_post_type_archive_link($cpt); 27 | } 28 | 29 | public function checkCurrent($classes) { 30 | return preg_match('/(current[-_])|active|dropdown/', $classes); 31 | } 32 | 33 | // @codingStandardsIgnoreStart 34 | function start_lvl(&$output, $depth = 0, $args = []) { 35 | $output .= "\n