Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
SiGaCode / genesis_menus_labels
Created June 7, 2014 14:46
Shows a chosen menu only on pages with a certain label:
//* Remove the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action('genesis_meta','dynamik_show_primary_navigation');
function dynamik_show_primary_navigation() {
if ( dynamik_has_label('show-primary-navigation') ) {
add_action( 'genesis_header_right', 'genesis_do_nav' );
}
}
/* nav current item highlight - children */
.genesis-nav-menu li.current-menu-ancestor a {
background: #98B33E;
}
@SiGaCode
SiGaCode / ez-rows-kirki.php
Created June 20, 2014 11:07
Wrap each EZ home row in a separate div so they can get a full-width background color/image. The divs are injected via JS (jQuery). They will be applied only if the related row exists. The classes can be changed to whatever you want. Goes to Dynamik Custom - JS.
//* Goes to Dynamik Custom - Functions. Only if you want to use Kirki, else you won´t need it
//* Kirki Customizer configuration
add_filter( 'kirki/config', 'jr_kirki_config' );
function jr_kirki_config() {
if ( class_exists('Kirki') && is_front_page() ) {
$args = array( 'stylesheet_id' => 'dynamik_minified_stylesheet', );
@SiGaCode
SiGaCode / responsive_iframe.css
Created June 26, 2014 17:35
Responsive iframes and maps with just CSS
/* Responsive iFrame */
.responsive-iframe-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
@SiGaCode
SiGaCode / raw-html.php
Created November 21, 2014 17:53
Stop Wordpress editor from stripping your HTML when switching between Visual and text editor or while saving. Be sure to test and keep an eye on conflicts with plugins! https://ikreativ.com/stop-wordpress-removing-html/
// stop wp removing div tags - goes to Functions
function ikreativ_tinymce_fix( $init )
{
// html elements being stripped
$init['extended_valid_elements'] = 'div[*],article[*]';
// don't remove line breaks
$init['remove_linebreaks'] = false;
@SiGaCode
SiGaCode / widget_aware_widget_areas.php
Last active August 29, 2015 14:12
Here is an example of widget areas that know how many widgets are in them. For example, if you put two widgets in the widget area they each get a width of half. Credits: Junior Atoms / Larry http://cobaltapps.com/forum/forum/dynamik-skin-forums/tools-tips-other-skin-resources-aa/45619-widget-aware-widget-areas
//* Count the number of widgets in a widget-area
function dynamik_count_sidebar_widgets( $sidebar_id ) {
$the_widgets = wp_get_sidebars_widgets();
if( isset( $the_widgets[$sidebar_id] ) ) {
return count( $the_widgets[$sidebar_id] );
}
}
@SiGaCode
SiGaCode / no_comments_for_media.php
Last active August 29, 2015 14:12
This snippet comes in handy if you want to disable comments on attachment pages, got lots of media already and don´t want to go through each single one (no bulk edit here unfortunately). Credits: http://premium.wpmudev.org/blog/wordpress-comments-off/ Goes to Dynamik Custom - Functions
//* Don´t allow any comments on media attachment pages
function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );
@SiGaCode
SiGaCode / concise-meta-styles.css
Last active August 29, 2015 14:12
The Concise Child Theme has nice post info/meta. http://wpspeak.com/introducing-concise-theme/ Here is how to adapt it's layout to Dynamik! Credits to Junioratoms/Larry: http://cobaltapps.com/forum/forum/dynamik-skin-forums/tools-tips-other-skin-resources-aa/47008-fun-with-meta
/* Goes to Dynamik Custom - CSS */
/* Entry Header */
.entry-header.one-third,
.entry-content.two-thirds {
padding-bottom: 0;
}
p.entry-meta {
padding-top: 15px;
@SiGaCode
SiGaCode / custom-code-highlight.php
Last active August 29, 2015 14:13
Turn the "Custom Code" buttoms in Dynamik Design area light green when in use (visually highlight them to signalize "there´s code in there"). Goes to Dynamik Custom - Functions. Credits: Junior Atoms / Larry: http://cobaltapps.com/forum/forum/main-category/feedback-suggestions/47450-more-dwb-in-2015
//* Turn Custom Code buttons in Design area colored when code in use
add_action('admin_head', 'admin_css');
function admin_css() {
echo '<style> .wp-core-ui .button.custom-hilight { background: #EDFFAF; box-shadow: none; } </style>';
}
@SiGaCode
SiGaCode / remove-html-comments-extended.php
Last active August 29, 2015 14:13
Remove allowed HTML tags from the comments. Goes to Dynamik Custom - Functions
function remove_comment_form_allowed_tags() {
add_filter('comment_form_defaults','wordpress_comment_form_defaults');
}
add_action('after_setup_theme','remove_comment_form_allowed_tags');
/**
* @author Brad Dalton - WP Sites
* @learn more http://wp.me/p1lTu0-9Yd
*/
function wordpress_comment_form_defaults($default) {
unset($default['comment_notes_after']);