diff --git a/02-Download.md b/02-Download.md index 74015c61..ebcbd54f 100644 --- a/02-Download.md +++ b/02-Download.md @@ -8,11 +8,11 @@ permalink: /download/ The latest stable release is version {{ site.tgmpa.version }}. -[![Download the zip file]({{ site.tgmpa.zipimage }}){: style="width: 100px;"}]({{ site.tgmpa.github }}/archive/{{ site.tgmpa.version }}.zip){:.latest-zip} [![Download the tarball file]({{ site.tgmpa.tarimage }}){: style="width: 100px;"}]({{ site.tgmpa.github }}/archive/{{ site.tgmpa.version }}.tar.gz){:.latest-tar} -You can also download your own package (such as the development version) [on GitHub]. +{% include generator-form.html %} +You can also download the official latest release as [zipfile]({{ site.tgmpa.github }}/archive/{{ site.tgmpa.version }}.zip){:.latest-zip} or [tarball]({{ site.tgmpa.github }}/archive/{{ site.tgmpa.version }}.tar.gz){:.latest-tar} or download your own package - such as the development version - [on GitHub]. ##### Older versions diff --git a/03-Installation.md b/03-Installation.md index a745f827..b0c0bf32 100644 --- a/03-Installation.md +++ b/03-Installation.md @@ -9,25 +9,25 @@ permalink: /installation/ Installing the **{{ site.tgmpa.name }}** library is easy. Follow the instructions below: -1. [Download] the latest release. +1. [Download] the latest release, preferably using the _**[Custom TGMPA Generator]**_. 2. Drop the class file somewhere in your theme or plugin hierarchy. 3. Add a `require_once` call within `functions.php` (or other theme or plugin file) referencing the class file. 4. Create a function, hooked to `tgmpa_register`, that registers the plugin and configurations. - For steps 3 and 4, it is **_strongly recommended_** you view, copy and paste the contents of the `example.php` file which is included in the release package and amend to suit. The `example.php` file is a model for how you should include the class in your theme. Some important things to note: -1. With the `require_once` call, make sure to amend the path to the correct location within your theme. +1. With the `require_once` call, make sure to amend the path to the correct location within your theme/plugin. 2. For plugins pulled from the .org repo, the `source` argument is optional. Otherwise it is required and should point to the absolute path for the plugin zips within your theme, or to a URL for zips elsewhere online. 3. Updating bundled plugins will _only_ work if you provide a `version` argument for the plugin where the value of that argument is the version number of the new version included. 4. The `$config` variable holds an array of arguments that can be used to customize aspects of the class. If you define an absolute `default_path` for bundled plugins, you do not need to specify the directory path for your bundled plugin within the `source` argument. You will only need to specify the zip file name. -5. Only add the `strings` array in the `$config` variable if you want to change the text strings. Remove them to use the default TGMPA text strings and translations. If you _do_ add your own text strings, make sure you change the text domain (`theme-slug`) to the text domain of your theme or plugin. +5. Only add the `strings` array in the `$config` variable if you want to change the text strings. Remove them to use the default TGMPA text strings and translations. If you _do_ add your own text strings, make sure you change the text domain (`theme-slug`) to the text domain of your theme or plugin if you didn't download your package via the [Custom TGMPA Generator]. Continue reading about the [Configuration options]. +[Custom TGMPA Generator]: {{ '/download/' | prepend: site.tgmpa.url }} [Download]: {{ '/download/' | prepend: site.tgmpa.url }} [Configuration options]: {{ '/configuration/' | prepend: site.tgmpa.url }} diff --git a/07-Roadmap.md b/07-Roadmap.md index dd6b1ec1..f97c4f12 100644 --- a/07-Roadmap.md +++ b/07-Roadmap.md @@ -12,7 +12,7 @@ permalink: /roadmap/ * Improved UI by having the admin page always in the same location * Updatability of TGMPA independently of the plugin/theme which ships it * Show dependencies more clearly -* Provide translations of the TGMPA strings under own text-domain. + ##### For more detailed information: diff --git a/README.md b/README.md index 33912ae7..0f24068d 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,18 @@ fork with a subdomain (e.g. "ru.tgmpluginactivation.com"), enter the subdomain i to setup DNS for you. When your translation is ready, open an issue on the Issue Tracker to let us know. + +## Attributions + +This site is generated using [Jekyll](http://jekyllrb.com/) on [GitHub Pages](https://pages.github.com/). + +The site uses the following external resources: + +* [Syntax highlighter styles](https://github.com/mojombo/tpw/blob/master/css/syntax.css) by [Tom Preston-Werner](http://tom.preston-werner.com/) and [Pygments](https://github.com/richleland/pygments-css/blob/master/github.css), licensed under the MIT license. +* [jQuery](http://jquery.com/) by the [jQuery Foundation](https://jquery.org/team/), also licensed under the MIT license. +* [Marked](https://github.com/chjj/marked) by [Christopher Jeffrey](https://twitter.com/_chjj), also licensed under the MIT license. +* [To Title Case script](http://individed.com/code/to-title-case/) by [David Gouch](http://davidgouch.com/), also licensed under the MIT license. +* [JsZip](http://stuk.github.io/jszip/) / [GH](https://github.com/Stuk/jszip) by [Stuart Knightley](http://stuartk.com/), dual licensed under the MIT license and GPLv3. +* [JsZip Utils](http://stuk.github.io/jszip-utils/) / [GH](https://github.com/Stuk/jszip-utils) by [Stuart Knightley](http://stuartk.com/), dual licensed under the MIT license and GPLv3. +* [FileSave.js](http://eligrey.com/blog/post/saving-generated-files-on-the-client-side/) / [GH](https://github.com/eligrey/FileSaver.js) by [Eli Grey](http://eligrey.com/), also licensed under the MIT license. +* and of course [TGM Plugin Activation](https://github.com/TGMPA/TGM-Plugin-Activation) by the [TGMPA team](https://github.com/TGMPA), licensed under GPLv2. diff --git a/_config.yml b/_config.yml index 5c99c82b..10970222 100644 --- a/_config.yml +++ b/_config.yml @@ -18,8 +18,6 @@ tgmpa: description: "TGM Plugin Activation is a PHP library that allows you to easily and automatically require, recommend and install plugins for your WordPress themes and plugins." url: "http://tgmpluginactivation.com" logo: "http://tgmpluginactivation.com/TGM-Plugin-Activation/images/logo.png" - zipimage: https://github.com/images/modules/download/zip.png - tarimage: https://github.com/images/modules/download/tar.png version: 2.5.2 minwp: 3.7 minphp: 5.2.4 diff --git a/_drafts/example-page.md b/_drafts/example-page.md index 227b689e..0517c058 100644 --- a/_drafts/example-page.md +++ b/_drafts/example-page.md @@ -72,8 +72,6 @@ There are also a number of variables available for use in all documents. It is s - {{ site.tgmpa.description }}: Fallback for the < header tag if no `description` is set in the Frontmatter at the top of the file. - {{ site.tgmpa.url }}: http://tgmpluginactivation.com, i.e. the site url - {{ site.tgmpa.logo }}: http://tgmpluginactivation.com/images/logo.png, the url to the logo file -- {{ site.tgmpa.zipimage }}: https://github.com/images/modules/download/zip.png, the url to the image used for zip files -- {{ site.tgmpa.tarimage }}: https://github.com/images/modules/download/tar.png, the url to the image used for tar files - {{ site.tgmpa.version }}: 2.5.1, the current version - not to worry if this is not up to date as we'll use the GitHub API for up-to-date info - {{ site.tgmpa.minwp }}: 3.7, the minimum WP version needed for the current TGMPA version - {{ site.tgmpa.minphp }}: 5.2.4, the minimum PHP version needed for the current TGMPA version diff --git a/_homepage/03-Download.md b/_homepage/03-Download.md index 91edf4d4..a7b83342 100644 --- a/_homepage/03-Download.md +++ b/_homepage/03-Download.md @@ -4,13 +4,12 @@ anchor: getcurrent ### Download -The latest stable release is version {{ site.tgmpa.version }}. You can download it as a [zipball]{:.latest-zip} or [tarball]{:.latest-tar}. +The latest stable release is version {{ site.tgmpa.version }}. The recommended way to get your own package is to use the [custom TGMPA Generator]. For older releases and the changelog, visit the [Download] page. -You can also download your own package (such as the development version) [on GitHub]. +You can also download other packages (such as the development version) [on GitHub]. +[custom TGMPA Generator]: {{ '/download/' | prepend: site.tgmpa.url }} [Download]: {{ '/download/' | prepend: site.tgmpa.url }} -[zipball]: {{ '/releases/latest' | prepend: site.tgmpa.github }} -[tarball]: {{ '/releases/latest' | prepend: site.tgmpa.github }} [on GitHub]: {{ site.tgmpa.github }} diff --git a/_includes/footer.html b/_includes/footer.html index b0bfc2e9..e6417133 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -13,7 +13,21 @@ + + {% if page.anchor == "download" %} + + + + + + + {% endif %} + {% if site.tgmpa.url == "http://tgmpluginactivation.com" %} {% else %} diff --git a/_includes/generator-form.html b/_includes/generator-form.html new file mode 100644 index 00000000..e14907d0 --- /dev/null +++ b/_includes/generator-form.html @@ -0,0 +1,73 @@ +{::options parse_block_html="false" entity_output="as_input" /} +
- Current version: - {{ site.tgmpa.version }} + + Current version: + {{ site.tgmpa.version }} +
+ ![screenshot-1]({{ '/images/screenshots/tgmpa-generator-medium.png' | prepend: site.tgmpa.url }}) +
+ +Well, no more. We've heard you and we've worked hard to make this easier for you. + +So today, we are releasing a _**Custom TGMPA Generator**_. You can find it on the [Download] page. + +Just fill out the form with the _text-domain_ of your theme or plugin, what sort of WordPress add-on you will be including TGMPA in and, if it's a theme, the publication channel you'll be using and we'll generate a custom download of the current version of TGMPA for you with all the relevant code already adjusted. + +We hope you like it. As this is a first release, there may of course still be some bugs. If you find one, please [report] it to us and we'll try and fix it as soon as possible. + +Enjoy! + +Oh and don't forget that [our survey] is still open, so if you haven't given your opinion yet, go and [do so now]! + + + +[Download]: {{ '/download/' | prepend: site.tgmpa.url }} +[report]: {{ '/issues' | prepend: site.tgmpa.github }} +[our survey]: {{ '/2016/01/11/tgmpa-survey/' | prepend: site.tgmpa.github }} +[do so now]: http://goo.gl/forms/Fq1gbY9vCW \ No newline at end of file diff --git a/css/style.css b/css/style.css index baa530f3..360baa19 100644 --- a/css/style.css +++ b/css/style.css @@ -131,7 +131,7 @@ a:hover { hgroup.text { color: #000; float: left; - max-width: 570px; + max-width: 590px; padding-top: 10px; min-height: 119px; padding-left: 135px; @@ -140,13 +140,35 @@ hgroup.text { .download { float: right; - width: 186px; + width: 158px; +} + +.download .download-icon { + text-align: center; + margin: -10px 0 -25px; } .download a { + color: #757575; display: inline-block; } +.download a:hover { + color: #5490ca; +} +.download-icon a span { + /* Show image */ + padding: 0; + width: 158px; + height: 135px; + background: url(../images/download-icon.png); + background-position: center bottom; + display: inline-block; + /* Hide text */ + text-indent: 100%; /* get out of the window */ + white-space: nowrap; /* don't come back in */ + overflow: hidden; /* no really, don't come back in */ +} hgroup h1 a, hgroup h1 a:hover { @@ -155,7 +177,7 @@ hgroup h1 a:hover { } hgroup h2 { - color: #444; + color: #585858; font-size: 1.3em; } @@ -269,7 +291,7 @@ img { /* new */ /* Styles for the version number box in the header. */ .doc-head-content p.version { - margin: -0.3em 1em 0 1em; + margin: -0.3em 0.5em 0; vertical-align: middle; } .doc-head-content p.version .version-label { @@ -280,7 +302,7 @@ img { .doc-head-content p.version .version-number { float: right; width: 40%; - text-align: center; + text-align: right; font-size: 120%; color: #2E8B57; overflow: visible; @@ -375,6 +397,145 @@ div#download table { width: 60%; } +/* Styling for the custom TGMPA generator on the download page. */ +.tgmpa-generator-form { + background-color: #E7E6E6; + border-bottom: 2px solid #E73A74; + border-top: 2px solid #E73A74; + padding: 10px; + font-size: 85%; +} +.tgmpa-generator-form:before, +.tgmpa-generator-form:after { + content: ""; + display: table; + table-layout: fixed; +} +.tgmpa-generator-form:after { + clear: both; +} + +.tgmpa-generator-form section { + float: left; + padding: 0 1% 0 0; +} +.tgmpa-generator-form .tgmpa-form-primary { + width: 25%; +} +.tgmpa-generator-form .tgmpa-form-secondary { + width: 45%; +} +.tgmpa-generator-form .tgmpa-form-ternary { + width: 28%; + text-align: center; + padding-right: 0; + float: right; +} +.tgmpa-generator-form .tgmpa-form-secondary label { + width: 30%; + min-width: 115px; + float: left; + clear: left; +} +.tgmpa-generator-form .tgmpa-form-secondary input { + width: 65%; + min-width: 140px; + font-size: 100%; +} +.tgmpa-generator-form fieldset { + border: 0 none; +} +.tgmpa-generator-form fieldset legend { + padding-bottom: 8px; +} +.tgmpa-generator-form .tgmpa-form-primary fieldset { + padding: 4px 0 10px; +} +.tgmpa-generator-form #tgmpa-form-wporg { + opacity: 0; +} +.tgmpa-generator-form #tgmpa-form-wporg input { + width: auto; + min-width: 0; +} +.tgmpa-generator-form #tgmpa-form-wporg label { + float: none; + min-width: 0; + width: auto; +} +.tgmpa-generator-form #spinner { + display: none; + background-image: url('../images/spinner.gif'); + width: 150px; + height: 14px; +} +.tgmpa-generator-form .required { + color: #e73a74; + padding: 0 5px; + font-weight: bold; +} +.tgmpa-generator-form .generator-form-submit { + padding-top: 6px; +} +.tgmpa-generator-form .tgmpa-form-submit { + cursor: pointer; + font-size: 120%; + -moz-border-radius: 25px; + -webkit-border-radius: 25px; + border-radius: 25px; + border: 1px solid #ee1eb5; + padding: 13px 22px; + background: -moz-linear-gradient( center top, #ff5bb0 5%, #ef027d 100% ); + background: -ms-linear-gradient( top, #ff5bb0 5%, #ef027d 100% ); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bb0', endColorstr='#ef027d'); + background: -webkit-gradient( linear, left top, left bottom, color-stop(5%, #ff5bb0), color-stop(100%, #ef027d) ); + background-color: #ff5bb0; + color:#ffffff; + text-shadow: 2px 1px 1px #c70067; + -webkit-box-shadow: inset 1px 1px 13px 0px #fbafe3; + -moz-box-shadow: inset 1px 1px 13px 0px #fbafe3; + box-shadow: inset 1px 1px 13px 0px #fbafe3; +} +.tgmpa-generator-form .tgmpa-form-submit:hover { + background: -moz-linear-gradient( center top, #ef027d 5%, #ff5bb0 100% ); + background: -ms-linear-gradient( top, #ef027d 5%, #ff5bb0 100% ); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ef027d', endColorstr='#ff5bb0'); + background: -webkit-gradient( linear, left top, left bottom, color-stop(5%, #ef027d), color-stop(100%, #ff5bb0) ); + background-color: #ef027d; +} +.tgmpa-generator-form .tgmpa-form-submit:active { + position: relative; + top: 1px; +} + +.tgmpa-generator-form .tgmpa-form-ternary .generator-feedback { + opacity: 0; + padding-left: 5px; +} +.tgmpa-generator-form .tgmpa-form-ternary .success { + border-left: 5px solid #2bf092; +} +.tgmpa-generator-form .tgmpa-form-ternary .warning { + border-left: 5px solid #f0922b; +} +.tgmpa-generator-form .tgmpa-form-ternary .error { + border-left: 5px solid #e73a74; +} +.tgmpa-generator-form #report-generator-error { + opacity: 0; + font-size: 90%; +} + +.tgmpa-generator-form .generator-notes { + float: left; + width: 46%; + font-size: 80%; +} +.tgmpa-generator-form .generator-notes ul { + padding: 5em 0 0 2em; + margin: 1em 0 0; +} + /* Minimal styling for the 'continue reading' paragraph below the changelog */ .continue-reading { @@ -501,3 +662,24 @@ div#download table { padding-bottom: 100px; } +/* Image alignment styles. */ +.align-left { + display: inline; + float: left; + margin-right: 1.5em; + width: auto; +} + +.align-right { + display: inline; + float: right; + margin-left: 1.5em; + width: auto; +} + +.align-center { + clear: both; + display: block; + margin-left: auto; + margin-right: auto; +} diff --git a/css/style.min.css b/css/style.min.css index 2f317796..2d584891 100644 --- a/css/style.min.css +++ b/css/style.min.css @@ -1 +1 @@ -body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;background:#f4f4f4;color:#838383;font:1em/1.5 'Helvetica Neue',Helvetica,Arial,sans-serif;margin:0}nav,subline{display:block}.clear{clear:both}dl,ol,p,pre,ul{margin:1em 0}dl,ol,ul{padding:0 0 0 3em}ul li{padding-top:.2em}ol li{padding-top:.8em}blockquote{border-left:5px double #e73a74;border-right:5px double #e73a74;margin:1em 5px 2em;padding:0 30px;font-style:italic}h1,h2,h3,h4,h5,h6{color:#e73a74;line-height:1.1;margin:1.5em 0}h1{font-size:2.5em}h2,h3{font-size:1.5em}h4{font-size:1.2em}h5,h6{font-size:1em}a{color:#4183c4;text-decoration:none}a:active,a:focus,a:hover{text-decoration:underline}.doc-head h1,.doc-head h2,.doc-head h3,.doc-head h4,.doc-head h5,.doc-head h6{margin:0}.doc-body h1,.doc-body h2,.doc-body h3,.doc-body h4{border-top:.2em solid #EEE;padding-top:.5em}.doc-head,.doc-body,.doc-foot{padding:0 10px}.doc-body{margin-bottom:15px}.doc-head-content,.doc-body-content,.doc-foot-content{margin:0 auto;max-width:860px;padding:20px}.doc-head-content{max-width:900px;padding:20px 0 10px 0}.doc-foot-content{padding:0 0 .8em;overflow:hidden}hgroup.text{color:#000;float:left;max-width:570px;padding-top:10px;min-height:119px;padding-left:135px;background:url('../images/logo-transparent.png') no-repeat scroll 0 0 / 129px 129px #f4f4f4}.download{float:right;width:186px}.download a{display:inline-block}hgroup h1 a,hgroup h1 a:hover{color:#e73a74;text-decoration:none}hgroup h2{color:#444;font-size:1.3em}.doc-body-content{background:#FFF;border-radius:1em;box-shadow:0 0 4px #DDD;padding:20px 25px;position:relative}nav ul{font:0/0 'Courier New',monospace;letter-spacing:-0.63em;padding:0;text-align:right}nav li{display:inline-block;*display:inline;font:bold 12px sans-serif;letter-spacing:normal;text-align:left;*zoom:1}nav a{display:block;margin:0 .25em;padding:.5em 1em}pre,pre code{font:85%/1.1 'Bitstream Vera Sans Mono','Courier',monospace}code{background-color:#f6f6f6;font-size:110%}.highlight{margin:0}.highlight pre{background:#f6f6f6;border:1px solid #EEE;border-radius:5px;color:#440;margin:1em 3em 1em 0;padding:.5em 0;overflow:auto;max-height:40em}.highlight pre code{counter-reset:line}.highlight pre code span.lineno{counter-increment:line;position:relative;left:-2em;margin-left:2em}.highlight pre code span.lineno:before{content:counter(line);background-color:#555;border-right:1px solid #e73a74;color:#fff;display:inline-block;margin:0;padding:2px 10px 1px;text-align:right;min-width:2em;font-style:normal;-webkit-user-select:none;-webkit-touch-callout:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.required{color:red}.possibly-required{color:orange}.deprecated{text-decoration:line-through;color:#bababa}img{height:auto;max-width:100%}.doc-head-content p.version{margin:-0.3em 1em 0 1em;vertical-align:middle}.doc-head-content p.version .version-label{float:left;width:55%;font-size:80%}.doc-head-content p.version .version-number{float:right;width:40%;text-align:center;font-size:120%;color:#2e8b57;overflow:visible;padding-top:2px}nav .active{border-top:1px solid #e73a74;border-bottom:1px solid #e73a74;text-decoration:none}.top{text-align:right;padding-right:2em}a.top{display:block;font-size:70%}.twitter-follow-button{float:right;font-size:80%;padding-top:.8em}.twitter-share-button{float:right;font-size:70%;margin:1.5em 2em 0 0;padding-top:4em}.page-home .twitter-share-button{float:left;font-size:70%;margin:-5px 0 0 0;padding:0}.tweet-post .twitter-share-button{float:none;margin:0 0 0 2em;padding:0;vertical-align:-40%}.version-number{font-weight:bold}table{border-collapse:collapse}table,th,td{border:1px solid #ccc}th,td{padding:.1em .4em;text-align:left;vertical-align:top}th{text-align:left;color:#e73a74;background-color:#ccc}td{font-size:90%}tr td:first-child{font-weight:bold}table tr:nth-child(even){background:#f6f6f6}table tr:nth-child(even) code{background:#fff}div#download table{width:60%}.continue-reading{border-top:2px solid #eee;padding:.6em 1em 1em;text-align:right}.contributors{overflow:hidden}.contributors p{margin:0 0 1em}.contributor{float:left;margin:.3em 0;padding-right:5px;vertical-align:top;width:165px;font-size:90%}.contributor img{margin-right:5px;vertical-align:-25%}.doc-foot-content .build-date{text-align:right;font-size:70%;padding-right:2em}.recent-posts{border:1px solid #ccc;float:right;font-size:90%;margin:5em 0 3em 1em;width:210px}.recent-posts h3{color:#e73a74;background-color:#ccc;border-top:0 none;border-bottom:.2em solid #EEE;margin:0 0 .8em;padding:.5em .8em;font-size:1em;text-align:center}.recent-posts ul{padding:0 1em 0 2em;word-wrap:normal}.recent-posts li .post-meta{font-size:75%;color:#bbb}.recent-posts li .post-meta a{color:#bbb}.post-meta{color:#bbb;font-size:90%;overflow:hidden}.post-meta .post-author{padding:0 .3em 0 .4em}.post-meta img{vertical-align:-20%}.post-meta .post-category-tags{font-size:85%;margin:-0.7em 0 1em}.post-meta .post-category-tags span{padding-right:2em}.post-nav{overflow:hidden;border-top:1px solid #eee;border-bottom:1px solid #eee;margin:1em 0}.post-nav p{margin:.2em 0}.post-nav .post-previous,.post-nav .post-next{width:32%}.post-nav .post-previous,.post-nav .post-index{float:left}.post-nav .post-index{text-align:center}.post-nav .post-next{float:right;text-align:right;padding-right:1em}.broken{float:left;margin-right:50px;padding-bottom:100px} \ No newline at end of file +body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;background:#f4f4f4;color:#838383;font:1em/1.5 'Helvetica Neue',Helvetica,Arial,sans-serif;margin:0}nav,subline{display:block}.clear{clear:both}dl,ol,p,pre,ul{margin:1em 0}dl,ol,ul{padding:0 0 0 3em}ul li{padding-top:.2em}ol li{padding-top:.8em}blockquote{border-left:5px double #e73a74;border-right:5px double #e73a74;margin:1em 5px 2em;padding:0 30px;font-style:italic}h1,h2,h3,h4,h5,h6{color:#e73a74;line-height:1.1;margin:1.5em 0}h1{font-size:2.5em}h2,h3{font-size:1.5em}h4{font-size:1.2em}h5,h6{font-size:1em}a{color:#4183c4;text-decoration:none}a:active,a:focus,a:hover{text-decoration:underline}.doc-head h1,.doc-head h2,.doc-head h3,.doc-head h4,.doc-head h5,.doc-head h6{margin:0}.doc-body h1,.doc-body h2,.doc-body h3,.doc-body h4{border-top:.2em solid #EEE;padding-top:.5em}.doc-head,.doc-body,.doc-foot{padding:0 10px}.doc-body{margin-bottom:15px}.doc-head-content,.doc-body-content,.doc-foot-content{margin:0 auto;max-width:860px;padding:20px}.doc-head-content{max-width:900px;padding:20px 0 10px 0}.doc-foot-content{padding:0 0 .8em;overflow:hidden}hgroup.text{color:#000;float:left;max-width:590px;padding-top:10px;min-height:119px;padding-left:135px;background:url('../images/logo-transparent.png') no-repeat scroll 0 0 / 129px 129px #f4f4f4}.download{float:right;width:158px}.download .download-icon{text-align:center;margin:-10px 0 -25px}.download a{color:#757575;display:inline-block}.download a:hover{color:#5490ca}.download-icon a span{padding:0;width:158px;height:135px;background:url(../images/download-icon.png);background-position:center bottom;display:inline-block;text-indent:100%;white-space:nowrap;overflow:hidden}hgroup h1 a,hgroup h1 a:hover{color:#e73a74;text-decoration:none}hgroup h2{color:#585858;font-size:1.3em}.doc-body-content{background:#FFF;border-radius:1em;box-shadow:0 0 4px #DDD;padding:20px 25px;position:relative}nav ul{font:0/0 'Courier New',monospace;letter-spacing:-0.63em;padding:0;text-align:right}nav li{display:inline-block;*display:inline;font:bold 12px sans-serif;letter-spacing:normal;text-align:left;*zoom:1}nav a{display:block;margin:0 .25em;padding:.5em 1em}pre,pre code{font:85%/1.1 'Bitstream Vera Sans Mono','Courier',monospace}code{background-color:#f6f6f6;font-size:110%}.highlight{margin:0}.highlight pre{background:#f6f6f6;border:1px solid #EEE;border-radius:5px;color:#440;margin:1em 3em 1em 0;padding:.5em 0;overflow:auto;max-height:40em}.highlight pre code{counter-reset:line}.highlight pre code span.lineno{counter-increment:line;position:relative;left:-2em;margin-left:2em}.highlight pre code span.lineno:before{content:counter(line);background-color:#555;border-right:1px solid #e73a74;color:#fff;display:inline-block;margin:0;padding:2px 10px 1px;text-align:right;min-width:2em;font-style:normal;-webkit-user-select:none;-webkit-touch-callout:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.required{color:red}.possibly-required{color:orange}.deprecated{text-decoration:line-through;color:#bababa}img{height:auto;max-width:100%}.doc-head-content p.version{margin:-0.3em .5em 0;vertical-align:middle}.doc-head-content p.version .version-label{float:left;width:55%;font-size:80%}.doc-head-content p.version .version-number{float:right;width:40%;text-align:right;font-size:120%;color:#2e8b57;overflow:visible;padding-top:2px}nav .active{border-top:1px solid #e73a74;border-bottom:1px solid #e73a74;text-decoration:none}.top{text-align:right;padding-right:2em}a.top{display:block;font-size:70%}.twitter-follow-button{float:right;font-size:80%;padding-top:.8em}.twitter-share-button{float:right;font-size:70%;margin:1.5em 2em 0 0;padding-top:4em}.page-home .twitter-share-button{float:left;font-size:70%;margin:-5px 0 0 0;padding:0}.tweet-post .twitter-share-button{float:none;margin:0 0 0 2em;padding:0;vertical-align:-40%}.version-number{font-weight:bold}table{border-collapse:collapse}table,th,td{border:1px solid #ccc}th,td{padding:.1em .4em;text-align:left;vertical-align:top}th{text-align:left;color:#e73a74;background-color:#ccc}td{font-size:90%}tr td:first-child{font-weight:bold}table tr:nth-child(even){background:#f6f6f6}table tr:nth-child(even) code{background:#fff}div#download table{width:60%}.tgmpa-generator-form{background-color:#e7e6e6;border-bottom:2px solid #e73a74;border-top:2px solid #e73a74;padding:10px;font-size:85%}.tgmpa-generator-form:before,.tgmpa-generator-form:after{content:"";display:table;table-layout:fixed}.tgmpa-generator-form:after{clear:both}.tgmpa-generator-form section{float:left;padding:0 1% 0 0}.tgmpa-generator-form .tgmpa-form-primary{width:25%}.tgmpa-generator-form .tgmpa-form-secondary{width:45%}.tgmpa-generator-form .tgmpa-form-ternary{width:28%;text-align:center;padding-right:0;float:right}.tgmpa-generator-form .tgmpa-form-secondary label{width:30%;min-width:115px;float:left;clear:left}.tgmpa-generator-form .tgmpa-form-secondary input{width:65%;min-width:140px;font-size:100%}.tgmpa-generator-form fieldset{border:0 none}.tgmpa-generator-form fieldset legend{padding-bottom:8px}.tgmpa-generator-form .tgmpa-form-primary fieldset{padding:4px 0 10px}.tgmpa-generator-form #tgmpa-form-wporg{opacity:0}.tgmpa-generator-form #tgmpa-form-wporg input{width:auto;min-width:0}.tgmpa-generator-form #tgmpa-form-wporg label{float:none;min-width:0;width:auto}.tgmpa-generator-form #spinner{display:none;background-image:url('../images/spinner.gif');width:150px;height:14px}.tgmpa-generator-form .required{color:#e73a74;padding:0 5px;font-weight:bold}.tgmpa-generator-form .generator-form-submit{padding-top:6px}.tgmpa-generator-form .tgmpa-form-submit{cursor:pointer;font-size:120%;-moz-border-radius:25px;-webkit-border-radius:25px;border-radius:25px;border:1px solid #ee1eb5;padding:13px 22px;background:-moz-linear-gradient(center top,#ff5bb0 5%,#ef027d 100%);background:-ms-linear-gradient(top,#ff5bb0 5%,#ef027d 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bb0',endColorstr='#ef027d');background:-webkit-gradient(linear,left top,left bottom,color-stop(5%,#ff5bb0),color-stop(100%,#ef027d));background-color:#ff5bb0;color:#fff;text-shadow:2px 1px 1px #c70067;-webkit-box-shadow:inset 1px 1px 13px 0 #fbafe3;-moz-box-shadow:inset 1px 1px 13px 0 #fbafe3;box-shadow:inset 1px 1px 13px 0 #fbafe3}.tgmpa-generator-form .tgmpa-form-submit:hover{background:-moz-linear-gradient(center top,#ef027d 5%,#ff5bb0 100%);background:-ms-linear-gradient(top,#ef027d 5%,#ff5bb0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ef027d',endColorstr='#ff5bb0');background:-webkit-gradient(linear,left top,left bottom,color-stop(5%,#ef027d),color-stop(100%,#ff5bb0));background-color:#ef027d}.tgmpa-generator-form .tgmpa-form-submit:active{position:relative;top:1px}.tgmpa-generator-form .tgmpa-form-ternary .generator-feedback{opacity:0;padding-left:5px}.tgmpa-generator-form .tgmpa-form-ternary .success{border-left:5px solid #2bf092}.tgmpa-generator-form .tgmpa-form-ternary .warning{border-left:5px solid #f0922b}.tgmpa-generator-form .tgmpa-form-ternary .error{border-left:5px solid #e73a74}.tgmpa-generator-form #report-generator-error{opacity:0;font-size:90%}.tgmpa-generator-form .generator-notes{float:left;width:46%;font-size:80%}.tgmpa-generator-form .generator-notes ul{padding:5em 0 0 2em;margin:1em 0 0}.continue-reading{border-top:2px solid #eee;padding:.6em 1em 1em;text-align:right}.contributors{overflow:hidden}.contributors p{margin:0 0 1em}.contributor{float:left;margin:.3em 0;padding-right:5px;vertical-align:top;width:165px;font-size:90%}.contributor img{margin-right:5px;vertical-align:-25%}.doc-foot-content .build-date{text-align:right;font-size:70%;padding-right:2em}.recent-posts{border:1px solid #ccc;float:right;font-size:90%;margin:5em 0 3em 1em;width:210px}.recent-posts h3{color:#e73a74;background-color:#ccc;border-top:0 none;border-bottom:.2em solid #EEE;margin:0 0 .8em;padding:.5em .8em;font-size:1em;text-align:center}.recent-posts ul{padding:0 1em 0 2em;word-wrap:normal}.recent-posts li .post-meta{font-size:75%;color:#bbb}.recent-posts li .post-meta a{color:#bbb}.post-meta{color:#bbb;font-size:90%;overflow:hidden}.post-meta .post-author{padding:0 .3em 0 .4em}.post-meta img{vertical-align:-20%}.post-meta .post-category-tags{font-size:85%;margin:-0.7em 0 1em}.post-meta .post-category-tags span{padding-right:2em}.post-nav{overflow:hidden;border-top:1px solid #eee;border-bottom:1px solid #eee;margin:1em 0}.post-nav p{margin:.2em 0}.post-nav .post-previous,.post-nav .post-next{width:32%}.post-nav .post-previous,.post-nav .post-index{float:left}.post-nav .post-index{text-align:center}.post-nav .post-next{float:right;text-align:right;padding-right:1em}.broken{float:left;margin-right:50px;padding-bottom:100px}.align-left{display:inline;float:left;margin-right:1.5em;width:auto}.align-right{display:inline;float:right;margin-left:1.5em;width:auto}.align-center{clear:both;display:block;margin-left:auto;margin-right:auto} diff --git a/images/download-icon.png b/images/download-icon.png new file mode 100644 index 00000000..8d6e24a2 Binary files /dev/null and b/images/download-icon.png differ diff --git a/images/screenshots/tgmpa-generator-medium.png b/images/screenshots/tgmpa-generator-medium.png new file mode 100644 index 00000000..e5ae1279 Binary files /dev/null and b/images/screenshots/tgmpa-generator-medium.png differ diff --git a/images/spinner.gif b/images/spinner.gif new file mode 100644 index 00000000..16c35c2f Binary files /dev/null and b/images/spinner.gif differ diff --git a/js/FileSaver.min.js b/js/FileSaver.min.js new file mode 100644 index 00000000..eb062f25 --- /dev/null +++ b/js/FileSaver.min.js @@ -0,0 +1,2 @@ +/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ +var saveAs=saveAs||function(view){"use strict";if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var doc=view.document,get_URL=function(){return view.URL||view.webkitURL||view},save_link=doc.createElementNS("http://www.w3.org/1999/xhtml","a"),can_use_save_link="download"in save_link,click=function(node){var event=new MouseEvent("click");node.dispatchEvent(event)},is_safari=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),webkit_req_fs=view.webkitRequestFileSystem,req_fs=view.requestFileSystem||webkit_req_fs||view.mozRequestFileSystem,throw_outside=function(ex){(view.setImmediate||view.setTimeout)(function(){throw ex},0)},force_saveable_type="application/octet-stream",fs_min_size=0,arbitrary_revoke_timeout=500,revoke=function(file){var revoker=function(){if(typeof file==="string"){get_URL().revokeObjectURL(file)}else{file.remove()}};if(view.chrome){revoker()}else{setTimeout(revoker,arbitrary_revoke_timeout)}},dispatch=function(filesaver,event_types,event){event_types=[].concat(event_types);var i=event_types.length;while(i--){var listener=filesaver["on"+event_types[i]];if(typeof listener==="function"){try{listener.call(filesaver,event||filesaver)}catch(ex){throw_outside(ex)}}}},auto_bom=function(blob){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)){return new Blob(["\ufeff",blob],{type:blob.type})}return blob},FileSaver=function(blob,name,no_auto_bom){if(!no_auto_bom){blob=auto_bom(blob)}var filesaver=this,type=blob.type,blob_changed=false,object_url,target_view,dispatch_all=function(){dispatch(filesaver,"writestart progress write writeend".split(" "))},fs_error=function(){if(target_view&&is_safari&&typeof FileReader!=="undefined"){var reader=new FileReader;reader.onloadend=function(){var base64Data=reader.result;target_view.location.href="data:attachment/file"+base64Data.slice(base64Data.search(/[,;]/));filesaver.readyState=filesaver.DONE;dispatch_all()};reader.readAsDataURL(blob);filesaver.readyState=filesaver.INIT;return}if(blob_changed||!object_url){object_url=get_URL().createObjectURL(blob)}if(target_view){target_view.location.href=object_url}else{var new_tab=view.open(object_url,"_blank");if(new_tab==undefined&&is_safari){view.location.href=object_url}}filesaver.readyState=filesaver.DONE;dispatch_all();revoke(object_url)},abortable=function(func){return function(){if(filesaver.readyState!==filesaver.DONE){return func.apply(this,arguments)}}},create_if_not_found={create:true,exclusive:false},slice;filesaver.readyState=filesaver.INIT;if(!name){name="download"}if(can_use_save_link){object_url=get_URL().createObjectURL(blob);setTimeout(function(){save_link.href=object_url;save_link.download=name;click(save_link);dispatch_all();revoke(object_url);filesaver.readyState=filesaver.DONE});return}if(view.chrome&&type&&type!==force_saveable_type){slice=blob.slice||blob.webkitSlice;blob=slice.call(blob,0,blob.size,force_saveable_type);blob_changed=true}if(webkit_req_fs&&name!=="download"){name+=".download"}if(type===force_saveable_type||webkit_req_fs){target_view=view}if(!req_fs){fs_error();return}fs_min_size+=blob.size;req_fs(view.TEMPORARY,fs_min_size,abortable(function(fs){fs.root.getDirectory("saved",create_if_not_found,abortable(function(dir){var save=function(){dir.getFile(name,create_if_not_found,abortable(function(file){file.createWriter(abortable(function(writer){writer.onwriteend=function(event){target_view.location.href=file.toURL();filesaver.readyState=filesaver.DONE;dispatch(filesaver,"writeend",event);revoke(file)};writer.onerror=function(){var error=writer.error;if(error.code!==error.ABORT_ERR){fs_error()}};"writestart progress write abort".split(" ").forEach(function(event){writer["on"+event]=filesaver["on"+event]});writer.write(blob);filesaver.abort=function(){writer.abort();filesaver.readyState=filesaver.DONE};filesaver.readyState=filesaver.WRITING}),fs_error)}),fs_error)};dir.getFile(name,{create:false},abortable(function(file){file.remove();save()}),abortable(function(ex){if(ex.code===ex.NOT_FOUND_ERR){save()}else{fs_error()}}))}),fs_error)}),fs_error)},FS_proto=FileSaver.prototype,saveAs=function(blob,name,no_auto_bom){return new FileSaver(blob,name,no_auto_bom)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(blob,name,no_auto_bom){if(!no_auto_bom){blob=auto_bom(blob)}return navigator.msSaveOrOpenBlob(blob,name||"download")}}FS_proto.abort=function(){var filesaver=this;filesaver.readyState=filesaver.DONE;dispatch(filesaver,"abort")};FS_proto.readyState=FS_proto.INIT=0;FS_proto.WRITING=1;FS_proto.DONE=2;FS_proto.error=FS_proto.onwritestart=FS_proto.onprogress=FS_proto.onwrite=FS_proto.onabort=FS_proto.onerror=FS_proto.onwriteend=null;return saveAs}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!=null){define([],function(){return saveAs})} diff --git a/js/jszip-utils-ie.min.js b/js/jszip-utils-ie.min.js new file mode 100644 index 00000000..3cdbbf83 --- /dev/null +++ b/js/jszip-utils-ie.min.js @@ -0,0 +1,10 @@ +/*! + +JSZipUtils - A collection of cross-browser utilities to go along with JSZip. +>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]< >>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]< q&&(p+=B[f++]<k){a.msg="invalid distance too far back",e.mode=c;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&e.sane){a.msg="invalid distance too far back",e.mode=c;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),e.hold=p,e.bits=q}},{}],35:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(ob),b.distcode=b.distdyn=new r.Buf32(pb),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,rb)}function k(a){if(sb){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sb=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whave n;){if(0===i)break a;i--,m+=e[g++]< >>8&255,c.check=t(c.check,Bb,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=lb;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=lb;break}if(m>>>=4,n-=4,wb=(15&m)+8,0===c.wbits)c.wbits=wb;else if(wb>c.wbits){a.msg="invalid window size",c.mode=lb;break}c.dmax=1< n;){if(0===i)break a;i--,m+=e[g++]< >8&1),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]< >>8&255,Bb[2]=m>>>16&255,Bb[3]=m>>>24&255,c.check=t(c.check,Bb,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]< >8),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]< >>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wb=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wb)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.name+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.comment+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]< >9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]< >>=7&n,n-=7&n,c.mode=ib;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]< >>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=bb,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=lb}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]< >>16^65535)){a.msg="invalid stored block lengths",c.mode=lb;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]< >>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=lb;break}c.have=0,c.mode=_;case _:for(;c.have n;){if(0===i)break a;i--,m+=e[g++]< >>=3,n-=3}for(;c.have<19;)c.lens[Cb[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,yb={bits:c.lenbits},xb=v(w,c.lens,0,19,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid code lengths set",c.mode=lb;break}c.have=0,c.mode=ab;case ab:for(;c.have >>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]< sb)m>>>=qb,n-=qb,c.lens[c.have++]=sb;else{if(16===sb){for(zb=qb+2;zb>n;){if(0===i)break a;i--,m+=e[g++]< >>=qb,n-=qb,0===c.have){a.msg="invalid bit length repeat",c.mode=lb;break}wb=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sb){for(zb=qb+3;zb>n;){if(0===i)break a;i--,m+=e[g++]< >>=qb,n-=qb,wb=0,q=3+(7&m),m>>>=3,n-=3}else{for(zb=qb+7;zb>n;){if(0===i)break a;i--,m+=e[g++]< >>=qb,n-=qb,wb=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=lb;break}for(;q--;)c.lens[c.have++]=wb}}if(c.mode===lb)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=lb;break}if(c.lenbits=9,yb={bits:c.lenbits},xb=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid literal/lengths set",c.mode=lb;break}if(c.distbits=6,c.distcode=c.distdyn,yb={bits:c.distbits},xb=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,yb),c.distbits=yb.bits,xb){a.msg="invalid distances set",c.mode=lb;break}if(c.mode=bb,b===B)break a;case bb:c.mode=cb;case cb:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1); +break}for(c.back=0;Ab=c.lencode[m&(1< >>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]< >tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]< >>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,c.length=sb,0===rb){c.mode=hb;break}if(32&rb){c.back=-1,c.mode=V;break}if(64&rb){a.msg="invalid literal/length code",c.mode=lb;break}c.extra=15&rb,c.mode=db;case db:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]< >>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=eb;case eb:for(;Ab=c.distcode[m&(1< >>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]< >tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]< >>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,64&rb){a.msg="invalid distance code",c.mode=lb;break}c.offset=sb,c.extra=15&rb,c.mode=fb;case fb:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]< >>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=lb;break}c.mode=gb;case gb:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=lb;break}q>c.wnext?(q-=c.wnext,ob=c.wsize-q):ob=c.wnext-q,q>c.length&&(q=c.length),pb=c.window}else pb=f,ob=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pb[ob++];while(--q);0===c.length&&(c.mode=cb);break;case hb:if(0===j)break a;f[h++]=c.length,j--,c.mode=cb;break;case ib:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]< n;){if(0===i)break a;i--,m+=e[g++]< =D;D++)P[D]=0;for(E=0;o>E;E++)P[b[n+E]]++;for(H=C,G=d;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;d>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===g||1!==G))return-1;for(Q[1]=0,D=1;d>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[n+E]&&(r[Q[b[n+E]]++]=E);if(a===g?(N=R=r,y=19):a===h?(N=j,O-=257,R=k,S-=257,y=256):(N=l,R=m,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1< e||a===i&&L>f)return 1;for(var T=0;;){T++,z=D-J,r[E] y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1< >J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1< >=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[n+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<e||a===i&&L>f)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":27}],37:[function(a,b){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a){return 256>a?gb[a]:gb[256+(a>>>7)]}function f(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function g(a,b,c){a.bi_valid>V-c?(a.bi_buf|=b< >V-a.bi_valid,a.bi_valid+=c-V):(a.bi_buf|=b< >>=1,c<<=1;while(--b>0);return c>>>1}function j(a){16===a.bi_valid?(f(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function k(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;U>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;T>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function l(a,b,c){var d,e,f=new Array(U+1),g=0;for(d=1;U>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=i(f[h]++,h))}}function m(){var a,b,c,d,e,f=new Array(U+1);for(c=0,d=0;O-1>d;d++)for(ib[d]=c,a=0;a<1<<_[d];a++)hb[c++]=d;for(hb[c-1]=d,e=0,d=0;16>d;d++)for(jb[d]=e,a=0;a<1< >=7;R>d;d++)for(jb[d]=e<<7,a=0;a<1< =b;b++)f[b]=0;for(a=0;143>=a;)eb[2*a+1]=8,a++,f[8]++;for(;255>=a;)eb[2*a+1]=9,a++,f[9]++;for(;279>=a;)eb[2*a+1]=7,a++,f[7]++;for(;287>=a;)eb[2*a+1]=8,a++,f[8]++;for(l(eb,Q+1,f),a=0;R>a;a++)fb[2*a+1]=5,fb[2*a]=i(a,5);kb=new nb(eb,_,P+1,Q,U),lb=new nb(fb,ab,0,R,U),mb=new nb(new Array(0),bb,0,S,W)}function n(a){var b;for(b=0;Q>b;b++)a.dyn_ltree[2*b]=0;for(b=0;R>b;b++)a.dyn_dtree[2*b]=0;for(b=0;S>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*X]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function o(a){a.bi_valid>8?f(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function p(a,b,c,d){o(a),d&&(f(a,c),f(a,~c)),E.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function q(a,b,c,d){var e=2*b,f=2*c;return a[e]c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)r(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],r(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,r(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],k(a,b),l(f,j,a.bl_count)}function u(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1],++hh?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*Y]++):10>=h?a.bl_tree[2*Z]++:a.bl_tree[2*$]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function v(a,b,c){var d,e,f=-1,i=b[1],j=0,k=7,l=4;for(0===i&&(k=138,l=3),d=0;c>=d;d++)if(e=i,i=b[2*(d+1)+1],!(++j j){do h(a,e,a.bl_tree);while(0!==--j)}else 0!==e?(e!==f&&(h(a,e,a.bl_tree),j--),h(a,Y,a.bl_tree),g(a,j-3,2)):10>=j?(h(a,Z,a.bl_tree),g(a,j-3,3)):(h(a,$,a.bl_tree),g(a,j-11,7));j=0,f=e,0===i?(k=138,l=3):e===i?(k=6,l=3):(k=7,l=4)}}function w(a){var b;for(u(a,a.dyn_ltree,a.l_desc.max_code),u(a,a.dyn_dtree,a.d_desc.max_code),t(a,a.bl_desc),b=S-1;b>=3&&0===a.bl_tree[2*cb[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function x(a,b,c,d){var e;for(g(a,b-257,5),g(a,c-1,5),g(a,d-4,4),e=0;d>e;e++)g(a,a.bl_tree[2*cb[e]+1],3);v(a,a.dyn_ltree,b-1),v(a,a.dyn_dtree,c-1)}function y(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return G;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return H;for(b=32;P>b;b++)if(0!==a.dyn_ltree[2*b])return H;return G}function z(a){pb||(m(),pb=!0),a.l_desc=new ob(a.dyn_ltree,kb),a.d_desc=new ob(a.dyn_dtree,lb),a.bl_desc=new ob(a.bl_tree,mb),a.bi_buf=0,a.bi_valid=0,n(a)}function A(a,b,c,d){g(a,(J<<1)+(d?1:0),3),p(a,b,c,!0)}function B(a){g(a,K<<1,3),h(a,X,eb),j(a)}function C(a,b,c,d){var e,f,h=0;a.level>0?(a.strm.data_type===I&&(a.strm.data_type=y(a)),t(a,a.l_desc),t(a,a.d_desc),h=w(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?A(a,b,c,d):a.strategy===F||f===e?(g(a,(K<<1)+(d?1:0),3),s(a,eb,fb)):(g(a,(L<<1)+(d?1:0),3),x(a,a.l_desc.max_code+1,a.d_desc.max_code+1,h+1),s(a,a.dyn_ltree,a.dyn_dtree)),n(a),d&&o(a)}function D(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(hb[c]+P+1)]++,a.dyn_dtree[2*e(b)]++),a.last_lit===a.lit_bufsize-1}var E=a("../utils/common"),F=4,G=0,H=1,I=2,J=0,K=1,L=2,M=3,N=258,O=29,P=256,Q=P+1+O,R=30,S=19,T=2*Q+1,U=15,V=16,W=7,X=256,Y=16,Z=17,$=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ab=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],db=512,eb=new Array(2*(Q+2));d(eb);var fb=new Array(2*R);d(fb);var gb=new Array(db);d(gb);var hb=new Array(N-M+1);d(hb);var ib=new Array(O);d(ib);var jb=new Array(R);d(jb);var kb,lb,mb,nb=function(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length},ob=function(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b},pb=!1;c._tr_init=z,c._tr_stored_block=A,c._tr_flush_block=C,c._tr_tally=D,c._tr_align=B},{"../utils/common":27}],39:[function(a,b){"use strict";function c(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=c},{}]},{},[9])(9)}); \ No newline at end of file diff --git a/js/tgmpa.js b/js/tgmpa.js index 1def47a5..43517b42 100644 --- a/js/tgmpa.js +++ b/js/tgmpa.js @@ -1,13 +1,25 @@ (function( $ ) { - /*global siteurl, ghreleases, marked */ + 'use strict'; + + /*global siteurl, ghreleases, marked, JSZip, JSZipUtils, saveAs */ var _hash, - zipUrls = $( '.latest-zip' ), - tarUrls = $( '.latest-tar' ), - versionNr = $( '.version-number' ), - releaseDate = $( '.release-date' ), - releases = $( '#releases-table tbody' ), - latestRelease, latestVersion, releasePublished; + versionNr = $( '.version-number' ), // Site-wide. + releaseDate = $( '.release-date' ), // Homepage, download page. + zipUrls, tarUrls, releasesTable, releaseNotes, releases, spinner, publishFieldset, feedbackElm, + feedbackMsg, reportError, latestVersion, latestRelease, releasePublished; // Download page. + + zipUrls = $( '.latest-zip' ); + tarUrls = $( '.latest-tar' ); + releasesTable = $( '#releases-table' ); + releaseNotes = $( '#release-notes' ); + releases = releasesTable.find( 'tbody' ); + spinner = $( '#spinner' ); + publishFieldset = $( '#tgmpa-form-publish' ); + feedbackElm = $( '.generator-feedback' ); + feedbackMsg = $( '#generator-feedback' ); + reportError = $( '#report-generator-error' ); + latestVersion = ''; /** * Redirect hash locations from the pre-2.5.0 website to their new location. @@ -221,10 +233,10 @@ smartLists: true, smartypants: true }); - $( '#release-notes' ).prepend( marked( latestRelease.body ) ).prepend( ' Version ' + latestRelease.name + '
' ); + releaseNotes.prepend( marked( latestRelease.body ) ).prepend( 'Version ' + latestRelease.name + '
' ); $( '#no-release-notes' ).remove(); } else { - $( '#release-notes' ).remove(); + releaseNotes.remove(); } /* Add the last five releases before the current one to the 'Download' section. */ @@ -234,8 +246,476 @@ } /* Remove the releases table and changelog section if no GH data was received. */ else { - $( '#releases-table' ).remove(); - $( '#release-notes' ).remove(); + releasesTable.remove(); + releaseNotes.remove(); + } + + /** + * Report the`results back to the user. + * + * @param {string} text The text to show. + * @param {string} classname The class to give to the element. Either 'success', 'warning' or 'error'. + */ + function showMessage( text, classname ) { + spinner.hide(); + feedbackElm.fadeTo( 200, 1 ).attr( 'aria-hidden', 'false' ); + feedbackMsg.addClass( classname ).html( text ); + if ( 'error' === classname ) { + reportError.fadeTo( 0, 1 ).attr( 'aria-hidden', 'false' ); + } + if ( 'success' === classname ) { + feedbackElm.delay( 5000 ).fadeTo( 1200, 0 ).attr( 'aria-hidden', 'true' ); + } + } + + function resetMessage() { + spinner.show(); + feedbackElm.fadeTo( 0, 0 ).attr( 'aria-hidden', 'true' ); + feedbackMsg.removeClass().html( '' ); + reportError.fadeTo( 0, 0 ).attr( 'aria-hidden', 'true' ); + } + + /** + * Validate a text-domain slug. + * + * Allowed characters: alphanumeric, underscore and dash. + * + * @param {string} slug The slug to validate. + * @returns {number} -1 if it doesn't match, 0 if it does. + */ + function validateSlug( slug ) { + return slug.search( /^[a-z0-9_-]+$/i ); + } + + /** + * Validate function prefix. + * + * Allowed characters: alphanumeric, underscore. + * + * @param {string} prefix The prefix to validate. + * @returns {number} -1 if it doesn't match, 0 if it does. + */ + function validatePrefix( prefix ) { + return prefix.search( /^[a-z0-9_]+$/i ); + } + + /** + * Validate an addon name. + * + * Allowed characters (for now): alphanumeric, underscore, space and dash. + * + * @param {string} addonName The name to validate. + * @returns {number} -1 if it doesn't match, 0 if it does. + */ + function validateName( addonName ) { + return addonName.search( /^[a-z0-9 _-]+$/i ); + } + + /** + * Validate the received add-on type. + * + * @param {string} addonType The target usage of TGMPA. + * @returns {number} -1 if it doesn't match, 0 or higher if it does. + */ + function validateAddonType( addonType ) { + var valid = new Array( 'parent-theme', 'child-theme', 'plugin' ); + return $.inArray( addonType, valid ); + } + + /** + * Validate the received publish type. + * + * @param {string} publishType The target publication channel. + * @returns {number} -1 if it doesn't match, 0 or higher if it does. + */ + function validatePublishType( publishType ) { + var valid = new Array( 'wporg', 'themeforest', 'other' ); + return $.inArray( publishType, valid ); + } + + /** + * Escape a string for use in a regular expression. + * + * @param {string} str The string to escape. + * @returns {string} + */ + function reEscape( str ) { + return str.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&' ); + } + + /** + * Adjust the file level version tag to indicate that the file was adjusted with the generator. + * + * Used for both class-tgm-plugin-activation.php as well as example.php but only when they're adjusted. + * + * @param {string} content The content to search through. + * @param {string} addonName The name of the theme or plugin. + * @param {string} addonType Whether the target is a parent-theme, child-theme or plugin. + * @param {string} publishType The target publication channel. + * @returns {string} + */ + function addGeneratorUseIndicator( content, addonName, addonType, publishType ) { + var replacement = ' for ' + addonType.replace( /-/g, ' ' ) + ' ' + addonName; + if ( 'wporg' === publishType ) { + replacement += ' for publication on WordPress.org'; + } else if ( 'themeforest' === publishType ) { + replacement += ' for publication on ThemeForest'; + } + return content.replace( /(\* @version\s+[0-9\.]+)([\r\n]+)/, '$1' + replacement + '$2' ); + } + + /** + * Replace text domains in translation functions. + * + * Used for both class-tgm-plugin-activation.php as well as example.php. + * + * The regexes will work as long as there are no strings which contain a ')' within the string, + * though the few strings which contain '(%s)' and '%1$s (%2$d/%3$d)' are accounted for. + * If another type of string with a ')' in it would be added, the regexes will need adjusting + * or a new regex may need to be added. + * + * @param {string} searchString The original text domain. + * @param {string} replacement The text domain to replace it with. + * @param {string} content The content to search through. + * @returns {string} + */ + function replaceTextDomain( searchString, replacement, content ) { + var reBracketsA, reBracketsB, reNoBrackets; + + // Regex escape, but we're not going to be using the searchstring within brackets, so don't escape dashes. + searchString = reEscape( searchString ); + searchString = searchString.replace( /\\-/g, '-' ); + + replacement = '$1' + replacement + '$2'; + + // Deals with "All (%s)" type strings. + reBracketsA = new RegExp( '((?:_[_enx]|_[en]x|_n[x]?_noop|__ngettext_noop|translate_nooped_plural)\\((?:[^\\)]+%s\\)){2}[^\\)]+,\\s+\')' + searchString + '(\'\\s+\\))', 'g' ); + + // Deals with "Updating Plugin %1$s (%2$d/%3$d)" type strings. + reBracketsB = new RegExp( '((?:_[_enx]|_[en]x|_n[x]?_noop|__ngettext_noop|translate_nooped_plural)\\([^\\)]+?%1\\$s \\(%2\\$d/%3\\$d\\)\',\\s+\')' + searchString + '(\'\\s+\\))', 'g' ); + + // Deals with strings without () in them. + reNoBrackets = new RegExp( '((?:_[_enx]|_[en]x|_n[x]?_noop|__ngettext_noop|translate_nooped_plural)\\([^\\)]+,\\s+\')' + searchString + '(\'\\s+\\))', 'g' ); // N.B.: This will also catch esc_attr__ and esc_html__ variants. + + content = content.replace( reBracketsA, replacement ); + content = content.replace( reBracketsB, replacement ); + content = content.replace( reNoBrackets, replacement ); + return content; + } + + /** + * Adjust the path to the bundled plugin based on the target usage of TGMPA. + * + * Used for example.php. + * + * @param {string} content The content to search through. + * @param {string} addonType Whether the target is a parent-theme, child-theme or plugin. + * @returns {string} + */ + function replaceBundledPluginVariable( content, addonType ) { + var re = /('source'\s+=>\s+)get_stylesheet_directory\(\)([^,]+,)/; + if ( 'parent-theme' === addonType ) { + return content.replace( re, '$1get_template_directory()$2' ); + } else if ( 'plugin' === addonType ) { + return content.replace( re, '$1dirname( __FILE__ )$2' ); + } + return content; + } + + /** + * Adjust the file include call for the TGMPA file based on the target usage of TGMPA. + * + * Used for example.php. + * + * @param {string} content The content to search through. + * @param {string} addonType Whether the target is a parent-theme, child-theme or plugin. + * @returns {string} + */ + function replaceIncludeCall( content, addonType ) { + var searchString = 'require_once dirname( __FILE__ ) . \'/class-'; + if ( 'parent-theme' === addonType ) { + return content.replace( searchString, 'require_once get_template_directory() . \'/path/to/class-' ); + } else if ( 'child-theme' === addonType ) { + return content.replace( searchString, 'require_once get_stylesheet_directory() . \'/path/to/class-' ); + } + + return content; + } + + /** + * Replace the config variables to change the menu page with more logical defaults. + * + * Used for example.php when the target usage is a plugin. + * + * @param {string} content The content to search through. + * @returns {string} + */ + function replaceMenuConfigVariables( content ) { + content = content.replace( /('parent_slug'\s+=>\s+')themes.php(',)/, '$1plugins.php$2' ); + content = content.replace( /('capability'\s+=>\s+')edit_theme_options(',)/, '$1manage_options$2' ); + return content; + } + + /** + * Remove the config variables to change the menu page. + * + * Used for example.php when the target usage is a theme to be published on wp.org or themeforest. + * + * @param {string} content The content to search through. + * @returns {string} + */ + function removeMenuConfigVariables( content ) { + return content.replace( /(\t)+'parent_slug'[ ]+=> '[^']*',.*\s+'capability'[ ]+=> '[^']*',[ ]+.*[\n\r]*/, '' ); + } + + /** + * Replace the content of the add_admin_menu() function to comply with the theme review requirements. + * + * Used for class-tgm-plugin-activation.php when the target usage is a theme to be published + * on wp.org or themeforest. + * + * @param {string} content The content to search through. + * @returns {string} + */ + function replaceAddAdminMenuFunction( content ) { + var re, replacement; + + re = /(protected function add_admin_menu\([^\)]*\) \{\s+)(?:[^\}]+\}){3}(\s+})/; + replacement = '$1$this->page_hook = add_theme_page( $args[\'page_title\'], $args[\'menu_title\'], $args[\'capability\'], $args[\'menu_slug\'], $args[\'function\'] );$2'; + return content.replace( re, replacement ); + } + + /** + * Remove the hook-ins for loading of our own text domain and remove the related functions. + * + * Used for class-tgm-plugin-activation.php when the target usage is a theme to be published on wp.org. + * + * @param {string} content The content to search through. + * @returns {string} + */ + function removeLoadTextDomainFunctions( content ) { + var reHookIns, reLoadFunction, reOverloadFunctionA, reOverloadFunctionB, + replacement = ''; + + reHookIns = /[\t]+\/\*(?:[^\*]+\*)+\/\s+add_action\( 'init', array\( \$this, 'load_textdomain' \)[^)]*\);\s+add_filter\( 'load_textdomain_mofile'[^\r\n]+/; + reLoadFunction = /[\t]+\/[\*]{2}(?:[^*]+\*)+\/\s+public function load_textdomain\(\) \{(?:[^\}]+\}){4}/; + reOverloadFunctionA = /[\t]+\/[\*]{2}(?:[^*]+\*)+\/\s+public function correct_plugin_mofile\([^\)]*\) \{(?:[^\}]+\}){4}/; + reOverloadFunctionB = /[\t]+\/[\*]{2}(?:[^*]+\*)+\/\s+public function overload_textdomain_mofile\([^\)]*\) \{(?:[^\}]+\}){5}/; + + content = content.replace( reHookIns, replacement ); + content = content.replace( reLoadFunction, replacement ); + content = content.replace( reOverloadFunctionA, replacement ); + content = content.replace( reOverloadFunctionB, replacement ); + return content; } + /** + * If no prefix or name has been given (yet), pre-fill the fields based on the text-domain value. + */ + $( '#tgmpa-text-domain' ).on( 'blur', function() { + var prefixElm = $( '#tgmpa-prefix' ), + nameElm = $( '#tgmpa-name' ); + + if ( '' === prefixElm.val() ) { + prefixElm.val( $( this ).val().replace( /[ -]/g, '_' ) ); + } + + if ( '' === nameElm.val() ) { + nameElm.val( $( this ).val().replace( /[_-]/g, ' ' ).toTitleCase() ); + } + }); + + /** + * Only show the publication channel fieldset if the targeted usage is a theme. + */ + $( 'input:radio[name="tgmpa-flavor"]' ).on( 'change', function() { + var value = $( this ).val(); + + if ( 'parent-theme' === value || 'child-theme' === value ) { + publishFieldset.fadeTo( 400, 1 ).attr( 'aria-hidden', 'false' ); + } else { + publishFieldset.fadeTo( 400, 0 ).attr( 'aria-hidden', 'true' ); + } + }); + + // Make sure the state is correct on page load. + if ( $( 'input:radio[name="tgmpa-flavor"]' ).is( ':checked' ) ) { + $( 'input:radio[name="tgmpa-flavor"]:checked' ).trigger( 'change' ); + } else { + publishFieldset.fadeTo( 400, 0 ).attr( 'aria-hidden', 'true' ); + } + + //========================= + // Custom TGMPA Generation + //========================= + $( '#generator-form' ).on( 'submit', function( event ) { + var tgmpaDir, slug, prefix, addonName, addonType, publishType, + zip, exampleFileContent, classFileContent, blob; + + event.preventDefault(); + + // Don't do anything if not submitted through our form. + if ( '1' !== $( 'input[name="tgmpa_generate"]' ).val() ) { + return false; + } + + // Clear any old feedback. + resetMessage(); + + tgmpaDir = 'TGM-Plugin-Activation-' + latestVersion; + + // Get the input from the form. + if ( $( 'input:radio[name="tgmpa-flavor"]' ).is( ':checked' ) ) { + addonType = $( 'input:radio[name="tgmpa-flavor"]:checked' ).val(); + } + + slug = $( '#tgmpa-text-domain' ).val(); + + prefix = $( '#tgmpa-prefix' ).val(); + if ( 'undefined' === typeof prefix || '' === prefix ) { + prefix = slug; + } + + addonName = $( '#tgmpa-name' ).val(); + if ( 'undefined' === typeof addonName || '' === addonName ) { + addonName = slug.replace( /-/g, ' ' ).toTitleCase(); + } + + publishType = 'other'; + if ( $( 'input:radio[name="tgmpa-publish"]' ).is( ':checked' ) ) { + publishType = $( 'input:radio[name="tgmpa-publish"]:checked' ).val(); + } + + // Make sure the prefix has underscores, no dashes. + prefix = prefix.replace( /-/g, '_' ); + + /** + * Validate the received data. + */ + if ( ( validateSlug( slug ) === -1 || validatePrefix( prefix ) === -1 ) || ( validateName( addonName ) === -1 || validateAddonType( addonType ) === -1 ) || validatePublishType( publishType ) === -1 ) { + showMessage( 'Invalid input received.', 'error' ); + + return false; + } + + // JSZipUtils.getBinaryContent('https://api.github.com/repos/TGMPA/TGM-Plugin-Activation/zipball/2.5.2', function(err, data) { + JSZipUtils.getBinaryContent( '../releases/' + tgmpaDir + '.zip', function( err, data ) { + if ( err ) { + showMessage( 'Failed to retrieve TGMPA: ' + err, 'error' ); + return false; + } + + try { + + zip = new JSZip( data ); + + /* + * File example.php. + */ + exampleFileContent = zip.file( tgmpaDir + '/example.php' ).asText(); + + // Replace text domain. + exampleFileContent = replaceTextDomain( 'theme-slug', slug, exampleFileContent ); + exampleFileContent = replaceTextDomain( 'tgmpa', slug, exampleFileContent ); // In 2.5.2 is one wrongly tagged string. + + // Replace the file include call. + exampleFileContent = replaceIncludeCall( exampleFileContent, addonType ); + + // Replace the bundled plugin variable. + exampleFileContent = replaceBundledPluginVariable( exampleFileContent, addonType ); + + // Replace function name. + exampleFileContent = exampleFileContent.replace( /([ '"])my_theme_register_required_plugins(['"\(])/g, '$1' + prefix + '_register_required_plugins$2' ); + + // Replace id used for notices. + exampleFileContent = exampleFileContent.replace( /('id'\s+=>\s+')tgmpa(',)/, '$1' + slug + '$2' ); + + // If plugin: change the typical menu location and capability. + if ( 'plugin' === addonType ) { + exampleFileContent = replaceMenuConfigVariables( exampleFileContent ); + } + + // WP.org & Themeforest: remove config variables to change the menu page. + else if ( ( 'wporg' === publishType || 'themeforest' === publishType ) && ( 'parent-theme' === addonType || 'child-theme' === addonType ) ) { + exampleFileContent = removeMenuConfigVariables( exampleFileContent ); + } + + // Show that the file was adjusted using the generator. + exampleFileContent = addGeneratorUseIndicator( exampleFileContent, addonName, addonType, publishType ); + + // Replace the original file with the new content. + zip.file( tgmpaDir + '/example.php', exampleFileContent ); + + /* + * File class-tgm-plugin-activation.php. + */ + if ( 'other' !== publishType && ( 'parent-theme' === addonType || 'child-theme' === addonType ) ) { + classFileContent = zip.file( tgmpaDir + '/class-tgm-plugin-activation.php' ).asText(); + + // Replace the add admin menu function. + classFileContent = replaceAddAdminMenuFunction( classFileContent ); + + if ( 'wporg' === publishType ) { + + // Remove the load textdomain related functions. + classFileContent = removeLoadTextDomainFunctions( classFileContent ); + + // Replace text domain. + classFileContent = replaceTextDomain( 'tgmpa', slug, classFileContent ); + } + + // Show that the file was adjusted using the generator. + classFileContent = addGeneratorUseIndicator( classFileContent, addonName, addonType, publishType ); + + // Replace the original file with the new content. + zip.file( tgmpaDir + '/class-tgm-plugin-activation.php', classFileContent ); + + if ( 'wporg' === publishType ) { + + // Remove the languages directory. + zip.remove( tgmpaDir + '/languages' ); + } + } + + /* + * Remove various development related files. + */ + zip.remove( tgmpaDir + '/.editorconfig' ); + zip.remove( tgmpaDir + '/.jscsrc' ); + zip.remove( tgmpaDir + '/.jshintignore' ); + zip.remove( tgmpaDir + '/.scrutinizer.yml' ); + zip.remove( tgmpaDir + '/.travis.yml' ); + zip.remove( tgmpaDir + '/composer.json' ); + zip.remove( tgmpaDir + '/phpcs.xml' ); + + /* + * Everything has been adjusted, we can trigger the dl. + */ + if ( JSZip.support.blob ) { + try { + blob = zip.generate( { type:'blob' } ); + + // Uses FileSaver.js. + saveAs( blob, tgmpaDir + '-' + slug + '.zip' ); + + showMessage( 'Custom TGMPA succesfully created!', 'success' ); + + } catch ( e ) { + showMessage( 'Failed to generate Custom TGMPA file: ' + e, 'error' ); + } + } else { + showMessage( 'This browser is not supported.', 'warning' ); + } + + return false; + + } catch ( e ) { + showMessage( ' ' + e, 'error' ); + } + }); + + // Make sure that no matter what the spinner will be hidden. + spinner.hide(); + }); + })( jQuery ); diff --git a/js/tgmpa.min.js b/js/tgmpa.min.js index cc0b73db..df736454 100644 --- a/js/tgmpa.min.js +++ b/js/tgmpa.min.js @@ -1 +1 @@ -(function($){if(window.location.hash){if(window.location.hash==='#dependencies'){window.location.hash='#requirements'}else if(window.location.hash==='#download'||window.location.hash==='#installation'||window.location.hash==='#screenshots'||window.location.hash==='#authors'){var _hash=window.location.hash.split('#');window.location.replace(siteurl+'/'+_hash)}}function compare_version_number(a,b){var a_version=get_tag_from_tag_name(a.tag_name);var b_version=get_tag_from_tag_name(b.tag_name);var a_status=get_status_from_tag_name(a.tag_name);var b_status=get_status_from_tag_name(b.tag_name);if(a_versionb_version){return 1}if(a_status b_status){return 1}return 0}function get_tag_from_tag_name(tag_name){if(tag_name.match(/[0-9\.]+/)){return tag_name.replace(/^(?:v)?([0-9\.]+)(?:-(?:alpha|beta|rc[0-9-]?))?.*$/i,"$1")}else{return''}}function get_version_from_name(name){if(name.match(/[0-9]+\.[0-9]+\.[0-9]+/)){return name.replace(/^.*?([0-9]+\.[0-9]+\.[0-9]+\-(?:alpha|beta|rc[0-9-]?)).*$/i,"$1")}else{return''}}function get_status_from_tag_name(tag_name){if(tag_name.match(/alpha|beta|rc[0-9-]?/i)){return tag_name.replace(/^(?:v)?(?:[0-9\.]+)(?:-(alpha|beta|rc[0-9-]?))?.*$/i,"$1").toLowerCase()}else{return''}}function get_releasedate(release){var months=["January","February","March","April","May","June","July","August","September","October","November","December"];var release_date='';if(release.name.match(/\([0-9]{4}-[0-9]{2}-[0-9]{2}\)/)){release_date=release.name.replace(/^[^\(]+\(([0-9]{4}-[0-9]{2}-[0-9]{2})\).*$/,"$1")}if(''===release_date&&release.published_at){release_date=release.published_at.substr(0,10)}release_date=new Date(release_date);return months[release_date.getUTCMonth()]+' '+release_date.getUTCDate()+', '+release_date.getUTCFullYear()}var zip_urls=$('.latest-zip');var tar_urls=$('.latest-tar');var version_nr=$('.version-number');var release_date=$('.release-date');var releases=$('#releases-table tbody');if((ghreleases&&ghreleases.length)&&(zip_urls.length||tar_urls.length||version_nr.length||releases.length)){ghreleases.sort(compare_version_number);var latest_release=ghreleases.pop();if(version_nr.length&&latest_release.name){var latest_version=get_version_from_name(latest_release.name);if(''===latest_version&&latest_release.tag_name){latest_version=get_version_from_name(latest_release.tag_name)}if(''!==latest_version){version_nr.html(latest_version)}}if(zip_urls.length&&latest_release.zipball_url){zip_urls.attr('href',latest_release.zipball_url)}if(tar_urls.length&&latest_release.tarball_url){tar_urls.attr('href',latest_release.tarball_url)}if(release_date.length){var published=get_releasedate(latest_release);if(published){release_date.html(', released at '+published)}}if(latest_release.body.length){marked.setOptions({renderer:new marked.Renderer(),gfm:true,tables:true,breaks:true,pedantic:false,sanitize:true,smartLists:true,smartypants:true});$('#release-notes').prepend(marked(latest_release.body)).prepend(' Version '+latest_release.name+'
');$('#no-release-notes').remove()}else{$('#release-notes').remove()}if(releases.length){ghreleases.reverse();var tablerows='';var max_rows=Math.min(5,ghreleases.length);for(var i=0;i',ghreleases[i].tag_name,' ',release_date_cell,' zipball tarball '].join('')}releases.html(tablerows)}}else{$('#releases-table').remove();$('#release-notes').remove()}})(jQuery); \ No newline at end of file +(function($){var _hash,versionNr=$(".version-number"),releaseDate=$(".release-date"),zipUrls,tarUrls,releasesTable,releaseNotes,releases,spinner,publishFieldset,feedbackElm,feedbackMsg,reportError,latestVersion,latestRelease,releasePublished;zipUrls=$(".latest-zip");tarUrls=$(".latest-tar");releasesTable=$("#releases-table");releaseNotes=$("#release-notes");releases=releasesTable.find("tbody");spinner=$("#spinner");publishFieldset=$("#tgmpa-form-publish");feedbackElm=$(".generator-feedback");feedbackMsg=$("#generator-feedback");reportError=$("#report-generator-error");latestVersion="";if(window.location.hash){if("#dependencies"===window.location.hash){window.location.hash="#requirements"}else{if("#download"===window.location.hash||"#installation"===window.location.hash||"#screenshots"===window.location.hash||"#authors"===window.location.hash){_hash=window.location.hash.split("#");window.location.replace(siteurl+"/"+_hash)}}}function compareVersionNumber(a,b){var aVersion,bVersion,aStatus,bStatus;aVersion=getTagFromTagName(a.tag_name);bVersion=getTagFromTagName(b.tag_name);aStatus=getStatusFromTagName(a.tag_name);bStatus=getStatusFromTagName(b.tag_name);if(aVersionbVersion){return 1}if(aStatus bStatus){return 1}return 0}function getTagFromTagName(tagName){if(tagName.match(/[0-9\.]+/)){return tagName.replace(/^(?:v)?([0-9\.]+)(?:-(?:alpha|beta|rc[0-9-]?))?.*$/i,"$1")}else{return""}}function getVersionFromName(name){if(name.match(/[0-9]+\.[0-9]+\.[0-9]+/)){return name.replace(/^.*?([0-9]+\.[0-9]+\.[0-9]+\-(?:alpha|beta|rc[0-9-]?)).*$/i,"$1")}else{return""}}function getStatusFromTagName(tagName){if(tagName.match(/alpha|beta|rc[0-9-]?/i)){return tagName.replace(/^(?:v)?(?:[0-9\.]+)(?:-(alpha|beta|rc[0-9-]?))?.*$/i,"$1").toLowerCase()}else{return""}}function getReleaseDate(release){var months,releaseDate;months=["January","February","March","April","May","June","July","August","September","October","November","December"];releaseDate="";if(release.name.match(/\([0-9]{4}-[0-9]{2}-[0-9]{2}\)/)){releaseDate=release.name.replace(/^[^\(]+\(([0-9]{4}-[0-9]{2}-[0-9]{2})\).*$/,"$1")}if(""===releaseDate&&release.published_at){releaseDate=release.published_at.substr(0,10)}releaseDate=new Date(releaseDate);return months[releaseDate.getUTCMonth()]+" "+releaseDate.getUTCDate()+", "+releaseDate.getUTCFullYear()}function createReleaseTableRows(nrOfRows){var i,maxRows,releaseDate,tableRows="";ghreleases.reverse();maxRows=Math.min(nrOfRows,ghreleases.length);for(i=0;i ",ghreleases[i].tag_name," ",releaseDate,' zipball tarball '].join("")}return tableRows}if((ghreleases&&ghreleases.length)&&(zipUrls.length||tarUrls.length||versionNr.length||releases.length)){ghreleases.sort(compareVersionNumber);latestRelease=ghreleases.pop();if(versionNr.length&&latestRelease.name){latestVersion=getVersionFromName(latestRelease.name);if(""===latestVersion&&latestRelease.tag_name){latestVersion=getVersionFromName(latestRelease.tag_name)}if(""!==latestVersion){versionNr.html(latestVersion)}}if(zipUrls.length&&latestRelease.zipball_url){zipUrls.attr("href",latestRelease.zipball_url)}if(tarUrls.length&&latestRelease.tarball_url){tarUrls.attr("href",latestRelease.tarball_url)}if(releaseDate.length){releasePublished=getReleaseDate(latestRelease);if(releasePublished){releaseDate.html(", released at "+releasePublished)}}if(latestRelease.body.length){marked.setOptions({renderer:new marked.Renderer(),gfm:true,tables:true,breaks:true,pedantic:false,sanitize:true,smartLists:true,smartypants:true});releaseNotes.prepend(marked(latestRelease.body)).prepend("Version "+latestRelease.name+"
");$("#no-release-notes").remove()}else{releaseNotes.remove()}if(releases.length){releases.html(createReleaseTableRows(5))}}else{releasesTable.remove();releaseNotes.remove()}function showMessage(text,classname){spinner.hide();feedbackElm.fadeTo(200,1).attr("aria-hidden","false");feedbackMsg.addClass(classname).html(text);if("error"===classname){reportError.fadeTo(0,1).attr("aria-hidden","false")}if("success"===classname){feedbackElm.delay(5000).fadeTo(1200,0).attr("aria-hidden","true")}}function resetMessage(){spinner.show();feedbackElm.fadeTo(0,0).attr("aria-hidden","true");feedbackMsg.removeClass().html("");reportError.fadeTo(0,0).attr("aria-hidden","true")}function validateSlug(slug){return slug.search(/^[a-z0-9_-]+$/i)}function validatePrefix(prefix){return prefix.search(/^[a-z0-9_]+$/i)}function validateName(addonName){return addonName.search(/^[a-z0-9 _-]+$/i)}function validateAddonType(addonType){var valid=new Array("parent-theme","child-theme","plugin");return $.inArray(addonType,valid)}function validatePublishType(publishType){var valid=new Array("wporg","themeforest","other");return $.inArray(publishType,valid)}function reEscape(str){return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function addGeneratorUseIndicator(content,addonName,addonType,publishType){var replacement=" for "+addonType.replace(/-/g," ")+" "+addonName;if("wporg"===publishType){replacement+=" for publication on WordPress.org"}else{if("themeforest"===publishType){replacement+=" for publication on ThemeForest"}}return content.replace(/(\* @version\s+[0-9\.]+)([\r\n]+)/,"$1"+replacement+"$2")}function replaceTextDomain(searchString,replacement,content){var reBracketsA,reBracketsB,reNoBrackets;searchString=reEscape(searchString);searchString=searchString.replace(/\\-/g,"-");replacement="$1"+replacement+"$2";reBracketsA=new RegExp("((?:_[_enx]|_[en]x|_n[x]?_noop|__ngettext_noop|translate_nooped_plural)\\((?:[^\\)]+%s\\)){2}[^\\)]+,\\s+')"+searchString+"('\\s+\\))","g");reBracketsB=new RegExp("((?:_[_enx]|_[en]x|_n[x]?_noop|__ngettext_noop|translate_nooped_plural)\\([^\\)]+?%1\\$s \\(%2\\$d/%3\\$d\\)',\\s+')"+searchString+"('\\s+\\))","g");reNoBrackets=new RegExp("((?:_[_enx]|_[en]x|_n[x]?_noop|__ngettext_noop|translate_nooped_plural)\\([^\\)]+,\\s+')"+searchString+"('\\s+\\))","g");content=content.replace(reBracketsA,replacement);content=content.replace(reBracketsB,replacement);content=content.replace(reNoBrackets,replacement);return content}function replaceBundledPluginVariable(content,addonType){var re=/('source'\s+=>\s+)get_stylesheet_directory\(\)([^,]+,)/;if("parent-theme"===addonType){return content.replace(re,"$1get_template_directory()$2")}else{if("plugin"===addonType){return content.replace(re,"$1dirname( __FILE__ )$2")}}return content}function replaceIncludeCall(content,addonType){var searchString="require_once dirname( __FILE__ ) . '/class-";if("parent-theme"===addonType){return content.replace(searchString,"require_once get_template_directory() . '/path/to/class-")}else{if("child-theme"===addonType){return content.replace(searchString,"require_once get_stylesheet_directory() . '/path/to/class-")}}return content}function replaceMenuConfigVariables(content){content=content.replace(/('parent_slug'\s+=>\s+')themes.php(',)/,"$1plugins.php$2");content=content.replace(/('capability'\s+=>\s+')edit_theme_options(',)/,"$1manage_options$2");return content}function removeMenuConfigVariables(content){return content.replace(/(\t)+'parent_slug'[ ]+=> '[^']*',.*\s+'capability'[ ]+=> '[^']*',[ ]+.*[\n\r]*/,"")}function replaceAddAdminMenuFunction(content){var re,replacement;re=/(protected function add_admin_menu\([^\)]*\) \{\s+)(?:[^\}]+\}){3}(\s+})/;replacement="$1$this->page_hook = add_theme_page( $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function'] );$2";return content.replace(re,replacement)}function removeLoadTextDomainFunctions(content){var reHookIns,reLoadFunction,reOverloadFunctionA,reOverloadFunctionB,replacement="";reHookIns=/[\t]+\/\*(?:[^\*]+\*)+\/\s+add_action\( 'init', array\( \$this, 'load_textdomain' \)[^)]*\);\s+add_filter\( 'load_textdomain_mofile'[^\r\n]+/;reLoadFunction=/[\t]+\/[\*]{2}(?:[^*]+\*)+\/\s+public function load_textdomain\(\) \{(?:[^\}]+\}){4}/;reOverloadFunctionA=/[\t]+\/[\*]{2}(?:[^*]+\*)+\/\s+public function correct_plugin_mofile\([^\)]*\) \{(?:[^\}]+\}){4}/;reOverloadFunctionB=/[\t]+\/[\*]{2}(?:[^*]+\*)+\/\s+public function overload_textdomain_mofile\([^\)]*\) \{(?:[^\}]+\}){5}/;content=content.replace(reHookIns,replacement);content=content.replace(reLoadFunction,replacement);content=content.replace(reOverloadFunctionA,replacement);content=content.replace(reOverloadFunctionB,replacement);return content}$("#tgmpa-text-domain").on("blur",function(){var prefixElm=$("#tgmpa-prefix"),nameElm=$("#tgmpa-name");if(""===prefixElm.val()){prefixElm.val($(this).val().replace(/[ -]/g,"_"))}if(""===nameElm.val()){nameElm.val($(this).val().replace(/[_-]/g," ").toTitleCase())}});$('input:radio[name="tgmpa-flavor"]').on("change",function(){var value=$(this).val();if("parent-theme"===value||"child-theme"===value){publishFieldset.fadeTo(400,1).attr("aria-hidden","false")}else{publishFieldset.fadeTo(400,0).attr("aria-hidden","true")}});if($('input:radio[name="tgmpa-flavor"]').is(":checked")){$('input:radio[name="tgmpa-flavor"]:checked').trigger("change")}else{publishFieldset.fadeTo(400,0).attr("aria-hidden","true")}$("#generator-form").on("submit",function(event){var tgmpaDir,slug,prefix,addonName,addonType,publishType,zip,exampleFileContent,classFileContent,blob;event.preventDefault();if("1"!==$('input[name="tgmpa_generate"]').val()){return false}resetMessage();tgmpaDir="TGM-Plugin-Activation-"+latestVersion;if($('input:radio[name="tgmpa-flavor"]').is(":checked")){addonType=$('input:radio[name="tgmpa-flavor"]:checked').val()}slug=$("#tgmpa-text-domain").val();prefix=$("#tgmpa-prefix").val();if("undefined"===typeof prefix||""===prefix){prefix=slug}addonName=$("#tgmpa-name").val();if("undefined"===typeof addonName||""===addonName){addonName=slug.replace(/-/g," ").toTitleCase()}publishType="other";if($('input:radio[name="tgmpa-publish"]').is(":checked")){publishType=$('input:radio[name="tgmpa-publish"]:checked').val()}prefix=prefix.replace(/-/g,"_");if((validateSlug(slug)===-1||validatePrefix(prefix)===-1)||(validateName(addonName)===-1||validateAddonType(addonType)===-1)||validatePublishType(publishType)===-1){showMessage("Invalid input received.","error");return false}JSZipUtils.getBinaryContent("../releases/"+tgmpaDir+".zip",function(err,data){if(err){showMessage("Failed to retrieve TGMPA: "+err,"error");return false}try{zip=new JSZip(data);exampleFileContent=zip.file(tgmpaDir+"/example.php").asText();exampleFileContent=replaceTextDomain("theme-slug",slug,exampleFileContent);exampleFileContent=replaceTextDomain("tgmpa",slug,exampleFileContent);exampleFileContent=replaceIncludeCall(exampleFileContent,addonType);exampleFileContent=replaceBundledPluginVariable(exampleFileContent,addonType);exampleFileContent=exampleFileContent.replace(/([ '"])my_theme_register_required_plugins(['"\(])/g,"$1"+prefix+"_register_required_plugins$2");exampleFileContent=exampleFileContent.replace(/('id'\s+=>\s+')tgmpa(',)/,"$1"+slug+"$2");if("plugin"===addonType){exampleFileContent=replaceMenuConfigVariables(exampleFileContent)}else{if(("wporg"===publishType||"themeforest"===publishType)&&("parent-theme"===addonType||"child-theme"===addonType)){exampleFileContent=removeMenuConfigVariables(exampleFileContent)}}exampleFileContent=addGeneratorUseIndicator(exampleFileContent,addonName,addonType,publishType);zip.file(tgmpaDir+"/example.php",exampleFileContent);if("other"!==publishType&&("parent-theme"===addonType||"child-theme"===addonType)){classFileContent=zip.file(tgmpaDir+"/class-tgm-plugin-activation.php").asText();classFileContent=replaceAddAdminMenuFunction(classFileContent);if("wporg"===publishType){classFileContent=removeLoadTextDomainFunctions(classFileContent);classFileContent=replaceTextDomain("tgmpa",slug,classFileContent)}classFileContent=addGeneratorUseIndicator(classFileContent,addonName,addonType,publishType);zip.file(tgmpaDir+"/class-tgm-plugin-activation.php",classFileContent);if("wporg"===publishType){zip.remove(tgmpaDir+"/languages")}}zip.remove(tgmpaDir+"/.editorconfig");zip.remove(tgmpaDir+"/.jscsrc");zip.remove(tgmpaDir+"/.jshintignore");zip.remove(tgmpaDir+"/.scrutinizer.yml");zip.remove(tgmpaDir+"/.travis.yml");zip.remove(tgmpaDir+"/composer.json");zip.remove(tgmpaDir+"/phpcs.xml");if(JSZip.support.blob){try{blob=zip.generate({type:"blob"});saveAs(blob,tgmpaDir+"-"+slug+".zip");showMessage("Custom TGMPA succesfully created!","success")}catch(e){showMessage("Failed to generate Custom TGMPA file: "+e,"error")}}else{showMessage("This browser is not supported.","warning")}return false}catch(e){showMessage(" "+e,"error")}});spinner.hide()})})(jQuery); \ No newline at end of file diff --git a/js/to-title-case.min.js b/js/to-title-case.min.js new file mode 100644 index 00000000..ec18074d --- /dev/null +++ b/js/to-title-case.min.js @@ -0,0 +1,2 @@ +/* To Title Case 2.1 – http://individed.com/code/to-title-case/ */ +String.prototype.toTitleCase=function(){var smallWords=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;return this.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g,function(match,index,title){if(index>0&&index+match.length!==title.length&&match.search(smallWords)>-1&&title.charAt(index-2)!==":"&&(title.charAt(index+match.length)!=="-"||title.charAt(index-1)==="-")&&title.charAt(index-1).search(/[^\s-]/)<0){return match.toLowerCase()}if(match.substr(1).search(/[A-Z]|\../)>-1){return match}return match.charAt(0).toUpperCase()+match.substr(1)})}; \ No newline at end of file diff --git a/releases/TGM-Plugin-Activation-2.5.2.zip b/releases/TGM-Plugin-Activation-2.5.2.zip new file mode 100644 index 00000000..085558a7 Binary files /dev/null and b/releases/TGM-Plugin-Activation-2.5.2.zip differ