├── .bowerrc ├── .gitignore ├── .jshintrc ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Gruntfile.js ├── README.md ├── assets ├── images │ └── favicon.ico ├── js │ └── source │ │ ├── main.js │ │ └── plugins.js └── styles │ ├── editor-style.scss │ ├── partials │ ├── _comments.scss │ ├── _footer.scss │ ├── _forms.scss │ ├── _general.scss │ ├── _genesis.scss │ ├── _header.scss │ ├── _maincontent.scss │ ├── _menus.scss │ ├── _mixins.scss │ ├── _page-blog.scss │ ├── _page-home.scss │ ├── _page-post.scss │ ├── _variables.scss │ └── _widgets.scss │ └── style.scss ├── front-page.php ├── functions.php ├── lib ├── child-theme-settings.php ├── class-tgm-plugin-activation.php ├── theme-functions.php ├── theme-helpers.php ├── theme-require-plugins.php └── theme-views.php ├── package.json ├── screenshot.png └── templates └── portfolio.php /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "assets/js/vendor" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | .sass-cache 4 | .idea 5 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": true, 3 | "eqeqeq": true, 4 | "eqnull": true, 5 | "immed": true, 6 | "newcap": true, 7 | "esnext": true, 8 | "camelcase": true, 9 | "latedef": true, 10 | "noarg": true, 11 | "node": true, 12 | "undef": true, 13 | "browser": true, 14 | "trailing": true, 15 | "jquery": true, 16 | "curly": true, 17 | "supernew": true, 18 | "globals": { 19 | "Backbone": true, 20 | "_": true, 21 | "jQuery": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Version 3.0.0 4 | 5 | * move scss source files back to assets/styles 6 | * reorganize scss with new, more logical partials 7 | * change back to putting `style.css` and `editor-style.css` in the root of theme folder from scss compilation 8 | * general cleanup 9 | * change from using livereload to browsersync 10 | * update grunt dependencies 11 | * genesis 2.1.2 stylesheet 12 | 13 | ## Version 2.7.3 14 | 15 | * move load-grunt-tasks to devDependencies 16 | 17 | ## Version 2.7.2 18 | 19 | * update grunt dependencies 20 | * update removing version query string 21 | 22 | ## Version 2.7.1 23 | 24 | * update grunt dependencies 25 | * genesis 2.0.2 stylesheet 26 | * update comment for removing secondary nav menu in `functions.php` 27 | * update config.rb to reflect new `asset/styles/source` directory 28 | 29 | ## Version 2.7.0 30 | 31 | * rename assets/scss to assets/styles/source 32 | * move scss directory 33 | * process and livereload images in watch task 34 | * don't livereload html and php due to collisions and bugs in watch task 35 | * tweak imagemin processing 36 | * run all tasks on grunt run initially 37 | * update grunt dependencies 38 | 39 | ## Version 2.6.5 40 | 41 | * update grunt dependencies 42 | * update spacing in functions 43 | 44 | ## Version 2.6.4 45 | 46 | * update deployment info to fit new rsyncwrapper options 47 | 48 | ## Version 2.6.3 49 | 50 | * source maps fully work now! 51 | 52 | ## Version 2.6.2 53 | 54 | * update to Genesis 2.0.1 stylesheet 55 | * update grunt dependencies 56 | 57 | ## Version 2.6.1 58 | 59 | * update grunt dependencies 60 | * switch to load-grunt-tasks for loading everything 61 | * restructure deploy task based on grunt-rsync updates 62 | 63 | ## Version 2.6 64 | 65 | * update to Genesis 2.0.0 final 66 | 67 | ## Version 2.5 68 | 69 | * manually manage plugins in `Gruntfile` instead of automatically pulling all files to streamline bower usage. 70 | 71 | #### Verion 2.4 72 | 73 | * add bower support with `.bowerrc` (thanks [tjtate](https://github.com/tjtate)) 74 | * update to Genesis 2.0 RC1 75 | 76 | ## Version 2.3 77 | 78 | * remove duplicate meta tag function 79 | * add partials folder with social network sharing buttons partial as example 80 | 81 | ## Version 2.2 82 | 83 | * update to Genesis 2.0.0 beta 2 for HTML5 markup and structure 84 | * tweak Gruntfile.js to fix LiveReload issues and generate source maps for both main.js and plugins.js 85 | * optimizations and tweaks here and there 86 | 87 | ## Version 2.1 88 | 89 | * add deployments via rsync 90 | 91 | ## Version 2.0 92 | 93 | * reorganize code in `assets` folder for fonts, images, js and scss 94 | * setup Gruntfile to use Grunt for all compiling, concatenation and minification 95 | 96 | ## Version 1.1.4 97 | 98 | * add [TGM Plugin Activation](http://tgmpluginactivation.com/) to require plugins be installed and activated 99 | * prevent file editing in theme editor 100 | 101 | ## Version 1.1.3 102 | 103 | * load Apple touch icon in head 104 | 105 | ## Version 1.1.2 106 | 107 | * fix improper footer function 108 | 109 | ## Version 1.1.1 110 | 111 | * added `templates` folder for page templates with Portfolio page template (as an example) 112 | 113 | ## Version 1.1 114 | 115 | * code cleanup in `functions.php` - hooks and filters now here, functions moved to `lib/theme-functions.php` 116 | * added more functions and tweaked others to streamline development time 117 | * added `lib/theme-views.php` for placing all hooked functions for various pages (ie. custom queries, loops, addons, etc) 118 | 119 | ## Version 1.0 120 | 121 | * initial version 122 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | Hi, and thanks for considering contributing! Before you do though, here's a few notes on how best to contribute. Don't worry, I'll keep it short! 3 | 4 | ## Issues 5 | 6 | - Report issues or feature requests on [GitHub Issues](https://github.com/mattbanks/Genesis-Starter-Child-Theme/issues). 7 | - If reporting a bug, please add as much detail as possible (server environment, expected behavior, actual behavior, code examples, etc) 8 | 9 | ## Pull requests 10 | - Create a new topic branch for each change you make. 11 | - Create a test case if you are fixing a bug or implementing an important feature. 12 | - Make sure the theme runs successfully before submitting your pull request. 13 | - Open a Pull Request with a clear title and description. 14 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = function(grunt) { 3 | 4 | // load all grunt tasks matching the `grunt-*` pattern 5 | require('load-grunt-tasks')(grunt); 6 | 7 | grunt.initConfig({ 8 | 9 | // watch for changes and trigger sass, jshint, uglify and livereload 10 | watch: { 11 | sass: { 12 | files: ['assets/styles/**/*.{scss,sass}'], 13 | tasks: ['sass', 'autoprefixer', 'cssmin'] 14 | }, 15 | js: { 16 | files: '<%= jshint.all %>', 17 | tasks: ['jshint', 'uglify'] 18 | }, 19 | images: { 20 | files: ['assets/images/**/*.{png,jpg,gif}'], 21 | tasks: ['imagemin'] 22 | } 23 | }, 24 | 25 | // sass 26 | sass: { 27 | dist: { 28 | options: { 29 | style: 'expanded', 30 | }, 31 | files: { 32 | 'assets/styles/build/style.css': 'assets/styles/style.scss', 33 | 'assets/styles/build/editor-style.css': 'assets/styles/editor-style.scss' 34 | } 35 | } 36 | }, 37 | 38 | // autoprefixer 39 | autoprefixer: { 40 | options: { 41 | browsers: ['last 2 versions', 'ie 9', 'ios 6', 'android 4'], 42 | map: true 43 | }, 44 | files: { 45 | expand: true, 46 | flatten: true, 47 | src: 'assets/styles/build/*.css', 48 | dest: 'assets/styles/build' 49 | }, 50 | }, 51 | 52 | // css minify 53 | cssmin: { 54 | options: { 55 | keepSpecialComments: 1 56 | }, 57 | minify: { 58 | expand: true, 59 | cwd: 'assets/styles/build', 60 | src: ['*.css', '!*.min.css'], 61 | ext: '.css' 62 | } 63 | }, 64 | 65 | // javascript linting with jshint 66 | jshint: { 67 | options: { 68 | jshintrc: '.jshintrc', 69 | "force": true 70 | }, 71 | all: [ 72 | 'Gruntfile.js', 73 | 'assets/js/source/**/*.js' 74 | ] 75 | }, 76 | 77 | // uglify to concat, minify, and make source maps 78 | uglify: { 79 | plugins: { 80 | options: { 81 | sourceMap: 'assets/js/plugins.js.map', 82 | sourceMappingURL: 'plugins.js.map', 83 | sourceMapPrefix: 2 84 | }, 85 | files: { 86 | 'assets/js/plugins.min.js': [ 87 | 'assets/js/source/plugins.js', 88 | 'assets/js/vendor/navigation.js', 89 | 'assets/js/vendor/skip-link-focus-fix.js', 90 | // 'assets/js/vendor/yourplugin/yourplugin.js', 91 | ] 92 | } 93 | }, 94 | main: { 95 | options: { 96 | sourceMap: 'assets/js/main.js.map', 97 | sourceMappingURL: 'main.js.map', 98 | sourceMapPrefix: 2 99 | }, 100 | files: { 101 | 'assets/js/main.min.js': [ 102 | 'assets/js/source/main.js' 103 | ] 104 | } 105 | } 106 | }, 107 | 108 | // image optimization 109 | imagemin: { 110 | dist: { 111 | options: { 112 | optimizationLevel: 7, 113 | progressive: true, 114 | interlaced: true 115 | }, 116 | files: [{ 117 | expand: true, 118 | cwd: 'assets/images/', 119 | src: ['**/*.{png,jpg,gif}'], 120 | dest: 'assets/images/' 121 | }] 122 | } 123 | }, 124 | 125 | // browserSync 126 | browserSync: { 127 | dev: { 128 | bsFiles: { 129 | src : ['style.css', 'assets/js/*.js', 'assets/images/**/*.{png,jpg,jpeg,gif,webp,svg}'] 130 | }, 131 | options: { 132 | proxy: "local.dev", 133 | watchTask: true 134 | } 135 | } 136 | }, 137 | 138 | // deploy via rsync 139 | deploy: { 140 | options: { 141 | src: "./", 142 | args: ["--verbose"], 143 | exclude: ['.git*', 'node_modules', '.sass-cache', 'Gruntfile.js', 'package.json', '.DS_Store', 'README.md', 'config.rb', '.jshintrc'], 144 | recursive: true, 145 | syncDestIgnoreExcl: true 146 | }, 147 | staging: { 148 | options: { 149 | dest: "~/path/to/theme", 150 | host: "user@host.com" 151 | } 152 | }, 153 | production: { 154 | options: { 155 | dest: "~/path/to/theme", 156 | host: "user@host.com" 157 | } 158 | } 159 | } 160 | 161 | }); 162 | 163 | // rename tasks 164 | grunt.renameTask('rsync', 'deploy'); 165 | 166 | // register task 167 | grunt.registerTask('default', ['sass', 'autoprefixer', 'cssmin', 'uglify', 'imagemin', 'browserSync', 'watch']); 168 | 169 | }; 170 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress Genesis Starter Child Theme 2 | 3 | Version: 3.0.0 4 | 5 | ## Author: 6 | 7 | Matt Banks ( [@mattbanks](http://twitter.com/mattbanks) / [collectivthkg.com](http://collectivthkg.com) / [mattbanks.me](http://www.mattbanks.me) ) 8 | 9 | ## Summary 10 | 11 | WordPress Starter Theme for use as Child Theme of the Genesis Framework for building custom themes. Uses SCSS, AutoPrefixr and Grunt for all processing tasks. Syncs changes across local development devices with BrowserSync. Tested up to WordPress 4.0 RC1 and Genesis 2.1.2. 12 | 13 | ## Usage 14 | 15 | The theme is setup to use [Grunt](http://gruntjs.com/) to compile SCSS (with source maps), run it through [AutoPrefixr](https://github.com/ai/autoprefixer), lint, concatenate and minify JavaScript (with source maps), optimize images, and syncs changes across local development devices with [BrowserSync](https://github.com/shakyShane/browser-sync), with flexibility to add any additional tasks via the Gruntfile. Alternatively, you can use [CodeKit](http://incident57.com/codekit/) or whatever else you prefer to compile the SCSS and manage the JavaScript. 16 | 17 | Rename folder to your theme name, change the `style.scss` intro block to your theme information. Open the theme directory in terminal and run `npm install` to pull in all Grunt dependencies. Run `grunt` to execute tasks. Code as you will. 18 | 19 | If you are using MAMP or Vagrant, change the `proxy` option in the `grunt browserSync` task to match your vhost URL. 20 | 21 | - Compile `assets/styles/style.scss` to `style.css` 22 | - Compile `assets/styles/editor-style.scss` to `editor-style.css` 23 | - Concatenate and minify plugins in `assets/js/vendor` and `assets/js/source/plugins.js` to `assets/js/plugins.min.js` 24 | - Minify and lint `assets/js/source/main.js` to `assets/js/main.min.js` 25 | - ?? 26 | - Profit 27 | 28 | To concatenate and minify your jQuery plugins, add them to the `assets/js/vendor` directory and add the `js` filename and path to the `Gruntfile` `uglify` task. Previous versions of the starter theme automatically pulled all plugins in the `vendor` directory, but this has changed to allow more granular control and for managing plugins and assets with bower. 29 | 30 | ### Bower 31 | 32 | Supports [bower](https://github.com/bower/bower) to install and manage JavaScript dependencies in the `assets/js/vendor` folder. 33 | 34 | ### Deployment 35 | 36 | The theme includes deployments via [grunt-rsync](https://github.com/jedrichards/grunt-rsync). The Gruntfile includes setups for staging and production - edit your paths and host, then run `grunt rsync:staging` or `grunt rsync:production` to deploy your files via rsync. 37 | 38 | ### Features 39 | 40 | 1. SCSS with AutoPrefixr and easy-to-use of mixins ready to go 41 | 2. Easy to customize 42 | 3. Grunt and BrowserSync to make it more gooder 43 | 4. Child theme tweaks 44 | 5. More to come! 45 | 46 | ### Suggested Plugins 47 | 48 | * [WordPress SEO by Yoast](http://wordpress.org/extend/plugins/wordpress-seo/) 49 | * [Google Analytics for WordPress by Yoast](http://wordpress.org/extend/plugins/google-analytics-for-wordpress/) 50 | * [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/) 51 | * [Gravity Forms](http://www.gravityforms.com/) 52 | * [Pods Framework](http://www.podsframework.org/) 53 | 54 | ![dependencies](https://david-dm.org/mattbanks/Genesis-Starter-Child-Theme.png) 55 | 56 | ### Contributing: 57 | 58 | Anyone and everyone is welcome to contribute! Check out the [Contributing Guidelines](CONTRIBUTING.md). 59 | 60 | ### Credits 61 | 62 | Without these projects, this WordPress Genesis Starter Child Theme wouldn't be where it is today. 63 | 64 | * [Genesis Framework](http://my.studiopress.com/themes/genesis/) 65 | * [SASS / SCSS](http://sass-lang.com/) 66 | * [AutoPrefixr](https://github.com/ai/autoprefixer) 67 | * [Bill Erickson's Genesis Child Theme](https://github.com/billerickson/BE-Genesis-Child) 68 | * [HTML5 Boilerplate](http://html5boilerplate.com) 69 | * [Grunt](http://gruntjs.com/) 70 | * [Bower](https://github.com/bower/bower) 71 | -------------------------------------------------------------------------------- /assets/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattbanks/Genesis-Starter-Child-Theme/fd34938b3896662ec989136108b7c4528e7be80a/assets/images/favicon.ico -------------------------------------------------------------------------------- /assets/js/source/main.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | 3 | // all Javascript code goes here 4 | 5 | })(jQuery); 6 | -------------------------------------------------------------------------------- /assets/js/source/plugins.js: -------------------------------------------------------------------------------- 1 | // Avoid `console` errors in browsers that lack a console. 2 | (function() { 3 | var method; 4 | var noop = function () {}; 5 | var methods = [ 6 | 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 7 | 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 8 | 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 9 | 'timeStamp', 'trace', 'warn' 10 | ]; 11 | var length = methods.length; 12 | var console = (window.console = window.console || {}); 13 | 14 | while (length--) { 15 | method = methods[length]; 16 | 17 | // Only stub undefined methods. 18 | if (!console[method]) { 19 | console[method] = noop; 20 | } 21 | } 22 | }()); 23 | 24 | // Place any jQuery/helper plugins in here. 25 | -------------------------------------------------------------------------------- /assets/styles/editor-style.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Editor Styles 3 | ========================================================================== */ 4 | 5 | 6 | /* Column Classes 7 | ------------------------------------------------------------ */ 8 | 9 | .five-sixths, 10 | .four-fifths, 11 | .four-sixths, 12 | .one-fifth, 13 | .one-fourth, 14 | .one-half, 15 | .one-sixth, 16 | .one-third, 17 | .three-fifths, 18 | .three-fourths, 19 | .three-sixths, 20 | .two-fifths, 21 | .two-fourths, 22 | .two-sixths, 23 | .two-thirds { 24 | float: left; 25 | margin: 0 0 20px; 26 | padding-left: 3%; 27 | } 28 | 29 | .one-half, 30 | .three-sixths, 31 | .two-fourths { 32 | width: 48%; 33 | } 34 | 35 | .one-third, 36 | .two-sixths { 37 | width: 31%; 38 | } 39 | 40 | .four-sixths, 41 | .two-thirds { 42 | width: 65%; 43 | } 44 | 45 | .one-fourth { 46 | width: 22.5%; 47 | } 48 | 49 | .three-fourths { 50 | width: 73.5%; 51 | } 52 | 53 | .one-fifth { 54 | width: 17.4%; 55 | } 56 | 57 | .two-fifths { 58 | width: 37.8%; 59 | } 60 | 61 | .three-fifths { 62 | width: 58.2%; 63 | } 64 | 65 | .four-fifths { 66 | width: 78.6%; 67 | } 68 | 69 | .one-sixth { 70 | width: 14%; 71 | } 72 | 73 | .five-sixths { 74 | width: 82%; 75 | } 76 | 77 | .first { 78 | clear: both; 79 | padding-left: 0; 80 | } 81 | 82 | /* Images 83 | ------------------------------------------------------------ */ 84 | 85 | img { 86 | max-width: 100%; 87 | height: auto; 88 | } 89 | -------------------------------------------------------------------------------- /assets/styles/partials/_comments.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Comments 3 | ========================================================================== */ 4 | 5 | .comment-content a { 6 | word-wrap: break-word; 7 | } 8 | 9 | .bypostauthor { 10 | } 11 | -------------------------------------------------------------------------------- /assets/styles/partials/_footer.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Footer 3 | ========================================================================== */ 4 | 5 | .site-footer { 6 | } 7 | -------------------------------------------------------------------------------- /assets/styles/partials/_forms.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Forms 3 | ========================================================================== */ 4 | 5 | form { } 6 | 7 | /* Gravity Forms */ 8 | 9 | .gform_wrapper { } 10 | .gform_heading { } 11 | .gform_description { } 12 | .gform_body { } 13 | .gform_fields { } 14 | .gfield { } 15 | .ginput_container { } 16 | .gform_footer { } 17 | .gform_button { } 18 | -------------------------------------------------------------------------------- /assets/styles/partials/_general.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Selection Highlights 3 | ========================================================================== */ 4 | 5 | ::-moz-selection { 6 | background: $selectionColor; 7 | text-shadow: none; 8 | } 9 | 10 | ::selection { 11 | background: $selectionColor; 12 | text-shadow: none; 13 | } 14 | 15 | /* ========================================================================== 16 | Links 17 | ========================================================================== */ 18 | 19 | a, 20 | a:visited { 21 | color: $red; 22 | } 23 | a:hover { 24 | color: $blue; 25 | } 26 | 27 | /* ========================================================================== 28 | Typography 29 | ========================================================================== */ 30 | 31 | h1 { } 32 | h2 { } 33 | h3 { } 34 | h4 { } 35 | 36 | h1, h2, h3, h4, h5, h6 { 37 | } 38 | 39 | p { 40 | } 41 | 42 | blockquote { 43 | } 44 | 45 | address { 46 | } 47 | -------------------------------------------------------------------------------- /assets/styles/partials/_genesis.scss: -------------------------------------------------------------------------------- 1 | /* # Genesis Framework 2 | Theme Name: Genesis 3 | Theme URI: http://my.studiopress.com/themes/genesis/ 4 | Description: The industry standard for Premium WordPress Themes. Please do not modify this style sheet, as it might get overridden in updates. 5 | Author: StudioPress 6 | Author URI: http://www.studiopress.com/ 7 | Version: 2.1.2 8 | Tags: black, orange, white, one-column, two-columns, three-columns, left-sidebar, right-sidebar, responsive-layout, custom-menu, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready 9 | License: GPL-2.0+ 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 | */ 12 | 13 | /* # WARNING 14 | 15 | This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances. Please do all modifications in the form of a child theme. 16 | Copy the contents of this file to the child theme. Do not use @import, as the CSS included with Genesis might change in the future. 17 | 18 | */ 19 | 20 | /* # Table of Contents 21 | - Imports 22 | - HTML5 Reset 23 | - Baseline Normalize 24 | - Box Sizing 25 | - Float Clearing 26 | - Defaults 27 | - Typographical Elements 28 | - Headings 29 | - Objects 30 | - Gallery 31 | - Forms 32 | - Tables 33 | - Structure and Layout 34 | - Site Containers 35 | - Column Widths and Positions 36 | - Column Classes 37 | - Common Classes 38 | - Avatar 39 | - Genesis 40 | - Search Form 41 | - Titles 42 | - WordPress 43 | - Widgets 44 | - Featured Content 45 | - Plugins 46 | - Genesis eNews Extended 47 | - Jetpack 48 | - Site Header 49 | - Title Area 50 | - Widget Area 51 | - Site Navigation 52 | - Header Navigation 53 | - Primary Navigation 54 | - Secondary Navigation 55 | - Content Area 56 | - Entries 57 | - Entry Meta 58 | - Pagination 59 | - Comments 60 | - Sidebars 61 | - Footer Widgets 62 | - Site Footer 63 | - Media Queries 64 | - Retina Display 65 | - Max-width: 1200px 66 | - Max-width: 960px 67 | - Max-width: 800px 68 | */ 69 | 70 | 71 | /* # Imports 72 | ---------------------------------------------------------------------------------------------------- */ 73 | 74 | @import url(//fonts.googleapis.com/css?family=Lato:300,400,700); 75 | 76 | 77 | /* # HTML5 Reset 78 | ---------------------------------------------------------------------------------------------------- */ 79 | 80 | /* ## Baseline Normalize 81 | --------------------------------------------- */ 82 | /* normalize.css v3.0.1 | MIT License | git.io/normalize */ 83 | 84 | html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:0 0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#333}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} 85 | 86 | /* ## Box Sizing 87 | --------------------------------------------- */ 88 | 89 | *, 90 | input[type="search"] { 91 | -webkit-box-sizing: border-box; 92 | -moz-box-sizing: border-box; 93 | box-sizing: border-box; 94 | } 95 | 96 | /* ## Float Clearing 97 | --------------------------------------------- */ 98 | 99 | .author-box:before, 100 | .clearfix:before, 101 | .entry:before, 102 | .entry-content:before, 103 | .footer-widgets:before, 104 | .nav-primary:before, 105 | .nav-secondary:before, 106 | .pagination:before, 107 | .site-container:before, 108 | .site-footer:before, 109 | .site-header:before, 110 | .site-inner:before, 111 | .wrap:before { 112 | content: " "; 113 | display: table; 114 | } 115 | 116 | .author-box:after, 117 | .clearfix:after, 118 | .entry:after, 119 | .entry-content:after, 120 | .footer-widgets:after, 121 | .nav-primary:after, 122 | .nav-secondary:after, 123 | .pagination:after, 124 | .site-container:after, 125 | .site-footer:after, 126 | .site-header:after, 127 | .site-inner:after, 128 | .wrap:after { 129 | clear: both; 130 | content: " "; 131 | display: table; 132 | } 133 | 134 | 135 | /* # Defaults 136 | ---------------------------------------------------------------------------------------------------- */ 137 | 138 | /* ## Typographical Elements 139 | --------------------------------------------- */ 140 | 141 | body { 142 | background-color: #f5f5f5; 143 | color: #333; 144 | font-family: Lato, sans-serif; 145 | font-size: 18px; 146 | font-weight: 300; 147 | line-height: 1.625; 148 | margin: 0; 149 | } 150 | 151 | a, 152 | button, 153 | input:focus, 154 | input[type="button"], 155 | input[type="reset"], 156 | input[type="submit"], 157 | textarea:focus, 158 | .button, 159 | .gallery img { 160 | -webkit-transition: all 0.1s ease-in-out; 161 | -moz-transition: all 0.1s ease-in-out; 162 | -ms-transition: all 0.1s ease-in-out; 163 | -o-transition: all 0.1s ease-in-out; 164 | transition: all 0.1s ease-in-out; 165 | } 166 | 167 | ::-moz-selection { 168 | background-color: #333; 169 | color: #fff; 170 | } 171 | 172 | ::selection { 173 | background-color: #333; 174 | color: #fff; 175 | } 176 | 177 | a { 178 | color: #e5554e; 179 | text-decoration: none; 180 | } 181 | 182 | a:hover { 183 | color: #333; 184 | } 185 | 186 | p { 187 | margin: 0 0 28px; 188 | padding: 0; 189 | } 190 | 191 | ol, 192 | ul { 193 | margin: 0; 194 | padding: 0; 195 | } 196 | 197 | li { 198 | list-style-type: none; 199 | } 200 | 201 | b, 202 | strong { 203 | font-weight: 700; 204 | } 205 | 206 | blockquote, 207 | cite, 208 | em, 209 | i { 210 | font-style: italic; 211 | } 212 | 213 | blockquote { 214 | margin: 40px; 215 | } 216 | 217 | blockquote::before { 218 | content: "\201C"; 219 | display: block; 220 | font-size: 30px; 221 | height: 0; 222 | left: -20px; 223 | position: relative; 224 | top: -10px; 225 | } 226 | 227 | 228 | /* ## Headings 229 | --------------------------------------------- */ 230 | 231 | h1, 232 | h2, 233 | h3, 234 | h4, 235 | h5, 236 | h6 { 237 | color: #333; 238 | font-family: Lato, sans-serif; 239 | font-weight: 400; 240 | line-height: 1.2; 241 | margin: 0 0 10px; 242 | } 243 | 244 | h1 { 245 | font-size: 36px; 246 | } 247 | 248 | h2 { 249 | font-size: 30px; 250 | } 251 | 252 | h3 { 253 | font-size: 24px; 254 | } 255 | 256 | h4 { 257 | font-size: 20px; 258 | } 259 | 260 | h5 { 261 | font-size: 18px; 262 | } 263 | 264 | h6 { 265 | font-size: 16px; 266 | } 267 | 268 | /* ## Objects 269 | --------------------------------------------- */ 270 | 271 | embed, 272 | iframe, 273 | img, 274 | object, 275 | video, 276 | .wp-caption { 277 | max-width: 100%; 278 | } 279 | 280 | img { 281 | height: auto; 282 | } 283 | 284 | .featured-content img, 285 | .gallery img { 286 | width: auto; 287 | } 288 | 289 | /* ## Gallery 290 | --------------------------------------------- */ 291 | 292 | .gallery { 293 | overflow: hidden; 294 | } 295 | 296 | .gallery-item { 297 | float: left; 298 | margin: 0 0 28px; 299 | text-align: center; 300 | } 301 | 302 | .gallery-columns-2 .gallery-item { 303 | width: 50%; 304 | } 305 | 306 | .gallery-columns-3 .gallery-item { 307 | width: 33%; 308 | } 309 | 310 | .gallery-columns-4 .gallery-item { 311 | width: 25%; 312 | } 313 | 314 | .gallery-columns-5 .gallery-item { 315 | width: 20%; 316 | } 317 | 318 | .gallery-columns-6 .gallery-item { 319 | width: 16.6666%; 320 | } 321 | 322 | .gallery-columns-7 .gallery-item { 323 | width: 14.2857%; 324 | } 325 | 326 | .gallery-columns-8 .gallery-item { 327 | width: 12.5%; 328 | } 329 | 330 | .gallery-columns-9 .gallery-item { 331 | width: 11.1111%; 332 | } 333 | 334 | .gallery img { 335 | border: 1px solid #ddd; 336 | height: auto; 337 | padding: 4px; 338 | } 339 | 340 | .gallery img:hover { 341 | border: 1px solid #999; 342 | } 343 | 344 | /* ## Forms 345 | --------------------------------------------- */ 346 | 347 | input, 348 | select, 349 | textarea { 350 | background-color: #fff; 351 | border: 1px solid #ddd; 352 | color: #333; 353 | font-size: 18px; 354 | font-weight: 300; 355 | padding: 16px; 356 | width: 100%; 357 | } 358 | 359 | input:focus, 360 | textarea:focus { 361 | border: 1px solid #999; 362 | outline: none; 363 | } 364 | 365 | input[type="checkbox"], 366 | input[type="image"], 367 | input[type="radio"] { 368 | width: auto; 369 | } 370 | 371 | ::-moz-placeholder { 372 | color: #333; 373 | font-weight: 300; 374 | opacity: 1; 375 | } 376 | 377 | ::-webkit-input-placeholder { 378 | color: #333; 379 | font-weight: 300; 380 | } 381 | 382 | button, 383 | input[type="button"], 384 | input[type="reset"], 385 | input[type="submit"], 386 | .button { 387 | background-color: #333; 388 | border: none; 389 | color: #fff; 390 | cursor: pointer; 391 | font-size: 16px; 392 | font-weight: 300; 393 | padding: 16px 24px; 394 | text-transform: uppercase; 395 | width: auto; 396 | } 397 | 398 | .footer-widgets button, 399 | .footer-widgets input[type="button"], 400 | .footer-widgets input[type="reset"], 401 | .footer-widgets input[type="submit"], 402 | .footer-widgets .button { 403 | background-color: #e5554e; 404 | color: #fff; 405 | } 406 | 407 | button:hover, 408 | input:hover[type="button"], 409 | input:hover[type="reset"], 410 | input:hover[type="submit"], 411 | .button:hover { 412 | background-color: #e5554e; 413 | color: #fff; 414 | } 415 | 416 | .entry-content .button:hover { 417 | color: #fff; 418 | } 419 | 420 | .footer-widgets button:hover, 421 | .footer-widgets input:hover[type="button"], 422 | .footer-widgets input:hover[type="reset"], 423 | .footer-widgets input:hover[type="submit"], 424 | .footer-widgets .button:hover { 425 | background-color: #fff; 426 | color: #333; 427 | } 428 | 429 | .button { 430 | display: inline-block; 431 | } 432 | 433 | input[type="search"]::-webkit-search-cancel-button, 434 | input[type="search"]::-webkit-search-results-button { 435 | display: none; 436 | } 437 | 438 | /* ## Tables 439 | --------------------------------------------- */ 440 | 441 | table { 442 | border-collapse: collapse; 443 | border-spacing: 0; 444 | line-height: 2; 445 | margin-bottom: 40px; 446 | width: 100%; 447 | } 448 | 449 | tbody { 450 | border-bottom: 1px solid #ddd; 451 | } 452 | 453 | td, 454 | th { 455 | text-align: left; 456 | } 457 | 458 | td { 459 | border-top: 1px solid #ddd; 460 | padding: 6px 0; 461 | } 462 | 463 | th { 464 | font-weight: 400; 465 | } 466 | 467 | 468 | /* # Structure and Layout 469 | ---------------------------------------------------------------------------------------------------- */ 470 | 471 | /* ## Site Containers 472 | --------------------------------------------- */ 473 | 474 | .site-inner, 475 | .wrap { 476 | margin: 0 auto; 477 | max-width: 1200px; 478 | } 479 | 480 | .site-inner { 481 | clear: both; 482 | padding-top: 40px; 483 | } 484 | 485 | /* ## Column Widths and Positions 486 | --------------------------------------------- */ 487 | 488 | /* ### Wrapping div for .content and .sidebar-primary */ 489 | 490 | .content-sidebar-sidebar .content-sidebar-wrap, 491 | .sidebar-content-sidebar .content-sidebar-wrap, 492 | .sidebar-sidebar-content .content-sidebar-wrap { 493 | width: 980px; 494 | } 495 | 496 | .content-sidebar-sidebar .content-sidebar-wrap { 497 | float: left; 498 | } 499 | 500 | .sidebar-content-sidebar .content-sidebar-wrap, 501 | .sidebar-sidebar-content .content-sidebar-wrap { 502 | float: right; 503 | } 504 | 505 | /* ### Content */ 506 | 507 | .content { 508 | float: right; 509 | width: 800px; 510 | } 511 | 512 | .content-sidebar .content, 513 | .content-sidebar-sidebar .content, 514 | .sidebar-content-sidebar .content { 515 | float: left; 516 | } 517 | 518 | .content-sidebar-sidebar .content, 519 | .sidebar-content-sidebar .content, 520 | .sidebar-sidebar-content .content { 521 | width: 580px; 522 | } 523 | 524 | .full-width-content .content { 525 | width: 100%; 526 | } 527 | 528 | /* ### Primary Sidebar */ 529 | 530 | .sidebar-primary { 531 | float: right; 532 | width: 360px; 533 | } 534 | 535 | .sidebar-content .sidebar-primary, 536 | .sidebar-sidebar-content .sidebar-primary { 537 | float: left; 538 | } 539 | 540 | /* ### Secondary Sidebar */ 541 | 542 | .sidebar-secondary { 543 | float: left; 544 | width: 180px; 545 | } 546 | 547 | .content-sidebar-sidebar .sidebar-secondary { 548 | float: right; 549 | } 550 | 551 | /* ## Column Classes 552 | --------------------------------------------- */ 553 | /* Link: http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css */ 554 | 555 | .five-sixths, 556 | .four-sixths, 557 | .one-fourth, 558 | .one-half, 559 | .one-sixth, 560 | .one-third, 561 | .three-fourths, 562 | .three-sixths, 563 | .two-fourths, 564 | .two-sixths, 565 | .two-thirds { 566 | float: left; 567 | margin-left: 2.564102564102564%; 568 | } 569 | 570 | .one-half, 571 | .three-sixths, 572 | .two-fourths { 573 | width: 48.717948717948715%; 574 | } 575 | 576 | .one-third, 577 | .two-sixths { 578 | width: 31.623931623931625%; 579 | } 580 | 581 | .four-sixths, 582 | .two-thirds { 583 | width: 65.81196581196582%; 584 | } 585 | 586 | .one-fourth { 587 | width: 23.076923076923077%; 588 | } 589 | 590 | .three-fourths { 591 | width: 74.35897435897436%; 592 | } 593 | 594 | .one-sixth { 595 | width: 14.52991452991453%; 596 | } 597 | 598 | .five-sixths { 599 | width: 82.90598290598291%; 600 | } 601 | 602 | .first { 603 | clear: both; 604 | margin-left: 0; 605 | } 606 | 607 | 608 | /* # Common Classes 609 | ---------------------------------------------------------------------------------------------------- */ 610 | 611 | /* ## Avatar 612 | --------------------------------------------- */ 613 | 614 | .avatar { 615 | float: left; 616 | } 617 | 618 | .alignleft .avatar, 619 | .author-box .avatar { 620 | margin-right: 24px; 621 | } 622 | 623 | .alignright .avatar { 624 | margin-left: 24px; 625 | } 626 | 627 | .comment .avatar { 628 | margin: 0 16px 24px 0; 629 | } 630 | 631 | /* ## Genesis 632 | --------------------------------------------- */ 633 | 634 | .breadcrumb { 635 | margin-bottom: 20px; 636 | } 637 | 638 | .archive-description, 639 | .author-box { 640 | background-color: #fff; 641 | font-size: 16px; 642 | margin-bottom: 40px; 643 | padding: 40px; 644 | } 645 | 646 | .author-box-title { 647 | font-size: 16px; 648 | margin-bottom: 4px; 649 | } 650 | 651 | .archive-description p:last-child, 652 | .author-box p:last-child { 653 | margin-bottom: 0; 654 | } 655 | 656 | /* ## Search Form 657 | --------------------------------------------- */ 658 | 659 | .search-form { 660 | overflow: hidden; 661 | } 662 | 663 | .site-header .search-form { 664 | float: right; 665 | margin-top: 12px; 666 | } 667 | 668 | .entry-content .search-form, 669 | .site-header .search-form { 670 | width: 50%; 671 | } 672 | 673 | .genesis-nav-menu .search input[type="submit"], 674 | .widget_search input[type="submit"] { 675 | border: 0; 676 | clip: rect(0, 0, 0, 0); 677 | height: 1px; 678 | margin: -1px; 679 | padding: 0; 680 | position: absolute; 681 | width: 1px; 682 | } 683 | 684 | /* ## Titles 685 | --------------------------------------------- */ 686 | 687 | .archive-title { 688 | font-size: 20px; 689 | } 690 | 691 | .entry-title { 692 | font-size: 36px; 693 | } 694 | 695 | .entry-title a, 696 | .sidebar .widget-title a { 697 | color: #333; 698 | } 699 | 700 | .entry-title a:hover { 701 | color: #e5554e; 702 | } 703 | 704 | .widget-title { 705 | font-size: 18px; 706 | margin-bottom: 20px; 707 | } 708 | 709 | .footer-widgets .widget-title { 710 | color: #fff; 711 | } 712 | 713 | /* ## WordPress 714 | --------------------------------------------- */ 715 | 716 | a.aligncenter img { 717 | display: block; 718 | margin: 0 auto; 719 | } 720 | 721 | a.alignnone { 722 | display: inline-block; 723 | } 724 | 725 | .alignleft { 726 | float: left; 727 | text-align: left; 728 | } 729 | 730 | .alignright { 731 | float: right; 732 | text-align: right; 733 | } 734 | 735 | a.alignleft, 736 | a.alignnone, 737 | a.alignright { 738 | max-width: 100%; 739 | } 740 | 741 | img.centered, 742 | .aligncenter { 743 | display: block; 744 | margin: 0 auto 24px; 745 | } 746 | 747 | img.alignnone, 748 | .alignnone { 749 | margin-bottom: 12px; 750 | } 751 | 752 | a.alignleft, 753 | img.alignleft, 754 | .wp-caption.alignleft { 755 | margin: 0 24px 24px 0; 756 | } 757 | 758 | a.alignright, 759 | img.alignright, 760 | .wp-caption.alignright { 761 | margin: 0 0 24px 24px; 762 | } 763 | 764 | .wp-caption-text { 765 | font-size: 14px; 766 | font-weight: 700; 767 | text-align: center; 768 | } 769 | 770 | .entry-content p.wp-caption-text { 771 | margin-bottom: 0; 772 | } 773 | 774 | .sticky { 775 | } 776 | 777 | 778 | /* # Widgets 779 | ---------------------------------------------------------------------------------------------------- */ 780 | 781 | .widget { 782 | word-wrap: break-word; 783 | } 784 | 785 | .widget ol > li { 786 | list-style-position: inside; 787 | list-style-type: decimal; 788 | padding-left: 20px; 789 | text-indent: -20px; 790 | } 791 | 792 | .widget li li { 793 | border: none; 794 | margin: 0 0 0 30px; 795 | padding: 0; 796 | } 797 | 798 | .widget_calendar table { 799 | width: 100%; 800 | } 801 | 802 | .widget_calendar td, 803 | .widget_calendar th { 804 | text-align: center; 805 | } 806 | 807 | /* ## Featured Content 808 | --------------------------------------------- */ 809 | 810 | .featured-content .entry { 811 | border-bottom: 2px solid #f5f5f5; 812 | margin-bottom: 20px; 813 | padding: 0 0 24px; 814 | } 815 | 816 | .footer-widgets .entry { 817 | border-bottom: 1px dotted #666; 818 | } 819 | 820 | .featured-content .entry-title { 821 | font-size: 20px; 822 | } 823 | 824 | 825 | /* # Plugins 826 | ---------------------------------------------------------------------------------------------------- */ 827 | 828 | /* ## Genesis eNews Extended 829 | --------------------------------------------- */ 830 | 831 | .enews-widget, 832 | .enews-widget .widget-title { 833 | color: #fff; 834 | } 835 | 836 | .sidebar .widget.enews-widget { 837 | background-color: #333; 838 | } 839 | 840 | .enews-widget input, 841 | .enews-widget input:focus { 842 | border: 1px solid #333; 843 | } 844 | 845 | .enews-widget input { 846 | font-size: 16px; 847 | margin-bottom: 16px; 848 | } 849 | 850 | .enews-widget input[type="submit"] { 851 | background-color: #e5554e; 852 | color: #fff; 853 | margin: 0; 854 | width: 100%; 855 | } 856 | 857 | .enews-widget input:hover[type="submit"] { 858 | background-color: #fff; 859 | color: #333; 860 | } 861 | 862 | .enews form + p { 863 | margin-top: 24px; 864 | } 865 | 866 | /* ## Jetpack 867 | --------------------------------------------- */ 868 | 869 | #wpstats { 870 | display: none; 871 | } 872 | 873 | 874 | /* # Site Header 875 | ---------------------------------------------------------------------------------------------------- */ 876 | 877 | .site-header { 878 | background-color: #fff; 879 | min-height: 160px; 880 | } 881 | 882 | .site-header .wrap { 883 | padding: 40px 0; 884 | } 885 | 886 | /* ## Title Area 887 | --------------------------------------------- */ 888 | 889 | .title-area { 890 | float: left; 891 | padding: 10px 0; 892 | width: 360px; 893 | } 894 | 895 | .header-full-width .title-area { 896 | width: 100%; 897 | } 898 | 899 | .site-title { 900 | font-size: 32px; 901 | font-weight: 400; 902 | line-height: 1.2; 903 | } 904 | 905 | .site-title a, 906 | .site-title a:hover { 907 | color: #333; 908 | } 909 | 910 | .header-image .site-title > a { 911 | background: url(images/logo.png) no-repeat left; 912 | float: left; 913 | min-height: 60px; 914 | width: 100%; 915 | } 916 | 917 | .site-description { 918 | font-size: 16px; 919 | font-weight: 300; 920 | line-height: 1.5; 921 | } 922 | 923 | .site-description, 924 | .site-title { 925 | margin-bottom: 0; 926 | } 927 | 928 | .header-image .site-description, 929 | .header-image .site-title { 930 | display: block; 931 | text-indent: -9999px; 932 | } 933 | 934 | /* ## Widget Area 935 | --------------------------------------------- */ 936 | 937 | .site-header .widget-area { 938 | float: right; 939 | text-align: right; 940 | width: 800px; 941 | } 942 | 943 | 944 | /* # Site Navigation 945 | ---------------------------------------------------------------------------------------------------- */ 946 | 947 | .genesis-nav-menu { 948 | clear: both; 949 | font-size: 16px; 950 | line-height: 1; 951 | width: 100%; 952 | } 953 | 954 | .genesis-nav-menu .menu-item { 955 | display: inline-block; 956 | text-align: left; 957 | } 958 | 959 | .genesis-nav-menu a { 960 | color: #333; 961 | display: block; 962 | padding: 30px 24px; 963 | } 964 | 965 | .genesis-nav-menu a:hover, 966 | .genesis-nav-menu .current-menu-item > a, 967 | .genesis-nav-menu .sub-menu .current-menu-item > a:hover { 968 | color: #e5554e; 969 | } 970 | 971 | .genesis-nav-menu .sub-menu { 972 | left: -9999px; 973 | opacity: 0; 974 | position: absolute; 975 | -webkit-transition: opacity .4s ease-in-out; 976 | -moz-transition: opacity .4s ease-in-out; 977 | -ms-transition: opacity .4s ease-in-out; 978 | -o-transition: opacity .4s ease-in-out; 979 | transition: opacity .4s ease-in-out; 980 | width: 200px; 981 | z-index: 99; 982 | } 983 | 984 | .genesis-nav-menu .sub-menu a { 985 | background-color: #fff; 986 | border: 1px solid #eee; 987 | border-top: none; 988 | font-size: 14px; 989 | padding: 20px; 990 | position: relative; 991 | width: 200px; 992 | } 993 | 994 | .genesis-nav-menu .sub-menu .sub-menu { 995 | margin: -55px 0 0 199px; 996 | } 997 | 998 | .genesis-nav-menu .menu-item:hover { 999 | position: static; 1000 | } 1001 | 1002 | .genesis-nav-menu .menu-item:hover > .sub-menu { 1003 | left: auto; 1004 | opacity: 1; 1005 | } 1006 | 1007 | .genesis-nav-menu > .first > a { 1008 | padding-left: 0; 1009 | } 1010 | 1011 | .genesis-nav-menu > .last > a { 1012 | padding-right: 0; 1013 | } 1014 | 1015 | .genesis-nav-menu > .right { 1016 | color: #fff; 1017 | float: right; 1018 | list-style-type: none; 1019 | padding: 30px 0; 1020 | } 1021 | 1022 | .genesis-nav-menu > .right > a { 1023 | display: inline; 1024 | padding: 0; 1025 | } 1026 | 1027 | .genesis-nav-menu > .rss > a { 1028 | margin-left: 48px; 1029 | } 1030 | 1031 | .genesis-nav-menu > .search { 1032 | padding: 10px 0 0; 1033 | } 1034 | 1035 | /* ## Site Header Navigation 1036 | --------------------------------------------- */ 1037 | 1038 | .site-header .sub-menu { 1039 | border-top: 1px solid #eee; 1040 | } 1041 | 1042 | .site-header .sub-menu .sub-menu { 1043 | margin-top: -56px; 1044 | } 1045 | 1046 | .site-header .genesis-nav-menu li li { 1047 | margin-left: 0; 1048 | } 1049 | 1050 | /* ## Primary Navigation 1051 | --------------------------------------------- */ 1052 | 1053 | .nav-primary { 1054 | background-color: #333; 1055 | } 1056 | 1057 | .nav-primary .genesis-nav-menu a { 1058 | color: #fff; 1059 | } 1060 | 1061 | .nav-primary .genesis-nav-menu .sub-menu a { 1062 | color: #333; 1063 | } 1064 | 1065 | .nav-primary .genesis-nav-menu a:hover, 1066 | .nav-primary .genesis-nav-menu .current-menu-item > a, 1067 | .nav-primary .genesis-nav-menu .sub-menu .current-menu-item > a:hover { 1068 | color: #e5554e; 1069 | } 1070 | 1071 | /* ## Secondary Navigation 1072 | --------------------------------------------- */ 1073 | 1074 | .nav-secondary { 1075 | background-color: #fff; 1076 | } 1077 | 1078 | 1079 | /* # Content Area 1080 | ---------------------------------------------------------------------------------------------------- */ 1081 | 1082 | /* ## Entries 1083 | --------------------------------------------- */ 1084 | 1085 | .entry { 1086 | margin-bottom: 40px; 1087 | padding: 50px 60px; 1088 | } 1089 | 1090 | .content .entry { 1091 | background-color: #fff; 1092 | } 1093 | 1094 | .entry-content ol, 1095 | .entry-content ul { 1096 | margin-bottom: 28px; 1097 | margin-left: 40px; 1098 | } 1099 | 1100 | .entry-content ol > li { 1101 | list-style-type: decimal; 1102 | } 1103 | 1104 | .entry-content ul > li { 1105 | list-style-type: disc; 1106 | } 1107 | 1108 | .entry-content ol ol, 1109 | .entry-content ul ul { 1110 | margin-bottom: 0; 1111 | } 1112 | 1113 | .entry-content code { 1114 | background-color: #333; 1115 | color: #ddd; 1116 | } 1117 | 1118 | /* ## Entry Meta 1119 | --------------------------------------------- */ 1120 | 1121 | p.entry-meta { 1122 | font-size: 16px; 1123 | margin-bottom: 0; 1124 | } 1125 | 1126 | .entry-header .entry-meta { 1127 | margin-bottom: 24px; 1128 | } 1129 | 1130 | .entry-footer .entry-meta { 1131 | border-top: 2px solid #f5f5f5; 1132 | padding-top: 24px; 1133 | } 1134 | 1135 | .entry-categories, 1136 | .entry-tags { 1137 | display: block; 1138 | } 1139 | 1140 | .entry-comments-link::before { 1141 | content: "\2014"; 1142 | margin: 0 6px 0 2px; 1143 | } 1144 | 1145 | /* ## Pagination 1146 | --------------------------------------------- */ 1147 | 1148 | .pagination { 1149 | clear: both; 1150 | margin: 40px 0; 1151 | } 1152 | 1153 | .adjacent-entry-pagination { 1154 | margin-bottom: 0; 1155 | } 1156 | 1157 | .archive-pagination li { 1158 | display: inline; 1159 | } 1160 | 1161 | .archive-pagination li a { 1162 | background-color: #333; 1163 | color: #fff; 1164 | cursor: pointer; 1165 | display: inline-block; 1166 | font-size: 16px; 1167 | padding: 8px 12px; 1168 | } 1169 | 1170 | .archive-pagination li a:hover, 1171 | .archive-pagination .active a { 1172 | background-color: #e5554e; 1173 | } 1174 | 1175 | /* ## Comments 1176 | --------------------------------------------- */ 1177 | 1178 | .comment-respond, 1179 | .entry-comments, 1180 | .entry-pings { 1181 | background-color: #fff; 1182 | margin-bottom: 40px; 1183 | } 1184 | 1185 | .comment-respond, 1186 | .entry-pings { 1187 | padding: 40px 40px 16px; 1188 | } 1189 | 1190 | .entry-comments { 1191 | padding: 40px; 1192 | } 1193 | 1194 | .comment-header { 1195 | font-size: 16px; 1196 | } 1197 | 1198 | li.comment { 1199 | background-color: #f5f5f5; 1200 | border: 2px solid #fff; 1201 | border-right: none; 1202 | } 1203 | 1204 | .comment-content { 1205 | clear: both; 1206 | } 1207 | 1208 | .comment-list li { 1209 | margin-top: 24px; 1210 | padding: 32px; 1211 | } 1212 | 1213 | .comment-list li li { 1214 | margin-right: -32px; 1215 | } 1216 | 1217 | .comment-respond input[type="email"], 1218 | .comment-respond input[type="text"], 1219 | .comment-respond input[type="url"] { 1220 | width: 50%; 1221 | } 1222 | 1223 | .comment-respond label { 1224 | display: block; 1225 | margin-right: 12px; 1226 | } 1227 | 1228 | .entry-comments .comment-author { 1229 | margin-bottom: 0; 1230 | } 1231 | 1232 | .entry-pings .reply { 1233 | display: none; 1234 | } 1235 | 1236 | .bypostauthor { 1237 | } 1238 | 1239 | .form-allowed-tags { 1240 | background-color: #f5f5f5; 1241 | font-size: 16px; 1242 | padding: 24px; 1243 | } 1244 | 1245 | 1246 | /* # Sidebars 1247 | ---------------------------------------------------------------------------------------------------- */ 1248 | 1249 | .sidebar { 1250 | font-size: 16px; 1251 | } 1252 | 1253 | .sidebar li { 1254 | border-bottom: 1px dotted #ddd; 1255 | margin-bottom: 10px; 1256 | padding-bottom: 10px; 1257 | } 1258 | 1259 | .sidebar p:last-child, 1260 | .sidebar ul > li:last-child { 1261 | margin-bottom: 0; 1262 | } 1263 | 1264 | .sidebar .widget { 1265 | background-color: #fff; 1266 | margin-bottom: 40px; 1267 | padding: 40px; 1268 | } 1269 | 1270 | 1271 | /* # Footer Widgets 1272 | ---------------------------------------------------------------------------------------------------- */ 1273 | 1274 | .footer-widgets { 1275 | background-color: #333; 1276 | clear: both; 1277 | padding-top: 40px; 1278 | } 1279 | 1280 | .footer-widgets, 1281 | .footer-widgets a { 1282 | color: #999; 1283 | } 1284 | 1285 | .footer-widgets input { 1286 | border: 1px solid #333; 1287 | } 1288 | 1289 | .footer-widgets a.button, 1290 | .footer-widgets a:hover { 1291 | color: #fff; 1292 | } 1293 | 1294 | .footer-widgets li { 1295 | border-bottom: 1px dotted #666; 1296 | margin-bottom: 10px; 1297 | padding-bottom: 10px; 1298 | } 1299 | 1300 | .footer-widgets .widget { 1301 | margin-bottom: 40px; 1302 | } 1303 | 1304 | .footer-widgets p:last-child { 1305 | margin-bottom: 0; 1306 | } 1307 | 1308 | .footer-widgets-1, 1309 | .footer-widgets-2, 1310 | .footer-widgets-3 { 1311 | width: 340px; 1312 | } 1313 | 1314 | .footer-widgets-1 { 1315 | margin-right: 60px; 1316 | } 1317 | 1318 | .footer-widgets-1, 1319 | .footer-widgets-2 { 1320 | float: left; 1321 | } 1322 | 1323 | .footer-widgets-3 { 1324 | float: right; 1325 | } 1326 | 1327 | 1328 | /* # Site Footer 1329 | ---------------------------------------------------------------------------------------------------- */ 1330 | 1331 | .site-footer { 1332 | background-color: #fff; 1333 | font-size: 16px; 1334 | line-height: 1; 1335 | padding: 40px 0; 1336 | text-align: center; 1337 | } 1338 | 1339 | .site-footer p { 1340 | margin-bottom: 0; 1341 | } 1342 | 1343 | 1344 | /* # Media Queries 1345 | ---------------------------------------------------------------------------------------------------- */ 1346 | 1347 | @media only screen and (max-width: 1200px) { 1348 | 1349 | .site-inner, 1350 | .wrap { 1351 | max-width: 960px; 1352 | } 1353 | 1354 | .content-sidebar-sidebar .content-sidebar-wrap, 1355 | .sidebar-content-sidebar .content-sidebar-wrap, 1356 | .sidebar-sidebar-content .content-sidebar-wrap { 1357 | width: 740px; 1358 | } 1359 | 1360 | .content, 1361 | .site-header .widget-area { 1362 | width: 620px; 1363 | } 1364 | 1365 | .sidebar-content-sidebar .content, 1366 | .sidebar-sidebar-content .content, 1367 | .content-sidebar-sidebar .content { 1368 | width: 400px; 1369 | } 1370 | 1371 | .footer-widgets-1, 1372 | .footer-widgets-2, 1373 | .footer-widgets-3, 1374 | .sidebar-primary, 1375 | .title-area { 1376 | width: 300px; 1377 | } 1378 | 1379 | .footer-widgets-1 { 1380 | margin-right: 30px; 1381 | } 1382 | 1383 | } 1384 | 1385 | @media only screen and (max-width: 960px) { 1386 | 1387 | .site-inner, 1388 | .wrap { 1389 | max-width: 800px; 1390 | } 1391 | 1392 | .content, 1393 | .content-sidebar-sidebar .content, 1394 | .content-sidebar-sidebar .content-sidebar-wrap, 1395 | .footer-widgets-1, 1396 | .footer-widgets-2, 1397 | .footer-widgets-3, 1398 | .sidebar-content-sidebar .content, 1399 | .sidebar-content-sidebar .content-sidebar-wrap, 1400 | .sidebar-primary, 1401 | .sidebar-secondary, 1402 | .sidebar-sidebar-content .content, 1403 | .sidebar-sidebar-content .content-sidebar-wrap, 1404 | .site-header .widget-area, 1405 | .title-area { 1406 | width: 100%; 1407 | } 1408 | 1409 | .site-header .wrap { 1410 | padding: 20px 5%; 1411 | } 1412 | 1413 | .header-image .title-area { 1414 | background-position: center top; 1415 | } 1416 | 1417 | .genesis-nav-menu li, 1418 | .site-header ul.genesis-nav-menu, 1419 | .site-header .search-form { 1420 | float: none; 1421 | } 1422 | 1423 | .genesis-nav-menu, 1424 | .site-description, 1425 | .site-header .title-area, 1426 | .site-header .search-form, 1427 | .site-title { 1428 | text-align: center; 1429 | } 1430 | 1431 | .genesis-nav-menu a, 1432 | .genesis-nav-menu > .first > a, 1433 | .genesis-nav-menu > .last > a { 1434 | padding: 20px 16px; 1435 | } 1436 | 1437 | .site-header .search-form { 1438 | margin: 16px auto; 1439 | } 1440 | 1441 | .genesis-nav-menu li.right { 1442 | display: none; 1443 | } 1444 | 1445 | .footer-widgets-1 { 1446 | margin-right: 0; 1447 | } 1448 | 1449 | } 1450 | 1451 | @media only screen and (max-width: 800px) { 1452 | 1453 | body { 1454 | background-color: #fff; 1455 | font-size: 16px; 1456 | } 1457 | 1458 | .site-inner, 1459 | .wrap { 1460 | padding-left: 5%; 1461 | padding-right: 5%; 1462 | } 1463 | 1464 | .archive-description, 1465 | .author-box, 1466 | .comment-respond, 1467 | .entry, 1468 | .entry-comments, 1469 | .entry-pings, 1470 | .sidebar .widget, 1471 | .site-header { 1472 | padding: 0; 1473 | } 1474 | 1475 | .archive-pagination li a { 1476 | margin-bottom: 4px; 1477 | } 1478 | 1479 | .five-sixths, 1480 | .four-sixths, 1481 | .one-fourth, 1482 | .one-half, 1483 | .one-sixth, 1484 | .one-third, 1485 | .three-fourths, 1486 | .three-sixths, 1487 | .two-fourths, 1488 | .two-sixths, 1489 | .two-thirds { 1490 | margin: 0; 1491 | width: 100%; 1492 | } 1493 | 1494 | .sidebar .widget.enews-widget { 1495 | padding: 40px; 1496 | } 1497 | 1498 | } 1499 | -------------------------------------------------------------------------------- /assets/styles/partials/_header.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Header 3 | ========================================================================== */ 4 | 5 | .site-header { 6 | } 7 | 8 | .title-area { 9 | } 10 | 11 | .site-title { 12 | } 13 | 14 | .site-description { 15 | } 16 | 17 | .header-widget-area { 18 | } 19 | -------------------------------------------------------------------------------- /assets/styles/partials/_maincontent.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Main Content 3 | ========================================================================== */ 4 | 5 | .site-inner { 6 | } 7 | 8 | .content-sidebar-wrap { 9 | } 10 | 11 | .content { 12 | } 13 | 14 | /* ========================================================================== 15 | Sidebars 16 | ========================================================================== */ 17 | 18 | .sidebar-primary { 19 | } 20 | 21 | .sidebar-secondary { 22 | } 23 | -------------------------------------------------------------------------------- /assets/styles/partials/_menus.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Menus 3 | ========================================================================== */ 4 | 5 | .genesis-nav-menu { 6 | } 7 | 8 | .menu-primary { 9 | } 10 | -------------------------------------------------------------------------------- /assets/styles/partials/_mixins.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Mixins 3 | ========================================================================== */ 4 | 5 | /* 6 | * Mixin for easy media queries 7 | * @include bp(tablet) { SCSS here }; 8 | */ 9 | @mixin bp($point) { 10 | @if $point == biggie { 11 | @media (max-width : 1600px) { @content; } 12 | } 13 | @if $point == tablet { 14 | @media (max-width : 1024px) { @content; } 15 | } 16 | @else if $point == phone { 17 | @media (max-width : 768px) { @content; } 18 | } 19 | } 20 | 21 | /* 22 | * Mixin for clearfix 23 | * @include clearfix; 24 | */ 25 | @mixin clearfix { 26 | &:before, 27 | &:after { 28 | content: " "; /* 1 */ 29 | display: table; /* 2 */ 30 | } 31 | 32 | &:after { 33 | clear: both; 34 | } 35 | } 36 | 37 | /* 38 | * Mixin for basic CSS triangles 39 | * @include triangle(up, #000, 50px) 40 | */ 41 | @mixin triangle($direction:up, $color:#000, $size:100px) { 42 | @if($direction == up) { 43 | border-color: transparent transparent $color; 44 | border-style: solid; 45 | border-width: 0 $size $size; 46 | height: 0; 47 | width: 0; 48 | } 49 | @if($direction == down) { 50 | border-color: $color transparent transparent transparent; 51 | border-style: solid; 52 | border-width: $size; 53 | height:0; 54 | width:0; 55 | } 56 | @if($direction == left) { 57 | border-color: transparent $color transparent transparent; 58 | border-style: solid; 59 | border-width: $size $size $size 0; 60 | height: 0; 61 | width: 0; 62 | } 63 | @if($direction == right) { 64 | border-color: transparent transparent transparent $color; 65 | border-style: solid; 66 | border-width: $size 0 $size $size; 67 | height:0; 68 | width:0; 69 | } 70 | } 71 | 72 | /* 73 | * @font-face mixin 74 | * Bulletproof font-face via Font Squirrel 75 | * @include fontface('family', 'assets/fonts/', 'myfontname'); 76 | */ 77 | 78 | @mixin fontface($font-family, $font-url, $font-name) { 79 | @font-face { 80 | font: { 81 | family: $font-family; 82 | style: normal; 83 | weight: normal; 84 | } 85 | src: url($font-url + '/' + $font-name + '.eot'); 86 | src: url($font-url + '/' + $font-name + '.eot#iefix') format('embedded-opentype'), 87 | url($font-url + '/' + $font-name + '.woff') format('woff'), 88 | url($font-url + '/' + $font-name + '.ttf') format('truetype'), 89 | url($font-url + '/' + $font-name + '.svg#' + $font-name) format('svg'); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /assets/styles/partials/_page-blog.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Blog pages 3 | ========================================================================== */ 4 | 5 | body.blog { } 6 | -------------------------------------------------------------------------------- /assets/styles/partials/_page-home.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Home Page Template 3 | ========================================================================== */ 4 | 5 | body.home {} 6 | -------------------------------------------------------------------------------- /assets/styles/partials/_page-post.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Posts 3 | ========================================================================== */ 4 | 5 | .entry { 6 | } 7 | 8 | // Meta 9 | .entry-header .entry-meta { 10 | } 11 | 12 | .entry-footer .entry-meta { 13 | } 14 | 15 | .entry-meta-author { 16 | } 17 | 18 | .entry-meta-categories { 19 | } 20 | 21 | .entry-meta-time { 22 | } 23 | 24 | .entry-meta-comments { 25 | } 26 | 27 | .entry-meta-tags { 28 | } 29 | 30 | -------------------------------------------------------------------------------- /assets/styles/partials/_variables.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Variables 3 | ========================================================================== */ 4 | 5 | // Font Face 6 | // @include fontface('FONT_NAME', 'assets/fonts/', 'FONT_FAMILY'); 7 | 8 | // Structure 9 | $pageWidth: 1000px; 10 | 11 | // Text Selection 12 | $selectionColor: orange; 13 | 14 | // Colors 15 | $red: red; 16 | $blue: blue; 17 | -------------------------------------------------------------------------------- /assets/styles/partials/_widgets.scss: -------------------------------------------------------------------------------- 1 | /* ========================================================================== 2 | Widgets 3 | ========================================================================== */ 4 | 5 | .widget { 6 | } 7 | 8 | .footer-widgets { 9 | } 10 | -------------------------------------------------------------------------------- /assets/styles/style.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | Theme Name: Genesis Child Theme Starter 3 | Theme URI: http://www.THEME.com 4 | Description: WordPress Starter Theme for use as Child Theme of the Genesis Framework for building custom themes. 5 | Author: Matt Banks 6 | Author URI: http://www.kernelcreativemedia.com 7 | License: GNU General Public License v2.0 8 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 | Version: 1.0 10 | 11 | Template: genesis 12 | */ 13 | 14 | // Reset, Variables, Mixins, Etc 15 | // DO NOT EDIT ORDER OF FILES 16 | @import "partials/mixins"; 17 | @import "partials/variables"; 18 | 19 | // Genesis 20 | @import "partials/genesis"; 21 | 22 | // General, Typography 23 | @import "partials/general"; 24 | 25 | // Layout 26 | @import "partials/header"; 27 | @import "partials/maincontent"; 28 | @import "partials/footer"; 29 | 30 | // Menus, Page and Post styles 31 | @import "partials/menus"; 32 | @import "partials/page-post"; 33 | 34 | // Page Templates 35 | @import "partials/page-home"; 36 | @import "partials/page-blog"; 37 | 38 | // Widgets, Search, Comments, Forms, Sharing 39 | @import "partials/widgets"; 40 | @import "partials/comments"; 41 | @import "partials/forms"; 42 | -------------------------------------------------------------------------------- /front-page.php: -------------------------------------------------------------------------------- 1 | 'Primary Navigation Menu' 63 | ) ); 64 | 65 | // Sidebars 66 | unregister_sidebar( 'sidebar-alt' ); 67 | genesis_register_sidebar( array( 68 | 'name' => 'Footer', 69 | 'id' => 'custom-footer' 70 | ) ); 71 | //add_theme_support( 'genesis-footer-widgets', 4 ); 72 | 73 | // Execute shortcodes in widgets 74 | // add_filter( 'widget_text', 'do_shortcode' ); 75 | 76 | // Remove Unused Page Layouts 77 | genesis_unregister_layout( 'content-sidebar-sidebar' ); 78 | genesis_unregister_layout( 'sidebar-sidebar-content' ); 79 | genesis_unregister_layout( 'sidebar-content-sidebar' ); 80 | 81 | // Remove Unused User Settings 82 | // remove_action( 'show_user_profile', 'genesis_user_options_fields' ); 83 | // remove_action( 'edit_user_profile', 'genesis_user_options_fields' ); 84 | // remove_action( 'show_user_profile', 'genesis_user_archive_fields' ); 85 | // remove_action( 'edit_user_profile', 'genesis_user_archive_fields' ); 86 | // remove_action( 'show_user_profile', 'genesis_user_seo_fields' ); 87 | // remove_action( 'edit_user_profile', 'genesis_user_seo_fields' ); 88 | // remove_action( 'show_user_profile', 'genesis_user_layout_fields' ); 89 | // remove_action( 'edit_user_profile', 'genesis_user_layout_fields' ); 90 | 91 | // Editor Styles 92 | add_editor_style( 'editor-style.css' ); 93 | 94 | // Remove Genesis Theme Settings Metaboxes 95 | add_action( 'genesis_theme_settings_metaboxes', 'mb_remove_genesis_metaboxes' ); 96 | 97 | // Reposition Genesis Layout Settings Metabox 98 | remove_action( 'admin_menu', 'genesis_add_inpost_layout_box' ); 99 | add_action( 'admin_menu', 'mb_add_inpost_layout_box' ); 100 | 101 | // Setup Child Theme Settings 102 | include_once( CHILD_DIR . '/lib/child-theme-settings.php' ); 103 | 104 | // Prevent File Modifications 105 | define ( 'DISALLOW_FILE_EDIT', true ); 106 | 107 | // Set Content Width 108 | $content_width = apply_filters( 'content_width', 740, 740, 1140 ); 109 | 110 | // Add support for custom background 111 | add_theme_support( 'custom-background' ); 112 | 113 | // Add support for custom header 114 | add_theme_support( 'genesis-custom-header', array( 115 | 'width' => 960, 116 | 'height' => 80 117 | ) ); 118 | 119 | // Remove Dashboard Meta Boxes 120 | add_action( 'wp_dashboard_setup', 'mb_remove_dashboard_widgets' ); 121 | 122 | // Change Admin Menu Order 123 | add_filter( 'custom_menu_order', 'mb_custom_menu_order' ); 124 | add_filter( 'menu_order', 'mb_custom_menu_order' ); 125 | 126 | // Hide Admin Areas that are not used 127 | add_action( 'admin_menu', 'mb_remove_menu_pages' ); 128 | 129 | // Remove default link for images 130 | add_action( 'admin_init', 'mb_imagelink_setup', 10 ); 131 | 132 | // Define custom post type capabilities for use with Members 133 | // add_action( 'admin_init', 'mb_add_post_type_caps' ); 134 | 135 | 136 | /**************************************** 137 | Frontend 138 | *****************************************/ 139 | 140 | // Add HTML5 markup structure 141 | add_theme_support( 'html5', array( 142 | 'comment-list', 143 | 'search-form', 144 | 'comment-form', 145 | 'gallery', 146 | 'caption', 147 | ) ); 148 | 149 | // Add viewport meta tag for mobile browsers 150 | add_theme_support( 'genesis-responsive-viewport' ); 151 | 152 | // Load Apple touch icon in header 153 | add_action( 'wp_head', 'mb_apple_touch_icon', 9 ); 154 | 155 | // Remove Edit link 156 | add_filter( 'genesis_edit_post_link', '__return_false' ); 157 | 158 | // Footer 159 | remove_action( 'genesis_footer', 'genesis_do_footer' ); 160 | add_action( 'genesis_footer', 'mb_footer' ); 161 | 162 | // Enqueue Scripts 163 | add_action( 'wp_enqueue_scripts', 'mb_scripts' ); 164 | 165 | // Remove Query Strings From Static Resources 166 | add_filter( 'script_loader_src', 'mb_remove_script_version', 15, 1 ); 167 | add_filter( 'style_loader_src', 'mb_remove_script_version', 15, 1 ); 168 | 169 | // Remove Read More Jump 170 | add_filter( 'the_content_more_link', 'mb_remove_more_jump_link' ); 171 | 172 | 173 | /**************************************** 174 | Theme Views 175 | *****************************************/ 176 | 177 | include_once( CHILD_DIR . '/lib/theme-views.php' ); 178 | 179 | 180 | /**************************************** 181 | Require Plugins 182 | *****************************************/ 183 | 184 | require_once( CHILD_DIR . '/lib/class-tgm-plugin-activation.php' ); 185 | require_once( CHILD_DIR . '/lib/theme-require-plugins.php' ); 186 | 187 | add_action( 'tgmpa_register', 'mb_register_required_plugins' ); 188 | 189 | } 190 | 191 | 192 | /**************************************** 193 | Misc Theme Functions 194 | *****************************************/ 195 | 196 | // Unregister the superfish scripts 197 | add_action( 'custom_disable_superfish', 'mb_unregister_superfish' ); 198 | 199 | // Filter Yoast SEO Metabox Priority 200 | add_filter( 'wpseo_metabox_prio', 'mb_filter_yoast_seo_metabox' ); 201 | -------------------------------------------------------------------------------- /lib/child-theme-settings.php: -------------------------------------------------------------------------------- 1 | Child Theme Settings. 7 | * 8 | * @package BE_Genesis_Child 9 | * @since 1.0.0 10 | * @link https://github.com/billerickson/BE-Genesis-Child 11 | * @author Bill Erickson 12 | * @copyright Copyright (c) 2011, Bill Erickson 13 | * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) 14 | * @link https://github.com/billerickson/BE-Genesis-Child 15 | */ 16 | 17 | /** 18 | * Registers a new admin page, providing content and corresponding menu item 19 | * for the Child Theme Settings page. 20 | * 21 | * @since 1.0.0 22 | * 23 | * @package BE_Genesis_Child 24 | * @subpackage Child_Theme_Settings 25 | */ 26 | class Child_Theme_Settings extends Genesis_Admin_Boxes { 27 | 28 | /** 29 | * Create an admin menu item and settings page. 30 | * @since 1.0.0 31 | */ 32 | function __construct() { 33 | 34 | // Specify a unique page ID. 35 | $page_id = 'child'; 36 | 37 | // Set it as a child to genesis, and define the menu and page titles 38 | $menu_ops = array( 39 | 'submenu' => array( 40 | 'parent_slug' => 'genesis', 41 | 'page_title' => 'Genesis - Child Theme Settings', 42 | 'menu_title' => 'Child Theme Settings', 43 | ) 44 | ); 45 | 46 | // Set up page options. These are optional, so only uncomment if you want to change the defaults 47 | $page_ops = array( 48 | // 'screen_icon' => 'options-general', 49 | // 'save_button_text' => 'Save Settings', 50 | // 'reset_button_text' => 'Reset Settings', 51 | // 'save_notice_text' => 'Settings saved.', 52 | // 'reset_notice_text' => 'Settings reset.', 53 | ); 54 | 55 | // Give it a unique settings field. 56 | // You'll access them from genesis_get_option( 'option_name', 'child-settings' ); 57 | $settings_field = 'child-settings'; 58 | 59 | // Set the default values 60 | $default_settings = array( 61 | 'footer-left' => 'Copyright © ' . date( 'Y' ) . ' All Rights Reserved', 62 | 'footer-right' => 'Site by Matt Banks', 63 | ); 64 | 65 | // Create the Admin Page 66 | $this->create( $page_id, $menu_ops, $page_ops, $settings_field, $default_settings ); 67 | 68 | // Initialize the Sanitization Filter 69 | add_action( 'genesis_settings_sanitizer_init', array( $this, 'sanitization_filters' ) ); 70 | 71 | } 72 | 73 | /** 74 | * Set up Sanitization Filters 75 | * @since 1.0.0 76 | * 77 | * See /lib/classes/sanitization.php for all available filters. 78 | */ 79 | function sanitization_filters() { 80 | 81 | genesis_add_option_filter( 'safe_html', $this->settings_field, 82 | array( 83 | 'footer-left', 84 | 'footer-right', 85 | ) ); 86 | } 87 | 88 | /** 89 | * Set up Help Tab 90 | * @since 1.0.0 91 | * 92 | * Genesis automatically looks for a help() function, and if provided uses it for the help tabs 93 | * @link http://wpdevel.wordpress.com/2011/12/06/help-and-screen-api-changes-in-3-3/ 94 | */ 95 | function help() { 96 | $screen = get_current_screen(); 97 | 98 | $screen->add_help_tab( array( 99 | 'id' => 'sample-help', 100 | 'title' => 'Sample Help', 101 | 'content' => '

Help content goes here.

', 102 | ) ); 103 | } 104 | 105 | /** 106 | * Register metaboxes on Child Theme Settings page 107 | * @since 1.0.0 108 | */ 109 | function metaboxes() { 110 | 111 | add_meta_box('footer_metabox', 'Footer', array( $this, 'footer_metabox' ), $this->pagehook, 'main', 'high'); 112 | 113 | } 114 | 115 | /** 116 | * Footer Metabox 117 | * @since 1.0.0 118 | */ 119 | function footer_metabox() { 120 | 121 | echo '

Footer Left:

'; 122 | wp_editor( $this->get_field_value( 'footer-left' ), $this->get_field_id( 'footer-left' ), array( 'textarea_rows' => 5 ) ); 123 | 124 | echo '

Footer Right:

'; 125 | wp_editor( $this->get_field_value( 'footer-right' ), $this->get_field_id( 'footer-right' ), array( 'textarea_rows' => 5 ) ); 126 | } 127 | 128 | 129 | } 130 | 131 | /** 132 | * Add the Theme Settings Page 133 | * @since 1.0.0 134 | */ 135 | function be_add_child_theme_settings() { 136 | global $_child_theme_settings; 137 | $_child_theme_settings = new Child_Theme_Settings; 138 | } 139 | add_action( 'genesis_admin_menu', 'be_add_child_theme_settings' ); 140 | -------------------------------------------------------------------------------- /lib/class-tgm-plugin-activation.php: -------------------------------------------------------------------------------- 1 | wp_version = $GLOBALS['wp_version']; 266 | 267 | // Announce that the class is ready, and pass the object (for advanced use). 268 | do_action_ref_array( 'tgmpa_init', array( $this ) ); 269 | 270 | // When the rest of WP has loaded, kick-start the rest of the class. 271 | add_action( 'init', array( $this, 'init' ) ); 272 | } 273 | 274 | /** 275 | * Initialise the interactions between this class and WordPress. 276 | * 277 | * Hooks in three new methods for the class: admin_menu, notices and styles. 278 | * 279 | * @since 2.0.0 280 | * 281 | * @see TGM_Plugin_Activation::admin_menu() 282 | * @see TGM_Plugin_Activation::notices() 283 | * @see TGM_Plugin_Activation::styles() 284 | */ 285 | public function init() { 286 | /** 287 | * By default TGMPA only loads on the WP back-end and not in an Ajax call. Using this filter 288 | * you can overrule that behaviour. 289 | * 290 | * @since 2.5.0 291 | * 292 | * @param bool $load Whether or not TGMPA should load. 293 | * Defaults to the return of `is_admin() && ! defined( 'DOING_AJAX' )`. 294 | */ 295 | if ( true !== apply_filters( 'tgmpa_load', ( is_admin() && ! defined( 'DOING_AJAX' ) ) ) ) { 296 | return; 297 | } 298 | 299 | // Load class strings. 300 | $this->strings = array( 301 | 'page_title' => __( 'Install Required Plugins', 'tgmpa' ), 302 | 'menu_title' => __( 'Install Plugins', 'tgmpa' ), 303 | 'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), 304 | 'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ), 305 | 'notice_can_install_required' => _n_noop( 306 | 'This theme requires the following plugin: %1$s.', 307 | 'This theme requires the following plugins: %1$s.', 308 | 'tgmpa' 309 | ), 310 | 'notice_can_install_recommended' => _n_noop( 311 | 'This theme recommends the following plugin: %1$s.', 312 | 'This theme recommends the following plugins: %1$s.', 313 | 'tgmpa' 314 | ), 315 | 'notice_cannot_install' => _n_noop( 316 | 'Sorry, but you do not have the correct permissions to install the %1$s plugin.', 317 | 'Sorry, but you do not have the correct permissions to install the %1$s plugins.', 318 | 'tgmpa' 319 | ), 320 | 'notice_ask_to_update' => _n_noop( 321 | 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 322 | 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 323 | 'tgmpa' 324 | ), 325 | 'notice_ask_to_update_maybe' => _n_noop( 326 | 'There is an update available for: %1$s.', 327 | 'There are updates available for the following plugins: %1$s.', 328 | 'tgmpa' 329 | ), 330 | 'notice_cannot_update' => _n_noop( 331 | 'Sorry, but you do not have the correct permissions to update the %1$s plugin.', 332 | 'Sorry, but you do not have the correct permissions to update the %1$s plugins.', 333 | 'tgmpa' 334 | ), 335 | 'notice_can_activate_required' => _n_noop( 336 | 'The following required plugin is currently inactive: %1$s.', 337 | 'The following required plugins are currently inactive: %1$s.', 338 | 'tgmpa' 339 | ), 340 | 'notice_can_activate_recommended' => _n_noop( 341 | 'The following recommended plugin is currently inactive: %1$s.', 342 | 'The following recommended plugins are currently inactive: %1$s.', 343 | 'tgmpa' 344 | ), 345 | 'notice_cannot_activate' => _n_noop( 346 | 'Sorry, but you do not have the correct permissions to activate the %1$s plugin.', 347 | 'Sorry, but you do not have the correct permissions to activate the %1$s plugins.', 348 | 'tgmpa' 349 | ), 350 | 'install_link' => _n_noop( 351 | 'Begin installing plugin', 352 | 'Begin installing plugins', 353 | 'tgmpa' 354 | ), 355 | 'update_link' => _n_noop( 356 | 'Begin updating plugin', 357 | 'Begin updating plugins', 358 | 'tgmpa' 359 | ), 360 | 'activate_link' => _n_noop( 361 | 'Begin activating plugin', 362 | 'Begin activating plugins', 363 | 'tgmpa' 364 | ), 365 | 'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ), 366 | 'dashboard' => __( 'Return to the dashboard', 'tgmpa' ), 367 | 'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ), 368 | 'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ), 369 | 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'tgmpa' ), 370 | 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'tgmpa' ), 371 | 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'tgmpa' ), 372 | 'dismiss' => __( 'Dismiss this notice', 'tgmpa' ), 373 | 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'tgmpa' ), 374 | ); 375 | 376 | do_action( 'tgmpa_register' ); 377 | 378 | /* After this point, the plugins should be registered and the configuration set. */ 379 | 380 | // Proceed only if we have plugins to handle. 381 | if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) { 382 | return; 383 | } 384 | 385 | // Set up the menu and notices if we still have outstanding actions. 386 | if ( true !== $this->is_tgmpa_complete() ) { 387 | // Sort the plugins. 388 | array_multisort( $this->sort_order, SORT_ASC, $this->plugins ); 389 | 390 | add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 391 | add_action( 'admin_head', array( $this, 'dismiss' ) ); 392 | 393 | // Prevent the normal links from showing underneath a single install/update page. 394 | add_filter( 'install_plugin_complete_actions', array( $this, 'actions' ) ); 395 | add_filter( 'update_plugin_complete_actions', array( $this, 'actions' ) ); 396 | 397 | if ( $this->has_notices ) { 398 | add_action( 'admin_notices', array( $this, 'notices' ) ); 399 | add_action( 'admin_init', array( $this, 'admin_init' ), 1 ); 400 | add_action( 'admin_enqueue_scripts', array( $this, 'thickbox' ) ); 401 | } 402 | 403 | add_action( 'load-plugins.php', array( $this, 'add_plugin_action_link_filters' ), 1 ); 404 | } 405 | 406 | // Make sure things get reset on switch theme. 407 | add_action( 'switch_theme', array( $this, 'flush_plugins_cache' ) ); 408 | 409 | if ( $this->has_notices ) { 410 | add_action( 'switch_theme', array( $this, 'update_dismiss' ) ); 411 | } 412 | 413 | // Setup the force activation hook. 414 | if ( true === $this->has_forced_activation ) { 415 | add_action( 'admin_init', array( $this, 'force_activation' ) ); 416 | } 417 | 418 | // Setup the force deactivation hook. 419 | if ( true === $this->has_forced_deactivation ) { 420 | add_action( 'switch_theme', array( $this, 'force_deactivation' ) ); 421 | } 422 | } 423 | 424 | /** 425 | * Prevent activation of plugins which don't meet the minimum version requirement from the 426 | * WP native plugins page. 427 | * 428 | * @since 2.5.0 429 | */ 430 | public function add_plugin_action_link_filters() { 431 | foreach ( $this->plugins as $slug => $plugin ) { 432 | if ( false === $this->can_plugin_activate( $slug ) ) { 433 | add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_activate' ), 20 ); 434 | } 435 | 436 | if ( true === $plugin['force_activation'] ) { 437 | add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_deactivate' ), 20 ); 438 | } 439 | 440 | if ( false !== $this->does_plugin_require_update( $slug ) ) { 441 | add_filter( 'plugin_action_links_' . $plugin['file_path'], array( $this, 'filter_plugin_action_links_update' ), 20 ); 442 | } 443 | } 444 | } 445 | 446 | /** 447 | * Remove the 'Activate' link on the WP native plugins page if the plugin does not meet the 448 | * minimum version requirements. 449 | * 450 | * @since 2.5.0 451 | * 452 | * @param array $actions Action links. 453 | * @return array 454 | */ 455 | public function filter_plugin_action_links_activate( $actions ) { 456 | unset( $actions['activate'] ); 457 | 458 | return $actions; 459 | } 460 | 461 | /** 462 | * Remove the 'Deactivate' link on the WP native plugins page if the plugin has been set to force activate. 463 | * 464 | * @since 2.5.0 465 | * 466 | * @param array $actions Action links. 467 | * @return array 468 | */ 469 | public function filter_plugin_action_links_deactivate( $actions ) { 470 | unset( $actions['deactivate'] ); 471 | 472 | return $actions; 473 | } 474 | 475 | /** 476 | * Add a 'Requires update' link on the WP native plugins page if the plugin does not meet the 477 | * minimum version requirements. 478 | * 479 | * @since 2.5.0 480 | * 481 | * @param array $actions Action links. 482 | * @return array 483 | */ 484 | public function filter_plugin_action_links_update( $actions ) { 485 | $actions['update'] = sprintf( 486 | '%3$s', 487 | esc_url( $this->get_tgmpa_status_url( 'update' ) ), 488 | esc_attr__( 'This plugin needs to be updated to be compatible with your theme.', 'tgmpa' ), 489 | esc_html__( 'Update Required', 'tgmpa' ) 490 | ); 491 | 492 | return $actions; 493 | } 494 | 495 | /** 496 | * Handles calls to show plugin information via links in the notices. 497 | * 498 | * We get the links in the admin notices to point to the TGMPA page, rather 499 | * than the typical plugin-install.php file, so we can prepare everything 500 | * beforehand. 501 | * 502 | * WP does not make it easy to show the plugin information in the thickbox - 503 | * here we have to require a file that includes a function that does the 504 | * main work of displaying it, enqueue some styles, set up some globals and 505 | * finally call that function before exiting. 506 | * 507 | * Down right easy once you know how... 508 | * 509 | * Returns early if not the TGMPA page. 510 | * 511 | * @since 2.1.0 512 | * 513 | * @global string $tab Used as iframe div class names, helps with styling 514 | * @global string $body_id Used as the iframe body ID, helps with styling 515 | * 516 | * @return null Returns early if not the TGMPA page. 517 | */ 518 | public function admin_init() { 519 | if ( ! $this->is_tgmpa_page() ) { 520 | return; 521 | } 522 | 523 | if ( isset( $_REQUEST['tab'] ) && 'plugin-information' === $_REQUEST['tab'] ) { 524 | // Needed for install_plugin_information(). 525 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; 526 | 527 | wp_enqueue_style( 'plugin-install' ); 528 | 529 | global $tab, $body_id; 530 | $body_id = 'plugin-information'; 531 | // @codingStandardsIgnoreStart 532 | $tab = 'plugin-information'; 533 | // @codingStandardsIgnoreEnd 534 | 535 | install_plugin_information(); 536 | 537 | exit; 538 | } 539 | } 540 | 541 | /** 542 | * Enqueue thickbox scripts/styles for plugin info. 543 | * 544 | * Thickbox is not automatically included on all admin pages, so we must 545 | * manually enqueue it for those pages. 546 | * 547 | * Thickbox is only loaded if the user has not dismissed the admin 548 | * notice or if there are any plugins left to install and activate. 549 | * 550 | * @since 2.1.0 551 | */ 552 | public function thickbox() { 553 | if ( ! get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { 554 | add_thickbox(); 555 | } 556 | } 557 | 558 | /** 559 | * Adds submenu page if there are plugin actions to take. 560 | * 561 | * This method adds the submenu page letting users know that a required 562 | * plugin needs to be installed. 563 | * 564 | * This page disappears once the plugin has been installed and activated. 565 | * 566 | * @since 1.0.0 567 | * 568 | * @see TGM_Plugin_Activation::init() 569 | * @see TGM_Plugin_Activation::install_plugins_page() 570 | * 571 | * @return null Return early if user lacks capability to install a plugin. 572 | */ 573 | public function admin_menu() { 574 | // Make sure privileges are correct to see the page. 575 | if ( ! current_user_can( 'install_plugins' ) ) { 576 | return; 577 | } 578 | 579 | $args = apply_filters( 580 | 'tgmpa_admin_menu_args', 581 | array( 582 | 'parent_slug' => $this->parent_slug, // Parent Menu slug. 583 | 'page_title' => $this->strings['page_title'], // Page title. 584 | 'menu_title' => $this->strings['menu_title'], // Menu title. 585 | 'capability' => $this->capability, // Capability. 586 | 'menu_slug' => $this->menu, // Menu slug. 587 | 'function' => array( $this, 'install_plugins_page' ), // Callback. 588 | ) 589 | ); 590 | 591 | $this->add_admin_menu( $args ); 592 | } 593 | 594 | /** 595 | * Add the menu item. 596 | * 597 | * @since 2.5.0 598 | * 599 | * @param array $args Menu item configuration. 600 | */ 601 | protected function add_admin_menu( array $args ) { 602 | if ( has_filter( 'tgmpa_admin_menu_use_add_theme_page' ) ) { 603 | _deprecated_function( 'The "tgmpa_admin_menu_use_add_theme_page" filter', '2.5.0', esc_html__( 'Set the parent_slug config variable instead.', 'tgmpa' ) ); 604 | } 605 | 606 | if ( 'themes.php' === $this->parent_slug ) { 607 | $this->page_hook = call_user_func( 'add_theme_page', $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); 608 | } else { 609 | $this->page_hook = call_user_func( 'add_submenu_page', $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] ); 610 | } 611 | } 612 | 613 | /** 614 | * Echoes plugin installation form. 615 | * 616 | * This method is the callback for the admin_menu method function. 617 | * This displays the admin page and form area where the user can select to install and activate the plugin. 618 | * Aborts early if we're processing a plugin installation action. 619 | * 620 | * @since 1.0.0 621 | * 622 | * @return null Aborts early if we're processing a plugin installation action. 623 | */ 624 | public function install_plugins_page() { 625 | // Store new instance of plugin table in object. 626 | $plugin_table = new TGMPA_List_Table; 627 | 628 | // Return early if processing a plugin installation action. 629 | if ( ( ( 'tgmpa-bulk-install' === $plugin_table->current_action() || 'tgmpa-bulk-update' === $plugin_table->current_action() ) && $plugin_table->process_bulk_actions() ) || $this->do_plugin_install() ) { 630 | return; 631 | } 632 | 633 | // Force refresh of available plugin information so we'll know about manual updates/deletes. 634 | wp_clean_plugins_cache( false ); 635 | 636 | ?> 637 |
638 |

639 | prepare_items(); ?> 640 | 641 | message ) && is_string( $this->message ) ) { 643 | echo wp_kses_post( $this->message ); 644 | } 645 | ?> 646 | views(); ?> 647 | 648 |
649 | 650 | 651 | display(); ?> 652 |
653 |
654 | sanitize_key( urldecode( $_GET['plugin'] ) ); 684 | 685 | if ( ! isset( $this->plugins[ $slug ] ) ) { 686 | return false; 687 | } 688 | 689 | // Was an install or upgrade action link clicked? 690 | if ( ( isset( $_GET['tgmpa-install'] ) && 'install-plugin' === $_GET['tgmpa-install'] ) || ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) ) { 691 | 692 | $install_type = 'install'; 693 | if ( isset( $_GET['tgmpa-update'] ) && 'update-plugin' === $_GET['tgmpa-update'] ) { 694 | $install_type = 'update'; 695 | } 696 | 697 | check_admin_referer( 'tgmpa-' . $install_type, 'tgmpa-nonce' ); 698 | 699 | // Pass necessary information via URL if WP_Filesystem is needed. 700 | $url = wp_nonce_url( 701 | add_query_arg( 702 | array( 703 | 'plugin' => urlencode( $slug ), 704 | 'tgmpa-' . $install_type => $install_type . '-plugin', 705 | ), 706 | $this->get_tgmpa_url() 707 | ), 708 | 'tgmpa-' . $install_type, 709 | 'tgmpa-nonce' 710 | ); 711 | 712 | $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. 713 | 714 | if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, array() ) ) ) { 715 | return true; 716 | } 717 | 718 | if ( ! WP_Filesystem( $creds ) ) { 719 | request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, array() ); // Setup WP_Filesystem. 720 | return true; 721 | } 722 | 723 | /* If we arrive here, we have the filesystem. */ 724 | 725 | // Prep variables for Plugin_Installer_Skin class. 726 | $extra = array(); 727 | $extra['slug'] = $slug; // Needed for potentially renaming of directory name. 728 | $source = $this->get_download_url( $slug ); 729 | $api = ( 'repo' === $this->plugins[ $slug ]['source_type'] ) ? $this->get_plugins_api( $slug ) : null; 730 | $api = ( false !== $api ) ? $api : null; 731 | 732 | $url = add_query_arg( 733 | array( 734 | 'action' => $install_type . '-plugin', 735 | 'plugin' => urlencode( $slug ), 736 | ), 737 | 'update.php' 738 | ); 739 | 740 | if ( ! class_exists( 'Plugin_Upgrader', false ) ) { 741 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 742 | } 743 | 744 | $skin_args = array( 745 | 'type' => ( 'bundled' !== $this->plugins[ $slug ]['source_type'] ) ? 'web' : 'upload', 746 | 'title' => sprintf( $this->strings['installing'], $this->plugins[ $slug ]['name'] ), 747 | 'url' => esc_url_raw( $url ), 748 | 'nonce' => $install_type . '-plugin_' . $slug, 749 | 'plugin' => '', 750 | 'api' => $api, 751 | 'extra' => $extra, 752 | ); 753 | 754 | if ( 'update' === $install_type ) { 755 | $skin_args['plugin'] = $this->plugins[ $slug ]['file_path']; 756 | $skin = new Plugin_Upgrader_Skin( $skin_args ); 757 | } else { 758 | $skin = new Plugin_Installer_Skin( $skin_args ); 759 | } 760 | 761 | // Create a new instance of Plugin_Upgrader. 762 | $upgrader = new Plugin_Upgrader( $skin ); 763 | 764 | // Perform the action and install the plugin from the $source urldecode(). 765 | add_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 ); 766 | 767 | if ( 'update' === $install_type ) { 768 | // Inject our info into the update transient. 769 | $to_inject = array( $slug => $this->plugins[ $slug ] ); 770 | $to_inject[ $slug ]['source'] = $source; 771 | $this->inject_update_info( $to_inject ); 772 | 773 | $upgrader->upgrade( $this->plugins[ $slug ]['file_path'] ); 774 | } else { 775 | $upgrader->install( $source ); 776 | } 777 | 778 | remove_filter( 'upgrader_source_selection', array( $this, 'maybe_adjust_source_dir' ), 1, 3 ); 779 | 780 | // Make sure we have the correct file path now the plugin is installed/updated. 781 | $this->populate_file_path( $slug ); 782 | 783 | // Only activate plugins if the config option is set to true and the plugin isn't 784 | // already active (upgrade). 785 | if ( $this->is_automatic && ! $this->is_plugin_active( $slug ) ) { 786 | $plugin_activate = $upgrader->plugin_info(); // Grab the plugin info from the Plugin_Upgrader method. 787 | if ( false === $this->activate_single_plugin( $plugin_activate, $slug, true ) ) { 788 | return true; // Finish execution of the function early as we encountered an error. 789 | } 790 | } 791 | 792 | $this->show_tgmpa_version(); 793 | 794 | // Display message based on if all plugins are now active or not. 795 | if ( $this->is_tgmpa_complete() ) { 796 | echo '

', sprintf( esc_html( $this->strings['complete'] ), '' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '' ), '

'; 797 | echo ''; 798 | } else { 799 | echo '

', esc_html( $this->strings['return'] ), '

'; 800 | } 801 | 802 | return true; 803 | } elseif ( isset( $this->plugins[ $slug ]['file_path'], $_GET['tgmpa-activate'] ) && 'activate-plugin' === $_GET['tgmpa-activate'] ) { 804 | // Activate action link was clicked. 805 | check_admin_referer( 'tgmpa-activate', 'tgmpa-nonce' ); 806 | 807 | if ( false === $this->activate_single_plugin( $this->plugins[ $slug ]['file_path'], $slug ) ) { 808 | return true; // Finish execution of the function early as we encountered an error. 809 | } 810 | } 811 | 812 | return false; 813 | } 814 | 815 | /** 816 | * Inject information into the 'update_plugins' site transient as WP checks that before running an update. 817 | * 818 | * @since 2.5.0 819 | * 820 | * @param array $plugins The plugin information for the plugins which are to be updated. 821 | */ 822 | public function inject_update_info( $plugins ) { 823 | $repo_updates = get_site_transient( 'update_plugins' ); 824 | 825 | if ( ! is_object( $repo_updates ) ) { 826 | $repo_updates = new stdClass; 827 | } 828 | 829 | foreach ( $plugins as $slug => $plugin ) { 830 | $file_path = $plugin['file_path']; 831 | 832 | if ( empty( $repo_updates->response[ $file_path ] ) ) { 833 | $repo_updates->response[ $file_path ] = new stdClass; 834 | } 835 | 836 | // We only really need to set package, but let's do all we can in case WP changes something. 837 | $repo_updates->response[ $file_path ]->slug = $slug; 838 | $repo_updates->response[ $file_path ]->plugin = $file_path; 839 | $repo_updates->response[ $file_path ]->new_version = $plugin['version']; 840 | $repo_updates->response[ $file_path ]->package = $plugin['source']; 841 | if ( empty( $repo_updates->response[ $file_path ]->url ) && ! empty( $plugin['external_url'] ) ) { 842 | $repo_updates->response[ $file_path ]->url = $plugin['external_url']; 843 | } 844 | } 845 | 846 | set_site_transient( 'update_plugins', $repo_updates ); 847 | } 848 | 849 | /** 850 | * Adjust the plugin directory name if necessary. 851 | * 852 | * The final destination directory of a plugin is based on the subdirectory name found in the 853 | * (un)zipped source. In some cases - most notably GitHub repository plugin downloads -, this 854 | * subdirectory name is not the same as the expected slug and the plugin will not be recognized 855 | * as installed. This is fixed by adjusting the temporary unzipped source subdirectory name to 856 | * the expected plugin slug. 857 | * 858 | * @since 2.5.0 859 | * 860 | * @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/. 861 | * @param string $remote_source Path to upgrade/zip-file-name.tmp. 862 | * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin. 863 | * @return string $source 864 | */ 865 | public function maybe_adjust_source_dir( $source, $remote_source, $upgrader ) { 866 | if ( ! $this->is_tgmpa_page() || ! is_object( $GLOBALS['wp_filesystem'] ) ) { 867 | return $source; 868 | } 869 | 870 | // Check for single file plugins. 871 | $source_files = array_keys( $GLOBALS['wp_filesystem']->dirlist( $remote_source ) ); 872 | if ( 1 === count( $source_files ) && false === $GLOBALS['wp_filesystem']->is_dir( $source ) ) { 873 | return $source; 874 | } 875 | 876 | // Multi-file plugin, let's see if the directory is correctly named. 877 | $desired_slug = ''; 878 | 879 | // Figure out what the slug is supposed to be. 880 | if ( false === $upgrader->bulk && ! empty( $upgrader->skin->options['extra']['slug'] ) ) { 881 | $desired_slug = $upgrader->skin->options['extra']['slug']; 882 | } else { 883 | // Bulk installer contains less info, so fall back on the info registered here. 884 | foreach ( $this->plugins as $slug => $plugin ) { 885 | if ( ! empty( $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) && $plugin['name'] === $upgrader->skin->plugin_names[ $upgrader->skin->i ] ) { 886 | $desired_slug = $slug; 887 | break; 888 | } 889 | } 890 | unset( $slug, $plugin ); 891 | } 892 | 893 | if ( ! empty( $desired_slug ) ) { 894 | $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) ); 895 | 896 | if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) { 897 | $from = untrailingslashit( $source ); 898 | $to = trailingslashit( $remote_source ) . $desired_slug; 899 | 900 | if ( true === $GLOBALS['wp_filesystem']->move( $from, $to ) ) { 901 | return trailingslashit( $to ); 902 | } else { 903 | return new WP_Error( 'rename_failed', esc_html__( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) ); 904 | } 905 | } elseif ( empty( $subdir_name ) ) { 906 | return new WP_Error( 'packaged_wrong', esc_html__( 'The remote plugin package consists of more than one file, but the files are not packaged in a folder.', 'tgmpa' ) . ' ' . esc_html__( 'Please contact the plugin provider and ask them to package their plugin according to the WordPress guidelines.', 'tgmpa' ), array( 'found' => $subdir_name, 'expected' => $desired_slug ) ); 907 | } 908 | } 909 | 910 | return $source; 911 | } 912 | 913 | /** 914 | * Activate a single plugin and send feedback about the result to the screen. 915 | * 916 | * @since 2.5.0 917 | * 918 | * @param string $file_path Path within wp-plugins/ to main plugin file. 919 | * @param string $slug Plugin slug. 920 | * @param bool $automatic Whether this is an automatic activation after an install. Defaults to false. 921 | * This determines the styling of the output messages. 922 | * @return bool False if an error was encountered, true otherwise. 923 | */ 924 | protected function activate_single_plugin( $file_path, $slug, $automatic = false ) { 925 | if ( $this->can_plugin_activate( $slug ) ) { 926 | $activate = activate_plugin( $file_path ); 927 | 928 | if ( is_wp_error( $activate ) ) { 929 | echo '

', wp_kses_post( $activate->get_error_message() ), '

', 930 | '

', esc_html( $this->strings['return'] ), '

'; 931 | 932 | return false; // End it here if there is an error with activation. 933 | } else { 934 | if ( ! $automatic ) { 935 | // Make sure message doesn't display again if bulk activation is performed 936 | // immediately after a single activation. 937 | if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. 938 | echo '

', esc_html( $this->strings['activated_successfully'] ), ' ', esc_html( $this->plugins[ $slug ]['name'] ), '.

'; 939 | } 940 | } else { 941 | // Simpler message layout for use on the plugin install page. 942 | echo '

', esc_html( $this->strings['plugin_activated'] ), '

'; 943 | } 944 | } 945 | } elseif ( $this->is_plugin_active( $slug ) ) { 946 | // No simpler message format provided as this message should never be encountered 947 | // on the plugin install page. 948 | echo '

', 949 | sprintf( 950 | esc_html( $this->strings['plugin_already_active'] ), 951 | '' . esc_html( $this->plugins[ $slug ]['name'] ) . '' 952 | ), 953 | '

'; 954 | } elseif ( $this->does_plugin_require_update( $slug ) ) { 955 | if ( ! $automatic ) { 956 | // Make sure message doesn't display again if bulk activation is performed 957 | // immediately after a single activation. 958 | if ( ! isset( $_POST['action'] ) ) { // WPCS: CSRF OK. 959 | echo '

', 960 | sprintf( 961 | esc_html( $this->strings['plugin_needs_higher_version'] ), 962 | '' . esc_html( $this->plugins[ $slug ]['name'] ) . '' 963 | ), 964 | '

'; 965 | } 966 | } else { 967 | // Simpler message layout for use on the plugin install page. 968 | echo '

', sprintf( esc_html( $this->strings['plugin_needs_higher_version'] ), esc_html( $this->plugins[ $slug ]['name'] ) ), '

'; 969 | } 970 | } 971 | 972 | return true; 973 | } 974 | 975 | /** 976 | * Echoes required plugin notice. 977 | * 978 | * Outputs a message telling users that a specific plugin is required for 979 | * their theme. If appropriate, it includes a link to the form page where 980 | * users can install and activate the plugin. 981 | * 982 | * Returns early if we're on the Install page. 983 | * 984 | * @since 1.0.0 985 | * 986 | * @global object $current_screen 987 | * 988 | * @return null Returns early if we're on the Install page. 989 | */ 990 | public function notices() { 991 | // Remove nag on the install page / Return early if the nag message has been dismissed. 992 | if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) ) { 993 | return; 994 | } 995 | 996 | // Store for the plugin slugs by message type. 997 | $message = array(); 998 | 999 | // Initialize counters used to determine plurality of action link texts. 1000 | $install_link_count = 0; 1001 | $update_link_count = 0; 1002 | $activate_link_count = 0; 1003 | 1004 | foreach ( $this->plugins as $slug => $plugin ) { 1005 | if ( $this->is_plugin_active( $slug ) && false === $this->does_plugin_have_update( $slug ) ) { 1006 | continue; 1007 | } 1008 | 1009 | if ( ! $this->is_plugin_installed( $slug ) ) { 1010 | if ( current_user_can( 'install_plugins' ) ) { 1011 | $install_link_count++; 1012 | 1013 | if ( true === $plugin['required'] ) { 1014 | $message['notice_can_install_required'][] = $slug; 1015 | } else { 1016 | $message['notice_can_install_recommended'][] = $slug; 1017 | } 1018 | } else { 1019 | // Need higher privileges to install the plugin. 1020 | $message['notice_cannot_install'][] = $slug; 1021 | } 1022 | } else { 1023 | if ( ! $this->is_plugin_active( $slug ) && $this->can_plugin_activate( $slug ) ) { 1024 | if ( current_user_can( 'activate_plugins' ) ) { 1025 | $activate_link_count++; 1026 | 1027 | if ( true === $plugin['required'] ) { 1028 | $message['notice_can_activate_required'][] = $slug; 1029 | } else { 1030 | $message['notice_can_activate_recommended'][] = $slug; 1031 | } 1032 | } else { 1033 | // Need higher privileges to activate the plugin. 1034 | $message['notice_cannot_activate'][] = $slug; 1035 | } 1036 | } 1037 | 1038 | if ( $this->does_plugin_require_update( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) { 1039 | 1040 | if ( current_user_can( 'install_plugins' ) ) { 1041 | $update_link_count++; 1042 | 1043 | if ( $this->does_plugin_require_update( $slug ) ) { 1044 | $message['notice_ask_to_update'][] = $slug; 1045 | } elseif ( false !== $this->does_plugin_have_update( $slug ) ) { 1046 | $message['notice_ask_to_update_maybe'][] = $slug; 1047 | } 1048 | } else { 1049 | // Need higher privileges to update the plugin. 1050 | $message['notice_cannot_update'][] = $slug; 1051 | } 1052 | } 1053 | } 1054 | } 1055 | unset( $slug, $plugin ); 1056 | 1057 | // If we have notices to display, we move forward. 1058 | if ( ! empty( $message ) ) { 1059 | krsort( $message ); // Sort messages. 1060 | $rendered = ''; 1061 | 1062 | // As add_settings_error() wraps the final message in a

and as the final message can't be 1063 | // filtered, using

's in our html would render invalid html output. 1064 | $line_template = '%s' . "\n"; 1065 | 1066 | // If dismissable is false and a message is set, output it now. 1067 | if ( ! $this->dismissable && ! empty( $this->dismiss_msg ) ) { 1068 | $rendered .= sprintf( $line_template, wp_kses_post( $this->dismiss_msg ) ); 1069 | } 1070 | 1071 | // Render the individual message lines for the notice. 1072 | foreach ( $message as $type => $plugin_group ) { 1073 | $linked_plugins = array(); 1074 | 1075 | // Get the external info link for a plugin if one is available. 1076 | foreach ( $plugin_group as $plugin_slug ) { 1077 | $linked_plugins[] = $this->get_info_link( $plugin_slug ); 1078 | } 1079 | unset( $plugin_slug ); 1080 | 1081 | $count = count( $plugin_group ); 1082 | $linked_plugins = array_map( array( 'TGM_Utils', 'wrap_in_em' ), $linked_plugins ); 1083 | $last_plugin = array_pop( $linked_plugins ); // Pop off last name to prep for readability. 1084 | $imploded = empty( $linked_plugins ) ? $last_plugin : ( implode( ', ', $linked_plugins ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); 1085 | 1086 | $rendered .= sprintf( 1087 | $line_template, 1088 | sprintf( 1089 | translate_nooped_plural( $this->strings[ $type ], $count, 'tgmpa' ), 1090 | $imploded, 1091 | $count 1092 | ) 1093 | ); 1094 | 1095 | if ( 0 === strpos( $type, 'notice_cannot' ) ) { 1096 | $rendered .= $this->strings['contact_admin']; 1097 | } 1098 | } 1099 | unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded ); 1100 | 1101 | // Setup action links. 1102 | $action_links = array( 1103 | 'install' => '', 1104 | 'update' => '', 1105 | 'activate' => '', 1106 | 'dismiss' => $this->dismissable ? '' . esc_html( $this->strings['dismiss'] ) . '' : '', 1107 | ); 1108 | 1109 | $link_template = '%1$s'; 1110 | 1111 | if ( current_user_can( 'install_plugins' ) ) { 1112 | if ( $install_link_count > 0 ) { 1113 | $action_links['install'] = sprintf( 1114 | $link_template, 1115 | translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ), 1116 | esc_url( $this->get_tgmpa_status_url( 'install' ) ) 1117 | ); 1118 | } 1119 | if ( $update_link_count > 0 ) { 1120 | $action_links['update'] = sprintf( 1121 | $link_template, 1122 | translate_nooped_plural( $this->strings['update_link'], $update_link_count, 'tgmpa' ), 1123 | esc_url( $this->get_tgmpa_status_url( 'update' ) ) 1124 | ); 1125 | } 1126 | } 1127 | 1128 | if ( current_user_can( 'activate_plugins' ) && $activate_link_count > 0 ) { 1129 | $action_links['activate'] = sprintf( 1130 | $link_template, 1131 | translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ), 1132 | esc_url( $this->get_tgmpa_status_url( 'activate' ) ) 1133 | ); 1134 | } 1135 | 1136 | $action_links = apply_filters( 'tgmpa_notice_action_links', $action_links ); 1137 | 1138 | $action_links = array_filter( (array) $action_links ); // Remove any empty array items. 1139 | 1140 | if ( ! empty( $action_links ) && is_array( $action_links ) ) { 1141 | $action_links = sprintf( $line_template, implode( ' | ', $action_links ) ); 1142 | $rendered .= apply_filters( 'tgmpa_notice_rendered_action_links', $action_links ); 1143 | } 1144 | 1145 | // Register the nag messages and prepare them to be processed. 1146 | if ( ! empty( $this->strings['nag_type'] ) ) { 1147 | add_settings_error( 'tgmpa', 'tgmpa', $rendered, sanitize_html_class( strtolower( $this->strings['nag_type'] ) ) ); 1148 | } else { 1149 | $nag_class = version_compare( $this->wp_version, '3.8', '<' ) ? 'updated' : 'update-nag'; 1150 | add_settings_error( 'tgmpa', 'tgmpa', $rendered, $nag_class ); 1151 | } 1152 | } 1153 | 1154 | // Admin options pages already output settings_errors, so this is to avoid duplication. 1155 | if ( 'options-general' !== $GLOBALS['current_screen']->parent_base ) { 1156 | $this->display_settings_errors(); 1157 | } 1158 | } 1159 | 1160 | /** 1161 | * Display settings errors and remove those which have been displayed to avoid duplicate messages showing 1162 | * 1163 | * @since 2.5.0 1164 | */ 1165 | protected function display_settings_errors() { 1166 | global $wp_settings_errors; 1167 | 1168 | settings_errors( 'tgmpa' ); 1169 | 1170 | foreach ( (array) $wp_settings_errors as $key => $details ) { 1171 | if ( 'tgmpa' === $details['setting'] ) { 1172 | unset( $wp_settings_errors[ $key ] ); 1173 | break; 1174 | } 1175 | } 1176 | } 1177 | 1178 | /** 1179 | * Add dismissable admin notices. 1180 | * 1181 | * Appends a link to the admin nag messages. If clicked, the admin notice disappears and no longer is visible to users. 1182 | * 1183 | * @since 2.1.0 1184 | */ 1185 | public function dismiss() { 1186 | if ( isset( $_GET['tgmpa-dismiss'] ) ) { 1187 | update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, 1 ); 1188 | } 1189 | } 1190 | 1191 | /** 1192 | * Add individual plugin to our collection of plugins. 1193 | * 1194 | * If the required keys are not set or the plugin has already 1195 | * been registered, the plugin is not added. 1196 | * 1197 | * @since 2.0.0 1198 | * 1199 | * @param array|null $plugin Array of plugin arguments or null if invalid argument. 1200 | * @return null Return early if incorrect argument. 1201 | */ 1202 | public function register( $plugin ) { 1203 | if ( empty( $plugin['slug'] ) || empty( $plugin['name'] ) ) { 1204 | return; 1205 | } 1206 | 1207 | if ( empty( $plugin['slug'] ) || ! is_string( $plugin['slug'] ) || isset( $this->plugins[ $plugin['slug'] ] ) ) { 1208 | return; 1209 | } 1210 | 1211 | $defaults = array( 1212 | 'name' => '', // String 1213 | 'slug' => '', // String 1214 | 'source' => 'repo', // String 1215 | 'required' => false, // Boolean 1216 | 'version' => '', // String 1217 | 'force_activation' => false, // Boolean 1218 | 'force_deactivation' => false, // Boolean 1219 | 'external_url' => '', // String 1220 | 'is_callable' => '', // String|Array. 1221 | ); 1222 | 1223 | // Prepare the received data. 1224 | $plugin = wp_parse_args( $plugin, $defaults ); 1225 | 1226 | // Standardize the received slug. 1227 | $plugin['slug'] = $this->sanitize_key( $plugin['slug'] ); 1228 | 1229 | // Forgive users for using string versions of booleans or floats for version number. 1230 | $plugin['version'] = (string) $plugin['version']; 1231 | $plugin['source'] = empty( $plugin['source'] ) ? 'repo' : $plugin['source']; 1232 | $plugin['required'] = TGM_Utils::validate_bool( $plugin['required'] ); 1233 | $plugin['force_activation'] = TGM_Utils::validate_bool( $plugin['force_activation'] ); 1234 | $plugin['force_deactivation'] = TGM_Utils::validate_bool( $plugin['force_deactivation'] ); 1235 | 1236 | // Enrich the received data. 1237 | $plugin['file_path'] = $this->_get_plugin_basename_from_slug( $plugin['slug'] ); 1238 | $plugin['source_type'] = $this->get_plugin_source_type( $plugin['source'] ); 1239 | 1240 | // Set the class properties. 1241 | $this->plugins[ $plugin['slug'] ] = $plugin; 1242 | $this->sort_order[ $plugin['slug'] ] = $plugin['name']; 1243 | 1244 | // Should we add the force activation hook ? 1245 | if ( true === $plugin['force_activation'] ) { 1246 | $this->has_forced_activation = true; 1247 | } 1248 | 1249 | // Should we add the force deactivation hook ? 1250 | if ( true === $plugin['force_deactivation'] ) { 1251 | $this->has_forced_deactivation = true; 1252 | } 1253 | } 1254 | 1255 | /** 1256 | * Determine what type of source the plugin comes from. 1257 | * 1258 | * @since 2.5.0 1259 | * 1260 | * @param string $source The source of the plugin as provided, either empty (= WP repo), a file path 1261 | * (= bundled) or an external URL. 1262 | * @return string 'repo', 'external', or 'bundled' 1263 | */ 1264 | protected function get_plugin_source_type( $source ) { 1265 | if ( 'repo' === $source || preg_match( self::WP_REPO_REGEX, $source ) ) { 1266 | return 'repo'; 1267 | } elseif ( preg_match( self::IS_URL_REGEX, $source ) ) { 1268 | return 'external'; 1269 | } else { 1270 | return 'bundled'; 1271 | } 1272 | } 1273 | 1274 | /** 1275 | * Sanitizes a string key. 1276 | * 1277 | * Near duplicate of WP Core `sanitize_key()`. The difference is that uppercase characters *are* 1278 | * allowed, so as not to break upgrade paths from non-standard bundled plugins using uppercase 1279 | * characters in the plugin directory path/slug. Silly them. 1280 | * 1281 | * @see https://developer.wordpress.org/reference/hooks/sanitize_key/ 1282 | * 1283 | * @since 2.5.0 1284 | * 1285 | * @param string $key String key. 1286 | * @return string Sanitized key 1287 | */ 1288 | public function sanitize_key( $key ) { 1289 | $raw_key = $key; 1290 | $key = preg_replace( '`[^A-Za-z0-9_-]`', '', $key ); 1291 | 1292 | /** 1293 | * Filter a sanitized key string. 1294 | * 1295 | * @since 3.0.0 1296 | * 1297 | * @param string $key Sanitized key. 1298 | * @param string $raw_key The key prior to sanitization. 1299 | */ 1300 | return apply_filters( 'tgmpa_sanitize_key', $key, $raw_key ); 1301 | } 1302 | 1303 | /** 1304 | * Amend default configuration settings. 1305 | * 1306 | * @since 2.0.0 1307 | * 1308 | * @param array $config Array of config options to pass as class properties. 1309 | */ 1310 | public function config( $config ) { 1311 | $keys = array( 1312 | 'id', 1313 | 'default_path', 1314 | 'has_notices', 1315 | 'dismissable', 1316 | 'dismiss_msg', 1317 | 'menu', 1318 | 'parent_slug', 1319 | 'capability', 1320 | 'is_automatic', 1321 | 'message', 1322 | 'strings', 1323 | ); 1324 | 1325 | foreach ( $keys as $key ) { 1326 | if ( isset( $config[ $key ] ) ) { 1327 | if ( is_array( $config[ $key ] ) ) { 1328 | $this->$key = array_merge( $this->$key, $config[ $key ] ); 1329 | } else { 1330 | $this->$key = $config[ $key ]; 1331 | } 1332 | } 1333 | } 1334 | } 1335 | 1336 | /** 1337 | * Amend action link after plugin installation. 1338 | * 1339 | * @since 2.0.0 1340 | * 1341 | * @param array $install_actions Existing array of actions. 1342 | * @return array Amended array of actions. 1343 | */ 1344 | public function actions( $install_actions ) { 1345 | // Remove action links on the TGMPA install page. 1346 | if ( $this->is_tgmpa_page() ) { 1347 | return false; 1348 | } 1349 | 1350 | return $install_actions; 1351 | } 1352 | 1353 | /** 1354 | * Flushes the plugins cache on theme switch to prevent stale entries 1355 | * from remaining in the plugin table. 1356 | * 1357 | * @since 2.4.0 1358 | * 1359 | * @param bool $clear_update_cache Optional. Whether to clear the Plugin updates cache. 1360 | * Parameter added in v2.5.0. 1361 | */ 1362 | public function flush_plugins_cache( $clear_update_cache = true ) { 1363 | wp_clean_plugins_cache( $clear_update_cache ); 1364 | } 1365 | 1366 | /** 1367 | * Set file_path key for each installed plugin. 1368 | * 1369 | * @since 2.1.0 1370 | * 1371 | * @param string $plugin_slug Optional. If set, only (re-)populates the file path for that specific plugin. 1372 | * Parameter added in v2.5.0. 1373 | */ 1374 | public function populate_file_path( $plugin_slug = '' ) { 1375 | if ( ! empty( $plugin_slug ) && is_string( $plugin_slug ) && isset( $this->plugins[ $plugin_slug ] ) ) { 1376 | $this->plugins[ $plugin_slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $plugin_slug ); 1377 | } else { 1378 | // Add file_path key for all plugins. 1379 | foreach ( $this->plugins as $slug => $values ) { 1380 | $this->plugins[ $slug ]['file_path'] = $this->_get_plugin_basename_from_slug( $slug ); 1381 | } 1382 | } 1383 | } 1384 | 1385 | /** 1386 | * Helper function to extract the file path of the plugin file from the 1387 | * plugin slug, if the plugin is installed. 1388 | * 1389 | * @since 2.0.0 1390 | * 1391 | * @param string $slug Plugin slug (typically folder name) as provided by the developer. 1392 | * @return string Either file path for plugin if installed, or just the plugin slug. 1393 | */ 1394 | protected function _get_plugin_basename_from_slug( $slug ) { 1395 | $keys = array_keys( $this->get_plugins() ); 1396 | 1397 | foreach ( $keys as $key ) { 1398 | if ( preg_match( '|^' . $slug . '/|', $key ) ) { 1399 | return $key; 1400 | } 1401 | } 1402 | 1403 | return $slug; 1404 | } 1405 | 1406 | /** 1407 | * Retrieve plugin data, given the plugin name. 1408 | * 1409 | * Loops through the registered plugins looking for $name. If it finds it, 1410 | * it returns the $data from that plugin. Otherwise, returns false. 1411 | * 1412 | * @since 2.1.0 1413 | * 1414 | * @param string $name Name of the plugin, as it was registered. 1415 | * @param string $data Optional. Array key of plugin data to return. Default is slug. 1416 | * @return string|boolean Plugin slug if found, false otherwise. 1417 | */ 1418 | public function _get_plugin_data_from_name( $name, $data = 'slug' ) { 1419 | foreach ( $this->plugins as $values ) { 1420 | if ( $name === $values['name'] && isset( $values[ $data ] ) ) { 1421 | return $values[ $data ]; 1422 | } 1423 | } 1424 | 1425 | return false; 1426 | } 1427 | 1428 | /** 1429 | * Retrieve the download URL for a package. 1430 | * 1431 | * @since 2.5.0 1432 | * 1433 | * @param string $slug Plugin slug. 1434 | * @return string Plugin download URL or path to local file or empty string if undetermined. 1435 | */ 1436 | public function get_download_url( $slug ) { 1437 | $dl_source = ''; 1438 | 1439 | switch ( $this->plugins[ $slug ]['source_type'] ) { 1440 | case 'repo': 1441 | return $this->get_wp_repo_download_url( $slug ); 1442 | case 'external': 1443 | return $this->plugins[ $slug ]['source']; 1444 | case 'bundled': 1445 | return $this->default_path . $this->plugins[ $slug ]['source']; 1446 | } 1447 | 1448 | return $dl_source; // Should never happen. 1449 | } 1450 | 1451 | /** 1452 | * Retrieve the download URL for a WP repo package. 1453 | * 1454 | * @since 2.5.0 1455 | * 1456 | * @param string $slug Plugin slug. 1457 | * @return string Plugin download URL. 1458 | */ 1459 | protected function get_wp_repo_download_url( $slug ) { 1460 | $source = ''; 1461 | $api = $this->get_plugins_api( $slug ); 1462 | 1463 | if ( false !== $api && isset( $api->download_link ) ) { 1464 | $source = $api->download_link; 1465 | } 1466 | 1467 | return $source; 1468 | } 1469 | 1470 | /** 1471 | * Try to grab information from WordPress API. 1472 | * 1473 | * @since 2.5.0 1474 | * 1475 | * @param string $slug Plugin slug. 1476 | * @return object Plugins_api response object on success, WP_Error on failure. 1477 | */ 1478 | protected function get_plugins_api( $slug ) { 1479 | static $api = array(); // Cache received responses. 1480 | 1481 | if ( ! isset( $api[ $slug ] ) ) { 1482 | if ( ! function_exists( 'plugins_api' ) ) { 1483 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; 1484 | } 1485 | 1486 | $response = plugins_api( 'plugin_information', array( 'slug' => $slug, 'fields' => array( 'sections' => false ) ) ); 1487 | 1488 | $api[ $slug ] = false; 1489 | 1490 | if ( is_wp_error( $response ) ) { 1491 | wp_die( esc_html( $this->strings['oops'] ) ); 1492 | } else { 1493 | $api[ $slug ] = $response; 1494 | } 1495 | } 1496 | 1497 | return $api[ $slug ]; 1498 | } 1499 | 1500 | /** 1501 | * Retrieve a link to a plugin information page. 1502 | * 1503 | * @since 2.5.0 1504 | * 1505 | * @param string $slug Plugin slug. 1506 | * @return string Fully formed html link to a plugin information page if available 1507 | * or the plugin name if not. 1508 | */ 1509 | public function get_info_link( $slug ) { 1510 | if ( ! empty( $this->plugins[ $slug ]['external_url'] ) && preg_match( self::IS_URL_REGEX, $this->plugins[ $slug ]['external_url'] ) ) { 1511 | $link = sprintf( 1512 | '%2$s', 1513 | esc_url( $this->plugins[ $slug ]['external_url'] ), 1514 | esc_html( $this->plugins[ $slug ]['name'] ) 1515 | ); 1516 | } elseif ( 'repo' === $this->plugins[ $slug ]['source_type'] ) { 1517 | $url = add_query_arg( 1518 | array( 1519 | 'tab' => 'plugin-information', 1520 | 'plugin' => urlencode( $slug ), 1521 | 'TB_iframe' => 'true', 1522 | 'width' => '640', 1523 | 'height' => '500', 1524 | ), 1525 | self_admin_url( 'plugin-install.php' ) 1526 | ); 1527 | 1528 | $link = sprintf( 1529 | '%2$s', 1530 | esc_url( $url ), 1531 | esc_html( $this->plugins[ $slug ]['name'] ) 1532 | ); 1533 | } else { 1534 | $link = esc_html( $this->plugins[ $slug ]['name'] ); // No hyperlink. 1535 | } 1536 | 1537 | return $link; 1538 | } 1539 | 1540 | /** 1541 | * Determine if we're on the TGMPA Install page. 1542 | * 1543 | * @since 2.1.0 1544 | * 1545 | * @return boolean True when on the TGMPA page, false otherwise. 1546 | */ 1547 | protected function is_tgmpa_page() { 1548 | return isset( $_GET['page'] ) && $this->menu === $_GET['page']; 1549 | } 1550 | 1551 | /** 1552 | * Retrieve the URL to the TGMPA Install page. 1553 | * 1554 | * I.e. depending on the config settings passed something along the lines of: 1555 | * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins 1556 | * 1557 | * @since 2.5.0 1558 | * 1559 | * @return string Properly encoded URL (not escaped). 1560 | */ 1561 | public function get_tgmpa_url() { 1562 | static $url; 1563 | 1564 | if ( ! isset( $url ) ) { 1565 | $parent = $this->parent_slug; 1566 | if ( false === strpos( $parent, '.php' ) ) { 1567 | $parent = 'admin.php'; 1568 | } 1569 | $url = add_query_arg( 1570 | array( 1571 | 'page' => urlencode( $this->menu ), 1572 | ), 1573 | self_admin_url( $parent ) 1574 | ); 1575 | } 1576 | 1577 | return $url; 1578 | } 1579 | 1580 | /** 1581 | * Retrieve the URL to the TGMPA Install page for a specific plugin status (view). 1582 | * 1583 | * I.e. depending on the config settings passed something along the lines of: 1584 | * http://example.com/wp-admin/themes.php?page=tgmpa-install-plugins&plugin_status=install 1585 | * 1586 | * @since 2.5.0 1587 | * 1588 | * @param string $status Plugin status - either 'install', 'update' or 'activate'. 1589 | * @return string Properly encoded URL (not escaped). 1590 | */ 1591 | public function get_tgmpa_status_url( $status ) { 1592 | return add_query_arg( 1593 | array( 1594 | 'plugin_status' => urlencode( $status ), 1595 | ), 1596 | $this->get_tgmpa_url() 1597 | ); 1598 | } 1599 | 1600 | /** 1601 | * Determine whether there are open actions for plugins registered with TGMPA. 1602 | * 1603 | * @since 2.5.0 1604 | * 1605 | * @return bool True if complete, i.e. no outstanding actions. False otherwise. 1606 | */ 1607 | public function is_tgmpa_complete() { 1608 | $complete = true; 1609 | foreach ( $this->plugins as $slug => $plugin ) { 1610 | if ( ! $this->is_plugin_active( $slug ) || false !== $this->does_plugin_have_update( $slug ) ) { 1611 | $complete = false; 1612 | break; 1613 | } 1614 | } 1615 | 1616 | return $complete; 1617 | } 1618 | 1619 | /** 1620 | * Check if a plugin is installed. Does not take must-use plugins into account. 1621 | * 1622 | * @since 2.5.0 1623 | * 1624 | * @param string $slug Plugin slug. 1625 | * @return bool True if installed, false otherwise. 1626 | */ 1627 | public function is_plugin_installed( $slug ) { 1628 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). 1629 | 1630 | return ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ] ) ); 1631 | } 1632 | 1633 | /** 1634 | * Check if a plugin is active. 1635 | * 1636 | * @since 2.5.0 1637 | * 1638 | * @param string $slug Plugin slug. 1639 | * @return bool True if active, false otherwise. 1640 | */ 1641 | public function is_plugin_active( $slug ) { 1642 | return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); 1643 | } 1644 | 1645 | /** 1646 | * Check if a plugin can be updated, i.e. if we have information on the minimum WP version required 1647 | * available, check whether the current install meets them. 1648 | * 1649 | * @since 2.5.0 1650 | * 1651 | * @param string $slug Plugin slug. 1652 | * @return bool True if OK to update, false otherwise. 1653 | */ 1654 | public function can_plugin_update( $slug ) { 1655 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. 1656 | if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { 1657 | return true; 1658 | } 1659 | 1660 | $api = $this->get_plugins_api( $slug ); 1661 | 1662 | if ( false !== $api && isset( $api->requires ) ) { 1663 | return version_compare( $GLOBALS['wp_version'], $api->requires, '>=' ); 1664 | } 1665 | 1666 | // No usable info received from the plugins API, presume we can update. 1667 | return true; 1668 | } 1669 | 1670 | /** 1671 | * Check if a plugin can be activated, i.e. is not currently active and meets the minimum 1672 | * plugin version requirements set in TGMPA (if any). 1673 | * 1674 | * @since 2.5.0 1675 | * 1676 | * @param string $slug Plugin slug. 1677 | * @return bool True if OK to activate, false otherwise. 1678 | */ 1679 | public function can_plugin_activate( $slug ) { 1680 | return ( ! $this->is_plugin_active( $slug ) && ! $this->does_plugin_require_update( $slug ) ); 1681 | } 1682 | 1683 | /** 1684 | * Retrieve the version number of an installed plugin. 1685 | * 1686 | * @since 2.5.0 1687 | * 1688 | * @param string $slug Plugin slug. 1689 | * @return string Version number as string or an empty string if the plugin is not installed 1690 | * or version unknown (plugins which don't comply with the plugin header standard). 1691 | */ 1692 | public function get_installed_version( $slug ) { 1693 | $installed_plugins = $this->get_plugins(); // Retrieve a list of all installed plugins (WP cached). 1694 | 1695 | if ( ! empty( $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version'] ) ) { 1696 | return $installed_plugins[ $this->plugins[ $slug ]['file_path'] ]['Version']; 1697 | } 1698 | 1699 | return ''; 1700 | } 1701 | 1702 | /** 1703 | * Check whether a plugin complies with the minimum version requirements. 1704 | * 1705 | * @since 2.5.0 1706 | * 1707 | * @param string $slug Plugin slug. 1708 | * @return bool True when a plugin needs to be updated, otherwise false. 1709 | */ 1710 | public function does_plugin_require_update( $slug ) { 1711 | $installed_version = $this->get_installed_version( $slug ); 1712 | $minimum_version = $this->plugins[ $slug ]['version']; 1713 | 1714 | return version_compare( $minimum_version, $installed_version, '>' ); 1715 | } 1716 | 1717 | /** 1718 | * Check whether there is an update available for a plugin. 1719 | * 1720 | * @since 2.5.0 1721 | * 1722 | * @param string $slug Plugin slug. 1723 | * @return false|string Version number string of the available update or false if no update available. 1724 | */ 1725 | public function does_plugin_have_update( $slug ) { 1726 | // Presume bundled and external plugins will point to a package which meets the minimum required version. 1727 | if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { 1728 | if ( $this->does_plugin_require_update( $slug ) ) { 1729 | return $this->plugins[ $slug ]['version']; 1730 | } 1731 | 1732 | return false; 1733 | } 1734 | 1735 | $repo_updates = get_site_transient( 'update_plugins' ); 1736 | 1737 | if ( isset( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version ) ) { 1738 | return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->new_version; 1739 | } 1740 | 1741 | return false; 1742 | } 1743 | 1744 | /** 1745 | * Retrieve potential upgrade notice for a plugin. 1746 | * 1747 | * @since 2.5.0 1748 | * 1749 | * @param string $slug Plugin slug. 1750 | * @return string The upgrade notice or an empty string if no message was available or provided. 1751 | */ 1752 | public function get_upgrade_notice( $slug ) { 1753 | // We currently can't get reliable info on non-WP-repo plugins - issue #380. 1754 | if ( 'repo' !== $this->plugins[ $slug ]['source_type'] ) { 1755 | return ''; 1756 | } 1757 | 1758 | $repo_updates = get_site_transient( 'update_plugins' ); 1759 | 1760 | if ( ! empty( $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice ) ) { 1761 | return $repo_updates->response[ $this->plugins[ $slug ]['file_path'] ]->upgrade_notice; 1762 | } 1763 | 1764 | return ''; 1765 | } 1766 | 1767 | /** 1768 | * Wrapper around the core WP get_plugins function, making sure it's actually available. 1769 | * 1770 | * @since 2.5.0 1771 | * 1772 | * @param string $plugin_folder Optional. Relative path to single plugin folder. 1773 | * @return array Array of installed plugins with plugin information. 1774 | */ 1775 | public function get_plugins( $plugin_folder = '' ) { 1776 | if ( ! function_exists( 'get_plugins' ) ) { 1777 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; 1778 | } 1779 | 1780 | return get_plugins( $plugin_folder ); 1781 | } 1782 | 1783 | /** 1784 | * Delete dismissable nag option when theme is switched. 1785 | * 1786 | * This ensures that the user(s) is/are again reminded via nag of required 1787 | * and/or recommended plugins if they re-activate the theme. 1788 | * 1789 | * @since 2.1.1 1790 | */ 1791 | public function update_dismiss() { 1792 | delete_metadata( 'user', null, 'tgmpa_dismissed_notice_' . $this->id, null, true ); 1793 | } 1794 | 1795 | /** 1796 | * Forces plugin activation if the parameter 'force_activation' is 1797 | * set to true. 1798 | * 1799 | * This allows theme authors to specify certain plugins that must be 1800 | * active at all times while using the current theme. 1801 | * 1802 | * Please take special care when using this parameter as it has the 1803 | * potential to be harmful if not used correctly. Setting this parameter 1804 | * to true will not allow the specified plugin to be deactivated unless 1805 | * the user switches themes. 1806 | * 1807 | * @since 2.2.0 1808 | */ 1809 | public function force_activation() { 1810 | foreach ( $this->plugins as $slug => $plugin ) { 1811 | if ( true === $plugin['force_activation'] ) { 1812 | if ( ! $this->is_plugin_installed( $slug ) ) { 1813 | // Oops, plugin isn't there so iterate to next condition. 1814 | continue; 1815 | } elseif ( $this->can_plugin_activate( $slug ) ) { 1816 | // There we go, activate the plugin. 1817 | activate_plugin( $plugin['file_path'] ); 1818 | } 1819 | } 1820 | } 1821 | } 1822 | 1823 | /** 1824 | * Forces plugin deactivation if the parameter 'force_deactivation' 1825 | * is set to true. 1826 | * 1827 | * This allows theme authors to specify certain plugins that must be 1828 | * deactivated upon switching from the current theme to another. 1829 | * 1830 | * Please take special care when using this parameter as it has the 1831 | * potential to be harmful if not used correctly. 1832 | * 1833 | * @since 2.2.0 1834 | */ 1835 | public function force_deactivation() { 1836 | foreach ( $this->plugins as $slug => $plugin ) { 1837 | // Only proceed forward if the parameter is set to true and plugin is active. 1838 | if ( true === $plugin['force_deactivation'] && $this->is_plugin_active( $slug ) ) { 1839 | deactivate_plugins( $plugin['file_path'] ); 1840 | } 1841 | } 1842 | } 1843 | 1844 | /** 1845 | * Echo the current TGMPA version number to the page. 1846 | */ 1847 | public function show_tgmpa_version() { 1848 | echo '

', 1849 | esc_html( sprintf( _x( 'TGMPA v%s', '%s = version number', 'tgmpa' ), self::TGMPA_VERSION ) ), 1850 | '

'; 1851 | } 1852 | 1853 | /** 1854 | * Returns the singleton instance of the class. 1855 | * 1856 | * @since 2.4.0 1857 | * 1858 | * @return object The TGM_Plugin_Activation object. 1859 | */ 1860 | public static function get_instance() { 1861 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { 1862 | self::$instance = new self(); 1863 | } 1864 | 1865 | return self::$instance; 1866 | } 1867 | } 1868 | 1869 | if ( ! function_exists( 'load_tgm_plugin_activation' ) ) { 1870 | /** 1871 | * Ensure only one instance of the class is ever invoked. 1872 | */ 1873 | function load_tgm_plugin_activation() { 1874 | $GLOBALS['tgmpa'] = TGM_Plugin_Activation::get_instance(); 1875 | } 1876 | } 1877 | 1878 | if ( did_action( 'plugins_loaded' ) ) { 1879 | load_tgm_plugin_activation(); 1880 | } else { 1881 | add_action( 'plugins_loaded', 'load_tgm_plugin_activation' ); 1882 | } 1883 | } 1884 | 1885 | if ( ! function_exists( 'tgmpa' ) ) { 1886 | /** 1887 | * Helper function to register a collection of required plugins. 1888 | * 1889 | * @since 2.0.0 1890 | * @api 1891 | * 1892 | * @param array $plugins An array of plugin arrays. 1893 | * @param array $config Optional. An array of configuration values. 1894 | */ 1895 | function tgmpa( $plugins, $config = array() ) { 1896 | $instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); 1897 | 1898 | foreach ( $plugins as $plugin ) { 1899 | call_user_func( array( $instance, 'register' ), $plugin ); 1900 | } 1901 | 1902 | if ( ! empty( $config ) && is_array( $config ) ) { 1903 | call_user_func( array( $instance, 'config' ), $config ); 1904 | } 1905 | } 1906 | } 1907 | 1908 | /** 1909 | * WP_List_Table isn't always available. If it isn't available, 1910 | * we load it here. 1911 | * 1912 | * @since 2.2.0 1913 | */ 1914 | if ( ! class_exists( 'WP_List_Table' ) ) { 1915 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; 1916 | } 1917 | 1918 | if ( ! class_exists( 'TGMPA_List_Table' ) ) { 1919 | 1920 | /** 1921 | * List table class for handling plugins. 1922 | * 1923 | * Extends the WP_List_Table class to provide a future-compatible 1924 | * way of listing out all required/recommended plugins. 1925 | * 1926 | * Gives users an interface similar to the Plugin Administration 1927 | * area with similar (albeit stripped down) capabilities. 1928 | * 1929 | * This class also allows for the bulk install of plugins. 1930 | * 1931 | * @since 2.2.0 1932 | * 1933 | * @package TGM-Plugin-Activation 1934 | * @author Thomas Griffin 1935 | * @author Gary Jones 1936 | */ 1937 | class TGMPA_List_Table extends WP_List_Table { 1938 | /** 1939 | * TGMPA instance. 1940 | * 1941 | * @since 2.5.0 1942 | * 1943 | * @var object 1944 | */ 1945 | protected $tgmpa; 1946 | 1947 | /** 1948 | * The currently chosen view. 1949 | * 1950 | * @since 2.5.0 1951 | * 1952 | * @var string One of: 'all', 'install', 'update', 'activate' 1953 | */ 1954 | public $view_context = 'all'; 1955 | 1956 | /** 1957 | * The plugin counts for the various views. 1958 | * 1959 | * @since 2.5.0 1960 | * 1961 | * @var array 1962 | */ 1963 | protected $view_totals = array( 1964 | 'all' => 0, 1965 | 'install' => 0, 1966 | 'update' => 0, 1967 | 'activate' => 0, 1968 | ); 1969 | 1970 | /** 1971 | * References parent constructor and sets defaults for class. 1972 | * 1973 | * @since 2.2.0 1974 | */ 1975 | public function __construct() { 1976 | $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); 1977 | 1978 | parent::__construct( 1979 | array( 1980 | 'singular' => 'plugin', 1981 | 'plural' => 'plugins', 1982 | 'ajax' => false, 1983 | ) 1984 | ); 1985 | 1986 | if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'install', 'update', 'activate' ), true ) ) { 1987 | $this->view_context = sanitize_key( $_REQUEST['plugin_status'] ); 1988 | } 1989 | 1990 | add_filter( 'tgmpa_table_data_items', array( $this, 'sort_table_items' ) ); 1991 | } 1992 | 1993 | /** 1994 | * Get a list of CSS classes for the tag. 1995 | * 1996 | * Overruled to prevent the 'plural' argument from being added. 1997 | * 1998 | * @since 2.5.0 1999 | * 2000 | * @return array CSS classnames. 2001 | */ 2002 | public function get_table_classes() { 2003 | return array( 'widefat', 'fixed' ); 2004 | } 2005 | 2006 | /** 2007 | * Gathers and renames all of our plugin information to be used by WP_List_Table to create our table. 2008 | * 2009 | * @since 2.2.0 2010 | * 2011 | * @return array $table_data Information for use in table. 2012 | */ 2013 | protected function _gather_plugin_data() { 2014 | // Load thickbox for plugin links. 2015 | $this->tgmpa->admin_init(); 2016 | $this->tgmpa->thickbox(); 2017 | 2018 | // Categorize the plugins which have open actions. 2019 | $plugins = $this->categorize_plugins_to_views(); 2020 | 2021 | // Set the counts for the view links. 2022 | $this->set_view_totals( $plugins ); 2023 | 2024 | // Prep variables for use and grab list of all installed plugins. 2025 | $table_data = array(); 2026 | $i = 0; 2027 | 2028 | // Redirect to the 'all' view if no plugins were found for the selected view context. 2029 | if ( empty( $plugins[ $this->view_context ] ) ) { 2030 | $this->view_context = 'all'; 2031 | } 2032 | 2033 | foreach ( $plugins[ $this->view_context ] as $slug => $plugin ) { 2034 | $table_data[ $i ]['sanitized_plugin'] = $plugin['name']; 2035 | $table_data[ $i ]['slug'] = $slug; 2036 | $table_data[ $i ]['plugin'] = '' . $this->tgmpa->get_info_link( $slug ) . ''; 2037 | $table_data[ $i ]['source'] = $this->get_plugin_source_type_text( $plugin['source_type'] ); 2038 | $table_data[ $i ]['type'] = $this->get_plugin_advise_type_text( $plugin['required'] ); 2039 | $table_data[ $i ]['status'] = $this->get_plugin_status_text( $slug ); 2040 | $table_data[ $i ]['installed_version'] = $this->tgmpa->get_installed_version( $slug ); 2041 | $table_data[ $i ]['minimum_version'] = $plugin['version']; 2042 | $table_data[ $i ]['available_version'] = $this->tgmpa->does_plugin_have_update( $slug ); 2043 | 2044 | // Prep the upgrade notice info. 2045 | $upgrade_notice = $this->tgmpa->get_upgrade_notice( $slug ); 2046 | if ( ! empty( $upgrade_notice ) ) { 2047 | $table_data[ $i ]['upgrade_notice'] = $upgrade_notice; 2048 | 2049 | add_action( "tgmpa_after_plugin_row_$slug", array( $this, 'wp_plugin_update_row' ), 10, 2 ); 2050 | } 2051 | 2052 | $table_data[ $i ] = apply_filters( 'tgmpa_table_data_item', $table_data[ $i ], $plugin ); 2053 | 2054 | $i++; 2055 | } 2056 | 2057 | return $table_data; 2058 | } 2059 | 2060 | /** 2061 | * Categorize the plugins which have open actions into views for the TGMPA page. 2062 | * 2063 | * @since 2.5.0 2064 | */ 2065 | protected function categorize_plugins_to_views() { 2066 | $plugins = array( 2067 | 'all' => array(), // Meaning: all plugins which still have open actions. 2068 | 'install' => array(), 2069 | 'update' => array(), 2070 | 'activate' => array(), 2071 | ); 2072 | 2073 | foreach ( $this->tgmpa->plugins as $slug => $plugin ) { 2074 | if ( $this->tgmpa->is_plugin_active( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { 2075 | // No need to display plugins if they are installed, up-to-date and active. 2076 | continue; 2077 | } else { 2078 | $plugins['all'][ $slug ] = $plugin; 2079 | 2080 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { 2081 | $plugins['install'][ $slug ] = $plugin; 2082 | } else { 2083 | if ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { 2084 | $plugins['update'][ $slug ] = $plugin; 2085 | } 2086 | 2087 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { 2088 | $plugins['activate'][ $slug ] = $plugin; 2089 | } 2090 | } 2091 | } 2092 | } 2093 | 2094 | return $plugins; 2095 | } 2096 | 2097 | /** 2098 | * Set the counts for the view links. 2099 | * 2100 | * @since 2.5.0 2101 | * 2102 | * @param array $plugins Plugins order by view. 2103 | */ 2104 | protected function set_view_totals( $plugins ) { 2105 | foreach ( $plugins as $type => $list ) { 2106 | $this->view_totals[ $type ] = count( $list ); 2107 | } 2108 | } 2109 | 2110 | /** 2111 | * Get the plugin required/recommended text string. 2112 | * 2113 | * @since 2.5.0 2114 | * 2115 | * @param string $required Plugin required setting. 2116 | * @return string 2117 | */ 2118 | protected function get_plugin_advise_type_text( $required ) { 2119 | if ( true === $required ) { 2120 | return __( 'Required', 'tgmpa' ); 2121 | } 2122 | 2123 | return __( 'Recommended', 'tgmpa' ); 2124 | } 2125 | 2126 | /** 2127 | * Get the plugin source type text string. 2128 | * 2129 | * @since 2.5.0 2130 | * 2131 | * @param string $type Plugin type. 2132 | * @return string 2133 | */ 2134 | protected function get_plugin_source_type_text( $type ) { 2135 | $string = ''; 2136 | 2137 | switch ( $type ) { 2138 | case 'repo': 2139 | $string = __( 'WordPress Repository', 'tgmpa' ); 2140 | break; 2141 | case 'external': 2142 | $string = __( 'External Source', 'tgmpa' ); 2143 | break; 2144 | case 'bundled': 2145 | $string = __( 'Pre-Packaged', 'tgmpa' ); 2146 | break; 2147 | } 2148 | 2149 | return $string; 2150 | } 2151 | 2152 | /** 2153 | * Determine the plugin status message. 2154 | * 2155 | * @since 2.5.0 2156 | * 2157 | * @param string $slug Plugin slug. 2158 | * @return string 2159 | */ 2160 | protected function get_plugin_status_text( $slug ) { 2161 | if ( ! $this->tgmpa->is_plugin_installed( $slug ) ) { 2162 | return __( 'Not Installed', 'tgmpa' ); 2163 | } 2164 | 2165 | if ( ! $this->tgmpa->is_plugin_active( $slug ) ) { 2166 | $install_status = __( 'Installed But Not Activated', 'tgmpa' ); 2167 | } else { 2168 | $install_status = __( 'Active', 'tgmpa' ); 2169 | } 2170 | 2171 | $update_status = ''; 2172 | 2173 | if ( $this->tgmpa->does_plugin_require_update( $slug ) && false === $this->tgmpa->does_plugin_have_update( $slug ) ) { 2174 | $update_status = __( 'Required Update not Available', 'tgmpa' ); 2175 | 2176 | } elseif ( $this->tgmpa->does_plugin_require_update( $slug ) ) { 2177 | $update_status = __( 'Requires Update', 'tgmpa' ); 2178 | 2179 | } elseif ( false !== $this->tgmpa->does_plugin_have_update( $slug ) ) { 2180 | $update_status = __( 'Update recommended', 'tgmpa' ); 2181 | } 2182 | 2183 | if ( '' === $update_status ) { 2184 | return $install_status; 2185 | } 2186 | 2187 | return sprintf( 2188 | _x( '%1$s, %2$s', '%1$s = install status, %2$s = update status', 'tgmpa' ), 2189 | $install_status, 2190 | $update_status 2191 | ); 2192 | } 2193 | 2194 | /** 2195 | * Sort plugins by Required/Recommended type and by alphabetical plugin name within each type. 2196 | * 2197 | * @since 2.5.0 2198 | * 2199 | * @param array $items Prepared table items. 2200 | * @return array Sorted table items. 2201 | */ 2202 | public function sort_table_items( $items ) { 2203 | $type = array(); 2204 | $name = array(); 2205 | 2206 | foreach ( $items as $i => $plugin ) { 2207 | $type[ $i ] = $plugin['type']; // Required / recommended. 2208 | $name[ $i ] = $plugin['sanitized_plugin']; 2209 | } 2210 | 2211 | array_multisort( $type, SORT_DESC, $name, SORT_ASC, $items ); 2212 | 2213 | return $items; 2214 | } 2215 | 2216 | /** 2217 | * Get an associative array ( id => link ) of the views available on this table. 2218 | * 2219 | * @since 2.5.0 2220 | * 2221 | * @return array 2222 | */ 2223 | public function get_views() { 2224 | $status_links = array(); 2225 | 2226 | foreach ( $this->view_totals as $type => $count ) { 2227 | if ( $count < 1 ) { 2228 | continue; 2229 | } 2230 | 2231 | switch ( $type ) { 2232 | case 'all': 2233 | $text = _nx( 'All (%s)', 'All (%s)', $count, 'plugins', 'tgmpa' ); 2234 | break; 2235 | case 'install': 2236 | $text = _n( 'To Install (%s)', 'To Install (%s)', $count, 'tgmpa' ); 2237 | break; 2238 | case 'update': 2239 | $text = _n( 'Update Available (%s)', 'Update Available (%s)', $count, 'tgmpa' ); 2240 | break; 2241 | case 'activate': 2242 | $text = _n( 'To Activate (%s)', 'To Activate (%s)', $count, 'tgmpa' ); 2243 | break; 2244 | default: 2245 | $text = ''; 2246 | break; 2247 | } 2248 | 2249 | if ( ! empty( $text ) ) { 2250 | 2251 | $status_links[ $type ] = sprintf( 2252 | '%s', 2253 | esc_url( $this->tgmpa->get_tgmpa_status_url( $type ) ), 2254 | ( $type === $this->view_context ) ? ' class="current"' : '', 2255 | sprintf( $text, number_format_i18n( $count ) ) 2256 | ); 2257 | } 2258 | } 2259 | 2260 | return $status_links; 2261 | } 2262 | 2263 | /** 2264 | * Create default columns to display important plugin information 2265 | * like type, action and status. 2266 | * 2267 | * @since 2.2.0 2268 | * 2269 | * @param array $item Array of item data. 2270 | * @param string $column_name The name of the column. 2271 | * @return string 2272 | */ 2273 | public function column_default( $item, $column_name ) { 2274 | return $item[ $column_name ]; 2275 | } 2276 | 2277 | /** 2278 | * Required for bulk installing. 2279 | * 2280 | * Adds a checkbox for each plugin. 2281 | * 2282 | * @since 2.2.0 2283 | * 2284 | * @param array $item Array of item data. 2285 | * @return string The input checkbox with all necessary info. 2286 | */ 2287 | public function column_cb( $item ) { 2288 | return sprintf( 2289 | '', 2290 | esc_attr( $this->_args['singular'] ), 2291 | esc_attr( $item['slug'] ), 2292 | esc_attr( $item['sanitized_plugin'] ) 2293 | ); 2294 | } 2295 | 2296 | /** 2297 | * Create default title column along with the action links. 2298 | * 2299 | * @since 2.2.0 2300 | * 2301 | * @param array $item Array of item data. 2302 | * @return string The plugin name and action links. 2303 | */ 2304 | public function column_plugin( $item ) { 2305 | return sprintf( 2306 | '%1$s %2$s', 2307 | $item['plugin'], 2308 | $this->row_actions( $this->get_row_actions( $item ), true ) 2309 | ); 2310 | } 2311 | 2312 | /** 2313 | * Create version information column. 2314 | * 2315 | * @since 2.5.0 2316 | * 2317 | * @param array $item Array of item data. 2318 | * @return string HTML-formatted version information. 2319 | */ 2320 | public function column_version( $item ) { 2321 | $output = array(); 2322 | 2323 | if ( $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { 2324 | $installed = ! empty( $item['installed_version'] ) ? $item['installed_version'] : _x( 'unknown', 'as in: "version nr unknown"', 'tgmpa' ); 2325 | 2326 | $color = ''; 2327 | if ( ! empty( $item['minimum_version'] ) && $this->tgmpa->does_plugin_require_update( $item['slug'] ) ) { 2328 | $color = ' color: #ff0000; font-weight: bold;'; 2329 | } 2330 | 2331 | $output[] = sprintf( 2332 | '

%2$s' . __( 'Installed version:', 'tgmpa' ) . '

', 2333 | $color, 2334 | $installed 2335 | ); 2336 | } 2337 | 2338 | if ( ! empty( $item['minimum_version'] ) ) { 2339 | $output[] = sprintf( 2340 | '

%1$s' . __( 'Minimum required version:', 'tgmpa' ) . '

', 2341 | $item['minimum_version'] 2342 | ); 2343 | } 2344 | 2345 | if ( ! empty( $item['available_version'] ) ) { 2346 | $color = ''; 2347 | if ( ! empty( $item['minimum_version'] ) && version_compare( $item['available_version'], $item['minimum_version'], '>=' ) ) { 2348 | $color = ' color: #71C671; font-weight: bold;'; 2349 | } 2350 | 2351 | $output[] = sprintf( 2352 | '

%2$s' . __( 'Available version:', 'tgmpa' ) . '

', 2353 | $color, 2354 | $item['available_version'] 2355 | ); 2356 | } 2357 | 2358 | if ( empty( $output ) ) { 2359 | return ' '; // Let's not break the table layout. 2360 | } else { 2361 | return implode( "\n", $output ); 2362 | } 2363 | } 2364 | 2365 | /** 2366 | * Sets default message within the plugins table if no plugins 2367 | * are left for interaction. 2368 | * 2369 | * Hides the menu item to prevent the user from clicking and 2370 | * getting a permissions error. 2371 | * 2372 | * @since 2.2.0 2373 | */ 2374 | public function no_items() { 2375 | printf( wp_kses_post( __( 'No plugins to install, update or activate. Return to the Dashboard', 'tgmpa' ) ), esc_url( self_admin_url() ) ); 2376 | echo ''; 2377 | } 2378 | 2379 | /** 2380 | * Output all the column information within the table. 2381 | * 2382 | * @since 2.2.0 2383 | * 2384 | * @return array $columns The column names. 2385 | */ 2386 | public function get_columns() { 2387 | $columns = array( 2388 | 'cb' => '', 2389 | 'plugin' => __( 'Plugin', 'tgmpa' ), 2390 | 'source' => __( 'Source', 'tgmpa' ), 2391 | 'type' => __( 'Type', 'tgmpa' ), 2392 | ); 2393 | 2394 | if ( 'all' === $this->view_context || 'update' === $this->view_context ) { 2395 | $columns['version'] = __( 'Version', 'tgmpa' ); 2396 | $columns['status'] = __( 'Status', 'tgmpa' ); 2397 | } 2398 | 2399 | return apply_filters( 'tgmpa_table_columns', $columns ); 2400 | } 2401 | 2402 | /** 2403 | * Get name of default primary column 2404 | * 2405 | * @since 2.5.0 / WP 4.3+ compatibility 2406 | * @access protected 2407 | * 2408 | * @return string 2409 | */ 2410 | protected function get_default_primary_column_name() { 2411 | return 'plugin'; 2412 | } 2413 | 2414 | /** 2415 | * Get the name of the primary column. 2416 | * 2417 | * @since 2.5.0 / WP 4.3+ compatibility 2418 | * @access protected 2419 | * 2420 | * @return string The name of the primary column. 2421 | */ 2422 | protected function get_primary_column_name() { 2423 | if ( method_exists( 'WP_List_Table', 'get_primary_column_name' ) ) { 2424 | return parent::get_primary_column_name(); 2425 | } else { 2426 | return $this->get_default_primary_column_name(); 2427 | } 2428 | } 2429 | 2430 | /** 2431 | * Get the actions which are relevant for a specific plugin row. 2432 | * 2433 | * @since 2.5.0 2434 | * 2435 | * @param array $item Array of item data. 2436 | * @return array Array with relevant action links. 2437 | */ 2438 | protected function get_row_actions( $item ) { 2439 | $actions = array(); 2440 | $action_links = array(); 2441 | 2442 | // Display the 'Install' action link if the plugin is not yet available. 2443 | if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) { 2444 | $actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); 2445 | } else { 2446 | // Display the 'Update' action link if an update is available and WP complies with plugin minimum. 2447 | if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) { 2448 | $actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); 2449 | } 2450 | 2451 | // Display the 'Activate' action link, but only if the plugin meets the minimum version. 2452 | if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) { 2453 | $actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' ); 2454 | } 2455 | } 2456 | 2457 | // Create the actual links. 2458 | foreach ( $actions as $action => $text ) { 2459 | $nonce_url = wp_nonce_url( 2460 | add_query_arg( 2461 | array( 2462 | 'plugin' => urlencode( $item['slug'] ), 2463 | 'tgmpa-' . $action => $action . '-plugin', 2464 | ), 2465 | $this->tgmpa->get_tgmpa_url() 2466 | ), 2467 | 'tgmpa-' . $action, 2468 | 'tgmpa-nonce' 2469 | ); 2470 | 2471 | $action_links[ $action ] = sprintf( 2472 | '' . esc_html( $text ) . '', 2473 | esc_url( $nonce_url ), 2474 | '' . esc_html( $item['sanitized_plugin'] ) . '' 2475 | ); 2476 | } 2477 | 2478 | $prefix = ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) ? 'network_admin_' : ''; 2479 | return apply_filters( "tgmpa_{$prefix}plugin_action_links", array_filter( $action_links ), $item['slug'], $item, $this->view_context ); 2480 | } 2481 | 2482 | /** 2483 | * Generates content for a single row of the table. 2484 | * 2485 | * @since 2.5.0 2486 | * 2487 | * @param object $item The current item. 2488 | */ 2489 | public function single_row( $item ) { 2490 | parent::single_row( $item ); 2491 | 2492 | /** 2493 | * Fires after each specific row in the TGMPA Plugins list table. 2494 | * 2495 | * The dynamic portion of the hook name, `$item['slug']`, refers to the slug 2496 | * for the plugin. 2497 | * 2498 | * @since 2.5.0 2499 | */ 2500 | do_action( "tgmpa_after_plugin_row_{$item['slug']}", $item['slug'], $item, $this->view_context ); 2501 | } 2502 | 2503 | /** 2504 | * Show the upgrade notice below a plugin row if there is one. 2505 | * 2506 | * @since 2.5.0 2507 | * 2508 | * @see /wp-admin/includes/update.php 2509 | * 2510 | * @param string $slug Plugin slug. 2511 | * @param array $item The information available in this table row. 2512 | * @return null Return early if upgrade notice is empty. 2513 | */ 2514 | public function wp_plugin_update_row( $slug, $item ) { 2515 | if ( empty( $item['upgrade_notice'] ) ) { 2516 | return; 2517 | } 2518 | 2519 | echo ' 2520 | 2521 | 2527 | '; 2528 | } 2529 | 2530 | /** 2531 | * Extra controls to be displayed between bulk actions and pagination. 2532 | * 2533 | * @since 2.5.0 2534 | * 2535 | * @param string $which 'top' or 'bottom' table navigation. 2536 | */ 2537 | public function extra_tablenav( $which ) { 2538 | if ( 'bottom' === $which ) { 2539 | $this->tgmpa->show_tgmpa_version(); 2540 | } 2541 | } 2542 | 2543 | /** 2544 | * Defines the bulk actions for handling registered plugins. 2545 | * 2546 | * @since 2.2.0 2547 | * 2548 | * @return array $actions The bulk actions for the plugin install table. 2549 | */ 2550 | public function get_bulk_actions() { 2551 | 2552 | $actions = array(); 2553 | 2554 | if ( 'update' !== $this->view_context && 'activate' !== $this->view_context ) { 2555 | if ( current_user_can( 'install_plugins' ) ) { 2556 | $actions['tgmpa-bulk-install'] = __( 'Install', 'tgmpa' ); 2557 | } 2558 | } 2559 | 2560 | if ( 'install' !== $this->view_context ) { 2561 | if ( current_user_can( 'update_plugins' ) ) { 2562 | $actions['tgmpa-bulk-update'] = __( 'Update', 'tgmpa' ); 2563 | } 2564 | if ( current_user_can( 'activate_plugins' ) ) { 2565 | $actions['tgmpa-bulk-activate'] = __( 'Activate', 'tgmpa' ); 2566 | } 2567 | } 2568 | 2569 | return $actions; 2570 | } 2571 | 2572 | /** 2573 | * Processes bulk installation and activation actions. 2574 | * 2575 | * The bulk installation process looks for the $_POST information and passes that 2576 | * through if a user has to use WP_Filesystem to enter their credentials. 2577 | * 2578 | * @since 2.2.0 2579 | */ 2580 | public function process_bulk_actions() { 2581 | // Bulk installation process. 2582 | if ( 'tgmpa-bulk-install' === $this->current_action() || 'tgmpa-bulk-update' === $this->current_action() ) { 2583 | 2584 | check_admin_referer( 'bulk-' . $this->_args['plural'] ); 2585 | 2586 | $install_type = 'install'; 2587 | if ( 'tgmpa-bulk-update' === $this->current_action() ) { 2588 | $install_type = 'update'; 2589 | } 2590 | 2591 | $plugins_to_install = array(); 2592 | 2593 | // Did user actually select any plugins to install/update ? 2594 | if ( empty( $_POST['plugin'] ) ) { 2595 | if ( 'install' === $install_type ) { 2596 | $message = __( 'No plugins were selected to be installed. No action taken.', 'tgmpa' ); 2597 | } else { 2598 | $message = __( 'No plugins were selected to be updated. No action taken.', 'tgmpa' ); 2599 | } 2600 | 2601 | echo '

', esc_html( $message ), '

'; 2602 | 2603 | return false; 2604 | } 2605 | 2606 | if ( is_array( $_POST['plugin'] ) ) { 2607 | $plugins_to_install = (array) $_POST['plugin']; 2608 | } elseif ( is_string( $_POST['plugin'] ) ) { 2609 | // Received via Filesystem page - un-flatten array (WP bug #19643). 2610 | $plugins_to_install = explode( ',', $_POST['plugin'] ); 2611 | } 2612 | 2613 | // Sanitize the received input. 2614 | $plugins_to_install = array_map( 'urldecode', $plugins_to_install ); 2615 | $plugins_to_install = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins_to_install ); 2616 | 2617 | // Validate the received input. 2618 | foreach ( $plugins_to_install as $key => $slug ) { 2619 | // Check if the plugin was registered with TGMPA and remove if not. 2620 | if ( ! isset( $this->tgmpa->plugins[ $slug ] ) ) { 2621 | unset( $plugins_to_install[ $key ] ); 2622 | continue; 2623 | } 2624 | 2625 | // For updates: make sure this is a plugin we *can* update (update available and WP version ok). 2626 | if ( 'update' === $install_type && ( $this->tgmpa->is_plugin_installed( $slug ) && ( false === $this->tgmpa->does_plugin_have_update( $slug ) || ! $this->tgmpa->can_plugin_update( $slug ) ) ) ) { 2627 | unset( $plugins_to_install[ $key ] ); 2628 | } 2629 | } 2630 | 2631 | // No need to proceed further if we have no plugins to handle. 2632 | if ( empty( $plugins_to_install ) ) { 2633 | if ( 'install' === $install_type ) { 2634 | $message = __( 'No plugins are available to be installed at this time.', 'tgmpa' ); 2635 | } else { 2636 | $message = __( 'No plugins are available to be updated at this time.', 'tgmpa' ); 2637 | } 2638 | 2639 | echo '

', esc_html( $message ), '

'; 2640 | 2641 | return false; 2642 | } 2643 | 2644 | // Pass all necessary information if WP_Filesystem is needed. 2645 | $url = wp_nonce_url( 2646 | $this->tgmpa->get_tgmpa_url(), 2647 | 'bulk-' . $this->_args['plural'] 2648 | ); 2649 | 2650 | // Give validated data back to $_POST which is the only place the filesystem looks for extra fields. 2651 | $_POST['plugin'] = implode( ',', $plugins_to_install ); // Work around for WP bug #19643. 2652 | 2653 | $method = ''; // Leave blank so WP_Filesystem can populate it as necessary. 2654 | $fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem. 2655 | 2656 | if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) { 2657 | return true; // Stop the normal page form from displaying, credential request form will be shown. 2658 | } 2659 | 2660 | // Now we have some credentials, setup WP_Filesystem. 2661 | if ( ! WP_Filesystem( $creds ) ) { 2662 | // Our credentials were no good, ask the user for them again. 2663 | request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields ); 2664 | 2665 | return true; 2666 | } 2667 | 2668 | /* If we arrive here, we have the filesystem */ 2669 | 2670 | // Store all information in arrays since we are processing a bulk installation. 2671 | $names = array(); 2672 | $sources = array(); // Needed for installs. 2673 | $file_paths = array(); // Needed for upgrades. 2674 | $to_inject = array(); // Information to inject into the update_plugins transient. 2675 | 2676 | // Prepare the data for validated plugins for the install/upgrade. 2677 | foreach ( $plugins_to_install as $slug ) { 2678 | $name = $this->tgmpa->plugins[ $slug ]['name']; 2679 | $source = $this->tgmpa->get_download_url( $slug ); 2680 | 2681 | if ( ! empty( $name ) && ! empty( $source ) ) { 2682 | $names[] = $name; 2683 | 2684 | switch ( $install_type ) { 2685 | 2686 | case 'install': 2687 | $sources[] = $source; 2688 | break; 2689 | 2690 | case 'update': 2691 | $file_paths[] = $this->tgmpa->plugins[ $slug ]['file_path']; 2692 | $to_inject[ $slug ] = $this->tgmpa->plugins[ $slug ]; 2693 | $to_inject[ $slug ]['source'] = $source; 2694 | break; 2695 | } 2696 | } 2697 | } 2698 | unset( $slug, $name, $source ); 2699 | 2700 | // Create a new instance of TGM_Bulk_Installer. 2701 | $installer = new TGM_Bulk_Installer( 2702 | new TGM_Bulk_Installer_Skin( 2703 | array( 2704 | 'url' => esc_url_raw( $this->tgmpa->get_tgmpa_url() ), 2705 | 'nonce' => 'bulk-' . $this->_args['plural'], 2706 | 'names' => $names, 2707 | 'install_type' => $install_type, 2708 | ) 2709 | ) 2710 | ); 2711 | 2712 | // Wrap the install process with the appropriate HTML. 2713 | echo '
', 2714 | '

', esc_html( get_admin_page_title() ), '

'; 2715 | 2716 | // Process the bulk installation submissions. 2717 | add_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); 2718 | 2719 | if ( 'tgmpa-bulk-update' === $this->current_action() ) { 2720 | // Inject our info into the update transient. 2721 | $this->tgmpa->inject_update_info( $to_inject ); 2722 | 2723 | $installer->bulk_upgrade( $file_paths ); 2724 | } else { 2725 | $installer->bulk_install( $sources ); 2726 | } 2727 | 2728 | remove_filter( 'upgrader_source_selection', array( $this->tgmpa, 'maybe_adjust_source_dir' ), 1, 3 ); 2729 | 2730 | echo '
'; 2731 | 2732 | return true; 2733 | } 2734 | 2735 | // Bulk activation process. 2736 | if ( 'tgmpa-bulk-activate' === $this->current_action() ) { 2737 | check_admin_referer( 'bulk-' . $this->_args['plural'] ); 2738 | 2739 | // Did user actually select any plugins to activate ? 2740 | if ( empty( $_POST['plugin'] ) ) { 2741 | echo '

', esc_html__( 'No plugins were selected to be activated. No action taken.', 'tgmpa' ), '

'; 2742 | 2743 | return false; 2744 | } 2745 | 2746 | // Grab plugin data from $_POST. 2747 | $plugins = array(); 2748 | if ( isset( $_POST['plugin'] ) ) { 2749 | $plugins = array_map( 'urldecode', (array) $_POST['plugin'] ); 2750 | $plugins = array_map( array( $this->tgmpa, 'sanitize_key' ), $plugins ); 2751 | } 2752 | 2753 | $plugins_to_activate = array(); 2754 | $plugin_names = array(); 2755 | 2756 | // Grab the file paths for the selected & inactive plugins from the registration array. 2757 | foreach ( $plugins as $slug ) { 2758 | if ( $this->tgmpa->can_plugin_activate( $slug ) ) { 2759 | $plugins_to_activate[] = $this->tgmpa->plugins[ $slug ]['file_path']; 2760 | $plugin_names[] = $this->tgmpa->plugins[ $slug ]['name']; 2761 | } 2762 | } 2763 | unset( $slug ); 2764 | 2765 | // Return early if there are no plugins to activate. 2766 | if ( empty( $plugins_to_activate ) ) { 2767 | echo '

', esc_html__( 'No plugins are available to be activated at this time.', 'tgmpa' ), '

'; 2768 | 2769 | return false; 2770 | } 2771 | 2772 | // Now we are good to go - let's start activating plugins. 2773 | $activate = activate_plugins( $plugins_to_activate ); 2774 | 2775 | if ( is_wp_error( $activate ) ) { 2776 | echo '

', wp_kses_post( $activate->get_error_message() ), '

'; 2777 | } else { 2778 | $count = count( $plugin_names ); // Count so we can use _n function. 2779 | $plugin_names = array_map( array( 'TGM_Utils', 'wrap_in_strong' ), $plugin_names ); 2780 | $last_plugin = array_pop( $plugin_names ); // Pop off last name to prep for readability. 2781 | $imploded = empty( $plugin_names ) ? $last_plugin : ( implode( ', ', $plugin_names ) . ' ' . esc_html_x( 'and', 'plugin A *and* plugin B', 'tgmpa' ) . ' ' . $last_plugin ); 2782 | 2783 | printf( // WPCS: xss ok. 2784 | '

%1$s %2$s.

', 2785 | esc_html( _n( 'The following plugin was activated successfully:', 'The following plugins were activated successfully:', $count, 'tgmpa' ) ), 2786 | $imploded 2787 | ); 2788 | 2789 | // Update recently activated plugins option. 2790 | $recent = (array) get_option( 'recently_activated' ); 2791 | foreach ( $plugins_to_activate as $plugin => $time ) { 2792 | if ( isset( $recent[ $plugin ] ) ) { 2793 | unset( $recent[ $plugin ] ); 2794 | } 2795 | } 2796 | update_option( 'recently_activated', $recent ); 2797 | } 2798 | 2799 | unset( $_POST ); // Reset the $_POST variable in case user wants to perform one action after another. 2800 | 2801 | return true; 2802 | } 2803 | 2804 | return false; 2805 | } 2806 | 2807 | /** 2808 | * Prepares all of our information to be outputted into a usable table. 2809 | * 2810 | * @since 2.2.0 2811 | */ 2812 | public function prepare_items() { 2813 | $columns = $this->get_columns(); // Get all necessary column information. 2814 | $hidden = array(); // No columns to hide, but we must set as an array. 2815 | $sortable = array(); // No reason to make sortable columns. 2816 | $primary = $this->get_primary_column_name(); // Column which has the row actions. 2817 | $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); // Get all necessary column headers. 2818 | 2819 | // Process our bulk activations here. 2820 | if ( 'tgmpa-bulk-activate' === $this->current_action() ) { 2821 | $this->process_bulk_actions(); 2822 | } 2823 | 2824 | // Store all of our plugin data into $items array so WP_List_Table can use it. 2825 | $this->items = apply_filters( 'tgmpa_table_data_items', $this->_gather_plugin_data() ); 2826 | } 2827 | 2828 | /* *********** DEPRECATED METHODS *********** */ 2829 | 2830 | /** 2831 | * Retrieve plugin data, given the plugin name. 2832 | * 2833 | * @since 2.2.0 2834 | * @deprecated 2.5.0 use {@see TGM_Plugin_Activation::_get_plugin_data_from_name()} instead. 2835 | * @see TGM_Plugin_Activation::_get_plugin_data_from_name() 2836 | * 2837 | * @param string $name Name of the plugin, as it was registered. 2838 | * @param string $data Optional. Array key of plugin data to return. Default is slug. 2839 | * @return string|boolean Plugin slug if found, false otherwise. 2840 | */ 2841 | protected function _get_plugin_data_from_name( $name, $data = 'slug' ) { 2842 | _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'TGM_Plugin_Activation::_get_plugin_data_from_name()' ); 2843 | 2844 | return $this->tgmpa->_get_plugin_data_from_name( $name, $data ); 2845 | } 2846 | } 2847 | } 2848 | 2849 | /** 2850 | * The WP_Upgrader file isn't always available. If it isn't available, 2851 | * we load it here. 2852 | * 2853 | * We check to make sure no action or activation keys are set so that WordPress 2854 | * does not try to re-include the class when processing upgrades or installs outside 2855 | * of the class. 2856 | * 2857 | * @since 2.2.0 2858 | */ 2859 | add_action( 'admin_init', 'tgmpa_load_bulk_installer' ); 2860 | if ( ! function_exists( 'tgmpa_load_bulk_installer' ) ) { 2861 | /** 2862 | * Load bulk installer 2863 | */ 2864 | function tgmpa_load_bulk_installer() { 2865 | // Get TGMPA class instance. 2866 | $tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); 2867 | 2868 | if ( isset( $_GET['page'] ) && $tgmpa_instance->menu === $_GET['page'] ) { 2869 | if ( ! class_exists( 'Plugin_Upgrader', false ) ) { 2870 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 2871 | } 2872 | 2873 | if ( ! class_exists( 'TGM_Bulk_Installer' ) ) { 2874 | 2875 | /** 2876 | * Installer class to handle bulk plugin installations. 2877 | * 2878 | * Extends WP_Upgrader and customizes to suit the installation of multiple 2879 | * plugins. 2880 | * 2881 | * @since 2.2.0 2882 | * 2883 | * @internal Since 2.5.0 the class is an extension of Plugin_Upgrader rather than WP_Upgrader 2884 | * 2885 | * @package TGM-Plugin-Activation 2886 | * @author Thomas Griffin 2887 | * @author Gary Jones 2888 | */ 2889 | class TGM_Bulk_Installer extends Plugin_Upgrader { 2890 | /** 2891 | * Holds result of bulk plugin installation. 2892 | * 2893 | * @since 2.2.0 2894 | * 2895 | * @var string 2896 | */ 2897 | public $result; 2898 | 2899 | /** 2900 | * Flag to check if bulk installation is occurring or not. 2901 | * 2902 | * @since 2.2.0 2903 | * 2904 | * @var boolean 2905 | */ 2906 | public $bulk = false; 2907 | 2908 | /** 2909 | * TGMPA instance 2910 | * 2911 | * @since 2.5.0 2912 | * 2913 | * @var object 2914 | */ 2915 | protected $tgmpa; 2916 | 2917 | /** 2918 | * Whether or not the destination directory needs to be cleared ( = on update). 2919 | * 2920 | * @since 2.5.0 2921 | * 2922 | * @var bool 2923 | */ 2924 | protected $clear_destination = false; 2925 | 2926 | /** 2927 | * References parent constructor and sets defaults for class. 2928 | * 2929 | * @since 2.2.0 2930 | * 2931 | * @param \Bulk_Upgrader_Skin|null $skin Installer skin. 2932 | */ 2933 | public function __construct( $skin = null ) { 2934 | // Get TGMPA class instance. 2935 | $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); 2936 | 2937 | parent::__construct( $skin ); 2938 | 2939 | if ( isset( $this->skin->options['install_type'] ) && 'update' === $this->skin->options['install_type'] ) { 2940 | $this->clear_destination = true; 2941 | } 2942 | 2943 | if ( $this->tgmpa->is_automatic ) { 2944 | $this->activate_strings(); 2945 | } 2946 | 2947 | add_action( 'upgrader_process_complete', array( $this->tgmpa, 'populate_file_path' ) ); 2948 | } 2949 | 2950 | /** 2951 | * Sets the correct activation strings for the installer skin to use. 2952 | * 2953 | * @since 2.2.0 2954 | */ 2955 | public function activate_strings() { 2956 | $this->strings['activation_failed'] = __( 'Plugin activation failed.', 'tgmpa' ); 2957 | $this->strings['activation_success'] = __( 'Plugin activated successfully.', 'tgmpa' ); 2958 | } 2959 | 2960 | /** 2961 | * Performs the actual installation of each plugin. 2962 | * 2963 | * @since 2.2.0 2964 | * 2965 | * @see WP_Upgrader::run() 2966 | * 2967 | * @param array $options The installation config options. 2968 | * @return null|array Return early if error, array of installation data on success. 2969 | */ 2970 | public function run( $options ) { 2971 | $result = parent::run( $options ); 2972 | 2973 | // Reset the strings in case we changed one during automatic activation. 2974 | if ( $this->tgmpa->is_automatic ) { 2975 | if ( 'update' === $this->skin->options['install_type'] ) { 2976 | $this->upgrade_strings(); 2977 | } else { 2978 | $this->install_strings(); 2979 | } 2980 | } 2981 | 2982 | return $result; 2983 | } 2984 | 2985 | /** 2986 | * Processes the bulk installation of plugins. 2987 | * 2988 | * @since 2.2.0 2989 | * 2990 | * @internal This is basically a near identical copy of the WP Core Plugin_Upgrader::bulk_upgrade() 2991 | * method, with minor adjustments to deal with new installs instead of upgrades. 2992 | * For ease of future synchronizations, the adjustments are clearly commented, but no other 2993 | * comments are added. Code style has been made to comply. 2994 | * 2995 | * @see Plugin_Upgrader::bulk_upgrade() 2996 | * @see https://core.trac.wordpress.org/browser/tags/4.2.1/src/wp-admin/includes/class-wp-upgrader.php#L838 2997 | * 2998 | * @param array $plugins The plugin sources needed for installation. 2999 | * @param array $args Arbitrary passed extra arguments. 3000 | * @return string|bool Install confirmation messages on success, false on failure. 3001 | */ 3002 | public function bulk_install( $plugins, $args = array() ) { 3003 | // [TGMPA + ] Hook auto-activation in. 3004 | add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); 3005 | 3006 | $defaults = array( 3007 | 'clear_update_cache' => true, 3008 | ); 3009 | $parsed_args = wp_parse_args( $args, $defaults ); 3010 | 3011 | $this->init(); 3012 | $this->bulk = true; 3013 | 3014 | $this->install_strings(); // [TGMPA + ] adjusted. 3015 | 3016 | /* [TGMPA - ] $current = get_site_transient( 'update_plugins' ); */ 3017 | 3018 | /* [TGMPA - ] add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); */ 3019 | 3020 | $this->skin->header(); 3021 | 3022 | // Connect to the Filesystem first. 3023 | $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); 3024 | if ( ! $res ) { 3025 | $this->skin->footer(); 3026 | 3027 | return false; 3028 | } 3029 | 3030 | $this->skin->bulk_header(); 3031 | 3032 | // Only start maintenance mode if: 3033 | // - running Multisite and there are one or more plugins specified, OR 3034 | // - a plugin with an update available is currently active. 3035 | // @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. 3036 | $maintenance = ( is_multisite() && ! empty( $plugins ) ); 3037 | 3038 | /* 3039 | [TGMPA - ] 3040 | foreach ( $plugins as $plugin ) 3041 | $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) ); 3042 | */ 3043 | if ( $maintenance ) { 3044 | $this->maintenance_mode( true ); 3045 | } 3046 | 3047 | $results = array(); 3048 | 3049 | $this->update_count = count( $plugins ); 3050 | $this->update_current = 0; 3051 | foreach ( $plugins as $plugin ) { 3052 | $this->update_current++; 3053 | 3054 | /* 3055 | [TGMPA - ] 3056 | $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); 3057 | 3058 | if ( !isset( $current->response[ $plugin ] ) ) { 3059 | $this->skin->set_result('up_to_date'); 3060 | $this->skin->before(); 3061 | $this->skin->feedback('up_to_date'); 3062 | $this->skin->after(); 3063 | $results[$plugin] = true; 3064 | continue; 3065 | } 3066 | 3067 | // Get the URL to the zip file 3068 | $r = $current->response[ $plugin ]; 3069 | 3070 | $this->skin->plugin_active = is_plugin_active($plugin); 3071 | */ 3072 | 3073 | $result = $this->run( array( 3074 | 'package' => $plugin, // [TGMPA + ] adjusted. 3075 | 'destination' => WP_PLUGIN_DIR, 3076 | 'clear_destination' => false, // [TGMPA + ] adjusted. 3077 | 'clear_working' => true, 3078 | 'is_multi' => true, 3079 | 'hook_extra' => array( 3080 | 'plugin' => $plugin, 3081 | ), 3082 | ) ); 3083 | 3084 | $results[ $plugin ] = $this->result; 3085 | 3086 | // Prevent credentials auth screen from displaying multiple times. 3087 | if ( false === $result ) { 3088 | break; 3089 | } 3090 | } //end foreach $plugins 3091 | 3092 | $this->maintenance_mode( false ); 3093 | 3094 | /** 3095 | * Fires when the bulk upgrader process is complete. 3096 | * 3097 | * @since WP 3.6.0 / TGMPA 2.5.0 3098 | * 3099 | * @param Plugin_Upgrader $this Plugin_Upgrader instance. In other contexts, $this, might 3100 | * be a Theme_Upgrader or Core_Upgrade instance. 3101 | * @param array $data { 3102 | * Array of bulk item update data. 3103 | * 3104 | * @type string $action Type of action. Default 'update'. 3105 | * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'. 3106 | * @type bool $bulk Whether the update process is a bulk update. Default true. 3107 | * @type array $packages Array of plugin, theme, or core packages to update. 3108 | * } 3109 | */ 3110 | do_action( 'upgrader_process_complete', $this, array( 3111 | 'action' => 'install', // [TGMPA + ] adjusted. 3112 | 'type' => 'plugin', 3113 | 'bulk' => true, 3114 | 'plugins' => $plugins, 3115 | ) ); 3116 | 3117 | $this->skin->bulk_footer(); 3118 | 3119 | $this->skin->footer(); 3120 | 3121 | // Cleanup our hooks, in case something else does a upgrade on this connection. 3122 | /* [TGMPA - ] remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); */ 3123 | 3124 | // [TGMPA + ] Remove our auto-activation hook. 3125 | remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); 3126 | 3127 | // Force refresh of plugin update information. 3128 | wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); 3129 | 3130 | return $results; 3131 | } 3132 | 3133 | /** 3134 | * Handle a bulk upgrade request. 3135 | * 3136 | * @since 2.5.0 3137 | * 3138 | * @see Plugin_Upgrader::bulk_upgrade() 3139 | * 3140 | * @param array $plugins The local WP file_path's of the plugins which should be upgraded. 3141 | * @param array $args Arbitrary passed extra arguments. 3142 | * @return string|bool Install confirmation messages on success, false on failure. 3143 | */ 3144 | public function bulk_upgrade( $plugins, $args = array() ) { 3145 | 3146 | add_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); 3147 | 3148 | $result = parent::bulk_upgrade( $plugins, $args ); 3149 | 3150 | remove_filter( 'upgrader_post_install', array( $this, 'auto_activate' ), 10 ); 3151 | 3152 | return $result; 3153 | } 3154 | 3155 | /** 3156 | * Abuse a filter to auto-activate plugins after installation. 3157 | * 3158 | * Hooked into the 'upgrader_post_install' filter hook. 3159 | * 3160 | * @since 2.5.0 3161 | * 3162 | * @param bool $bool The value we need to give back (true). 3163 | * @return bool 3164 | */ 3165 | public function auto_activate( $bool ) { 3166 | // Only process the activation of installed plugins if the automatic flag is set to true. 3167 | if ( $this->tgmpa->is_automatic ) { 3168 | // Flush plugins cache so the headers of the newly installed plugins will be read correctly. 3169 | wp_clean_plugins_cache(); 3170 | 3171 | // Get the installed plugin file. 3172 | $plugin_info = $this->plugin_info(); 3173 | 3174 | // Don't try to activate on upgrade of active plugin as WP will do this already. 3175 | if ( ! is_plugin_active( $plugin_info ) ) { 3176 | $activate = activate_plugin( $plugin_info ); 3177 | 3178 | // Adjust the success string based on the activation result. 3179 | $this->strings['process_success'] = $this->strings['process_success'] . "
\n"; 3180 | 3181 | if ( is_wp_error( $activate ) ) { 3182 | $this->skin->error( $activate ); 3183 | $this->strings['process_success'] .= $this->strings['activation_failed']; 3184 | } else { 3185 | $this->strings['process_success'] .= $this->strings['activation_success']; 3186 | } 3187 | } 3188 | } 3189 | 3190 | return $bool; 3191 | } 3192 | } 3193 | } 3194 | 3195 | if ( ! class_exists( 'TGM_Bulk_Installer_Skin' ) ) { 3196 | 3197 | /** 3198 | * Installer skin to set strings for the bulk plugin installations.. 3199 | * 3200 | * Extends Bulk_Upgrader_Skin and customizes to suit the installation of multiple 3201 | * plugins. 3202 | * 3203 | * @since 2.2.0 3204 | * 3205 | * @see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-upgrader-skins.php 3206 | * 3207 | * @package TGM-Plugin-Activation 3208 | * @author Thomas Griffin 3209 | * @author Gary Jones 3210 | */ 3211 | class TGM_Bulk_Installer_Skin extends Bulk_Upgrader_Skin { 3212 | /** 3213 | * Holds plugin info for each individual plugin installation. 3214 | * 3215 | * @since 2.2.0 3216 | * 3217 | * @var array 3218 | */ 3219 | public $plugin_info = array(); 3220 | 3221 | /** 3222 | * Holds names of plugins that are undergoing bulk installations. 3223 | * 3224 | * @since 2.2.0 3225 | * 3226 | * @var array 3227 | */ 3228 | public $plugin_names = array(); 3229 | 3230 | /** 3231 | * Integer to use for iteration through each plugin installation. 3232 | * 3233 | * @since 2.2.0 3234 | * 3235 | * @var integer 3236 | */ 3237 | public $i = 0; 3238 | 3239 | /** 3240 | * TGMPA instance 3241 | * 3242 | * @since 2.5.0 3243 | * 3244 | * @var object 3245 | */ 3246 | protected $tgmpa; 3247 | 3248 | /** 3249 | * Constructor. Parses default args with new ones and extracts them for use. 3250 | * 3251 | * @since 2.2.0 3252 | * 3253 | * @param array $args Arguments to pass for use within the class. 3254 | */ 3255 | public function __construct( $args = array() ) { 3256 | // Get TGMPA class instance. 3257 | $this->tgmpa = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) ); 3258 | 3259 | // Parse default and new args. 3260 | $defaults = array( 3261 | 'url' => '', 3262 | 'nonce' => '', 3263 | 'names' => array(), 3264 | 'install_type' => 'install', 3265 | ); 3266 | $args = wp_parse_args( $args, $defaults ); 3267 | 3268 | // Set plugin names to $this->plugin_names property. 3269 | $this->plugin_names = $args['names']; 3270 | 3271 | // Extract the new args. 3272 | parent::__construct( $args ); 3273 | } 3274 | 3275 | /** 3276 | * Sets install skin strings for each individual plugin. 3277 | * 3278 | * Checks to see if the automatic activation flag is set and uses the 3279 | * the proper strings accordingly. 3280 | * 3281 | * @since 2.2.0 3282 | */ 3283 | public function add_strings() { 3284 | if ( 'update' === $this->options['install_type'] ) { 3285 | parent::add_strings(); 3286 | $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); 3287 | } else { 3288 | $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while installing %1$s: %2$s.', 'tgmpa' ); 3289 | $this->upgrader->strings['skin_update_failed'] = __( 'The installation of %1$s failed.', 'tgmpa' ); 3290 | 3291 | if ( $this->tgmpa->is_automatic ) { 3292 | // Automatic activation strings. 3293 | $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation and activation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); 3294 | $this->upgrader->strings['skin_update_successful'] = __( '%1$s installed and activated successfully.', 'tgmpa' ) . ' ' . esc_html__( 'Show Details', 'tgmpa' ) . '.'; 3295 | $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations and activations have been completed.', 'tgmpa' ); 3296 | $this->upgrader->strings['skin_before_update_header'] = __( 'Installing and Activating Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); 3297 | } else { 3298 | // Default installation strings. 3299 | $this->upgrader->strings['skin_upgrade_start'] = __( 'The installation process is starting. This process may take a while on some hosts, so please be patient.', 'tgmpa' ); 3300 | $this->upgrader->strings['skin_update_successful'] = esc_html__( '%1$s installed successfully.', 'tgmpa' ) . ' ' . esc_html__( 'Show Details', 'tgmpa' ) . '.'; 3301 | $this->upgrader->strings['skin_upgrade_end'] = __( 'All installations have been completed.', 'tgmpa' ); 3302 | $this->upgrader->strings['skin_before_update_header'] = __( 'Installing Plugin %1$s (%2$d/%3$d)', 'tgmpa' ); 3303 | } 3304 | } 3305 | } 3306 | 3307 | /** 3308 | * Outputs the header strings and necessary JS before each plugin installation. 3309 | * 3310 | * @since 2.2.0 3311 | * 3312 | * @param string $title Unused in this implementation. 3313 | */ 3314 | public function before( $title = '' ) { 3315 | if ( empty( $title ) ) { 3316 | $title = esc_html( $this->plugin_names[ $this->i ] ); 3317 | } 3318 | parent::before( $title ); 3319 | } 3320 | 3321 | /** 3322 | * Outputs the footer strings and necessary JS after each plugin installation. 3323 | * 3324 | * Checks for any errors and outputs them if they exist, else output 3325 | * success strings. 3326 | * 3327 | * @since 2.2.0 3328 | * 3329 | * @param string $title Unused in this implementation. 3330 | */ 3331 | public function after( $title = '' ) { 3332 | if ( empty( $title ) ) { 3333 | $title = esc_html( $this->plugin_names[ $this->i ] ); 3334 | } 3335 | parent::after( $title ); 3336 | 3337 | $this->i++; 3338 | } 3339 | 3340 | /** 3341 | * Outputs links after bulk plugin installation is complete. 3342 | * 3343 | * @since 2.2.0 3344 | */ 3345 | public function bulk_footer() { 3346 | // Serve up the string to say installations (and possibly activations) are complete. 3347 | parent::bulk_footer(); 3348 | 3349 | // Flush plugins cache so we can make sure that the installed plugins list is always up to date. 3350 | wp_clean_plugins_cache(); 3351 | 3352 | $this->tgmpa->show_tgmpa_version(); 3353 | 3354 | // Display message based on if all plugins are now active or not. 3355 | $update_actions = array(); 3356 | 3357 | if ( $this->tgmpa->is_tgmpa_complete() ) { 3358 | // All plugins are active, so we display the complete string and hide the menu to protect users. 3359 | echo ''; 3360 | $update_actions['dashboard'] = sprintf( 3361 | esc_html( $this->tgmpa->strings['complete'] ), 3362 | '' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '' 3363 | ); 3364 | } else { 3365 | $update_actions['tgmpa_page'] = '' . esc_html( $this->tgmpa->strings['return'] ) . ''; 3366 | } 3367 | 3368 | /** 3369 | * Filter the list of action links available following bulk plugin installs/updates. 3370 | * 3371 | * @since 2.5.0 3372 | * 3373 | * @param array $update_actions Array of plugin action links. 3374 | * @param array $plugin_info Array of information for the last-handled plugin. 3375 | */ 3376 | $update_actions = apply_filters( 'tgmpa_update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info ); 3377 | 3378 | if ( ! empty( $update_actions ) ) { 3379 | $this->feedback( implode( ' | ', (array) $update_actions ) ); 3380 | } 3381 | } 3382 | 3383 | /* *********** DEPRECATED METHODS *********** */ 3384 | 3385 | /** 3386 | * Flush header output buffer. 3387 | * 3388 | * @since 2.2.0 3389 | * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead 3390 | * @see Bulk_Upgrader_Skin::flush_output() 3391 | */ 3392 | public function before_flush_output() { 3393 | _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); 3394 | $this->flush_output(); 3395 | } 3396 | 3397 | /** 3398 | * Flush footer output buffer and iterate $this->i to make sure the 3399 | * installation strings reference the correct plugin. 3400 | * 3401 | * @since 2.2.0 3402 | * @deprecated 2.5.0 use {@see Bulk_Upgrader_Skin::flush_output()} instead 3403 | * @see Bulk_Upgrader_Skin::flush_output() 3404 | */ 3405 | public function after_flush_output() { 3406 | _deprecated_function( __FUNCTION__, 'TGMPA 2.5.0', 'Bulk_Upgrader_Skin::flush_output()' ); 3407 | $this->flush_output(); 3408 | $this->i++; 3409 | } 3410 | } 3411 | } 3412 | } 3413 | } 3414 | } 3415 | 3416 | if ( ! class_exists( 'TGM_Utils' ) ) { 3417 | 3418 | /** 3419 | * Generic utilities for TGMPA. 3420 | * 3421 | * All methods are static, poor-dev name-spacing class wrapper. 3422 | * 3423 | * @since 2.5.0 3424 | * 3425 | * @package TGM-Plugin-Activation 3426 | * @author Juliette Reinders Folmer 3427 | */ 3428 | class TGM_Utils { 3429 | /** 3430 | * Whether the PHP filter extension is enabled. 3431 | * 3432 | * @see http://php.net/book.filter 3433 | * 3434 | * @since 2.5.0 3435 | * 3436 | * @static 3437 | * 3438 | * @var bool $has_filters True is the extension is enabled. 3439 | */ 3440 | public static $has_filters; 3441 | 3442 | /** 3443 | * Wrap an arbitrary string in tags. Meant to be used in combination with array_map(). 3444 | * 3445 | * @since 2.5.0 3446 | * 3447 | * @static 3448 | * 3449 | * @param string $string Text to be wrapped. 3450 | * @return string 3451 | */ 3452 | public static function wrap_in_em( $string ) { 3453 | return '' . wp_kses_post( $string ) . ''; 3454 | } 3455 | 3456 | /** 3457 | * Wrap an arbitrary string in tags. Meant to be used in combination with array_map(). 3458 | * 3459 | * @since 2.5.0 3460 | * 3461 | * @static 3462 | * 3463 | * @param string $string Text to be wrapped. 3464 | * @return string 3465 | */ 3466 | public static function wrap_in_strong( $string ) { 3467 | return '' . wp_kses_post( $string ) . ''; 3468 | } 3469 | 3470 | /** 3471 | * Helper function: Validate a value as boolean 3472 | * 3473 | * @since 2.5.0 3474 | * 3475 | * @static 3476 | * 3477 | * @param mixed $value Arbitrary value. 3478 | * @return bool 3479 | */ 3480 | public static function validate_bool( $value ) { 3481 | if ( ! isset( self::$has_filters ) ) { 3482 | self::$has_filters = extension_loaded( 'filter' ); 3483 | } 3484 | 3485 | if ( self::$has_filters ) { 3486 | return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); 3487 | } else { 3488 | return self::emulate_filter_bool( $value ); 3489 | } 3490 | } 3491 | 3492 | /** 3493 | * Helper function: Cast a value to bool 3494 | * 3495 | * @since 2.5.0 3496 | * 3497 | * @static 3498 | * 3499 | * @param mixed $value Value to cast. 3500 | * @return bool 3501 | */ 3502 | protected static function emulate_filter_bool( $value ) { 3503 | // @codingStandardsIgnoreStart 3504 | static $true = array( 3505 | '1', 3506 | 'true', 'True', 'TRUE', 3507 | 'y', 'Y', 3508 | 'yes', 'Yes', 'YES', 3509 | 'on', 'On', 'ON', 3510 | ); 3511 | static $false = array( 3512 | '0', 3513 | 'false', 'False', 'FALSE', 3514 | 'n', 'N', 3515 | 'no', 'No', 'NO', 3516 | 'off', 'Off', 'OFF', 3517 | ); 3518 | // @codingStandardsIgnoreEnd 3519 | 3520 | if ( is_bool( $value ) ) { 3521 | return $value; 3522 | } else if ( is_int( $value ) && ( 0 === $value || 1 === $value ) ) { 3523 | return (bool) $value; 3524 | } else if ( ( is_float( $value ) && ! is_nan( $value ) ) && ( (float) 0 === $value || (float) 1 === $value ) ) { 3525 | return (bool) $value; 3526 | } else if ( is_string( $value ) ) { 3527 | $value = trim( $value ); 3528 | if ( in_array( $value, $true, true ) ) { 3529 | return true; 3530 | } else if ( in_array( $value, $false, true ) ) { 3531 | return false; 3532 | } else { 3533 | return false; 3534 | } 3535 | } 3536 | 3537 | return false; 3538 | } 3539 | } // End of class TGM_Utils 3540 | } // End of class_exists wrapper 3541 | -------------------------------------------------------------------------------- /lib/theme-functions.php: -------------------------------------------------------------------------------- 1 | true ) ) as $type ) { 28 | if ( post_type_supports( $type, 'genesis-layouts' ) ) 29 | add_meta_box( 'genesis_inpost_layout_box', __( 'Layout Settings', 'genesis' ), 'genesis_inpost_layout_box', $type, 'normal', 'low' ); 30 | } 31 | } 32 | 33 | /** 34 | * Remove Dashboard Meta Boxes 35 | */ 36 | function mb_remove_dashboard_widgets() { 37 | global $wp_meta_boxes; 38 | // unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); 39 | unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); 40 | // unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); 41 | unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); 42 | // unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']); 43 | // unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); 44 | unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); 45 | unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); 46 | } 47 | 48 | /** 49 | * Change Admin Menu Order 50 | */ 51 | function mb_custom_menu_order( $menu_ord ) { 52 | if ( !$menu_ord ) return true; 53 | return array( 54 | // 'index.php', // Dashboard 55 | // 'separator1', // First separator 56 | // 'edit.php?post_type=page', // Pages 57 | // 'edit.php', // Posts 58 | // 'upload.php', // Media 59 | // 'gf_edit_forms', // Gravity Forms 60 | // 'genesis', // Genesis 61 | // 'edit-comments.php', // Comments 62 | // 'separator2', // Second separator 63 | // 'themes.php', // Appearance 64 | // 'plugins.php', // Plugins 65 | // 'users.php', // Users 66 | // 'tools.php', // Tools 67 | // 'options-general.php', // Settings 68 | // 'separator-last', // Last separator 69 | ); 70 | } 71 | 72 | /** 73 | * Hide Admin Areas that are not used 74 | */ 75 | function mb_remove_menu_pages() { 76 | // remove_menu_page('link-manager.php'); 77 | } 78 | 79 | /** 80 | * Remove default link for images 81 | */ 82 | function mb_imagelink_setup() { 83 | $image_set = get_option( 'image_default_link_type' ); 84 | if ($image_set !== 'none') { 85 | update_option( 'image_default_link_type', 'none' ); 86 | } 87 | } 88 | 89 | 90 | /**************************************** 91 | Frontend 92 | *****************************************/ 93 | 94 | /** 95 | * Load apple touch icon in header 96 | */ 97 | function mb_apple_touch_icon() { 98 | echo '' . "\n"; 99 | } 100 | 101 | /** 102 | * Footer 103 | */ 104 | function mb_footer() { 105 | echo ''; 106 | echo ''; 107 | } 108 | 109 | /** 110 | * Enqueue Script 111 | */ 112 | function mb_scripts() { 113 | if ( !is_admin() ) { 114 | // Custom plugins and scripts 115 | wp_enqueue_script( 'customplugins', get_stylesheet_directory_uri() . '/assets/js/plugins.min.js', array('jquery'), NULL, true ); 116 | wp_enqueue_script( 'customscripts', get_stylesheet_directory_uri() . '/assets/js/main.min.js', array('jquery'), NULL, true ); 117 | } 118 | } 119 | 120 | /** 121 | * Remove Query Strings From Static Resources 122 | */ 123 | function mb_remove_script_version( $src ){ 124 | $parts = explode( '?ver', $src ); 125 | return $parts[0]; 126 | } 127 | 128 | /** 129 | * Remove Read More Jump 130 | */ 131 | function mb_remove_more_jump_link( $link ) { 132 | $offset = strpos( $link, '#more-' ); 133 | if ($offset) { 134 | $end = strpos( $link, '"',$offset ); 135 | } 136 | if ($end) { 137 | $link = substr_replace( $link, '', $offset, $end-$offset ); 138 | } 139 | return $link; 140 | } 141 | 142 | /** 143 | * Define custom post type capabilities for use with Members 144 | */ 145 | function mb_add_post_type_caps() { 146 | // mb_add_capabilities( 'portfolio' ); 147 | } 148 | 149 | 150 | /**************************************** 151 | Misc Theme Functions 152 | *****************************************/ 153 | 154 | /** 155 | * Unregister the superfish scripts 156 | */ 157 | function mb_unregister_superfish() { 158 | wp_deregister_script( 'superfish' ); 159 | wp_deregister_script( 'superfish-args' ); 160 | } 161 | 162 | /** 163 | * Filter Yoast SEO Metabox Priority 164 | */ 165 | function mb_filter_yoast_seo_metabox() { 166 | return 'low'; 167 | } 168 | -------------------------------------------------------------------------------- /lib/theme-helpers.php: -------------------------------------------------------------------------------- 1 | add_cap( 'edit_' . $posttype . 's' ); 16 | $role->add_cap( 'edit_others_' . $posttype . 's' ); 17 | $role->add_cap( 'publish_' . $posttype . 's' ); 18 | $role->add_cap( 'read_private_' . $posttype . 's' ); 19 | $role->add_cap( 'delete_' . $posttype . 's' ); 20 | $role->add_cap( 'delete_private_' . $posttype . 's' ); 21 | $role->add_cap( 'delete_published_' . $posttype . 's' ); 22 | $role->add_cap( 'delete_others_' . $posttype . 's' ); 23 | $role->add_cap( 'edit_private_' . $posttype . 's' ); 24 | $role->add_cap( 'edit_published_' . $posttype . 's' ); 25 | } 26 | 27 | /** 28 | * Shortcode to display current year and company name for copyright 29 | */ 30 | function mb_shortcode_copyright() { 31 | $copyright = '© ' . date( 'Y' ) . ' ' . get_bloginfo( 'name' ); 32 | return $copyright; 33 | } 34 | add_shortcode( 'copyright', 'mb_shortcode_copyright' ); 35 | -------------------------------------------------------------------------------- /lib/theme-require-plugins.php: -------------------------------------------------------------------------------- 1 | 'WordPress SEO by Yoast', 12 | 'slug' => 'wordpress-seo', 13 | 'required' => true, 14 | 'force_activation' => true 15 | ), 16 | 17 | array( 18 | 'name' => 'Pods - Custom Content Types and Fields', 19 | 'slug' => 'pods', 20 | 'required' => true, 21 | 'force_activation' => true 22 | ), 23 | 24 | array( 25 | 'name' => 'Google Analytics for WordPress', 26 | 'slug' => 'google-analytics-for-wordpress', 27 | 'required' => true, 28 | 'force_activation' => true 29 | ), 30 | 31 | ); 32 | 33 | /** 34 | * Array of configuration settings. Amend each line as needed. 35 | * If you want the default strings to be available under your own theme domain, 36 | * leave the strings uncommented. 37 | * Some of the strings are added into a sprintf, so see the comments at the 38 | * end of each line for what each argument will be. 39 | */ 40 | $config = array( 41 | 'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA. 42 | 'default_path' => '', // Default absolute path to pre-packaged plugins. 43 | 'menu' => 'tgmpa-install-plugins', // Menu slug. 44 | 'has_notices' => true, // Show admin notices or not. 45 | 'dismissable' => true, // If false, a user cannot dismiss the nag message. 46 | 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 47 | 'is_automatic' => false, // Automatically activate plugins after installation or not. 48 | 'message' => '', // Message to output right before the plugins table. 49 | 'strings' => array( 50 | 'page_title' => __( 'Install Required Plugins', 'tgmpa' ), 51 | 'menu_title' => __( 'Install Plugins', 'tgmpa' ), 52 | 'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), // %s = plugin name. 53 | 'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ), 54 | 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'tgmpa' ), // %1$s = plugin name(s). 55 | 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'tgmpa' ), // %1$s = plugin name(s). 56 | 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'tgmpa' ), // %1$s = plugin name(s). 57 | 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'tgmpa' ), // %1$s = plugin name(s). 58 | 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'tgmpa' ), // %1$s = plugin name(s). 59 | 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'tgmpa' ), // %1$s = plugin name(s). 60 | 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'tgmpa' ), // %1$s = plugin name(s). 61 | 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'tgmpa' ), // %1$s = plugin name(s). 62 | 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'tgmpa' ), 63 | 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'tgmpa' ), 64 | 'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ), 65 | 'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ), 66 | 'complete' => __( 'All plugins installed and activated successfully. %s', 'tgmpa' ), // %s = dashboard link. 67 | 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'. 68 | ) 69 | ); 70 | 71 | tgmpa( $plugins, $config ); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /lib/theme-views.php: -------------------------------------------------------------------------------- 1 |
2522 |
', 2523 | esc_html__( 'Upgrade message from the plugin author:', 'tgmpa' ), 2524 | ' ', wp_kses_data( $item['upgrade_notice'] ), ' 2525 |
2526 |