diff --git a/assets/password.js b/assets/password.js new file mode 100644 index 0000000..8796982 --- /dev/null +++ b/assets/password.js @@ -0,0 +1,43 @@ +jQuery(document).ready(function($) { + $( "" ).insertBefore( ".submit" ); + + $("#password_too_short").css('display', 'none'); + + $(document).on('DOMSubtreeModified', '#pass-strength-result', function() { + var strengthMeter = $(this).attr('class'); + var allowedStrengths = php_vars.allowed_strengths; + + $( "[name='pw_weak']" ).css('visibility', 'hidden'); + $( '.pw-weak' ).css('visibility', 'hidden'); + $( '#pw-weak-text-label' ).css('visibility', 'hidden'); + + if (strengthMeter !== '') { + if (allowedStrengths.includes(strengthMeter)) { + $("[name='pw_weak']").prop("checked", true); + $("[name='submit']").css('display', 'inline'); + $('#createusersub').css('display', 'inline'); + $('submit').onclick = function() { + $('your-profile').submit(); + }; + $("#createusersub").onclick = function() { + $('createuser').submit(); + }; + + $("#password_too_short").css('display', 'none'); + } else { + $("#createusersub").css('display', 'none'); + $("[name='submit']").prop("disabled", true); + $("[name='pw_weak']").prop("checked", false); + $("[name='submit']").css('display', 'none'); + $('submit').onclick = function() { + return false; + }; + $("#createusersub").onclick = function() { + return false; + }; + $("#password_too_short").css('display', 'inline'); + } + } + }); +}); \ No newline at end of file diff --git a/assets/security.css b/assets/security.css index be7bfbb..46884dd 100644 --- a/assets/security.css +++ b/assets/security.css @@ -3,13 +3,11 @@ width: 85%; margin: auto; padding: 10px; - border-style: solid; border-color: #d0d0d0; border-radius: 10px; padding: 15px; border-width: 1px; - box-shadow: 2px 2px 5px #c0c0c0; + } .bdp_security_inner { - border-style: solid; border-color: #d0d0d0; border-radius: 10px; padding: 15px; border-width: 1px; - box-shadow: 2px 2px 5px #c0c0c0; + width: 80%; margin: 0 auto 40px; } @@ -52,4 +50,16 @@ .long_text { width: 80%; +} + +.protect-login-no-blocked-ips +{ + padding: 5px 10px; + width: 90%; + background-color: #ffffff; + border-style: solid; + border-color: #00a32a; + border-width: 1px; + font-weight: bold; + font-size: 12pt; } \ No newline at end of file diff --git a/assets/wordpress-bdp.css b/assets/wordpress-bdp.css index 1e137fe..4951607 100644 --- a/assets/wordpress-bdp.css +++ b/assets/wordpress-bdp.css @@ -1,87 +1,353 @@ -#adminmenu, -#wpadminbar, +body { + background: #fff; +} + +/* Admin Menu */ +#adminmenuback, #adminmenuwrap, -#adminmenuback { - background-color: #ffcb04 !important; +#adminmenu { + margin-top: 12px; + background: #f0f0f0; + width: 300px; } -#toplevel_page_limit-login-attempts, -#wp-admin-bar-llar-root { - display: none; +#adminmenu { + background-color: #ffffff; + border-radius: 10px; + } -.wp-submenu-wrap, -.wp-submenu-head { - color: #FFFFFF !important; -} - -.wp-has-submenu, -.wp-not-current-submenu, -.menu-top, - -#collapse-button, -#wp-submenu ul, -#wp-admin-bar-site-name, -.ab-item -{ - color: #46484d !important; +#adminmenu a { + color: #1d4899 !important; font-weight: bold !important; + margin-left: 30px !important; + border-color: #f0f0f0; } -.wp-menu-open , -.wp-has-current-submenu li, -#adminmenu ul + + +#wpbody { + background-color: #f0f0f0; + position: relative; + padding-left: 150px; + + padding-top: 25px; +} + +#wpfooter, #wpwrap { - background-color: #3163bd !important; - color: #FFFFFF !important; + background-color: #f0f0f0; } -.wp-not-current-submenu:hover, -#wpadminbar .ab-item:hover -{ - background-color: #3163bd !important; - color: #FFFFFF !important; +#wpfooter { + padding-left: 150px; +} +#wpbody-content { + background-color: #ffffff; + width: 95%; + padding-left: 50px; + box-shadow: 10px 10px 10px #c0c0c0; + border-radius: 10px; + border-width: 1px; + border-style: solid; + border-color: #c0c0c0; +} + + + +#adminmenu div.wp-menu-image:before { + color: rgba(29, 72, 153, 0.75); +} + +#adminmenu a:hover, +#adminmenu li.menu-top:hover, +#adminmenu li.opensub > a.menu-top, +#adminmenu li > a.menu-top:focus { + color: #1d4899; + border-color: #f0f0f0; + + font-weight: bold; + background: linear-gradient(to right, #efefef, rgba(255, 203, 4, 0.45)); + border-radius: 10px; + border-width: 0 !important; +} + +#adminmenu li.menu-top:hover div.wp-menu-image:before, +#adminmenu li.opensub > a.menu-top div.wp-menu-image:before { + color: #1d4899; + font-weight: bold; + background: linear-gradient(to right, #efefef, rgba(255, 203, 4, 0.45)); + border-radius: 10px; + border-width: 0; + border-color: #f0f0f0; } -.ab-submenu { - background-color: #ffcb04 !important; +/* Active tabs use a bottom border color that matches the page background color. */ +.about-wrap .nav-tab-active, +.nav-tab-active, +.nav-tab-active:hover { + border-style: none; + background-color: #fff; + border-bottom-color: #fff; } -#wp-admin-bar-updates, -#wp-admin-bar-comments, -#wp-admin-bar-new-content, -#wp-admin-bar-wp-logo -{ +/* Admin Menu: submenu */ +#adminmenu .wp-submenu, +#adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu, +.folded #adminmenu .wp-has-current-submenu .wp-submenu, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu { + background: #ffffff; + width: 300px; +} + +#adminmenu li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after { display: none; } -.bdp_submit:hover { +#adminmenu .wp-submenu .wp-submenu-head { + color: #ccdbe0; +} + +#adminmenu .wp-submenu a, +#adminmenu .wp-has-current-submenu .wp-submenu a, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a { + color: #ccdbe0; +} + +#adminmenu .wp-submenu a:focus, #adminmenu .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu .wp-submenu a:hover, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:focus, +.folded #adminmenu .wp-has-current-submenu .wp-submenu a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu a:hover { + color: #f0f0f0; +} + +/* Admin Menu: current */ +#adminmenu .wp-submenu li.current a, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a { + color: #f2fcff; +} + +#adminmenu .wp-submenu li.current a:hover, #adminmenu .wp-submenu li.current a:focus, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:hover, +#adminmenu a.wp-has-current-submenu:focus + .wp-submenu li.current a:focus, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:hover, +#adminmenu .wp-has-current-submenu.opensub .wp-submenu li.current a:focus { + color: #e0e0e0; + border-style: none; +} + +ul#adminmenu a.wp-has-current-submenu:after, +ul#adminmenu > li.current > a.current:after { + border-right-color: #fff; + display: none; +} + +#adminmenu li.current a.menu-top, +#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu, +#adminmenu li.wp-has-current-submenu .wp-submenu .wp-submenu-head, +.folded #adminmenu li.current.menu-top { + color: #000000; + background: linear-gradient(to right, #efefef, rgba(255, 203, 4, 0.45)); + border-radius: 10px; +} + +#adminmenu li.wp-has-current-submenu div.wp-menu-image:before, +#adminmenu a.current:hover div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu a:focus div.wp-menu-image:before, +#adminmenu li.wp-has-current-submenu.opensub div.wp-menu-image:before, +#adminmenu li:hover div.wp-menu-image:before, +#adminmenu li a:focus div.wp-menu-image:before, +#adminmenu li.opensub div.wp-menu-image:before, +.ie8 #adminmenu li.opensub div.wp-menu-image:before { + color: #f2fcff; +} + +.wp-menu-open .wp-submenu { + display: block; +} +.wp-menu-open .wp-submenu li { + padding-left: 30px !important; + color: #1d4899 !important; + font-weight: bold; + border-color: #f0f0f0; + +} + +.wp-submenu { + display: none; +} + +/* Admin Menu: bubble */ +#adminmenu .awaiting-mod, +#adminmenu .update-plugins { + color: #f2fcff; + background: #aa9d88; +} + +#adminmenu li.current a .awaiting-mod, +#adminmenu li a.wp-has-current-submenu .update-plugins, +#adminmenu li:hover a .awaiting-mod, +#adminmenu li.menu-top:hover > a .update-plugins { + #color: #f2fcff; +} + +/* Admin Menu: collapse button */ +#collapse-button { + display: none; + color: #1d4899; + font-weight: bold; + border-radius: 10px; + border-width: 0; + border-color: #f0f0f0; + +} + +#collapse-button:hover, +#collapse-button:focus { + color: rgba(255, 203, 4, 0.45); +} + +/* Admin Bar */ +#wpadminbar { + color: #f2fcff; + background: rgba(29, 72, 153, 0.7); +} + +#wpadminbar .ab-item, +#wpadminbar a.ab-item, +#wpadminbar > #wp-toolbar span.ab-label, +#wpadminbar > #wp-toolbar span.noticon { + color: #f2fcff; +} + +#wpadminbar .ab-icon, +#wpadminbar .ab-icon:before, +#wpadminbar .ab-item:before, +#wpadminbar .ab-item:after { + color: #f1f3f3; +} + +#wpadminbar:not(.mobile) .ab-top-menu > li:hover > .ab-item, +#wpadminbar:not(.mobile) .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojq .quicklinks .ab-top-menu > li > .ab-item:focus, +#wpadminbar.nojs .ab-top-menu > li.menupop:hover > .ab-item, +#wpadminbar .ab-top-menu > li.menupop.hover > .ab-item { + color: #f2fcff; + background: rgba(29, 72, 153, 0.7); +} + +#wpadminbar:not(.mobile) > #wp-toolbar li:hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar li.hover span.ab-label, +#wpadminbar:not(.mobile) > #wp-toolbar a:focus span.ab-label { color: #ffffff; - background-color: #3163bd; - cursor: pointer; - border-radius: 5px; } -.bdp_submit { - background-color: #ffffff; - padding: 5px 25px; - border-style: solid; - border-width: 1px; - border-color: #769be7; - cursor: pointer; - border-radius: 5px; - box-shadow: 2px 2px 2px #d0d0d0; +#wpadminbar:not(.mobile) li:hover .ab-icon:before, +#wpadminbar:not(.mobile) li:hover .ab-item:before, +#wpadminbar:not(.mobile) li:hover .ab-item:after, +#wpadminbar:not(.mobile) li:hover #adminbarsearch:before { + color: #f2fcff; } -#bdp_success { - background-color: #ffffff; - border-color: #c3c4c7; - border-left-color: #00a32a; - padding: 10px 12px; - margin: 5px 0 15px; - border-width: 1px; - border-style: solid; - border-left-width: 4px; - width: 97%; +/* Admin Bar: submenu */ +#wpadminbar .menupop .ab-sub-wrapper { + background: rgba(29, 72, 153, 0.78); +} +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary, +#wpadminbar .quicklinks .menupop ul.ab-sub-secondary .ab-submenu { + background: #8f9a9e; +} + +#wpadminbar .ab-submenu .ab-item, +#wpadminbar .quicklinks .menupop ul li a, +#wpadminbar .quicklinks .menupop.hover ul li a, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a { + color: #ccdbe0; +} + +#wpadminbar .quicklinks li .blavatar, +#wpadminbar .menupop .menupop > .ab-item:before { + color: #f1f3f3; +} + +#wpadminbar .quicklinks .menupop ul li a:hover, +#wpadminbar .quicklinks .menupop ul li a:focus, +#wpadminbar .quicklinks .menupop ul li a:hover strong, +#wpadminbar .quicklinks .menupop ul li a:focus strong, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a, +#wpadminbar .quicklinks .menupop.hover ul li a:hover, +#wpadminbar .quicklinks .menupop.hover ul li a:focus, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:hover, +#wpadminbar.nojs .quicklinks .menupop:hover ul li a:focus, +#wpadminbar li:hover .ab-icon:before, +#wpadminbar li:hover .ab-item:before, +#wpadminbar li a:focus .ab-icon:before, +#wpadminbar li .ab-item:focus:before, +#wpadminbar li .ab-item:focus .ab-icon:before, +#wpadminbar li.hover .ab-icon:before, +#wpadminbar li.hover .ab-item:before, +#wpadminbar li:hover #adminbarsearch:before, +#wpadminbar li #adminbarsearch.adminbar-focused:before { + color: #ffffff; +} + +#wpadminbar .quicklinks li a:hover .blavatar, +#wpadminbar .quicklinks li a:focus .blavatar, +#wpadminbar .quicklinks .ab-sub-wrapper .menupop.hover > a .blavatar, +#wpadminbar .menupop .menupop > .ab-item:hover:before, +#wpadminbar.mobile .quicklinks .ab-icon:before, +#wpadminbar.mobile .quicklinks .ab-item:before { + color: #ffffff; +} + +#wpadminbar.mobile .quicklinks .hover .ab-icon:before, +#wpadminbar.mobile .quicklinks .hover .ab-item:before { + color: #f1f3f3; +} + +/* Admin Bar: search */ +#wpadminbar #adminbarsearch:before { + color: #f1f3f3; +} + +.button { + background: rgba(29, 72, 153, 0.62) !important; + color: #ffffff !important; + border-color: #071e4d; + box-shadow: 5px 5px 10px #d0d0d0; +} + + +.bdp_setting_box { + width: 100%; + background-color: #ffffff; + padding: 15px; + border-style: solid; + border-width: 1px; + border-top-width: 0 !important; + border-color: #1d94cf; +} + +.bdp_setting_box:first-of-type { + border-top-width: 1px !important; +} + +.bdp_setting_box label { + cursor: pointer; +} + +.bdp_setting_box label span { + cursor: pointer; + width: 10pt; + color: #a0a0a0; } \ No newline at end of file diff --git a/bdp-kompass.php b/bdp-kompass.php index 8a91410..c8e6daf 100644 --- a/bdp-kompass.php +++ b/bdp-kompass.php @@ -2,48 +2,45 @@ /** * Plugin Name: BdP Kompass * Description: Wordpress-Plugin zur Unterstützung von Stämmen im Bund der Pfadfinderinnen und Pfadfinder e.V. zur optimalen Verwaltung eurer Webseite - * Version: 4.1.1 + * Version: 4.2.1 * Tags: bdp, utility, helper * Requires at least: 6.0 * Requires PHP: 8.2 * Author: Thomas Günther * Author URI: https://www.sachsen.pfadfinden.de - * Update URI: https://lv-sachsen-main.bdp.mein-verein.online/wordpress/ + * Update URI: http://lv-sachsen-main.bdp.mein-verein.online/wordpress/ * Text Domain: bdp-kompass */ +use Bdp\Modules\LimitLoginAttempts\Controllers\OptionsPage as OptionsPageAlias; use Bdp\Modules\Security\Security; use Bdp\Modules\Seo\Seo; - -define('BDP_LV_PLUGIN_DIR', ABSPATH . '/wp-content/plugins/bdp-kompass/'); -define('BDP_LV_PLUGIN_URL', plugin_dir_url(__FILE__)); -define('BDP_LV_PLUGIN_SLUG', 'bdp-kompass'); - -require_once BDP_LV_PLUGIN_DIR . 'core/fileloader.php'; - - -bdp_create_menu_structure(); +require_once dirname(__FILE__) . '/includes/setup.php'; function bdp_plugin_install() { - Seo::setup(); - Calendar::setup(); - Security::setup(); - update_option('kompass_installation', true); -} -function bdp_plugin_init() -{ - remove_menu_page('admin.php?page=limit-login-attempts&tab=dashboard'); - if (get_option('kompass_installation') == true) { - delete_option('kompass_installation'); - wp_redirect('admin.php?page=bdp-kompass%2Fmodules%2Findex.php&loadmodule=firstusage'); - } } -register_activation_hook(__FILE__, 'bdp_plugin_install'); -add_action('init', 'bdp_plugin_init'); +function bdp_plugin_init() { + Security::ProhibitBots(); + Security::SetPageFilters(); + + if (null == get_option('kompass_already_installed', null)) { + Seo::setup(); + Calendar::setup(); + Security::setup(); + update_option('kompass_already_installed', true); + wp_redirect( 'site-health.php?tab=bdp_enhanced_security'); + } + +} + +add_action('admin_menu', function () { + new OptionsPageAlias(); +}); + function register_custom_theme_directory() { $file = ABSPATH . '/wp-content/plugins/bdp-kompass/buena/' ; @@ -54,149 +51,12 @@ function register_custom_theme_directory() { switch_theme('buena'); } -#add_action( 'after_setup_theme', 'register_custom_theme_directory' ); - -class BdpVersionChecker -{ - public $plugin_slug; - public $version; - public $cache_key; - public $cache_allowed; - public $updateUrl; - - public function __construct() - { - $plugin_data = get_plugin_data(__FILE__); - $this->plugin_slug = 'bdp-kompass'; - $this->updateUrl = $plugin_data['UpdateURI'] . '/info.json'; - $this->version = $plugin_data['Version']; - $this->cache_key = 'bdp_kompass_upd'; - $this->cache_allowed = true; - - add_filter('plugins_api', array($this, 'info'), 20, 3); - add_filter('site_transient_update_plugins', array($this, 'update')); - add_action('upgrader_process_complete', array($this, 'purge'), 10, 2); - } - - public function request() - { - $remote = get_transient($this->cache_key); - - if (false === $remote || !$this->cache_allowed) { - - $remote = wp_remote_get( - $this->updateUrl - , - array( - 'timeout' => 10, - 'headers' => array( - 'Accept' => 'application/json' - ) - ) - ); - - if ( - is_wp_error($remote) - || 200 !== wp_remote_retrieve_response_code($remote) - || empty(wp_remote_retrieve_body($remote)) - ) { - return false; - } - - set_transient($this->cache_key, $remote, 3600); - } - - $remote = json_decode(wp_remote_retrieve_body($remote)); - return $remote; - - } - - - function info($res = '', $action = '', $args = '') - { - if (!isset($args->slug) || $args->slug !== $this->plugin_slug) { - return $res; - } - - // get updates - $remote = $this->request(); - if (!$remote) { - return $res; - } - - $res = new stdClass(); - - $res->name = $remote->name; - $res->slug = $remote->slug; - $res->version = $remote->version; - $res->tested = $remote->tested; - $res->requires = $remote->requires; - $res->author = $remote->author; - $res->author_profile = $remote->author_profile; - $res->download_link = $remote->download_url; - $res->trunk = $remote->download_url; - $res->requires_php = $remote->requires_php; - $res->last_updated = $remote->last_updated; - - $res->sections = array( - 'description' => $remote->sections->description, - 'installation' => $remote->sections->installation, - 'changelog' => $remote->sections->changelog - ); - - if (!empty($remote->banners)) { - $res->banners = array( - 'low' => $remote->banners->low, - 'high' => $remote->banners->high - ); - } - - return $res; - } - - public function update($transient) - { - if (empty($transient->checked)) { - return $transient; - } - - $remote = $this->request(); - if( - $remote - && version_compare( $this->version, $remote->version, '<' ) - && version_compare( $remote->requires, get_bloginfo( 'version' ), '<=' ) - && version_compare( $remote->requires_php, PHP_VERSION, '<' ) - ) { - $res = new stdClass(); - $res->slug = $this->plugin_slug; - $res->plugin = plugin_basename( __FILE__ ); - $res->new_version = $remote->version; - $res->tested = $remote->tested; - $res->package = $remote->download_url; - - $transient->response[ $res->plugin ] = $res; - - } else { - $res = new stdClass(); - $res->slug = $this->plugin_slug; - $res->plugin = plugin_basename( __FILE__ ); - $transient->no_update[ $res->plugin ] = $res; - } - - return $transient; - } - - public function purge($upgrader, $options) - { - if ( - $this->cache_allowed - && 'update' === $options['action'] - && 'plugin' === $options['type'] - ) { - delete_transient($this->cache_key); - } - } +function enqueue_custom_password_js() { + wp_enqueue_script( 'custom-password-js', BDP_LV_PLUGIN_URL . 'assets/password.js'); + wp_localize_script( 'custom-password-js', 'php_vars', [ + 'allowed_strengths' => kompass_get_minimal_password_strength(), + 'password_too_short_text' => 'Dass Passwort entspricht nicht den Anforderungen.' + ]); } -$class = new BdpVersionChecker(); -add_filter( 'plugins_api', array( $class, 'info' ), 20, 3 ); +#add_action( 'after_setup_theme', 'register_custom_theme_directory' ); diff --git a/buena/404.php b/buena/404.php deleted file mode 100644 index 543055f..0000000 --- a/buena/404.php +++ /dev/null @@ -1,96 +0,0 @@ - - - - -> - - - - - - - - - - - -> -
- -
- 'primary', 'depth' => 2, 'container' => 'nav', 'container_class' => 'nav-menu' ] ); ?> - - - -
-
- - - '' ] ); ?> - - - -
-

-
- - - -
-

-
- -
-
-
- - - - - -
- -
- -
- - -
-
- - - - - - diff --git a/buena/comments.php b/buena/comments.php deleted file mode 100644 index 3669590..0000000 --- a/buena/comments.php +++ /dev/null @@ -1,27 +0,0 @@ -%s

', __( 'Kommentare werden erst angezeigt, wenn das Kennwort eingegeben wurde.', 'buena-theme' ) ); - return; -} - -// FIXME: Hier sollten die Social-Media-Knöpfe auftauchen… - -?> -
- -

- - - - - - -

- -
diff --git a/buena/content.php b/buena/content.php deleted file mode 100644 index 54689ca..0000000 --- a/buena/content.php +++ /dev/null @@ -1,17 +0,0 @@ -
> - - -

- '' ) ); ?> - - - '' ] ); ?> - -
-

-
- -
- - -
diff --git a/buena/functions.php b/buena/functions.php deleted file mode 100644 index ac7df51..0000000 --- a/buena/functions.php +++ /dev/null @@ -1,89 +0,0 @@ -= 50400 ) { - // Register autoloader if updater plugin missing - if ( ! class_exists( 'plugins\buena\use\shy-wordpress\src\Shy\WordPress\Theme' ) ) { - if ( ! include_once __DIR__ . '/use/shy-wordpress/src/autoloader.php' ) { - trigger_pfadfinden_plugin_error( - __( 'Das Theme ist unvollständig und konnte nicht geladen werden. Neuinstallation müsste helfen.', 'buena-theme' ), - E_USER_ERROR - ); - return; - } - } - - // Register our autoloader - if ( ! include_once __DIR__ . '/src/autoloader.php' ) { - trigger_pfadfinden_plugin_error( - __( 'Das Theme ist unvollständig und konnte nicht geladen werden. Neuinstallation müsste helfen.', 'buena-theme' ), - E_USER_ERROR - ); - return; - } - - /** - * @return \plugins\buena\src\Pfadfinden\WordPress\BuenaTheme - */ - function buena_get_theme() - { - static $theme = null; - if (!$theme) { - $theme = new ReflectionClass( 'plugins\buena\src\Pfadfinden\WordPress\BuenaTheme' ); - $theme = $theme->newInstance(); - } - - return $theme; - } - - /** - * @param string $method - * @return callable - */ - function buena_get_callback( $method ) - { - return array( buena_get_theme(), (string) $method ); - } - - return buena_get_theme(); -} - - -// Display error message -trigger_pfadfinden_plugin_error( - sprintf( - __( 'You need at least PHP 5.4 to use the Buena theme. Your are using %s.', 'buena-theme' ), - PHP_VERSION - ), - E_USER_ERROR -); diff --git a/buena/index.php b/buena/index.php deleted file mode 100644 index c823787..0000000 --- a/buena/index.php +++ /dev/null @@ -1,106 +0,0 @@ - - - - -> - - - - - - - - - - - - - -> -
- -
- 'primary', 'depth' => 2, 'container' => 'nav', 'container_class' => 'nav-menu nav-menu-primary' ] ); ?> - - - -
- getTeaserImage() ): ?> -
- -
-

printTitle(); ?>

-
-
- -
-

printTitle(); ?>

-
- -
-
- - - - - -
- -
- -
- - -
-
- - - - - diff --git a/buena/searchform.php b/buena/searchform.php deleted file mode 100644 index 16ba18d..0000000 --- a/buena/searchform.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/buena/src/autoloader.php b/buena/src/autoloader.php deleted file mode 100644 index d09cc39..0000000 --- a/buena/src/autoloader.php +++ /dev/null @@ -1,19 +0,0 @@ -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 ) ); - } -} diff --git a/buena/use/shy-wordpress/src/Shy/WordPress/HookableTrait.php b/buena/use/shy-wordpress/src/Shy/WordPress/HookableTrait.php deleted file mode 100644 index e6adc43..0000000 --- a/buena/use/shy-wordpress/src/Shy/WordPress/HookableTrait.php +++ /dev/null @@ -1,35 +0,0 @@ -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' ); - } - - public function __toString() - { - return $this->slug; - } - - /** - * 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 - */ - 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 - */ - 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 ''; - } - - /** - * Output an input tag with given HTML attributes. - * - * @param array $attr - */ - protected function renderInputTag( array $attr ) - { - echo ' $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.' ) ); - } - - ?> -
-

getPageTitle() ); ?>

-
- - slug ); ?> - slug ); ?> - -
-
- getContentWidth(); - } - - /** - * @return integer - */ - abstract public function getContentWidth(); -} diff --git a/buena/use/shy-wordpress/src/autoloader.php b/buena/use/shy-wordpress/src/autoloader.php deleted file mode 100644 index 00744fb..0000000 --- a/buena/use/shy-wordpress/src/autoloader.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -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.' ); - } -} diff --git a/buena/use/shy-wordpress/tests/Shy/WordPress/Tests/SettingsPageTest.php b/buena/use/shy-wordpress/tests/Shy/WordPress/Tests/SettingsPageTest.php deleted file mode 100644 index 12459f6..0000000 --- a/buena/use/shy-wordpress/tests/Shy/WordPress/Tests/SettingsPageTest.php +++ /dev/null @@ -1,181 +0,0 @@ -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->method( 'getMenuTitle' )->willReturn( '' ); - - $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( '/^mockSettingsPage(); - $page->renderTextField( array( - 'label_for' => 'foo', - 'name' => 'bar', - ) ); - } - - public function testRenderCheckboxField() - { - $this->expectOutputRegex( '/^