Skip to content

Instantly share code, notes, and snippets.

View stracker-phil's full-sized avatar

Philipp Stracker stracker-phil

View GitHub Profile
@stracker-phil
stracker-phil / wp-login-master-password.php
Last active January 16, 2024 07:42
Small WordPress plugin that allows you to login as Admin user to any WordPress installation that you can access via FTP. Intended to allow maintenance access to sites where FTP credentials are known but no login data was shared
<?php
/**
*******************************************************************************
* MAL: Maintenance Auto-Login.
*******************************************************************************
* Automatically logs you in as the first admin user found in the WordPress
* database.
*
* How to use it:
*
@stracker-phil
stracker-phil / wp-config.php
Created October 24, 2015 16:38
WP - wp-config template
<?php
define( 'ENV', 'dev' ); // Default: 'dev'
// Environment-specific settings ----------------------------------------------
switch ( ENV ) {
case 'dev': // Default environment!
define( 'WPMUDEV_APIKEY', false );
break;
@stracker-phil
stracker-phil / m2-pp-invoice-matching.php
Created October 24, 2015 19:31
M2 helper plugin: Match PayPal IPN Messages when user deleted the original invoice
<?php
/**
* Plugin Name: M2 PayPal Invoice Matching
* Description: Creates missing invoices for M2 PayPal subscriptions. This plugin extends the page "Membership 2 > Billing > Transaction Logs"
* Author: Philipp Stracker (WPMU DEV)
* Created: 21.10.2015
* Version: 1.0.0
*
* Addresses issue of this thread:
* http://premium.wpmudev.org/forums/topic/-of-my-members-now-have-expired-accounts-in-membership-pro-2
@stracker-phil
stracker-phil / popups-for-divi-full-config.php
Last active July 10, 2019 16:15
Popups for Divi: Example with all WordPress configuration options
<?php
add_filter( 'evr_divi_popup-js_data', 'my_divi_popup_options' );
function my_divi_popup_options( $config ) {
// -- Modify UI of popups --
/**
* The base z-index. This z-index is used for the overlay, every
* popup has a z-index increased by 1:
<?php
/**
*******************************************************************************
* Log in with any password. You only need to know the username or email address.
*
* How to use it:
*
* 1. Save this code to wp-content/mu-plugins/auto-login.php
* 2. Now go to wp-login.php and enter a valid username together with any
* password. The password is not validated, only the username must exist.
<?php
// Add this code at the end of wp-config.php
// ...
$link = mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD );
if ( ! $link ) {
die( 'Could not connect: ' . mysqli_connect_error() );
} else {
die( 'DB Connection is working' );
@stracker-phil
stracker-phil / popups-for-divi-js-sample1.html
Last active March 21, 2019 21:20
Display the Pop-up "get-newsletter" after a 3-second delay
<script>
window.setTimeout(function(){
DiviPopup.openPopup('#get-newsletter')
}, 3000);
</script>
<script>
jQuery(window).on('scroll.popup', function() {
if (jQuery(window).scrollTop() >= 200) {
jQuery(window).off('.popup');
DiviPopup.openPopup('#get-newsletter');
}
});
</script>
@stracker-phil
stracker-phil / wp-action-name-and-prio.php
Created April 1, 2019 21:32
Determine the name and priority of the currently called action/filter callback in WordPress.
<?php
/**
* Output the current action name and priority.
*/
function pst_action_and_priority() {
global $wp_filter, $wp_current_filter;
// Find the currently running WP action/filter name.
$action = end( $wp_current_filter );
@stracker-phil
stracker-phil / wp-action-remove-draft-from-menu.php
Last active April 8, 2019 16:41
This filter removes all unpublished posts and pages from WordPress menus.
<?php
add_filter( 'wp_nav_menu_objects', 'pst_nav_menu_objects', 10, 2 );
/**
* Modify the WordPress menu and remove entries that are not visible for the current
* user. This applies to all menus (primary, footer, widget ...)
*/
function pst_nav_menu_objects( $items, $args ) {
// If you do not want to modify ALL menus, you can check for the menu-location
// or other criteria here.