View WPConfig
define('td', get_bloginfo('template_directory').'/' );
define('hd', esc_url(home_url( '/' )));
//WPconfig
$path = '/path';
define( 'WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . $path );
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . $path );
define( 'AUTOSAVE_INTERVAL', 3600 );
define( 'WP_POST_REVISIONS', 3 );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
View WP Breadcrumbs
//FOR POST
$t = wp_get_post_terms(get_the_id(),'taxonomy');
$t[0] = ($t[0]->parent && !$t[1]->parent) ? $t[0] : $t[1];
if($t[0]->parent)
{ $p = get_term_by('id',$t[0]->parent,'taxonomy');
echo '<a href="'.get_term_link($t[0]->parent,'taxonomy').'">'.$p->name.'</a> &raquo; '; }
echo '<a href="'.get_term_link($t[0]->term_id,'taxonomy').'" class="crumb-current">'.$t[0]->name.'</a>';
//FOR ARCHIVE
$t = get_term_by('id',$wp_query->queried_object_id,'taxonomy');
View delete_posts.sql
DELETE a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( c.post_id = a.ID )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE a.post_type = 'post' AND a.post_date > timestampadd(day, -1, now())
DELETE FROM wp_posts WHERE post_type = 'attachment' AND post_date > timestampadd(day, -1, now())
View plugin.php
add_filter('site_transient_update_plugins', 'remove_update_notification');
function remove_update_notification($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}
View Scroll to element on load
if(location.hash){
var e = document.getElementById(location.hash.substr(1));
e.scrollIntoView();
}
//Fix on scroll
var wrap = $("#wrapper-navbar .navbar");
$(document).scroll(function(e) {
if ($(this).scrollTop() > 247)
View gist:6123563
find . -name '*.php' -exec grep -Hn 'SEARCHSTRING' '{}' \
grep --include=\*.{php,php6} -rnw './' -ie "SEARCH"
View click loop
var inputs = document.querySelectorAll('a._42ft._4jy0._4jy3._517h');
for(var i=1; i<inputs.length;i++) {
var str =inputs[i].text, str2 ='Invite';
if(str.indexOf(str2) >= 0){inputs[i].click(); console.log('|');} }
View WP add custom profile field
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
add_action( 'user_new_form', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<table class="form-table">
View Unix commands
rename s/"SEARCH"/"REPLACE"/g *
//Replace Text
replace "old_string" "new_string" -- *.php
//Replace with regex
sed -i -- "s/<text .*svg>/<svg>/g" **.svg
//Find text in files
grep --include=\*.{php,php5} -rnw './' -e "NEEDLE"
View Center hero image
.hero{
height:200px;
overflow:hidden;
display:flex;
align-items:center;
justify-content:center
}
.hero div{
min-width:100%; display:flex;