celanup
@ -12,7 +12,7 @@ class BdpVersionChecker
|
||||
{
|
||||
$plugin_data = get_plugin_data( BDP_LV_STARTUP_FILE );
|
||||
$this->plugin_slug = BDP_LV_PLUGIN_SLUG;
|
||||
$this->updateUrl = $plugin_data['UpdateURI'] . '/info_development.json';
|
||||
$this->updateUrl = $plugin_data['UpdateURI'] . '/info.json';
|
||||
$this->version = $plugin_data['Version'];
|
||||
$this->cache_key = 'bdp-kompass-upd';
|
||||
$this->cache_allowed = false;
|
||||
|
@ -1,104 +0,0 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
@import url("font/ihs.css");
|
||||
|
||||
html, body { border: 0 none; padding: 0; margin: 0; min-height: 100%; position: static; }
|
||||
html { font-family: Sans-Serif; background: url("img/holz.jpg") #dbb97b; position: relative; }
|
||||
body { margin: 1em; padding: 1em; max-width: 710px; background: #fff; font-size: 81.3% !important; }
|
||||
body.post-type-gallery { background: transparent; }
|
||||
header, hgroup, nav, footer, article { display: block; }
|
||||
.h, h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 { margin: 0; font-family: IHS, Serif; font-size: 1em; font-weight: normal; font-style: normal; }
|
||||
button, input, select, optgroup, option { margin: 0; font: inherit; color: inherit; }
|
||||
button, input[type="button"], input[type="submit"], input[type="reset"] { cursor: pointer; }
|
||||
p, ul, ol, dt { line-height: 1.5; }
|
||||
abbr { border-bottom: 1px dotted; }
|
||||
a { color: #1d4899; }
|
||||
figure, .wp-caption { margin: 0; max-width: 100%; }
|
||||
figcaption, .wp-caption-text { font-style: italic; padding: 0.5em 0; }
|
||||
.screen-reader-text { display: none; }
|
||||
.aligncenter { margin: 0 auto; }
|
||||
.alignleft { float: left; margin: 0 1em 0 0; }
|
||||
.alignright { float: right; margin: 0 0 0 1em; }
|
||||
|
||||
::-moz-selection { background: #1d4899; color: #ffcb04; text-shadow: none; outline: 2px solid #1d4899; }
|
||||
::selection { background: #1d4899; color: #ffcb04; text-shadow: none; outline: 2px solid #1d4899; }
|
||||
|
||||
/* Media object */
|
||||
.media { margin: 1em 0; }
|
||||
.media, .bd { overflow: hidden; _overflow: visible; }
|
||||
/*.media img { display: block; }*/
|
||||
/* Clearfix */
|
||||
.clearfix::after,
|
||||
.clearfix::before,
|
||||
.media::after,
|
||||
.media::before { content: " "; display: table; }
|
||||
.clearfix::after,
|
||||
.media::after { clear: both; }
|
||||
|
||||
/* Überschriften mit Bild darunter */
|
||||
.h-box { position: relative; display: block; margin-bottom: 1em; text-decoration: none; }
|
||||
.h-box > img { position: absolute; top: 0; left: 0; height: 100%; width: 100%; }
|
||||
.h-box > .wrap { position: absolute; max-width: 100%; left: 0; }
|
||||
.h-box > .wrap > * { display: inline; -o-box-decoration-break: clone; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
|
||||
|
||||
.h-box-teaser { box-shadow: 0 5px 5px rgba(0, 0, 0, 0.3); margin-left: -240px; line-height: 1; display: inline-block; width: 1300px; max-width: 100%; }
|
||||
.h-box-teaser > img { position: static; }
|
||||
.h-box-teaser > .wrap { bottom: 1em; padding-left: 240px; }
|
||||
.h-box-teaser > .wrap > * { background: rgba(56, 46, 35, 0.7); color: #ffcb04; padding: 2px 13px 4px; font-size: 52px; line-height: 78px; }
|
||||
@media (max-width: 720px) {
|
||||
.h-box-teaser { margin-top: 1em; margin-left: 0; }
|
||||
.h-box-teaser > .wrap { padding-left: 1em; }
|
||||
.h-box-teaser > .wrap > * { font-size: 2em; line-height: 39px; }
|
||||
}
|
||||
|
||||
.h-box-blaugelb { padding-top: 47.1428571%; }
|
||||
.h-box-blaugelb > .wrap { bottom: 0; font-size: 18px; }
|
||||
.h-box-blaugelb > .wrap > * { color: #1d4899; background: #ffcb04; padding: 3px 5px; line-height: 26px; }
|
||||
|
||||
.h-box-blaugelb-bildlos { padding: 0; }
|
||||
.h-box-blaugelb-bildlos > .wrap { position: static; }
|
||||
/**/
|
||||
|
||||
.container { max-width: 1020px; }
|
||||
.page .container,
|
||||
.single-post:not(.single-format-gallery) .container { max-width: 710px; }
|
||||
|
||||
.content-singular .format-gallery { background: transparent; padding: 0; margin: 0; position: relative; }
|
||||
.content-singular .format-gallery .gallery { display: flex; flex-wrap: wrap; align-content: space-between; align-items: flex-start; }
|
||||
.content-singular .format-gallery .gallery-item { background: #fff; padding: 1em; margin: 0 1em 1em 0; }
|
||||
.gallery-columns-1 .gallery-item { flex: 1 0 50%; }
|
||||
.gallery-columns-2 .gallery-item { flex: 1 0 34%; }
|
||||
.gallery-columns-3 .gallery-item { flex: 1 0 25%; }
|
||||
.gallery-columns-4 .gallery-item { flex: 1 0 20%; }
|
||||
|
||||
.content-gallery { display: flex; position: relative; z-index: 10; flex-wrap: wrap; overflow: hidden; }
|
||||
.content-gallery > article { flex: 1 1 25%; }
|
||||
body > :first-child { margin-top: 0; }
|
||||
body > :last-child { margin-bottom: 0; }
|
||||
.content-singular > article:not(.format-gallery),
|
||||
.content-gallery > article,
|
||||
.commentlist article,
|
||||
.comment-form { min-width: 20em; background: #fff; box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1); }
|
||||
.content-gallery > article { max-width: calc(33.333% - 1em); }
|
||||
@media (max-width: 800px) { .content-gallery > article { max-width: 100%; } }
|
||||
|
||||
/* WordPress-Wünsche */
|
||||
.sticky {}
|
||||
|
||||
img { max-width: 100%; height: auto; border: 0 none; vertical-align: middle; }
|
||||
ul, ol { padding-left: 2em; }
|
||||
dl, ul, ol, h1, h2, h3, h4, h5, h6, blockquote, p, table { margin: 0.5em 0; }
|
||||
dd, li > ol, li > ul { margin: 0; }
|
||||
dt { font-weight: bold; }
|
||||
blockquote, dd { padding-left: 2em; }
|
||||
body > p:empty:last-child { margin: -0.5em 0 0.5em; }
|
||||
h3, .h3, h4, .h4, h5, .h5, h6, .h6 { display: inline-block; background: #ffcb04; color: #1d4899; margin-bottom: 0; padding: 2px 4px; }
|
||||
h3, .h3 { font-size: 18px; padding: 3px 5px; }
|
||||
h4, .h4 { font-size: 16px; }
|
||||
h5, .h5 { font-size: 14px; }
|
||||
.gallery-caption {}
|
||||
.bypostauthor {}
|
||||
.twitter-tweet {}
|
||||
|
||||
h1, .h1, h2, .h2 { font-size: 20px; }
|
||||
h1::after, h2::after { color: red; background: black; display: block; padding: 5px; content: "Bitte Überschriften ab 3. Ordnung benutzen."; }
|
@ -1,11 +0,0 @@
|
||||
@font-face {
|
||||
font-family: IHS;
|
||||
src: url('ihs.eot');
|
||||
src: url('ihs.eot?#iefix') format('embedded-opentype'),
|
||||
url('ihs.woff2') format('woff2'),
|
||||
url('ihs.woff') format('woff'),
|
||||
url('ihs.ttf') format('truetype'),
|
||||
url('ihs.svg#immenhausenregular') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
Before Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 783 B |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 332 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 599 B |
Before Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 561 B |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 34 KiB |
@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 2400 2400" width="14" height="14"><path style="fill:#fff;stroke:none" d="m 975,25 q 129,0 252,34 123,34 227,95.5 104,61.5 191.5,149 87.5,87.5 149,192 61.5,104.5 95.5,227.5 34,123 34,251 0,278 -152,514 l 588,588 q 15,14 15,35 0,21 -15,36 l -213,213 q -15,15 -36,15 -21,0 -35,-15 l -588,-588 q -235,152 -513,152 -129,0 -252,-34 Q 600,1856 496,1794.5 392,1733 304,1645.5 216,1558 155,1453.5 94,1349 59.5,1226 25,1103 25,974.5 25,846 59.5,723 94,600 155,495.5 216,391 304,303.5 392,216 496,154.5 600,93 723,59 846,25 975,25 Z m -0.5,302 Q 843,327 723,378 603,429 516.5,516 430,603 378.5,723 327,843 327,974.5 q 0,131.5 51.5,251.5 51.5,120 138,207 86.5,87 206.5,138 120,51 251.5,51 131.5,0 251.5,-51 120,-51 207,-138 87,-87 138.5,-207 Q 1623,1106 1623,974.5 1623,843 1571.5,723 1520,603 1433,516 1346,429 1226,378 1106,327 974.5,327 Z" /></svg>
|
Before Width: | Height: | Size: 907 B |
@ -1 +0,0 @@
|
||||
<svg xmlns='http://www.w3.org/2000/svg' height='300' width='470' viewBox='0 0 300 425' preserveAspectRatio='xMinYMin meet'><defs><linearGradient id='v' x1='0' y1='0' x2='0' y2='140%'><stop offset='0' stop-color='#000' stop-opacity='0.7' /><stop offset='50%' stop-color='#000' stop-opacity='0.4' /><stop offset='80%' stop-color='#000' stop-opacity='0.1' /><stop offset='100%' stop-color="#000" stop-opacity='0' /></linearGradient></defs><path d='M10,200 C150,170 450,180 615,190 L608,00 L15,0 Z' style='stroke:none;' fill='url(#v)'></path></svg>
|
Before Width: | Height: | Size: 545 B |
Before Width: | Height: | Size: 21 KiB |
@ -1,103 +0,0 @@
|
||||
Buena
|
||||
=======
|
||||
|
||||
Das WordPress-Theme zum neuen Corporate Design des BdP.
|
||||
|
||||
Änderungswünsche? Kritik?
|
||||
philipp.cordes@pfadfinden.de
|
||||
|
||||
|
||||
Anderthalb Hinweise zur Benutzung
|
||||
-----------------------------------
|
||||
|
||||
Das Theme ist noch nicht ganz fertig, an einigen Stellen wird noch gehobelt.
|
||||
|
||||
In Beiträgen mögt ihr bitte erst Überschriften ab 3. Ordnung verwenden,
|
||||
die erster Ordnung sind für den Header und die zweiter Ordnung sind für
|
||||
die Titel der Beiträge. Es gibt dafür auch fette Hinweise beim Bearbeiten.
|
||||
|
||||
|
||||
Eine kleine Änderungshistorie
|
||||
-------------------------------
|
||||
|
||||
v1.0 - TODO
|
||||
- Das Abschalten des Posterbilds für ist Seiten und Beiträge ohne Bild möglich.
|
||||
- Beitragsarten und deren unterschiedliche Darstellung ist auch für Seiten verfügbar.
|
||||
- Schmale Beitragsbilder (<1300px Breite) zerlegen das Layout nicht mehr.
|
||||
- Login-Formular im Widgetbereich unterstützen.
|
||||
|
||||
v0.99.7 - 21.09.2015
|
||||
- Safari bricht jetzt Artikelauflistungen richtig um. Die anderen machen es auch etwas besser.
|
||||
- Safari zeigt jetzt Suchfelder richtig an.
|
||||
- Safari malt die Trennline in der Navigation nicht mehr zu dick.
|
||||
- Wenn das Ajax-Login-Formular benutzt wird, verschwindet das Hamburgermenü nicht mehr.
|
||||
|
||||
v0.99.6 - 19.09.2015
|
||||
- Weitere Blau- und Gelbtöne einheitlich umgesetzt, v.a. im Editor.
|
||||
- Update für Milu: Zusatz „Kategorie“ wird im Titel auf abendlager.pfadfinden.de nicht mehr angezeigt.
|
||||
- Der linke Rand wird jetzt immer eingehalten, egal wie lang der Navigationsbereich ist.
|
||||
- Anpassung an WordPress 4.3: Favicon kommt nur aus dem Theme, wenn kein eigenes gesetzt ist.
|
||||
- Der Hinweis, dass Kommentare nicht möglich sind, wird standardmäßig ausgeblendet.
|
||||
- Links in der Navigation färben sich jetzt anhand der Hierarchie im Menü ein, nicht derer der Seiten.
|
||||
|
||||
v0.99.5 - 19.08.2015
|
||||
- Seitentitel beschreiben jetzt besser, was tatsächlich angezeigt wird.
|
||||
- Farben aus dem Handbuch einheitlich umgesetzt.
|
||||
|
||||
v0.99.4 - 13.08.2015
|
||||
- Das Menü wird automatisch wieder eingeblendet, wenn die Fensterbreite über 720px steigt.
|
||||
- Fehlerkorrektur: Es werden keine Urls mehr unter dem Editorfeld ausgegeben.
|
||||
- Das Theme ist nicht mehr auf das Plugin angewiesen. Die benötigte Bilbiothek shy-wordpress wird direkt mitgeliefert.
|
||||
|
||||
v0.99.3 - 01.08.2015
|
||||
- Der Editor sollte jetzt in den meisten Fällen eine realistische Vorschau bieten.
|
||||
- Überschriften sind jetzt blau auf gelb.
|
||||
Überschriften erster und zweiter Ordnung in Beiträgen und Seiten werden durch Überschriften dritter Ordnung ersetzt.
|
||||
- Schrift „Immenhausen“ durch verbesserte Variante ausgetauscht.
|
||||
- Kleinere Korrekturen an Abständen.
|
||||
|
||||
v0.99.2 - 27.07.2015
|
||||
- Kleinere Textanpassungen.
|
||||
|
||||
v0.99.1 - 27.07.2015
|
||||
- Auf großen Displays wird das Beitragsbild nicht mehr verzerrt.
|
||||
|
||||
v0.99 - 26.07.2015
|
||||
- Erster Kandidat zur Veröffentlichung als Version 1.0.
|
||||
- Die Überschriften erstrahlen in vollem Glanz.
|
||||
- Kommentare sehen besser aus.
|
||||
- Das Theme ist responsive bis runter auf 300px.
|
||||
- Fußleiste überarbeitet und zweigeteilt.
|
||||
|
||||
v0.9.1 - 07.07.2015
|
||||
- Fehlerkorrektur: Der Titel wird nicht mehr doppelt angezeigt.
|
||||
|
||||
v0.9 - 03.07.2015
|
||||
- Kommentare werden jetzt angezeigt.
|
||||
- Etwas mehr responsive: Mindestbreite 700px für ordentliche Anzeige.
|
||||
|
||||
v0.8 - 21.06.2015
|
||||
- Standardwidgets sehen jetzt in der Leiste gut aus.
|
||||
- Die Fußzeile sitzt jetzt fester an ihrem Platz.
|
||||
|
||||
v0.7 - 18.06.2015
|
||||
- Große Posterbilder hinzugefügt, die auch auf der Bundeswebseite zu sehen sind.
|
||||
- Erhebliche Verbesserungen der Darstellung.
|
||||
|
||||
v0.6 - 16.06.2015
|
||||
- Mehr Unterstützung für HTML5.
|
||||
|
||||
v0.5 - 16.06.2015
|
||||
- Fehler behoben, der die WordPress-Installation unbrauchbar machen könnte.
|
||||
|
||||
v0.4 - 11.06.2015
|
||||
- Navigation überarbeitet.
|
||||
|
||||
v0.3 - 10.06.2015
|
||||
- Webfont Immenhausen für Überschriften.
|
||||
|
||||
v0.2 - 04.06.2015
|
||||
- Grafiken eingebaut.
|
||||
|
||||
v0.1 - 20.04.2015
|
||||
- Erste Veröffentlichung.
|
Before Width: | Height: | Size: 336 KiB |
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace plugins\buena\src\Pfadfinden\WordPress;
|
||||
|
||||
use Pfadfinden\WordPress\wordpress;
|
||||
use wordpress\src\Shy\WordPress\CompositeOption;
|
||||
|
||||
|
||||
|
||||
class BuenaSettings extends wordpress\src\Shy\WordPress\CompositeOption
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct( 'buena-theme' );
|
||||
}
|
||||
|
||||
public function getDefaults()
|
||||
{
|
||||
return [
|
||||
'use_cdn' => false,
|
||||
'always_show_poster' => true,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace plugins\buena\src\Pfadfinden\WordPress;
|
||||
|
||||
use Shy\WordPress\Administration\SettingsPage;
|
||||
use Shy\WordPress\Administration\CheckboxField;
|
||||
|
||||
|
||||
|
||||
class BuenaSettingsPage extends SettingsPage
|
||||
{
|
||||
public function getFields()
|
||||
{
|
||||
$this->addSection( '', 'buena' );
|
||||
|
||||
return array(
|
||||
'use_cdn' => new CheckboxField(),
|
||||
'always_show_poster' => new CheckboxField(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getParentSlug()
|
||||
{
|
||||
return 'themes.php';
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return __( 'Buena-Einstellungen', 'buena-theme' );
|
||||
}
|
||||
}
|
@ -1,320 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace plugins\buena\src\Pfadfinden\WordPress;
|
||||
|
||||
use Pfadfinden\WordPress\wordpress;
|
||||
use plugins\buena\src\Pfadfinden\WordPress\BuenaSettings;
|
||||
use plugins\buena\src\Pfadfinden\WordPress\BuenaSettingsPage;
|
||||
use wordpress\src\Shy\WordPress\Theme;
|
||||
|
||||
|
||||
|
||||
class BuenaTheme extends wordpress\src\Shy\WordPress\Theme
|
||||
{
|
||||
/**
|
||||
* @var BuenaSettings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
|
||||
public function getContentWidth()
|
||||
{
|
||||
return 684;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->settings = new BuenaSettings();
|
||||
|
||||
$this->addHookMethod( 'after_setup_theme', 'afterSetupTheme' );
|
||||
$this->addHookMethod( 'wp_enqueue_scripts', 'enqueueScriptsStyles' );
|
||||
|
||||
$this->addHookMethod( 'buena_search_form', 'printSearchForm' );
|
||||
|
||||
$this->addHookMethod( 'admin_init', 'initAdministration' );
|
||||
$this->addHookMethod( 'mce_css', 'filterEditorStylesheets' );
|
||||
|
||||
$this->addHookMethod( 'wp_page_menu', 'filterPageMenu' );
|
||||
$this->addHookMethod( 'widgets_init', 'registerSidebars' );
|
||||
|
||||
$this->addHookMethod( 'the_content', 'filterContent' );
|
||||
|
||||
$this->addHookMethod( 'image_size_names_choose', 'filterImageSizeNames' );
|
||||
$this->addHookMethod( 'media_upload_tabs', 'filterMediaTabs' );
|
||||
$this->addHookMethod( 'media_view_settings', 'filterMediaViewSettings' );
|
||||
$this->addHookMethod( 'media_view_strings', 'filterMediaViewSettings' );
|
||||
$this->addHookMethod( 'print_media_templates', 'printMediaTemplates' );
|
||||
}
|
||||
|
||||
|
||||
public function afterSetupTheme()
|
||||
{
|
||||
add_theme_support( 'title-tag' );
|
||||
add_theme_support( 'automatic-feed-links' );
|
||||
|
||||
register_nav_menu( 'primary', __( 'Hauptmenü', 'buena-theme' ) );
|
||||
register_nav_menu( 'footer', __( 'Fußzeile', 'buena-theme' ) );
|
||||
|
||||
add_theme_support( 'html5', [
|
||||
'comment-list', 'comment-form', 'search-form', 'gallery', 'caption',
|
||||
] );
|
||||
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
$custom_header = [
|
||||
'width' => apply_filters( 'buena_header_image_width', 1300 ),
|
||||
'height' => apply_filters( 'buena_header_image_height', 635 ),
|
||||
'flex-width' => true,
|
||||
'flex-height' => true,
|
||||
'default-image' => get_template_directory_uri() . '/img/leitbild_aktionen_low.jpg',
|
||||
'uploads' => true,
|
||||
'header-text' => false,
|
||||
];
|
||||
add_theme_support( 'custom-header', $custom_header );
|
||||
set_post_thumbnail_size( $custom_header['width'], $custom_header['height'], true );
|
||||
|
||||
add_image_size( 'gallery-thumb', 350, 165, true );
|
||||
|
||||
register_default_headers( [
|
||||
'aktionen' => [
|
||||
'url' => '%s/img/leitbild_aktionen_low.jpg',
|
||||
'thumbnail_url' => '%s/img/leitbild_aktionen_low_klein.jpg',
|
||||
'description' => __( 'Leitbild Aktionen', 'buena-theme' ),
|
||||
],
|
||||
'bund' => [
|
||||
'url' => '%s/img/leitbild_bund_crop.jpg',
|
||||
'thumbnail_url' => '%s/img/leitbild_bund_crop_klein.jpg',
|
||||
'description' => __( 'Leitbild Bund', 'buena-theme' ),
|
||||
],
|
||||
'ihs' => [
|
||||
'url' => '%s/img/leitbild_ihs.jpg',
|
||||
'thumbnail_url' => '%s/img/leitbild_ihs_klein.jpg',
|
||||
'description' => __( 'Leitbild Immenhausen', 'buena-theme' ),
|
||||
],
|
||||
'international' => [
|
||||
'url' => '%s/img/leitbild_int2_low.jpg',
|
||||
'thumbnail_url' => '%s/img/leitbild_int2_low_klein.jpg',
|
||||
'description' => __( 'Leitbild International', 'buena-theme' ),
|
||||
],
|
||||
'kontakt' => [
|
||||
'url' => '%s/img/leitbild_Kontakt_low.jpg',
|
||||
'thumbnail_url' => '%s/img/leitbild_Kontakt_low_klein.jpg',
|
||||
'description' => __( 'Leitbild Kontakt', 'buena-theme' ),
|
||||
],
|
||||
'pfadfinden' => [
|
||||
'url' => '%s/img/leitbild_pfadfinden_low.jpg',
|
||||
'thumbnail_url' => '%s/img/leitbild_pfadfinden_low_klein.jpg',
|
||||
'description' => __( 'Leitbild Pfadfinden', 'buena-theme' ),
|
||||
],
|
||||
] );
|
||||
}
|
||||
|
||||
public function getTeaserImage()
|
||||
{
|
||||
if ( is_page() || have_posts() && is_single() ) { // FIXME: is_singular()?
|
||||
the_post();
|
||||
$thumb = get_the_post_thumbnail( null, 'post-thumbnail', [ 'alt' => '' ] );
|
||||
rewind_posts();
|
||||
|
||||
if ( $thumb ) {
|
||||
return $thumb;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_home() || $this->settings['always_show_poster'] ) {
|
||||
return sprintf(
|
||||
'<img src="%s" height="%d" width="%d" alt="" />',
|
||||
get_header_image(),
|
||||
get_custom_header()->height,
|
||||
get_custom_header()->width
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt einen Titel für die aktuelle Seite aus.
|
||||
*/
|
||||
public function printTitle()
|
||||
{
|
||||
if ( is_singular() ) {
|
||||
the_title();
|
||||
} elseif ( is_category() && strpos( $_SERVER['HTTP_HOST'], 'abendlager.pfadfinden.de' ) !== false ) {
|
||||
// FIXME: Workaround mit 1.0 entfernen.
|
||||
single_cat_title( '', true );
|
||||
} elseif ( is_archive() ) {
|
||||
the_archive_title();
|
||||
} elseif ( is_search() ) {
|
||||
esc_html_e( sprintf(
|
||||
__( 'Suche nach „%s“', 'buena-theme' ),
|
||||
get_search_query( false )
|
||||
) );
|
||||
} else {
|
||||
bloginfo( 'description' );
|
||||
}
|
||||
}
|
||||
|
||||
public function enqueueScriptsStyles()
|
||||
{
|
||||
wp_enqueue_style( 'immenhausen-font', get_template_directory_uri() . '/font/ihs.css' );
|
||||
wp_enqueue_style( 'buena-style', get_stylesheet_uri() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt das Suchformular aus. Nötig, damit im Kopf anderer Code stehen kann als anderswo.
|
||||
*/
|
||||
public function printSearchForm()
|
||||
{
|
||||
get_search_form( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tut, was dransteht.
|
||||
*/
|
||||
public function registerSidebars()
|
||||
{
|
||||
register_sidebar( [
|
||||
'id' => 'below-navigation',
|
||||
'name' => __( 'Unter Navigation', 'buena-theme' ),
|
||||
'description' => __( 'Ziemlich schmal.', 'buena-theme' ),
|
||||
'before_title' => '<h4 class="h-widget">',
|
||||
'after_title' => '</h4>',
|
||||
] );
|
||||
register_sidebar( [
|
||||
'id' => 'footer',
|
||||
'name' => __( 'Fußleiste', 'buena-theme' ),
|
||||
'description' => __( 'Rechte Spalte des Briefumschlags. Recht flach. Füllt die ganze Breite aus, wenn kein Navigationsmenü zugewiesen ist.', 'buena-theme' ),
|
||||
'before_title' => '<h4 class="h-widget">',
|
||||
'after_title' => '</h4>',
|
||||
] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausgabe von wp_page_menu() filtern, dass sie wie wp_nav_menu() aussieht.
|
||||
*
|
||||
* @param string $menu
|
||||
* @param array $args
|
||||
* @return string
|
||||
*/
|
||||
public function filterPageMenu( $menu, array $args )
|
||||
{
|
||||
if ( ! isset( $args['fallback_cb'] ) || $args['fallback_cb'] !== 'wp_page_menu' ) {
|
||||
return $menu;
|
||||
}
|
||||
|
||||
$vorher = '<div class="' . esc_attr( $args['menu_class'] ) . '">';
|
||||
|
||||
$danach = '<' . $args['container'];
|
||||
if ( $args['container_class'] ) {
|
||||
// In diesem Fall doch optional…
|
||||
$danach .= ' class="' . esc_attr( $args['container_class'] ) . '"';
|
||||
}
|
||||
if ( $args['container_id'] ) {
|
||||
$danach .= ' id="' . esc_attr( $args['container_id'] ) . '"';
|
||||
}
|
||||
$danach .= '>';
|
||||
|
||||
if ( strpos( $menu, '<ul>' ) !== false ) {
|
||||
// Wenn das Menü leer ist, enthält es den <ul>-Teil nicht.
|
||||
$vorher .= '<ul>';
|
||||
$danach .= '<ul class="' . esc_attr( $args['menu_class'] ) . '">';
|
||||
}
|
||||
|
||||
$menu = str_replace( $vorher, $danach, $menu );
|
||||
$menu = substr( $menu, 0, -5 ) . $args['container'] . ">\n";
|
||||
|
||||
$menu = str_replace( "class='children'", 'class="sub-menu"', $menu );
|
||||
$menu = str_replace( 'current_page_item', 'current_page_item current-menu-item', $menu );
|
||||
$menu = str_replace( 'current_page_ancestor', 'current_page_ancestor current-menu-ancestor', $menu );
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zusatzfunktionen für das Backend laden.
|
||||
*/
|
||||
public function initAdministration()
|
||||
{
|
||||
if ( isset( $_GET['exp'] ) && class_exists( 'plugins\buena\src\Pfadfinden\WordPress\BuenaSettingsPage' ) ) {
|
||||
new BuenaSettingsPage( $this->settings );
|
||||
}
|
||||
|
||||
add_editor_style();
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard-Skin des Editors rauswerfen.
|
||||
*
|
||||
* @param string $stylesheets
|
||||
* @return string
|
||||
*/
|
||||
public function filterEditorStylesheets( $stylesheets )
|
||||
{
|
||||
$stylesheets = explode( ',', $stylesheets );
|
||||
$stylesheets = array_filter( $stylesheets, function ( $url ) {
|
||||
return strpos( $url, 'tinymce' ) === false;
|
||||
} );
|
||||
|
||||
return implode( ',', $stylesheets );
|
||||
}
|
||||
|
||||
/**
|
||||
* Überschriften <h1> und <h2> durch <h3> ersetzen.
|
||||
*
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
public function filterContent( $content )
|
||||
{
|
||||
$content = preg_replace( '/\\<h[12]([^>]*)>(.*?)\\<\\/h[12]>/', '<h3$1>$2</h3>', $content );
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $names
|
||||
* @return array
|
||||
*/
|
||||
public function filterImageSizeNames( array $names )
|
||||
{
|
||||
return $names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tabs
|
||||
* @return array
|
||||
*/
|
||||
public function filterMediaTabs( $tabs )
|
||||
{
|
||||
return $tabs;
|
||||
return $tabs + [
|
||||
'insert-poster' => __( 'Posterbilder', 'buena-theme' ),
|
||||
];
|
||||
// Erzeugt einen <iframe> von wp-admin/media-upload.php?chromeless=1&post_id=123456&tab=insert-poster
|
||||
}
|
||||
|
||||
public function filterMediaViewSettings( $settings )
|
||||
{
|
||||
//var_dump( $settings );
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Weitere Templates für Medienbrowser ausgeben.
|
||||
*/
|
||||
public function printMediaTemplates()
|
||||
{
|
||||
global $_wp_default_headers;
|
||||
?>
|
||||
<script type="text/html" id="tmpl-insert-poster">
|
||||
<ul>
|
||||
<?php foreach ( $_wp_default_headers as $k => $header ) : ?>
|
||||
<img alt="<?php esc_attr_e( $header['description'] ); ?>" src="<?php echo esc_url( sprintf( $header['thumbnail_url'], get_template_directory_uri() ) ); ?>" />
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
@ -1,250 +0,0 @@
|
||||
@charset "UTF-8";
|
||||
/**
|
||||
Theme Name: Buena
|
||||
Version: 0.99.7
|
||||
Theme URI: http://lab.hanseaten-bremen.de/themes/buena/
|
||||
Author: Philipp Cordes <philipp.cordes@pfadfinden.de>
|
||||
Description: Das neue Corporate Design, jetzt auch für WordPress.
|
||||
License: Proprietary
|
||||
Tags: one-column, three-columns, responsive-layout, automatic-feed-links, post-thumbnails, featured-images, custom-menu, blue, white, yellow, editor-style
|
||||
*/
|
||||
|
||||
/*
|
||||
Farben:
|
||||
- gelb: #ffcb04 (Handbuch, manchmal T3), #ffca28 (T3)
|
||||
- Verlauf: #9f7515 bis #e1af22, #e0cb84 bis #fff (IE-Fallback)
|
||||
- blass: #fff5d9 (T3-Zebra)
|
||||
- blau: #1d4899 (Handbuch, manchmal T3), #0d52a5 (T3)
|
||||
- Markierung (T3): #b3d4fc
|
||||
*/
|
||||
|
||||
html, body { border: 0 none; padding: 0; margin: 0; min-height: 100%; position: static; }
|
||||
html { font-family: Sans-Serif; font-size: 81.3%; background: url("img/holz.jpg") #dbb97b; position: relative; }
|
||||
header, hgroup, nav, footer, article { display: block; }
|
||||
.h, h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 { margin: 0; font-family: IHS, Serif; font-size: 1em; font-weight: normal; font-style: normal; }
|
||||
button, input, select, optgroup, option { margin: 0; font: inherit; color: inherit; }
|
||||
button, input[type="button"], input[type="submit"], input[type="reset"] { cursor: pointer; }
|
||||
input[type="search"] { -webkit-appearance: textfield; }
|
||||
p, ul, ol, dt { line-height: 1.5; }
|
||||
abbr { border-bottom: 1px dotted; }
|
||||
a { color: #1d4899; }
|
||||
figure, .wp-caption { margin: 0; max-width: 100%; }
|
||||
figcaption, .wp-caption-text { font-style: italic; padding: 0.5em 0; }
|
||||
.screen-reader-text { display: none; }
|
||||
.aligncenter { margin: 0 auto; }
|
||||
.alignleft { float: left; margin: 0 1em 0 0; }
|
||||
.alignright { float: right; margin: 0 0 0 1em; }
|
||||
|
||||
::-moz-selection { background: #1d4899; color: #ffcb04; text-shadow: none; outline: 2px solid #1d4899; }
|
||||
::selection { background: #1d4899; color: #ffcb04; text-shadow: none; outline: 2px solid #1d4899; }
|
||||
|
||||
/* Media object */
|
||||
.media { margin: 1em 0; }
|
||||
.media, .bd { overflow: hidden; _overflow: visible; }
|
||||
/*.media img { display: block; }*/
|
||||
/* Clearfix */
|
||||
.clearfix::after,
|
||||
.clearfix::before,
|
||||
.media::after,
|
||||
.media::before { content: " "; display: table; }
|
||||
.clearfix::after,
|
||||
.media::after { clear: both; }
|
||||
|
||||
/* Layout */
|
||||
#wrap { background: url("img/klufthemd.png") no-repeat; padding: 0 0 2em; }
|
||||
#footer { background: url("img/loeffel-topf.png") no-repeat 100% 100%; position: absolute; width: 100%; bottom: 0; }
|
||||
#footer .wrapper { background: url("img/briefumschlag.png") no-repeat; margin: 0 0 0 240px; padding: 112px 7px 0 21px; height: 286px; width: 700px; box-sizing: border-box; }
|
||||
#footer header { color: #ffcb04; text-align: center; font-size: 25px; margin: -111px 0 13px; line-height: 111px; }
|
||||
#footer .widgets { padding: 0 2em 0 0; }
|
||||
|
||||
#left { margin: -18px -200px 0 40px; width: 160px; z-index: 30; float: left; position: relative; }
|
||||
#main { overflow: hidden; padding: 0 0 286px 240px; }
|
||||
@media (max-width: 960px) {
|
||||
/* Umschlag unter die Navigation umbrechen */
|
||||
#left { margin-bottom: 300px; }
|
||||
#footer .wrapper { margin-left: 0; }
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
#main { padding-left: 0; }
|
||||
#left { margin-right: 0; }
|
||||
}
|
||||
|
||||
/* FIXME: Positionierung des Schattens weiter vereinfachen, auch Untertitel verlinken. */
|
||||
/* FIXME: Branding umbenennen, siehe https://github.com/pfadfinden/wordpress-theme-updater/issues/13 */
|
||||
#branding { min-height: 145px; padding: 0 33px 20px 240px; text-align: center; position: relative; width: 425px; margin-bottom: -27px; }
|
||||
#branding::after { content: ""; display: block; position: absolute; bottom: 0; right: 0; z-index: 15; height: 143px; width: 457px; background: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIGhlaWdodD0nMzAwJyB3aWR0aD0nNDcwJyB2aWV3Qm94PScwIDAgMzAwIDQyNScgcHJlc2VydmVBc3BlY3RSYXRpbz0neE1pbllNaW4gbWVldCc+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSd2JyB4MT0nMCcgeTE9JzAnIHgyPScwJyB5Mj0nMTQwJSc+PHN0b3Agb2Zmc2V0PScwJyBzdG9wLWNvbG9yPScjMDAwJyBzdG9wLW9wYWNpdHk9JzAuNycgLz48c3RvcCBvZmZzZXQ9JzUwJScgc3RvcC1jb2xvcj0nIzAwMCcgc3RvcC1vcGFjaXR5PScwLjQnIC8+PHN0b3Agb2Zmc2V0PSc4MCUnIHN0b3AtY29sb3I9JyMwMDAnIHN0b3Atb3BhY2l0eT0nMC4xJyAvPjxzdG9wIG9mZnNldD0nMTAwJScgc3RvcC1jb2xvcj0iIzAwMCIgc3RvcC1vcGFjaXR5PScwJyAvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxwYXRoIGQ9J00xMCwyMDAgQzE1MCwxNzAgNDUwLDE4MCA2MTUsMTkwIEw2MDgsMDAgTDE1LDAgWicgc3R5bGU9J3N0cm9rZTpub25lOycgZmlsbD0ndXJsKCN2KSc+PC9wYXRoPjwvc3ZnPg0K") no-repeat 50% 0; }
|
||||
#branding > * { margin: 0; position: relative; z-index: 20; }
|
||||
.site-title { font-size: 20px; background: #ffcb04; color: #0d53a5; margin-top: auto; line-height: 115px; }
|
||||
.site-title a { display: block; vertical-align: bottom; }
|
||||
.site-title img { vertical-align: bottom; padding-bottom: 16px; }
|
||||
.site-description { font-size: 18px; background: #0d53a5; color: #ffcb04; line-height: 30px; font-family: IHS, Serif; letter-spacing: 1px; word-spacing: 2px; }
|
||||
|
||||
#header .search-form { background: url("img/streichholzschachtel.png") no-repeat; position: absolute; height: 89px; left: 750px; top: 1.5em; width: 98px; padding: 25px 47px 0 35px; }
|
||||
#header .search-form label { display: block; position: relative; margin: 25px 0 -50px; text-align: left; }
|
||||
#header .search-field { background: transparent; border: 2px solid #ffcb04; padding: 2px; color: #fff; display: block; max-width: 100%; box-sizing: border-box; }
|
||||
#header .search-submit { background: transparent; color: #ffcb04; border: 0 none; font-family: IHS, Serif; font-size: 1.4em; padding: 0; display: block; box-sizing: border-box; }
|
||||
#header > nav { position: absolute; top: 0; right: 0; z-index: 9999; display: none; }/* FIXME: Workaround Branding-Doppelung */
|
||||
#responsiveMenu { border: 0 none; background: transparent; height: 51px; margin: 1em; }
|
||||
@media (max-width: 960px) { /* Suche ausblenden */
|
||||
#header .search-form { display: none; }
|
||||
}
|
||||
|
||||
.nav-menu ul { list-style: none; padding: 0; margin: 0; }
|
||||
.nav-menu-primary > ul { font-family: IHS, Serif; }
|
||||
.nav-menu-primary > ul > .current-menu-ancestor,
|
||||
.nav-menu-primary > ul > .current-menu-item { background: #e1af22 no-repeat; background-image: linear-gradient(#9f7515 0%, #e1af22 100%); border-bottom: 1px solid #9f7515; border-top: 1px solid #9f7515; margin: 0.5em 0; padding: 0.5em 0; }
|
||||
.nav-menu-primary .sub-menu { display: none; }
|
||||
.nav-menu-primary a { padding: 0.4em 0.5em 0.4em 1em; display: block; text-decoration: none; color: #6b5742; font-size: 1.4em; }
|
||||
.nav-menu-primary li ul a { font-family: Georgia, Serif; font-size: 12px; font-style: italic; padding: 5px 5px 5px 25px; color: #000; }
|
||||
.nav-menu-primary .current-menu-ancestor .sub-menu,
|
||||
.nav-menu-primary .current-menu-item .sub-menu { display: block; }
|
||||
.nav-menu-primary .current-menu-ancestor a { color: #000; }
|
||||
.nav-menu-primary .current-menu-item > a { color: #fff; }
|
||||
.nav-menu-primary a:hover,
|
||||
.nav-menu-primary a:focus { color: #000; }
|
||||
.nav-menu .current-menu-ancestor a:hover,
|
||||
.nav-menu .current-menu-ancestor a:focus,
|
||||
.nav-menu .sub-menu a:hover,
|
||||
.nav-menu .sub-menu a:focus,
|
||||
.nav-menu-footer a:hover,
|
||||
.nav-menu-footer a:focus { text-decoration: underline; }
|
||||
.nav-menu-footer { font-family: Georgia, Serif; font-style: italic; padding-left: 2em; }
|
||||
.nav-menu-footer > ul { width: 323px; height: 174px; position: relative; display: flex; -webkit-flex-flow: column; flex-flow: column; -webkit-justify-content: center; justify-content: center; -webkit-align-items: stretch; align-items: stretch; }
|
||||
.nav-menu-footer li { margin-bottom: 0.75em; }
|
||||
.nav-menu-footer a { padding: 4px 4px 4px 25px; text-decoration: none; }
|
||||
|
||||
.widget_recent_entries > ul,
|
||||
.widget_recent_comments > ul,
|
||||
.widget_archive > ul,
|
||||
.widget_categories > ul,
|
||||
.widget_meta > ul { list-style: none; padding: 0; margin: 0; }
|
||||
|
||||
#left > .nav-menu { background: #ffcb04; color: #6b5742; padding: 10px 0 2em; }
|
||||
#left > .widgets { background: rgba(56, 46, 35, 0.7); color: #ffcb04; padding: 1em 15px 15px 20px; font-size: 13px; font-style: italic; }
|
||||
#left > .widgets a { color: #fff; text-decoration: none; }
|
||||
#left > .widgets a:hover,
|
||||
#left > .widgets a:focus { text-decoration: underline; }
|
||||
|
||||
/* Widgets: Basisdarstellung */
|
||||
.widgets { list-style: none; padding: 0; margin: 0; font-family: Georgia, Serif; font-style: italic; }
|
||||
.widget_calendar table { text-align: center; }
|
||||
|
||||
/* Widgets: Korrekturen für unsere Seitenleiste */
|
||||
#left .widget_search form { display: flex; }
|
||||
#left .widget_search form > * { border: 2px solid #ffcb04; }
|
||||
#left .widget_search input { box-sizing: border-box; width: 100%; border: 0 none; background: transparent; color: #fff; text-align: center; padding: 3px 0.25em 4px; }
|
||||
#left .widget_search button { color: transparent; background: url("res/lupe.svg") 50% 50% no-repeat #ffcb04; width: 31px; }
|
||||
|
||||
#left .widget_calendar > div { margin: 0 -15px 0 -20px; }
|
||||
#left .widget_calendar > div > table { text-align: center; margin: 0 auto; }
|
||||
|
||||
#left .widget_pages ul { padding-left: 2em; }
|
||||
#left .widget_pages > ul { list-style: none; padding: 0; }
|
||||
|
||||
#left > .widgets .widget { margin: 0; padding: 1em 0; }
|
||||
.widgets .h-widget { color: #ffcb04; font-size: 16px; }
|
||||
#left > .widgets .menu,
|
||||
.widgets .widget_categories ul { list-style: none; padding: 0; }
|
||||
|
||||
/* Überschriften mit Bild darunter */
|
||||
.h-box { position: relative; display: block; margin-bottom: 1em; text-decoration: none; }
|
||||
.h-box > img { position: absolute; top: 0; left: 0; height: 100%; width: 100%; }
|
||||
.h-box > .wrap { position: absolute; max-width: 100%; left: 0; }
|
||||
.h-box > .wrap > * { display: inline; -o-box-decoration-break: clone; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
|
||||
|
||||
.h-box-teaser { box-shadow: 0 5px 5px rgba(0, 0, 0, 0.3); line-height: 1; display: inline-block; width: 1300px; max-width: 100%; }
|
||||
.h-box-teaser > img { position: static; }
|
||||
.h-box-teaser > .wrap { bottom: 1em; padding-left: 240px; }
|
||||
.h-box-teaser > .wrap > * { background: rgba(56, 46, 35, 0.7); color: #ffcb04; padding: 2px 13px 4px; font-size: 52px; line-height: 78px; }
|
||||
@media (max-width: 720px) {
|
||||
.h-box-teaser { margin-top: 1em; margin-left: 0; }
|
||||
.h-box-teaser > .wrap { padding-left: 1em; }
|
||||
.h-box-teaser > .wrap > * { font-size: 2em; line-height: 39px; }
|
||||
}
|
||||
|
||||
.h-box-blaugelb { padding-top: 47.1428571%; }
|
||||
.h-box-blaugelb > .wrap { bottom: 0; font-size: 18px; }
|
||||
.h-box-blaugelb > .wrap > * { color: #1d4899; background: #ffcb04; padding: 3px 5px; line-height: 26px; }
|
||||
|
||||
.h-box-blaugelb-bildlos { padding: 0; }
|
||||
.h-box-blaugelb-bildlos > .wrap { position: static; }
|
||||
/**/
|
||||
|
||||
.container { max-width: 1020px; }
|
||||
.page .container,
|
||||
.single-post:not(.single-format-gallery) .container { max-width: 710px; }
|
||||
|
||||
.content-singular .format-gallery { background: transparent; padding: 0; margin: 0; position: relative; }
|
||||
.content-singular .format-gallery .gallery { display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-content: space-between; align-content: space-between; -webkit-align-items: flex-start; align-items: flex-start; }
|
||||
.content-singular .format-gallery .gallery-item { background: #fff; padding: 1em; margin: 0 1em 1em 0; }
|
||||
.gallery-columns-1 .gallery-item { flex: 1 0 50%; }
|
||||
.gallery-columns-2 .gallery-item { flex: 1 0 34%; }
|
||||
.gallery-columns-3 .gallery-item { flex: 1 0 25%; }
|
||||
.gallery-columns-4 .gallery-item { flex: 1 0 20%; }
|
||||
|
||||
.content-gallery { display: flex; position: relative; z-index: 10; -webkit-flex-wrap: wrap; flex-wrap: wrap; overflow: hidden; }
|
||||
.container article,
|
||||
.commentlist article,
|
||||
.comment-form { padding: 1em; margin: 0 1em 1em 0; transition: width 0.5s, height 0.5s; box-sizing: border-box; }
|
||||
.container article > :first-child,
|
||||
.comment-form > :first-child { margin-top: 0; }
|
||||
.container article > :last-child,
|
||||
.comment-form > .form-submit { margin-bottom: 0; }
|
||||
.content-singular > article:not(.format-gallery),
|
||||
.content-gallery > article,
|
||||
.commentlist article,
|
||||
.comment-form { min-width: 20em; background: #fff; box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1); }
|
||||
.content-gallery > article { flex: 1 1 25%; max-width: calc(33.333% - 1em); }
|
||||
@media (max-width: 1070px) { .content-gallery > article { flex: 1 1 34%; max-width: calc(50% - 1em); } }
|
||||
@media (max-width: 800px) { .content-gallery > article { flex: 1 1 50%; max-width: 100%; } }
|
||||
.container > .pagination { margin-right: 1em; }
|
||||
|
||||
/* WordPress-Wünsche */
|
||||
.sticky {}
|
||||
|
||||
img { max-width: 100%; height: auto; border: 0 none; vertical-align: middle; }
|
||||
ul, ol { padding-left: 2em; }
|
||||
dl, ul, ol, h1, h2, h3, h4, h5, h6, blockquote, p, table { margin: 0.5em 0; }
|
||||
dd, li > ol, li > ul { margin: 0; }
|
||||
dt { font-weight: bold; }
|
||||
blockquote, dd { padding-left: 2em; }
|
||||
article > p:empty:last-child { margin: -0.5em 0 0.5em; }
|
||||
article h3, article .h3, article h4, article .h4, article h5, article .h5, article h6, article .h6 { display: inline-block; background: #ffcb04; color: #1d4899; margin-bottom: 0; padding: 2px 4px; }
|
||||
article h3, article .h3 { font-size: 18px; padding: 3px 5px; }
|
||||
article h4, article .h4 { font-size: 16px; }
|
||||
article h5, article .h5 { font-size: 14px; }
|
||||
.gallery-caption {}
|
||||
.bypostauthor {}
|
||||
.twitter-tweet {}
|
||||
|
||||
/* Kommentare */
|
||||
#comments, #reply-title { font-size: 2.5em; color: #fff; margin: 0.5em 0 0.25em; }
|
||||
.commentlist { list-style: none; padding: 0; }
|
||||
.commentlist .children { list-style: none; padding-left: 1em; }
|
||||
.comment-form > p > * { vertical-align: top; }
|
||||
.comment-form > p > label::after { content: ": "; }
|
||||
.comment-body { position: relative; }
|
||||
.comment-metadata { position: absolute; top: 1em; right: 1em; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-justify-content: flex-end; justify-content: flex-end; }
|
||||
.comment-form textarea { resize: vertical; display: block; box-sizing: border-box; width: 100%; }
|
||||
|
||||
/* Responsive: Der komplizierte Kram. Hurra! */
|
||||
@media (max-width: 720px) { /* Gestapelt anordnen */
|
||||
#main { padding-bottom: 0; }
|
||||
#wrap, #footer .wrapper { background-image: none; }
|
||||
#branding { text-align: left; width: auto; padding: 0; margin: 0; min-height: 0; }
|
||||
#branding::after { display: none; background-image: none; }
|
||||
#branding h1 { line-height: 51px; }
|
||||
#branding h2 { padding: 0 1em; }
|
||||
.site-title a { display: inline-block; }
|
||||
.site-title img { height: 51px; width: auto; padding: 13px; }
|
||||
#header > nav { display: block; }
|
||||
#left { float: none; transition: 0.5s height; margin: 0; width: auto; }
|
||||
#left, #left .widgets { display: none; }
|
||||
.show-responsive-menu #left { display: block; }
|
||||
#content, .comments { margin-left: 1em; }
|
||||
#footer { background: #c4a164; position: static; }
|
||||
#footer .wrapper { padding: 1em; height: auto; width: auto; }
|
||||
#footer header { color: #000; margin: 0; line-height: 1.5; }
|
||||
.nav-menu-footer, #footer .widgets { float: none; margin: 1em 0 0; padding: 1em; }
|
||||
.nav-menu-footer > ul { height: auto; }
|
||||
}
|
7
plugins/buena/use/shy-wordpress/.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
# Eclipse project files
|
||||
.buildpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
# Local PHPUnit configuration
|
||||
phpunit.xml
|
@ -1,7 +0,0 @@
|
||||
<phpunit boostrap="tests/bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory suffix="Test.php" phpVersion="5.4.0">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
@ -1,97 +0,0 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: pfadfinden-theme-updater\n"
|
||||
"POT-Creation-Date: 2015-08-26 01:49+0100\n"
|
||||
"PO-Revision-Date: 2015-08-26 02:02+0100\n"
|
||||
"Last-Translator: Philipp Cordes <philipp.cordes@pfadfinden.de>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.6.10\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_x;esc_html_e;esc_html__;esc_attr_e;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2;\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: pfadfinden-theme-updater.php:70
|
||||
msgid ""
|
||||
"Couldn’t load required library “shy-wordpress”. Reinstalling the plugin may "
|
||||
"solve this problem."
|
||||
msgstr ""
|
||||
"Konnte die erforderliche Bibliothek „shy-wordpress“ nicht laden. "
|
||||
"Neuinstallation des Plugins sollte das Problem beheben."
|
||||
|
||||
#: pfadfinden-theme-updater.php:81
|
||||
msgid "The plugin is incomplete. Reinstalling it may solve this problem."
|
||||
msgstr ""
|
||||
"Das Plugin ist unvollständig. Neuinstallation sollte das Problem beheben."
|
||||
|
||||
#: pfadfinden-theme-updater.php:96
|
||||
#, php-format
|
||||
msgid ""
|
||||
"You need at least PHP 5.4 to use Pfadfinden Theme Updater. Your are using %s."
|
||||
msgstr ""
|
||||
"Du brauchst mindestens PHP 5.4, um den Pfadfinden-Theme-Updater zu benutzen. "
|
||||
"Aktuell benutzt du PHP %s."
|
||||
|
||||
#: pfadfinden-theme-updater.php:104
|
||||
msgid "Pfadfinden Theme Updater"
|
||||
msgstr "Pfadfinden-Theme-Updater"
|
||||
|
||||
#: pfadfinden-theme-updater.php:105
|
||||
msgid ""
|
||||
"Adds the Pfadfinden theme repository to your choice of themes. Requires an "
|
||||
"API key."
|
||||
msgstr ""
|
||||
"Fügt den Pfadfinden-Theme-Katalog zu Deiner Auswahl an Themes hinzu. "
|
||||
"Benötigt einen API-Schlüssel."
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeRepository.php:81
|
||||
msgid "Your theme repository query is too long."
|
||||
msgstr "Deine Anfrage an den Theme-Katalog ist zu lang."
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeRepository.php:114
|
||||
msgid "Unknown theme repository server error, no message attached."
|
||||
msgstr ""
|
||||
"Unbekannter Theme-Katalog-Serverfehler, keine Fehlerbeschreibung "
|
||||
"mitgeschickt."
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeRepository.php:186
|
||||
msgid "Ambiguous result for single theme information call."
|
||||
msgstr "Mehrere Ergebnisse für Abfrage nach Informationen zu einem Theme."
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:69
|
||||
msgid "Pfadfinden Theme Updater Settings"
|
||||
msgstr "Pfadfinden-Theme-Updater-Einstellungen"
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:74
|
||||
msgid "Pfadfinden Updater"
|
||||
msgstr "Pfadfinden-Updater"
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:84
|
||||
msgid "API Key"
|
||||
msgstr "API-Schlüssel"
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:89
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:116
|
||||
msgid "An API key consists of 10 alphanumeric characters."
|
||||
msgstr "Ein API-Schlüssel besteht aus zehn alphanumerischen Zeichen."
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:96
|
||||
msgid "Keep Settings"
|
||||
msgstr "Einstellungen merken"
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:97
|
||||
msgid "Don’t delete settings when uninstalling the plugin."
|
||||
msgstr "Einstellungen nicht löschen, wenn das Plugin deinstalliert wird."
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:107
|
||||
msgid "Just testing? Try APITESTKEY."
|
||||
msgstr ""
|
||||
"Nur Ausprobieren? Nimm APITESTKEY. Aber BdP-Themes gibt es damit nicht…"
|
||||
|
||||
#~ msgid "Activated Features"
|
||||
#~ msgstr "Aktivierte Funktionen"
|
@ -1,84 +0,0 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: pfadfinden-theme-updater\n"
|
||||
"POT-Creation-Date: 2015-08-26 01:49+0100\n"
|
||||
"PO-Revision-Date: 2015-08-26 01:50+0100\n"
|
||||
"Last-Translator: Philipp Cordes <philipp.cordes@pfadfinden.de>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.6.10\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_x;esc_html_e;esc_html__;esc_attr_e;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2;\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: pfadfinden-theme-updater.php:70
|
||||
msgid ""
|
||||
"Couldn’t load required library “shy-wordpress”. Reinstalling the plugin may "
|
||||
"solve this problem."
|
||||
msgstr ""
|
||||
|
||||
#: pfadfinden-theme-updater.php:81
|
||||
msgid "The plugin is incomplete. Reinstalling it may solve this problem."
|
||||
msgstr ""
|
||||
|
||||
#: pfadfinden-theme-updater.php:96
|
||||
#, php-format
|
||||
msgid ""
|
||||
"You need at least PHP 5.4 to use Pfadfinden Theme Updater. Your are using %s."
|
||||
msgstr ""
|
||||
|
||||
#: pfadfinden-theme-updater.php:104
|
||||
msgid "Pfadfinden Theme Updater"
|
||||
msgstr ""
|
||||
|
||||
#: pfadfinden-theme-updater.php:105
|
||||
msgid ""
|
||||
"Adds the Pfadfinden theme repository to your choice of themes. Requires an "
|
||||
"API key."
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeRepository.php:81
|
||||
msgid "Your theme repository query is too long."
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeRepository.php:114
|
||||
msgid "Unknown theme repository server error, no message attached."
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeRepository.php:186
|
||||
msgid "Ambiguous result for single theme information call."
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:69
|
||||
msgid "Pfadfinden Theme Updater Settings"
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:74
|
||||
msgid "Pfadfinden Updater"
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:84
|
||||
msgid "API Key"
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:89
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:116
|
||||
msgid "An API key consists of 10 alphanumeric characters."
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:96
|
||||
msgid "Keep Settings"
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:97
|
||||
msgid "Don’t delete settings when uninstalling the plugin."
|
||||
msgstr ""
|
||||
|
||||
#: src/Pfadfinden/WordPress/ThemeUpdaterSettings.php:107
|
||||
msgid "Just testing? Try APITESTKEY."
|
||||
msgstr ""
|
@ -1,149 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Pfadfinden Theme Updater
|
||||
Plugin URI: http://lab.hanseaten-bremen.de/themes/
|
||||
Description: Adds the Pfadfinden theme repository to your choice of themes. Requires an API key.
|
||||
Version: 0.2
|
||||
Author: Philipp Cordes
|
||||
Text Domain: pfadfinden-theme-updater
|
||||
Domain Path: /languages/
|
||||
License: GPLv2 or later
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'I’m a plugin.' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load localized strings for the plugin.
|
||||
*
|
||||
* @see http://geertdedeckere.be/article/loading-wordpress-language-files-the-right-way
|
||||
*/
|
||||
function pfadfinden_theme_updater_load_textdomain()
|
||||
{
|
||||
remove_action( 'init', __FUNCTION__ );
|
||||
|
||||
$domain = 'pfadfinden-theme-updater';
|
||||
// Filter known from load_plugin_textdomain().
|
||||
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
||||
|
||||
load_textdomain( $domain, WP_LANG_DIR . "/pfadfinden-theme-updater/$domain-$locale.mo" );
|
||||
load_plugin_textdomain( $domain, false, basename( __DIR__ ) . '/languages/' );
|
||||
}
|
||||
add_action( 'init', 'pfadfinden_theme_updater_load_textdomain' );
|
||||
|
||||
|
||||
if ( ! function_exists( 'trigger_pfadfinden_plugin_error' ) ) {
|
||||
/**
|
||||
* Show an error message.
|
||||
*
|
||||
* @see http://www.squarepenguin.com/wordpress/?p=6 Inspiration
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $type optional
|
||||
* @return bool
|
||||
*/
|
||||
function trigger_pfadfinden_plugin_error( $message, $type = 0 )
|
||||
{
|
||||
if ( isset( $_GET['action'] ) && 'error_scrape' === $_GET['action'] ) {
|
||||
echo $message;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! $type ) {
|
||||
$type = E_USER_WARNING;
|
||||
}
|
||||
|
||||
return trigger_error( $message, $type );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check for suitable environment
|
||||
if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID >= 50400 ) {
|
||||
// If we’re the first user of the library, use the bundled one
|
||||
if ( ! class_exists( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\Plugin' ) ) {
|
||||
pfadfinden_theme_updater_load_textdomain();
|
||||
if ( ! include_once __DIR__ . '/use/shy-wordpress/src/autoloader.php' ) {
|
||||
trigger_pfadfinden_plugin_error(
|
||||
__( 'Couldn’t load required library “shy-wordpress”. Reinstalling the plugin may solve this problem.', 'pfadfinden-theme-updater' ),
|
||||
E_USER_ERROR
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Register our autoloader
|
||||
if ( ! include_once __DIR__ . '/src/autoloader.php' ) {
|
||||
pfadfinden_theme_updater_load_textdomain();
|
||||
trigger_pfadfinden_plugin_error(
|
||||
__( 'The plugin is incomplete. Reinstalling it may solve this problem.', 'pfadfinden-theme-updater' ),
|
||||
E_USER_ERROR
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// PHP < 5.3 issues a parse error if we instance the class here
|
||||
return require_once __DIR__ . '/startup.php';
|
||||
}
|
||||
|
||||
|
||||
// Display error message
|
||||
pfadfinden_theme_updater_load_textdomain();
|
||||
trigger_pfadfinden_plugin_error(
|
||||
sprintf(
|
||||
__( 'You need at least PHP 5.4 to use Pfadfinden Theme Updater. Your are using %s.', 'pfadfinden-theme-updater' ),
|
||||
PHP_VERSION
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
|
||||
if ( false ) {
|
||||
// Dummy calls for translation to include metadata in translation files
|
||||
__( 'Pfadfinden Theme Updater', 'pfadfinden-theme-updater' );
|
||||
__( 'Adds the Pfadfinden theme repository to your choice of themes. Requires an API key.', 'pfadfinden-theme-updater' );
|
||||
}
|
||||
|
||||
class Nginx {
|
||||
|
||||
private $plugin = 'nginx-helper/nginx-helper.php';
|
||||
private $pluginPath = ABSPATH . 'wp-content/plugins/nginx-helper/nginx-helper.php';
|
||||
|
||||
public function __construct() {
|
||||
if(is_readable($this->pluginPath)) {
|
||||
require_once(ABSPATH .'/wp-admin/includes/plugin.php');
|
||||
$this->activatePlugin();
|
||||
$this->loadCss();
|
||||
}
|
||||
}
|
||||
|
||||
private function activatePlugin() {
|
||||
if( is_plugin_active( $this->plugin ) && get_option('cloudpit_nginx_activated_once') == 1 ) {
|
||||
//if the plugin is active already and our option is set, do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
if( !is_plugin_active( $this->plugin ) && get_option('cloudpit_nginx_activated_once') == 1 ) {
|
||||
//if the plugin is deactivated on purpuse after installation, do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
activate_plugin($this->pluginPath);
|
||||
|
||||
$options = 'a:23:{s:12:"enable_purge";s:1:"1";s:12:"cache_method";s:14:"enable_fastcgi";s:12:"purge_method";s:11:"get_request";s:10:"enable_map";N;s:10:"enable_log";N;s:9:"log_level";s:4:"INFO";s:12:"log_filesize";s:1:"5";s:12:"enable_stamp";N;s:22:"purge_homepage_on_edit";s:1:"1";s:21:"purge_homepage_on_del";s:1:"1";s:21:"purge_archive_on_edit";s:1:"1";s:20:"purge_archive_on_del";s:1:"1";s:28:"purge_archive_on_new_comment";N;s:32:"purge_archive_on_deleted_comment";N;s:17:"purge_page_on_mod";s:1:"1";s:25:"purge_page_on_new_comment";s:1:"1";s:29:"purge_page_on_deleted_comment";s:1:"1";s:14:"redis_hostname";s:9:"127.0.0.1";s:10:"redis_port";s:4:"6379";s:12:"redis_prefix";s:12:"nginx-cache:";s:9:"purge_url";s:0:"";s:25:"redis_enabled_by_constant";i:0;s:28:"smart_http_expire_form_nonce";s:10:"87a3b2c240";}';
|
||||
add_option('rt_wp_nginx_helper_options', unserialize($options));
|
||||
|
||||
if(!get_option('cloudpit_nginx_activated_once')) {
|
||||
add_option('cloudpit_nginx_activated_once', 1);
|
||||
}
|
||||
}
|
||||
|
||||
private function loadCss() {
|
||||
if( !is_plugin_active( $this->plugin ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style('cloudpit-css', plugin_dir_url( __FILE__ ) . 'assets/style.css',array(), filemtime(plugin_dir_path( __FILE__ ) . 'assets/style.css'));
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<phpunit bootstrap="tests/bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory suffix="Test.php" phpVersion="5.4.0">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
@ -1,31 +0,0 @@
|
||||
=== Pfadfinden Theme Updater ===
|
||||
Contributors: Corphi
|
||||
Tags: themes
|
||||
Requires at least: 4.0
|
||||
Tested up to: 4.3
|
||||
Stable tag: trunk
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
This plugin allows for easy installation of BdP e.V. corporate design themes. If you <a href="http://lab.hanseaten-bremen.de/register/">have an API key</a>.
|
||||
|
||||
== Description ==
|
||||
|
||||
This plugins makes all corporate design themes of the BdP e.V. available to your WordPress installation.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Install the plugin from the plugin repository.
|
||||
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
||||
1. Get an API key from http://lab.hanseaten-bremen.de/register/.
|
||||
1. Enter the API key in the setting section.
|
||||
1. Browse the additional featured themes.
|
||||
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.2 =
|
||||
* Users of PHP versions below 5.3 should now get reasonable error messages.
|
||||
|
||||
= 0.1 =
|
||||
* Initial release.
|
@ -1,207 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pfadfinden\WordPress;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A theme repository.
|
||||
*
|
||||
* It’s a simple wrapper around a web service mimicking the wordpress.org theme repository.
|
||||
*
|
||||
* @author Philipp Cordes <philipp.cordes@pfadfinden.de>
|
||||
*/
|
||||
class ThemeRepository
|
||||
{
|
||||
const URL = 'http://lab.hanseaten-bremen.de/themes/api/';
|
||||
|
||||
|
||||
/**
|
||||
* Slugs of managed themes.
|
||||
*
|
||||
* FIXME: Move to a transient.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
private $known_themes = [ 'bdp-reloaded', 'bdp-test', 'buena' ];
|
||||
|
||||
|
||||
/**
|
||||
* @var ThemeUpdaterSettings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
|
||||
public function __construct( ThemeUpdaterSettings $settings )
|
||||
{
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether theme information is available.
|
||||
*
|
||||
* @param string $theme_slug
|
||||
* @return bool
|
||||
*/
|
||||
public function isKnownTheme( $theme_slug )
|
||||
{
|
||||
return in_array( $theme_slug, $this->known_themes, true );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper around HTTP calls, always returns an array of theme information.
|
||||
*
|
||||
* @param string $action One of the supported actions of the repository
|
||||
* @param array $params Parameters for the action
|
||||
* @param string $locale
|
||||
* @return array<object>|\WP_Error
|
||||
*/
|
||||
protected function doApiQuery( $action, array $params = [], $locale = '' )
|
||||
{
|
||||
$url_params = [
|
||||
'key' => $this->settings['key'],
|
||||
'action' => $action,
|
||||
];
|
||||
if ( $params ) {
|
||||
if ( function_exists( 'gzcompress' ) ) {
|
||||
$url_params['gzparams'] = gzcompress( json_encode( $params ), 9 );
|
||||
} else {
|
||||
$url_params['params'] = json_encode( $params );
|
||||
}
|
||||
}
|
||||
$url_params = array_map( 'rawurlencode', $url_params );
|
||||
|
||||
$url = add_query_arg( $url_params, self::URL );
|
||||
if ( strlen( $url ) > 2000 ) {
|
||||
// Lengths beyond 2000 seem unhealthy.
|
||||
return new \WP_Error(
|
||||
815,
|
||||
__( 'Your theme repository query is too long.', 'pfadfinden-theme-updater' )
|
||||
);
|
||||
}
|
||||
|
||||
$headers = [];
|
||||
if ( ! strlen( $locale ) ) {
|
||||
$locale = get_locale();
|
||||
}
|
||||
if ( strlen( $locale ) ) {
|
||||
$locale = str_replace( '_', '-', $locale );
|
||||
$headers['Accept-Language'] = "$locale, en; q=0.6, *; q=0.1";
|
||||
}
|
||||
|
||||
// A GET request allows for caching
|
||||
$response = wp_remote_get( $url, [
|
||||
'headers' => $headers,
|
||||
] );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$body = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
if ( isset( $body['type'] ) && 'success' === $body['type'] ) {
|
||||
return array_map( function ( array $theme ) {
|
||||
return (object) $theme;
|
||||
}, $body['themes'] );
|
||||
}
|
||||
|
||||
if ( WP_DEBUG ) {
|
||||
trigger_error( wp_remote_retrieve_body( $response ), E_USER_ERROR );
|
||||
}
|
||||
$error = new \WP_Error(
|
||||
wp_remote_retrieve_response_code( $response ),
|
||||
isset( $body['message'] ) ? $body['message'] : __( 'Unknown theme repository server error, no message attached.', 'pfadfinden-theme-updater' )
|
||||
);
|
||||
if ( isset( $body['exception'] ) ) {
|
||||
$error->add_data( $body['exception'] );
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array<bool> $fields to explicitly include or exclude
|
||||
* @param string $locale
|
||||
* @return array<object {
|
||||
* @type string $name
|
||||
* @type string $slug lowercase, hyphenated
|
||||
* @type string $version
|
||||
* @type string $author
|
||||
* @type string $preview_url
|
||||
* @type string $screenshot_url
|
||||
* @type float $rating between 0 and 100
|
||||
* @type int $num_ratings
|
||||
* @type int $downloaded
|
||||
* @type string $last_updated Y-m-d
|
||||
* @type string $homepage
|
||||
* @type string $description
|
||||
* @type array $tags
|
||||
* }>
|
||||
*/
|
||||
public function queryFeaturedThemes( array $fields = [], $locale = '' )
|
||||
{
|
||||
return $this->doApiQuery( 'featured', [ 'fields' => $fields ], $locale );
|
||||
}
|
||||
|
||||
/**
|
||||
* Query information about a specific theme.
|
||||
*
|
||||
* @param string|array $slugs theme slug(s)
|
||||
* @param array<bool> $fields to explicitly include or exclude
|
||||
* @param string $locale
|
||||
* @return object {
|
||||
* @type string $name
|
||||
* @type string $slug
|
||||
* @type string $version
|
||||
* @type string $author
|
||||
* @type string $preview_url
|
||||
* @type string $screenshot_url
|
||||
* @type float $rating between 0.0 and 100.0
|
||||
* @type int $num_ratings
|
||||
* @type int $downloaded
|
||||
* @type string $last_updated
|
||||
* @type string $homepage
|
||||
* @type array $sections {
|
||||
* @type string $description
|
||||
* }
|
||||
* @type string $description empty string when having sections
|
||||
* @type string $download_link
|
||||
* @type array<string> $tags keys are tag slugs, values also lowercase. strange.
|
||||
* }
|
||||
*/
|
||||
public function queryThemeInformation( $slugs, array $fields = [], $locale = '' )
|
||||
{
|
||||
$themes = $this->doApiQuery( 'information', [
|
||||
'slugs' => (array) $slugs,
|
||||
'fields' => $fields,
|
||||
], $locale );
|
||||
if ( is_wp_error( $themes ) ) {
|
||||
return $themes;
|
||||
}
|
||||
|
||||
if ( is_string( $slugs ) ) {
|
||||
if ( count( $themes ) !== 1 ) {
|
||||
return new \WP_Error( __( 'Ambiguous result for single theme information call.', 'pfadfinden-theme-updater' ) );
|
||||
}
|
||||
|
||||
return reset( $themes );
|
||||
}
|
||||
|
||||
return $themes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query information about updates for installed themes.
|
||||
*
|
||||
* @param array<bool> $fields to explicitly include or exclude
|
||||
* @param string $locale
|
||||
* @return array<object>
|
||||
*/
|
||||
public function queryUpdates( array $fields = [], $locale = '' )
|
||||
{
|
||||
// FIXME: Only include installed themes
|
||||
return $this->queryThemeInformation( $this->known_themes, $fields, $locale );
|
||||
}
|
||||
}
|
@ -1,231 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pfadfinden\WordPress;
|
||||
|
||||
use wordpress\src\Shy\WordPress\Plugin;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A plugin that hooks the Pfadfinden theme repository into the Theme Updater.
|
||||
*
|
||||
* It knows about the way that WordPress handles and stores theme information.
|
||||
*
|
||||
* @author Philipp Cordes <philipp.cordes@pfadfinden.de>
|
||||
*/
|
||||
class ThemeUpdaterPlugin extends wordpress\src\Shy\WordPress\Plugin
|
||||
{
|
||||
const ACTION_QUERY_THEMES = 'query_themes';
|
||||
const ACTION_FEATURE_LIST = 'feature_list';
|
||||
const ACTION_THEME_INFORMATION = 'theme_information';
|
||||
|
||||
|
||||
/**
|
||||
* @var ThemeUpdaterSettings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var ThemeRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->settings = new ThemeUpdaterSettings();
|
||||
|
||||
if ( ! $this->settings['key'] ) {
|
||||
// Bail out if there is no key.
|
||||
return;
|
||||
}
|
||||
|
||||
$this->repository = new ThemeRepository( $this->settings );
|
||||
|
||||
|
||||
$this->addHookMethod( 'themes_api', 'filterApiCall' );
|
||||
$this->addHookMethod( 'themes_api_result', 'filterApiResult' );
|
||||
|
||||
$this->addHookMethod( 'themes_update_check_locales', 'filterThemeUpdateLocales' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace a Theme API call.
|
||||
*
|
||||
* Actually, only the call for theme information in special cases.
|
||||
*
|
||||
* @param \WP_Error|object|false $result
|
||||
* @param string $action 'theme_information', 'feature_list' or 'query_themes'
|
||||
* @param object $args
|
||||
* @return \WP_Error|object|array|false
|
||||
*/
|
||||
public function filterApiCall( $result, $action, $args )
|
||||
{
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( self::ACTION_THEME_INFORMATION === $action
|
||||
&& $this->repository->isKnownTheme( $args->slug )
|
||||
) {
|
||||
// Only handle our theme information calls
|
||||
return $this->repository->queryThemeInformation( $args->slug, $args->fields, $args->locale );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter a Theme API result.
|
||||
*
|
||||
* Inject our themes at appropriate places.
|
||||
*
|
||||
* @param object|\WP_Error $result
|
||||
* @param string $action 'theme_information', 'feature_list', 'query_themes'
|
||||
* @param object|array $args An array after using built-in API, object otherwise.
|
||||
* @return object
|
||||
*/
|
||||
public function filterApiResult( $result, $action, $args )
|
||||
{
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// FIXME: Workaround to be removed on 2015-10-23
|
||||
if ( is_array( $args ) && isset( $args['body']['request'] ) ) {
|
||||
// See https://core.trac.wordpress.org/ticket/29079, fixed in 4.2
|
||||
$args = unserialize( $args['body']['request'] ); // Unpack original args
|
||||
}
|
||||
|
||||
if ( self::ACTION_QUERY_THEMES !== $action || ! isset( $args->browse ) || 'featured' !== $args->browse ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( ! $result || ! is_object( $result ) ) {
|
||||
// Construct empty result
|
||||
// FIXME: Maybe unneccessary
|
||||
$result = (object) [
|
||||
'info' => [
|
||||
'page' => 1,
|
||||
'pages' => 0,
|
||||
'results' => false,
|
||||
],
|
||||
'themes' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$themes = $this->repository->queryFeaturedThemes( $args->fields, $args->locale );
|
||||
if ( ! is_wp_error( $themes ) ) {
|
||||
$this->spliceThemes( $result, $themes );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splice additional themes into an existing Theme API result.
|
||||
*
|
||||
* Put them in front.
|
||||
*
|
||||
* @param object $result {
|
||||
* @type object $info {
|
||||
* @type integer|false $results have browser count if false
|
||||
* @type integer|string $page
|
||||
* @type integer $pages may be 0
|
||||
* }
|
||||
* @type array $themes
|
||||
* }
|
||||
* @param array $themes
|
||||
* @return void
|
||||
*/
|
||||
public function spliceThemes( $result, array $themes )
|
||||
{
|
||||
$add = function ( $number, $increment ) {
|
||||
return is_integer( $number ) ? $number + $increment : $number;
|
||||
};
|
||||
|
||||
if ( is_array( $result->info ) ) {
|
||||
$result->info['results'] = $add( $result->info['results'], count( $themes ) );
|
||||
} elseif ( is_object( $result->info ) ) {
|
||||
// Seemed to be an object once…
|
||||
$result->info->results = $add( $result->info->results, count( $themes ) );
|
||||
}
|
||||
|
||||
array_splice( $result->themes, 0, 0, $themes );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter locales queried for a theme update.
|
||||
*
|
||||
* Just in time to wait for the theme updates HTTP request…
|
||||
*
|
||||
* @param array $locales
|
||||
* @return array
|
||||
*/
|
||||
public function filterThemeUpdateLocales( $locales )
|
||||
{
|
||||
$this->addHookMethod( 'http_response', 'filterThemeUpdateResponse' );
|
||||
|
||||
return $locales;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return bool
|
||||
*/
|
||||
protected function isThemeUpdateUrl( $url )
|
||||
{
|
||||
return (bool) preg_match( '@^https?://api.wordpress.org/themes/update-check/1.1/$@', $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our updates to the list.
|
||||
*
|
||||
* @param array $response
|
||||
* @param array $args Original args to request
|
||||
* @param string $url
|
||||
*/
|
||||
public function filterThemeUpdateResponse( array $response, array $args, $url )
|
||||
{
|
||||
if ( ! $this->isThemeUpdateUrl( $url ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->removeHookMethod( 'http_response', __FUNCTION__ );
|
||||
|
||||
$themes = $this->repository->queryUpdates( [
|
||||
// Eliminate worst offenders
|
||||
'author' => false,
|
||||
'description' => false,
|
||||
'preview_url' => false,
|
||||
'screenshot_url' => false,
|
||||
] );
|
||||
if ( is_wp_error( $themes ) ) {
|
||||
// Silently fail.
|
||||
return $response;
|
||||
}
|
||||
|
||||
$updates = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
foreach ( $themes as $theme ) {
|
||||
$installed_theme = wp_get_theme( $theme->slug );
|
||||
if ( ! $installed_theme->exists() || version_compare( $theme->version, $installed_theme->version, '<=' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Because that’s why: Rename all the fields.
|
||||
$updates['themes'][ $theme->slug ] = [
|
||||
'theme' => $theme->slug,
|
||||
'new_version' => $theme->version,
|
||||
'url' => $theme->homepage,
|
||||
'package' => $theme->download_link,
|
||||
];
|
||||
}
|
||||
|
||||
$response['body'] = json_encode( $updates );
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pfadfinden\WordPress;
|
||||
|
||||
use wordpress\src\Shy\WordPress\SettingsPage;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The code managing the plugin settings.
|
||||
*
|
||||
* @author Philipp Cordes <philipp.cordes@pfadfinden.de>
|
||||
*/
|
||||
class ThemeUpdaterSettings extends wordpress\src\Shy\WordPress\SettingsPage
|
||||
{
|
||||
/**
|
||||
* Full path of plugin main file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPluginFilename()
|
||||
{
|
||||
return preg_replace( '/src\\/.*?$/', 'pfadfinden-theme-updater.php', __DIR__ );
|
||||
}
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct( 'pfadfinden-theme-updater' );
|
||||
|
||||
$this->addHookMethod( 'plugin_action_links', 'filterPluginActions' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add our settings entry to the plugin actions.
|
||||
*
|
||||
* @param array<string> $actions
|
||||
* @param string $plugin_file
|
||||
* @param array $plugin_data
|
||||
* @param string $context
|
||||
* @return array<string>
|
||||
*/
|
||||
public function filterPluginActions( array $actions, $plugin_file, array $plugin_data, $context )
|
||||
{
|
||||
// Dereference possible symlink
|
||||
$plugin_file = realpath( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin_file );
|
||||
if ( $this->getPluginFilename() !== $plugin_file ) {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
return array(
|
||||
'settings' => sprintf(
|
||||
'<a href="themes.php?page=%s">%s</a>',
|
||||
esc_attr( urlencode( $this->slug ) ),
|
||||
esc_html__( 'Settings' )
|
||||
),
|
||||
) + $actions;
|
||||
}
|
||||
|
||||
|
||||
protected function getParentSlug()
|
||||
{
|
||||
return 'themes.php';
|
||||
}
|
||||
|
||||
protected function getPageTitle()
|
||||
{
|
||||
return __( 'Pfadfinden Theme Updater Settings', 'pfadfinden-theme-updater' );
|
||||
}
|
||||
|
||||
protected function getMenuTitle()
|
||||
{
|
||||
return __( 'Pfadfinden Updater', 'pfadfinden-theme-updater' );
|
||||
}
|
||||
|
||||
|
||||
public function registerSettings()
|
||||
{
|
||||
$this->addSection( '', 'plugin' );
|
||||
|
||||
$this->addTextField(
|
||||
'key',
|
||||
__( 'API Key', 'pfadfinden-theme-updater' ),
|
||||
[ 'attr' => [
|
||||
'minlength' => '10',
|
||||
'maxlength' => '10',
|
||||
'pattern' => '^[A-Za-z0-9]{10}$',
|
||||
'title' => __( 'An API key consists of 10 alphanumeric characters.', 'pfadfinden-theme-updater' ),
|
||||
] ],
|
||||
[ $this, 'renderApiKeyField' ]
|
||||
);
|
||||
|
||||
$this->addCheckboxField(
|
||||
'keep-settings',
|
||||
__( 'Keep Settings', 'pfadfinden-theme-updater' ),
|
||||
__( 'Don’t delete settings when uninstalling the plugin.', 'pfadfinden-theme-updater' )
|
||||
);
|
||||
|
||||
parent::registerSettings();
|
||||
}
|
||||
|
||||
public function renderApiKeyField( array $args )
|
||||
{
|
||||
$this->renderTextField( $args );
|
||||
|
||||
echo '<p class="description">' . __( 'Just testing? Try APITESTKEY.', 'pfadfinden-theme-updater' ) . '</p>';
|
||||
}
|
||||
|
||||
public function sanitizeOptions( array $options )
|
||||
{
|
||||
if ( isset( $options['key'] ) ) {
|
||||
$key = preg_replace( '/[^A-Za-z0-9]+/', '', $options['key'] );
|
||||
$keylen = strlen( $key );
|
||||
if ( 0 !== $keylen && 10 !== $keylen ) {
|
||||
$this->addError( 'key', __( 'An API key consists of 10 alphanumeric characters.', 'pfadfinden-theme-updater' ) );
|
||||
}
|
||||
$options['key'] = $key;
|
||||
}
|
||||
|
||||
return $options + $this->getDefaults();
|
||||
}
|
||||
|
||||
public function getDefaults()
|
||||
{
|
||||
return [
|
||||
'key' => '',
|
||||
'keep-settings' => false,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Try to load a Pfadfinden WordPress class.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
function pfadfinden_wordpress_autoloader( $name )
|
||||
{
|
||||
if ( substr( $name, 0, 21 ) !== 'Pfadfinden\\WordPress\\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
|
||||
return is_file( $name ) && include( $name );
|
||||
}
|
||||
|
||||
spl_autoload_register( 'pfadfinden_wordpress_autoloader' );
|
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
return new \Pfadfinden\WordPress\ThemeUpdaterPlugin();
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pfadfinden\WordPress\Tests;
|
||||
|
||||
|
||||
|
||||
class ThemeRepositoryTest extends \WP_UnitTestCase
|
||||
{
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pfadfinden\WordPress\Tests;
|
||||
|
||||
|
||||
|
||||
class ThemeUpdaterPluginTest extends \WP_UnitTestCase
|
||||
{
|
||||
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Pfadfinden\WordPress\Tests;
|
||||
|
||||
use Pfadfinden\WordPress\ThemeUpdaterSettings;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit_Framework_MockObject_Builder_InvocationMocker as BuilderInvocationMocker;
|
||||
|
||||
|
||||
|
||||
class ThemeUpdaterSettingsTest extends \WP_UnitTestCase
|
||||
{
|
||||
/**
|
||||
* @return ThemeUpdaterSettings|MockObject {
|
||||
* @method BuilderInvocationMocker method(string)
|
||||
* }
|
||||
*/
|
||||
protected function createMock()
|
||||
{
|
||||
return $this->getMockBuilder( 'Pfadfinden\WordPress\ThemeUpdaterSettings' )
|
||||
->enableProxyingToOriginalMethods()
|
||||
->getMock();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array<array {
|
||||
* @type array<string> $0
|
||||
* }>
|
||||
*/
|
||||
public function pluginActionProvider()
|
||||
{
|
||||
return array(
|
||||
array( array() ),
|
||||
array( array( 'edit' => '<a href="edit-url.php">Edit</a>' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider pluginActionProvider
|
||||
* @param array<string> $old_actions
|
||||
*/
|
||||
public function testFilterPluginActions( array $old_actions )
|
||||
{
|
||||
$settings = $this->createMock();
|
||||
|
||||
$new_actions = $settings->filterPluginActions( $old_actions, 'pfadfinden-theme-updater/pfadfinden-theme-updater.php', array(), 'All' );
|
||||
$this->assertCount( 1, array_diff_assoc( $new_actions, $old_actions ), 'Our action gets added.' );
|
||||
$this->assertCount( 0, array_diff_assoc( $old_actions, $new_actions ), 'No actions are removed.' );
|
||||
}
|
||||
|
||||
public function testRegisterSettings()
|
||||
{
|
||||
global $wp_settings_fields;
|
||||
|
||||
$settings = $this->createMock();
|
||||
$settings->registerSettings();
|
||||
|
||||
$sections = $settings->getSections();
|
||||
$this->assertCount( 1, $sections, 'One section is generated.' );
|
||||
|
||||
$fields = $settings->getFieldsForSection( $sections[0] );
|
||||
$this->assertEquals( array( 'key', 'keep-settings' ), array_keys( $fields ), 'Known settings are there.' );
|
||||
}
|
||||
|
||||
public function testSanitizeOptionDefaults()
|
||||
{
|
||||
$settings = $this->createMock();
|
||||
|
||||
$this->assertEquals(
|
||||
$settings->getDefaults(),
|
||||
$settings->sanitizeOptions( array() ),
|
||||
'sanitizeOptions() adds in default values if missing.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array {
|
||||
* @type string $0
|
||||
* @type string $1
|
||||
* @type int $2
|
||||
* }>
|
||||
*/
|
||||
public function keyProvider()
|
||||
{
|
||||
return array(
|
||||
array( '', '', 0 ),
|
||||
array( 'ABCDEFGHIJ', 'ABCDEFGHIJ', 0 ),
|
||||
array( 'abcdefghij', 'abcdefghij', 0 ),
|
||||
array( '1234567890', '1234567890', 0 ),
|
||||
array( '123456789', '123456789', 1 ),
|
||||
array( '12345678901', '12345678901', 1 ),
|
||||
array( ' 1234567890', '1234567890', 0 ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider keyProvider
|
||||
* @param string $key
|
||||
* @param string $expected
|
||||
* @param int $errorCount
|
||||
*/
|
||||
public function testSanitizeKeyOption( $key, $expected, $errorCount )
|
||||
{
|
||||
$settings = $this->createMock();
|
||||
|
||||
$sanitized = $settings->sanitizeOptions( array( 'key' => $key ) )['key'];
|
||||
$this->assertEquals( $expected, $sanitized, 'Expected sanitized value.' );
|
||||
$this->assertCount( $errorCount, $settings->getErrors(), 'Number of generated errors.' );
|
||||
}
|
||||
|
||||
public function testDefaults()
|
||||
{
|
||||
$defaults = $this->createMock()->getDefaults();
|
||||
|
||||
$this->assertEquals(
|
||||
array( 'key', 'keep-settings' ),
|
||||
array_keys( $defaults ),
|
||||
'Defaults for all options.'
|
||||
);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Try to load a Pfadfinden WordPress class.
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
function pfadfinden_wordpress_tests_autoloader( $name )
|
||||
{
|
||||
if ( substr( $name, 0, 27 ) !== 'Pfadfinden\\WordPress\\Tests\\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
|
||||
return is_file( $name ) && include( $name );
|
||||
}
|
||||
|
||||
spl_autoload_register( 'pfadfinden_wordpress_tests_autoloader' );
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPUnit bootstrap file
|
||||
*
|
||||
* Variant of the one from github.com/tierra/wordpress-plugins-tests
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../use/shy-wordpress/src/autoloader.php';
|
||||
require_once __DIR__ . '/../src/autoloader.php';
|
||||
require_once __DIR__ . '/autoloader.php';
|
||||
|
||||
|
||||
|
||||
$GLOBALS['wp_test_plugins'] = array(
|
||||
'active_plugins' => array( 'pfadfinden-theme-updater/pfadfinden-theme-updater.php' ),
|
||||
);
|
||||
|
||||
|
||||
|
||||
echo 'Setting up WordPress...' . PHP_EOL;
|
||||
|
||||
if ( ! isset( $argv )
|
||||
|| ( ! in_array( '-v', $argv ) && ! in_array( '--verbose', $argv ) )
|
||||
) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
require_once ( getenv( 'WP_DEVELOP_DIR' ) ?: '../../../..' )
|
||||
. '/tests/phpunit/includes/bootstrap.php';
|
||||
|
||||
if ( ob_get_level() ) {
|
||||
ob_end_clean();
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<phpunit boostrap="tests/bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite>
|
||||
<directory suffix="Test.php" phpVersion="5.4.0">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
use plugins\buena\use\shy/**
|
||||
* A composite option with a fixed number of suboptions and their default values.
|
||||
*/
|
||||
abstract class CompositeOption implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
{
|
||||
use HookableTrait;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $slug;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug()
|
||||
{
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
|
||||
protected function __construct( $slug )
|
||||
{
|
||||
$this->slug = (string) $slug;
|
||||
|
||||
$this->addHookMethod( 'default_option_' . $this->slug, 'getDefaults' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return default values for all suboptions.
|
||||
* Hooked into get_option() defaults.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getDefaults();
|
||||
|
||||
/**
|
||||
* @param string $offset
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefault( $offset )
|
||||
{
|
||||
return $this->getDefaults()[ $offset ];
|
||||
}
|
||||
|
||||
|
||||
public function offsetExists( $offset )
|
||||
{
|
||||
$settings = get_option( $this->slug );
|
||||
return isset( $settings[ $offset ] );
|
||||
}
|
||||
|
||||
public function offsetGet( $offset )
|
||||
{
|
||||
$settings = get_option( $this->slug );
|
||||
if ( ! isset( $settings[ $offset ] ) ) {
|
||||
throw new \OutOfBoundsException( "There is no setting '$offset'." );
|
||||
}
|
||||
|
||||
return $settings[ $offset ];
|
||||
}
|
||||
|
||||
public function offsetSet( $offset, $value )
|
||||
{
|
||||
$settings = get_option( $this->slug );
|
||||
if ( ! isset( $settings[ $offset ] ) ) {
|
||||
throw new \OutOfBoundsException( "There is no setting '$offset'." );
|
||||
}
|
||||
|
||||
$settings[ $offset ] = $value;
|
||||
update_option( $this->slug, $settings );
|
||||
}
|
||||
|
||||
public function offsetUnset( $offset )
|
||||
{
|
||||
throw new \BadMethodCallException( 'You cannot unset settings.' );
|
||||
}
|
||||
|
||||
|
||||
public function count()
|
||||
{
|
||||
return count( $this->getDefaults() );
|
||||
}
|
||||
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayIterator( get_option( $this->slug ) );
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Making actions and filters how they should be.
|
||||
*
|
||||
* Default to pass all arguments.
|
||||
*/
|
||||
trait HookableTrait
|
||||
{
|
||||
/**
|
||||
* @param string $action_or_filter
|
||||
* @param string $method
|
||||
* @param int $priority
|
||||
* @param int $acceptedArgs
|
||||
*/
|
||||
protected function addHookMethod( $action_or_filter, $method, $priority = 10, $acceptedArgs = 99 )
|
||||
{
|
||||
add_filter( $action_or_filter, array( $this, $method ), $priority, $acceptedArgs );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action_or_filter
|
||||
* @param string $method
|
||||
* @param int $priority
|
||||
* @param int $acceptedArgs
|
||||
*/
|
||||
protected function removeHookMethod( $action_or_filter, $method, $priority = 10, $acceptedArgs = 99 )
|
||||
{
|
||||
remove_filter( $action_or_filter, array( $this, $method ), $priority, $acceptedArgs );
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Options wrapper.
|
||||
*/
|
||||
class Options implements \ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Remember a default value.
|
||||
*
|
||||
* Creates a closure and hooks it into the 'default_option_*' filter.
|
||||
*
|
||||
* @param string $option
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setDefault( $option, $value )
|
||||
{
|
||||
add_filter( 'default_option_' . $option, function () use ( $value ) {
|
||||
return $value;
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
public function offsetExists( $option )
|
||||
{
|
||||
// Unfortunately, we can’t really tell whether it exists…
|
||||
$value = get_option( $option );
|
||||
return false !== $value && null !== $value;
|
||||
}
|
||||
|
||||
public function offsetGet( $option )
|
||||
{
|
||||
return get_option( $option );
|
||||
}
|
||||
|
||||
public function offsetSet( $option, $value )
|
||||
{
|
||||
update_option( $option, $value );
|
||||
}
|
||||
|
||||
public function offsetUnset( $option )
|
||||
{
|
||||
delete_option( $option );
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
use plugins\buena\use\shy/**
|
||||
* Marker class for WordPress plugins.
|
||||
*/
|
||||
abstract class Plugin
|
||||
{
|
||||
use HookableTrait;
|
||||
}
|
@ -1,378 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
use plugins\buena\use\shyuse plugins\buena\use\shy/**
|
||||
* Abstracts common functionality and escaping for the Settings API.
|
||||
*
|
||||
* TODO: Check slug and field names for illegal characters.
|
||||
* TODO: Refactor to not extend but use CompositeOption
|
||||
*/
|
||||
abstract class SettingsPage extends CompositeOption
|
||||
{
|
||||
use HookableTrait;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $capability;
|
||||
|
||||
|
||||
/**
|
||||
* Slug (file name) of the parent menu entry.
|
||||
*
|
||||
* @see add_submenu_page() for suggestions.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getParentSlug()
|
||||
{
|
||||
return 'options-general.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Title for this setting page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getPageTitle();
|
||||
|
||||
/**
|
||||
* String to show in the menu entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getMenuTitle()
|
||||
{
|
||||
return $this->getPageTitle();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $slug Page slug
|
||||
* @param string $capability Required capability to view
|
||||
*/
|
||||
protected function __construct( $slug, $capability = 'manage_options' )
|
||||
{
|
||||
parent::__construct( $slug );
|
||||
|
||||
$this->capability = (string) $capability;
|
||||
|
||||
$this->addHookMethod( 'admin_menu', 'registerPage' );
|
||||
$this->addHookMethod( 'admin_init', 'registerSettings' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register our options page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerPage()
|
||||
{
|
||||
add_submenu_page(
|
||||
$this->getParentSlug(),
|
||||
$this->getPageTitle(),
|
||||
$this->getMenuTitle(),
|
||||
$this->capability,
|
||||
$this->slug,
|
||||
array( $this, 'renderPage' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the actual settings.
|
||||
* Override and use addSection() and add*Field() methods.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerSettings()
|
||||
{
|
||||
register_setting(
|
||||
$this->slug,
|
||||
$this->slug,
|
||||
array( $this, 'sanitizeOptions' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize option values after form submission.
|
||||
*
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
abstract public function sanitizeOptions( array $options );
|
||||
|
||||
|
||||
/**
|
||||
* Section to add fields to.
|
||||
*
|
||||
* Parameter default from add_settings_field().
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currentSection = 'default';
|
||||
|
||||
/**
|
||||
* Add a new section and return its generated name.
|
||||
*
|
||||
* @param string $title optional, can be empty
|
||||
* @param string $name optional, will be generated if empty
|
||||
* @return string
|
||||
*/
|
||||
protected function addSection( $title = '', $name = '' )
|
||||
{
|
||||
$name = (string) $name;
|
||||
if ( ! strlen( $name ) ) {
|
||||
$name = $this->slug . '-section' . ( count( $this->getSections() ) + 1 );
|
||||
}
|
||||
|
||||
add_settings_section(
|
||||
$name,
|
||||
esc_html( $title ),
|
||||
array( $this, 'renderSectionTeaser' ),
|
||||
$this->slug
|
||||
);
|
||||
|
||||
return $this->currentSection = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback before output of section fields.
|
||||
*
|
||||
* Teasers must escape their output themselves.
|
||||
*
|
||||
* @param array $section {
|
||||
* @type string $id
|
||||
* @type string $title
|
||||
* @type callable $callback
|
||||
* }
|
||||
*/
|
||||
public function renderSectionTeaser( array $section )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all known section names on this page.
|
||||
*
|
||||
* @global $wp_settings_fields
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getSections()
|
||||
{
|
||||
global $wp_settings_fields;
|
||||
|
||||
if ( ! isset( $wp_settings_fields[ $this->slug ] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array_keys( $wp_settings_fields[ $this->slug ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global $wp_settings_fields
|
||||
* @param string $section
|
||||
* @return array<string, array {
|
||||
* @type string $id
|
||||
* @type string $title
|
||||
* @type callable $callback
|
||||
* @type array $args
|
||||
* }>
|
||||
*/
|
||||
public function getFieldsForSection( $section )
|
||||
{
|
||||
global $wp_settings_fields;
|
||||
|
||||
return $wp_settings_fields[ $this->slug ][ $section ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a custom field to this setting page.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param callable $callback
|
||||
* @param array $args
|
||||
*/
|
||||
protected function addField( $name, $label, $callback, $args = array() )
|
||||
{
|
||||
if ( ! is_callable( $callback ) ) {
|
||||
throw new \InvalidArgumentException( 'Parameter $callback must be callable.' );
|
||||
}
|
||||
|
||||
add_settings_field(
|
||||
$name,
|
||||
esc_html( $label ),
|
||||
$callback,
|
||||
$this->slug,
|
||||
$this->currentSection,
|
||||
$args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a text field to this settings page.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param array $args
|
||||
* @param string $callback
|
||||
*/
|
||||
protected function addTextField( $name, $label, $args = array(), $callback = '' )
|
||||
{
|
||||
if ( ! $callback || ! is_callable( $callback ) ) {
|
||||
$callback = array( $this, 'renderTextField' );
|
||||
}
|
||||
|
||||
$this->addField(
|
||||
$name,
|
||||
$label,
|
||||
$callback,
|
||||
$args + array(
|
||||
'label_for' => $this->slug . '-' . $name,
|
||||
'name' => $name,
|
||||
'attr' => array(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $label
|
||||
* @param string $caption
|
||||
* @param array $args
|
||||
* @param callable $callback
|
||||
*/
|
||||
protected function addCheckboxField( $name, $label, $caption, $args = array(), $callback = '' )
|
||||
{
|
||||
if ( ! $callback || ! is_callable( $callback ) ) {
|
||||
$callback = array( $this, 'renderCheckboxField' );
|
||||
}
|
||||
|
||||
$this->addField(
|
||||
$name,
|
||||
$label,
|
||||
$callback,
|
||||
$args + array(
|
||||
'label_for' => $this->slug . '-' . $name,
|
||||
'name' => $name,
|
||||
'caption' => $caption,
|
||||
'attr' => array(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error.
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $message
|
||||
*/
|
||||
protected function addError( $code, $message )
|
||||
{
|
||||
add_settings_error( $this->slug, $code, $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Errors for this setting.
|
||||
*
|
||||
* @return array {
|
||||
* @type string $setting
|
||||
* @type string $code
|
||||
* @type string $message
|
||||
* @type string $type 'error'
|
||||
* }
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
return get_settings_errors( $this->slug );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render a setting as text field.
|
||||
*
|
||||
* @param array $args {
|
||||
* @type string $name
|
||||
* @type string $label_for
|
||||
* @type array $attr
|
||||
* }
|
||||
*/
|
||||
public function renderTextField( array $args )
|
||||
{
|
||||
$name = $args['name'];
|
||||
|
||||
$this->renderInputTag( array(
|
||||
'type' => 'text',
|
||||
'id' => $args['label_for'],
|
||||
'class' => 'regular-text',
|
||||
'name' => $this->slug . '[' . $name . ']',
|
||||
'value' => $this[ $name ],
|
||||
) + $args['attr'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a setting as checkbox.
|
||||
*
|
||||
* @param array $args {
|
||||
* @type string $caption
|
||||
* @type string $name
|
||||
* @type string $label_for
|
||||
* @type array $attr
|
||||
* }
|
||||
*/
|
||||
public function renderCheckboxField( array $args )
|
||||
{
|
||||
$name = $args['name'];
|
||||
|
||||
echo '<label>';
|
||||
$this->renderInputTag( array(
|
||||
'type' => 'checkbox',
|
||||
'id' => isset( $args['label_for'] ) ? $args['label_for'] : null,
|
||||
'name' => $this->slug . '[' . $name . ']',
|
||||
'value' => '1',
|
||||
'checked' => $this[ $name ] ? 'checked' : null,
|
||||
) + $args['attr'] );
|
||||
echo ' ' . esc_html( $args['caption'] ) . '</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an input tag with given HTML attributes.
|
||||
*
|
||||
* @param array $attr
|
||||
*/
|
||||
protected function renderInputTag( array $attr )
|
||||
{
|
||||
echo '<input';
|
||||
foreach ( $attr as $k => $v ) {
|
||||
if ( null !== $v ) {
|
||||
printf( ' %s="%s"', $k, esc_attr( $v ) );
|
||||
}
|
||||
}
|
||||
echo ' />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output settings page.
|
||||
*/
|
||||
public function renderPage()
|
||||
{
|
||||
if ( ! current_user_can( $this->capability ) ) {
|
||||
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php echo esc_html( $this->getPageTitle() ); ?></h2>
|
||||
<form action="options.php" method="post">
|
||||
<?php settings_errors( 'general' ); // “Settings saved.” message ?>
|
||||
<?php settings_fields( $this->slug ); ?>
|
||||
<?php do_settings_sections( $this->slug ); ?>
|
||||
<?php submit_button(); ?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Site options wrapper.
|
||||
*/
|
||||
class SiteOptions implements \ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Remember a default value.
|
||||
*
|
||||
* Creates a closure and hooks it into the 'default_site_option_*' filter.
|
||||
*
|
||||
* @param string $option
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setDefault( $option, $value )
|
||||
{
|
||||
add_filter( 'default_site_option_' . $option, function () use ( $value ) {
|
||||
return $value;
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
public function offsetExists( $option )
|
||||
{
|
||||
// Unfortunately, we can’t really tell whether it exists…
|
||||
$value = get_site_option( $option );
|
||||
return false !== $value && null !== $value;
|
||||
}
|
||||
|
||||
public function offsetGet( $option )
|
||||
{
|
||||
return get_site_option( $option );
|
||||
}
|
||||
|
||||
public function offsetSet( $option, $value )
|
||||
{
|
||||
update_site_option( $option, $value );
|
||||
}
|
||||
|
||||
public function offsetUnset( $option )
|
||||
{
|
||||
delete_site_option( $option );
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress;
|
||||
|
||||
|
||||
|
||||
use plugins\buena\use\shyabstract class Theme extends Plugin
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$GLOBALS['content_width'] = $this->getContentWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
abstract public function getContentWidth();
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Try to load a Shy WordPress class.
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
function shy_wordpress_autoloader( $name )
|
||||
{
|
||||
if ( substr( $name, 0, 14 ) !== 'Shy\\WordPress\\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
|
||||
|
||||
return is_file( $name ) && include( $name );
|
||||
}
|
||||
|
||||
spl_autoload_register( 'shy_wordpress_autoloader' );
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress\Tests;
|
||||
|
||||
use wordpress\src\Shy\WordPress\HookableTrait;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check that HookableTrait actually works.
|
||||
*
|
||||
* @author Philipp Cordes <pc@irgendware.net>
|
||||
*/
|
||||
class HookableTraitTest extends \WP_UnitTestCase
|
||||
{
|
||||
use HookableTrait;
|
||||
|
||||
|
||||
public function actionMethod()
|
||||
{
|
||||
}
|
||||
|
||||
public function testWorksAsAction()
|
||||
{
|
||||
$this->addHookMethod( 'shywp_test_action', 'actionMethod' );
|
||||
$this->assertTrue( has_action( 'shywp_test_action' ), 'Registering an action via addHookMethod() worked.' );
|
||||
}
|
||||
|
||||
|
||||
public function filterMethod( $value )
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function testWorksAsFilter()
|
||||
{
|
||||
$this->addHookMethod( 'shywp_test_filter', 'filterMethod' );
|
||||
$this->assertTrue( has_filter( 'shywp_test_filter' ), 'Registering a filter via addHookMethod() worked.' );
|
||||
}
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Shy\WordPress\Tests;
|
||||
|
||||
use wordpress\src\Shy\WordPress\SettingsPage;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit_Framework_MockObject_Builder_InvocationMocker as BuilderInvocationMocker;
|
||||
|
||||
|
||||
|
||||
class SettingsPageTest extends \WP_UnitTestCase
|
||||
{
|
||||
/**
|
||||
* Mock a SettingsPage.
|
||||
*
|
||||
* @param string|null $slug
|
||||
* @param string $capability
|
||||
*
|
||||
* @return wordpress\src\Shy\WordPress\SettingsPage|MockObject {
|
||||
* @method BuilderInvocationMocker method(string)
|
||||
* }
|
||||
*/
|
||||
protected function mockSettingsPage( $slug = null, $capability = 'manage_options' )
|
||||
{
|
||||
$builder = $this->getMockBuilder( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\SettingsPage' )
|
||||
->enableProxyingToOriginalMethods();
|
||||
|
||||
if ( null === $slug ) {
|
||||
$builder->disableOriginalConstructor();
|
||||
} else {
|
||||
$builder->setConstructorArgs( array( $slug, $capability ) );
|
||||
}
|
||||
|
||||
return $builder->getMock();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test reading defaults from the settings page.
|
||||
*
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::__construct()
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::getDefaults()
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::offsetExists()
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::offsetGet()
|
||||
* @expectedException OutOfBoundsException
|
||||
*/
|
||||
public function testReading()
|
||||
{
|
||||
$slug = 'shywp_settingspage_test_slug_reading';
|
||||
$defaults = array( 'foo' => 'bar' );
|
||||
|
||||
$page = $this->mockSettingsPage( $slug );
|
||||
$page->method( 'getDefaults' )->willReturn( $defaults );
|
||||
|
||||
$this->assertEquals( $defaults, get_option( $slug ) );
|
||||
|
||||
$this->assertArrayHasKey( 'foo', $page );
|
||||
$this->assertEquals( $defaults['foo'], $page['foo'] );
|
||||
|
||||
$this->assertArrayNotHasKey( 'baz', $page );
|
||||
$page['baz'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test writing to the settings page.
|
||||
*
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::offsetSet()
|
||||
* @expectedException OutOfBoundsException
|
||||
*/
|
||||
public function testWriting()
|
||||
{
|
||||
$slug = 'shywp_settingspage_test_slug_writing';
|
||||
$defaults = array( 'foo' => 'bar' );
|
||||
|
||||
$page = $this->mockSettingsPage( $slug );
|
||||
$page->method( 'getDefaults' )->willReturn( $defaults );
|
||||
|
||||
$page['foo'] = 'foo';
|
||||
$this->assertEquals( 'foo', $page['foo'] );
|
||||
$page['baz'] = '123';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail to remove a setting.
|
||||
*
|
||||
* @covers SettingPage::offsetUnset()
|
||||
* @expectedException BadMethodCallException
|
||||
*/
|
||||
public function testRemoving()
|
||||
{
|
||||
$slug = 'shywp_settingspage_test_slug_removing';
|
||||
$defaults = array();
|
||||
|
||||
$page = $this->mockSettingsPage( $slug );
|
||||
$page->method( 'getDefaults' )->willReturn( $defaults );
|
||||
|
||||
unset( $page['baz'] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test whether the settings page can be showed.
|
||||
*
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::__construct()
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::getParentSlug()
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::getPageTitle()
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::getMenuTitle()
|
||||
*/
|
||||
public function testRegisterPage()
|
||||
{
|
||||
$this->expectOutputRegex( '/<page&title>/' );
|
||||
|
||||
$slug = 'shywp_settingspage_test_slug_registerpage';
|
||||
|
||||
$page = $this->mockSettingsPage( $slug );
|
||||
$page->method( 'getParentSlug' )->willReturn( 'index.php' );
|
||||
$page->method( 'getPageTitle' )->willReturn( '<page&title>' );
|
||||
$page->method( 'getMenuTitle' )->willReturn( '<menu&title>' );
|
||||
|
||||
$page->expects( $this->once() )->method( 'registerPage' )->with();
|
||||
$page->expects( $this->once() )->method( 'registerSettings' )->with();
|
||||
|
||||
// FIXME: Simulate display of backend.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers wordpress\src\Shy\WordPress\SettingsPage::sanitizeOptions()
|
||||
*/
|
||||
public function testSanitize()
|
||||
{
|
||||
$slug = 'shywp_settingspage_test_slug_sanitize';
|
||||
|
||||
$page = $this->mockSettingsPage( $slug );
|
||||
$page->method( 'sanitizeOptions' )->will( $this->returnArgument( 0 ) );
|
||||
$page->expects( $this->atLeastOnce() )->method( 'sanitizeOptions' );
|
||||
|
||||
$this->markTestIncomplete();
|
||||
// FIXME: Simulate form submission
|
||||
}
|
||||
|
||||
public function testRenderTextField()
|
||||
{
|
||||
$this->expectOutputRegex( '/^<input type="text"/' );
|
||||
|
||||
$page = $this->mockSettingsPage();
|
||||
$page->renderTextField( array(
|
||||
'label_for' => 'foo',
|
||||
'name' => 'bar',
|
||||
) );
|
||||
}
|
||||
|
||||
public function testRenderCheckboxField()
|
||||
{
|
||||
$this->expectOutputRegex( '/^<label><input type="checkbox"/' );
|
||||
|
||||
$page = $this->mockSettingsPage();
|
||||
$page->renderCheckboxField( array(
|
||||
'label_for' => 'foo',
|
||||
'name' => 'bar',
|
||||
'caption' => 'baz',
|
||||
) );
|
||||
}
|
||||
|
||||
public function testRenderPage()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$this->expectOutputRegex( '/<form action="options.php" method="post">.*<3&>.*cryptic_teaser.*</form>/' );
|
||||
|
||||
$slug = 'shywp_settingspage_test_slug_renderpage';
|
||||
|
||||
$page = $this->mockSettingsPage( $slug, 'read' );
|
||||
$page->method( 'getPageTitle' )->willReturn( '<3&>' );
|
||||
$page->method( 'renderSectionTeaser' )->will( $this->returnCallback( function () use ( $teaser ) {
|
||||
echo 'cryptic_teaser';
|
||||
} ) );
|
||||
|
||||
// FIXME: Simulate view of the settings page
|
||||
$page->renderPage();
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Try to load a Shy WordPress test class.
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
function shy_wordpress_tests_autoloader( $name )
|
||||
{
|
||||
if ( substr( $name, 0, 20 ) !== 'Shy\\WordPress\\Tests\\' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = __DIR__ . '/' . str_replace( '\\', DIRECTORY_SEPARATOR, $name ) . '.php';
|
||||
|
||||
return is_file( $name ) && include( $name );
|
||||
}
|
||||
|
||||
spl_autoload_register( 'shy_wordpress_tests_autoloader' );
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPUnit bootstrap file
|
||||
*
|
||||
* Variant of the one from github.com/tierra/wordpress-plugins-tests
|
||||
*/
|
||||
|
||||
require_once '../src/autoloader.php';
|
||||
require_once 'autoloader.php';
|
||||
|
||||
|
||||
|
||||
require_once ( getenv( 'WP_DEVELOP_DIR' ) ?: '../../../..' )
|
||||
. '/tests/phpunit/includes/bootstrap.php';
|