Skip to content

Instantly share code, notes, and snippets.

@eyecandy91
eyecandy91 / gist:748dc33838f3e58126372f76afd24f85
Created March 24, 2020 21:20
CSS break long string into own lines
width: min-intrinsic;
width: -webkit-min-content;
width: -moz-min-content;
width: min-content;
display: table-caption;
display: -ms-grid;
-ms-grid-columns: min-content;
@eyecandy91
eyecandy91 / basic-dropdown-usage.php
Created December 12, 2019 05:31 — forked from joshuadavidnelson/basic-dropdown-usage.php
Filter wp_dropdown_categories by post type.
<?php
/**
* Using wp_dropdown_categories with the post type filter applied.
*
* @link https://joshuadnelson.com/category-taxonomy-dropdown-filtered-by-post-type/
*/
// Taxonomy dropdown arguments
$args = array(
'taxonomy' => 'department',
@eyecandy91
eyecandy91 / gist:802290a454ef3751d8eb62a897d43c91
Created October 2, 2019 14:24
remove all special characters from php string
$string = preg_replace('/[^a-zA-Z0-9_ -]/s','',$term->name); //$term->name change what string you need to change
@eyecandy91
eyecandy91 / bootstrap walker
Created September 4, 2019 13:59
bootstrap walker wp
<?php /* menu */
wp_nav_menu( array(
'menu' => 'menu-1',
'theme_location' => 'menu-1',
'depth' => 5,
'container' => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse ',
'menu_class' => 'nav navbar-nav ',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
@eyecandy91
eyecandy91 / add new class to wp nav menu
Last active September 4, 2019 07:20
add new class to wp nav menu
<?php
echo str_replace( '<li class="', '<li class="myclass ',
wp_nav_menu(
array(
'theme_location' => 'menu-1',
'container' => 'ul',
'menu_class' => 'nav nav-pills justify-content-center d-flex align-items-center justify-content-between',
'echo' => false
)
@eyecandy91
eyecandy91 / dashboard-activity-cpt.php
Created July 18, 2019 03:56 — forked from Mte90/dashboard-activity-cpt.php
Add your cpts to the Widget Activity of the Dashboard in WordPress
<?php
/*
Plugin Name: Dashboard Widget Activity Custom Post Type
Plugin URI:
Description:
Author: Daniele Mte90 Scasciafratte
Version: 1.0.0
Author URI: http://mte90.net
*/
@eyecandy91
eyecandy91 / gist:ab7aefe7ce82429fdaa72f1951a4c3be
Created July 16, 2019 12:55
Edit login and user messages
function forgotpass_message() {
$action = $_REQUEST['action'];
if( $action == 'lostpassword' ) {
$message = '<p class="message">Please enter your email address. Then check your email inbox for instructions to reset your password.</p>';
return $message;
}
}
add_filter('login_message', 'forgotpass_message');
The url on the forgot password page includes the query string “action=lostpassword” so that’s what I’m checking for with my $_REQUEST call. If we’re on the forgot password page, then make a new message and return it.
@eyecandy91
eyecandy91 / gist:b0d2b32137dc227287fd54fc9380a6b7
Created July 16, 2019 07:37
wp skip email address reset password unique link
$user = new WP_User( (int) $user_id );
$adt_rp_key = get_password_reset_key( $user );
$user_login = $user->user_login;
$rp_link = '<a href="' . network_site_url("wp-login.php?action=rp&key=$adt_rp_key&login=" . rawurlencode($user_login), 'login') . '">' . network_site_url("wp-login.php?action=rp&key=$adt_rp_key&login=" . rawurlencode($user_login), 'login') . '</a>';
?>
<div id="signup-welcome">
<p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
<p>To set your password, select the following link: <?php echo $rp_link; ?></p>
</div>
@eyecandy91
eyecandy91 / gist:53ecb48d918019ebe45667dc15c3edb6
Created July 16, 2019 07:34
change reset password button text
add_action( 'resetpass_form', 'resettext');
function resettext(){ ?>
<script type="text/javascript">
jQuery( document ).ready(function() {
jQuery('#resetpassform input#wp-submit').val("Set Password");
});
</script>
<?php
}
@eyecandy91
eyecandy91 / gist:dd09d2d3a98fc34513c252d354fa2e61
Created July 16, 2019 07:16
redirect back to home for user
function admin_login_redirect( $redirect_to, $request, $user ) {
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( "administrator", $user->roles ) ) {
return $redirect_to;
}
else {
return home_url('/portal');
}