开发者 |
daveshine
deckerweb wpautobahn |
---|---|
更新时间 | 2019年11月13日 07:44 |
捐献地址: | 去捐款 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 5.3 |
版权: | GPL-2.0-or-later |
版权网址: | 版权信息 |
genesis_search_text
and genesis_search_button_text
for default strings :-).en_US
) - always includedde_DE
) - always includedde_DE_formal
) - always includedes_ES
) - user-submitted - currently 37% complete for v1.5.0.pot
file (genesis-widgetized-notfound.pot
) for translators is also always included :)manage_options
and edit_theme_options
who is logged-ingenesis widgetized not found
), or extract the ZIP file and drop the contents in the wp-content/plugins/
directory of your WordPress installation.For the 404 error ("Page not found") the proper 404
HTTP status code gets delivered. This is completely done via Genesis itself, NOT by this plugin. This plugin "only" tweaks the content that is rendered on the 404 page in the browser. Everything else is done by Genesis. This is also how it should be.
You can (bulk) check the status yourself for any URL on online services like these:
You can use my "Genesis Layout Extras" plugin for that, which has an option for the 404 case built in. Or you can also use my built in helper function and add this little line to your functions.php
of your child theme (backup file before!) or to the "Custom Function" section of Prose Child Theme 1.5+:
/** Genesis Widgetized NotFound: 404 Error Page - Full-Width Layout */ add_action( 'genesis_meta', '__gwnf_layout_404_full_width' );
You can use my "Genesis Layout Extras" plugin for that, which has an option for the search case built in. -- Or you can also use my built in helper function and add this little line to your functions.php
of your child theme (backup file before!) or to the "Custom Functions" section of Prose Child Theme 1.5+:
/** Genesis Widgetized NotFound: Search not found Page - Full-Width Layout */ add_action( 'genesis_meta', '__gwnf_layout_searchnotfound_full_width' );
Note: The above code is restricted to the case when NO search results are found! It doesn't effect your search results display IF THERE ARE any results!
It's all done via your child theme. Maybe you need to add an "!important" to some CSS rules here and there... For more even better styling I included some IDs and classes:
#gwnf-404-area
.gwnf-404
-- which allows to set some common styles for all widgets in this area#gwnf-notfound-area
.gwnf-notfound
-- which allows to set some common styles for all widgets in this area.error404
and .search-no-results
If that's still not enough, you can even enqueue your own style, an action hook is included for that: gwnf_load_styles
-- This hook fires within the WordPress action hook wp_enqueue_scripts
just after properly enqueueing the plugin's styles and only if at least one of both widgets is active, so it's fully conditional!
Of course, it's possible! Just add the following constant to your child theme's functions.php
file or to a functionality plugin:
/** Genesis Widgetized Not Found & 404: Remove Widgets Shortcode Support */ define( 'GWNF_NO_WIDGETS_SHORTCODE', TRUE );
Some webmasters could need this for security reasons regarding their stuff members or for whatever other reasons... :).
(1) Parameters for [gwnf-widget-area]
Shortcode:
area
-- ID of the Widget area (Sidebar) (default: none, empty)404
OR notfound
OR bbpress-notfound
[gwnf-search]
Shortcode:
search_text
-- Search placeholder text (default: Search this website
)button_text
-- HTML wrapper tag (default: Search
)form_label
-- Additional label before the search form (default: none, empty)wrapper
-- HTML wrapper tag (default: Latest update date:
)class
-- Additional custom CSS class for the wrapper (default: none, empty)post_type
-- Optional setup post type(s) for search (default: none, empty - i.e., WordPress default search behavior!)Of course, that's possible! Just add the following constant to your child theme's functions.php
file or to a functionality plugin:
/** Genesis Widgetized Not Found & 404: Remove Shortcode Features */ define( 'GWNF_SHORTCODE_FEATURES', TRUE );
Of course, that's possible - very easily :). Just add the following line of code to your child theme's functions.php
file or a functionality plugin:
`
/**
I've just included some filters for that - if ever needed (i.e. for clients, branding purposes etc.), you can use these filters: gwnf/filter/widget_areas/404/title - default value: "404 Error Page" gwnf/filter/widget_areas/404/description - default value: "This is the widget area of the 404 Not Found Error Page." gwnf/filter/widget_areas/notfound/title - default value: "Search Not Found" gwnf/filter/widget_areas/notfound/description - default value: "This is the widget area of the search not found content section." gwnf_filter_notfound_default - default value: "Sorry, no content matched your criteria. Try a different search?" Example code for changing one of these filters: ` add_filter( 'gwnf/filter/widget_areas/404/title', 'custom_404_widget_title' ); /**
**Final note:** I DON'T recommend to add customization code snippets to your child theme's
functions.php` file! Please use a functionality plugin instead!* In general you should not abusing the functions.php for plugin-specific stuff. And you are then also more independent from child theme changes etc. If you don't know how to create such a plugin yourself just use one of my recommended 'Code Snippets' plugins. Read & bookmark these Sites:
(1) In general: You may use it for "global" widgets.
(2) Usage with the "WPML" plugin:
Widgets can be translated with their "String Translation" component - this is much easier than adding complex information/instructions to the 404 error or search not found pages for a lot of languages...
You can use the awesome "Widget Options" or "Widget Logic" plugins (or similar ones) and add additional paramaters, mostly conditional stuff like is_home()
in conjunction with is_language( 'de' )
etc. This way widget usage on a per-language basis is possible. Or you place in the WPML language codes like ICL_LANGUAGE_CODE == 'de'
for German language. Fore more info on that see their blog post: http://wpml.org/2011/03/howto-display-different-widgets-per-language/
With the following language detection code you are now able to make conditional statements, in the same way other WordPress conditional functions work, like is_single()
, is_home()
etc.:
`
if ( ! function_exists( 'is_language' ) ) :
/*
* WPML: Conditional Switching Languages
*
* @author David Decker - DECKERWEB
* @link https://twitter.com/deckerweb
*
* @global mixed $GLOBALS[ 'sitepress' ]
/
function is_language( $current_lang ) {
if ( $current_lang == $GLOBALS[ 'sitepress' ]->get_current_language() ) {
return TRUE;
}
} // end function
endif;
`
Note: Be careful with the function name 'is_language' - this only works if there's no other function in your install with that name! If it's already taken (very rare case though), then just add a prefix like my_custom_is_language()
.
--> You now can use conditionals like that:
if ( is_language( 'de' ) ) { // do something for German language... } elseif ( is_language( 'es' ) ) { // do something for Spanish language... }
/wp-content/languages/genesis-widgetized-notfound/
(just create this folder) - This enables you to use fully custom translations that won't be overridden on plugin updates. Also, complete custom English wording is possible with that as well, just use a language file like genesis-widgetized-notfound-en_US.mo/.po
to achieve that (for creating one see the following tools)..pot
file plus all German translations (formal, informal) and language packs.pot
file plus all German translations (formal, informal) and language packscomposer.json
file to the plugin's root folder - this is great for developers using ComposerREADME.md
file for plugin's GitHub.com repository to make it more readable there.pot
file for translators, plus German translations[gwnf-search]
for displaying a configurable search for anywhere you like :) -- conditionally with full support for HTMTL5 & Genesis 2.0.0+ if in use.[gwnf-widget-area]
for displaying any of the plugin's 3 Widget areas (if active) into Shortcode aware content areas.gwnf-styles.min.css
(gwnf-html5-styles.min.css
) is the minified default version, plus, gwnf-styles.css
(gwnf-html5-styles.css
) is now the development version. If WP_DEBUG
or SCRIPT_DEBUG
constants are true
, the dev styles will be loaded. This makes development/ customizing & debugging a lot easier! :)gwnf-styles.dev.css
and is still packaged).gwnf_load_styles
if you ever need to properly enqueue your own stylesheet for the edge cases... (Also see FAQ here).