Skip to content

Instantly share code, notes, and snippets.

@ingozoell
ingozoell / remove_nbsp_table_td.js
Created October 11, 2017 07:08
Remove " " table td
$("table").find("td").each(function() {
var $this = $(this);
$this.html($this.html().replace(/ /g, ''));
});
function the_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join("|",array("iz_mehr","iz_col", "text_platzhalter"));
// opening tag
$rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);
// closing tag
$rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);
return $rep;
}
@ingozoell
ingozoell / wp_last_login_time_user.php
Last active September 17, 2017 14:40
WordPress – How to get last login time in wordpress https://holisticwp.com/blog/capture-user-last-login-time/
/**
* How to get last login time in wordpress
* https://holisticwp.com/blog/capture-user-last-login-time/705
*
*/
add_action('wp_login','wpdb_capture_user_last_login', 10, 2);
function wpdb_capture_user_last_login($user_login, $user){
update_user_meta($user->ID, 'last_login', current_time('mysql'));
}
@ingozoell
ingozoell / wp_favicon_admin.php
Created August 24, 2017 08:21
WordPress Favicon Admin
/*
* Adding Favicons to the WordPress Admin & Login Pages
* http://clarknikdelpowell.com/blog/how-to-use-favicons-on-the-wordpress-admin-login-pages/
*
*/
function add_favicon() {
$favicon_url = get_stylesheet_directory_uri() . '/favicon.ico';
echo "\n";
echo '<link rel="shortcut icon" href="' . $favicon_url . '" />';
echo "\n";
# .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://www.NEUE_DOMAIN.de/$1 [R=301,L]
/*
* Display image file size in media library
* https://wordpress.stackexchange.com/questions/237131/display-image-file-size-in-media-library
*
*/
function wpse_237131_add_column_file_size( $columns ) { // Create the column
$columns['filesize'] = 'Dateigröße';
return $columns;
}
function wpse_237131_column_file_size( $column_name, $media_item ) { // Display the file size
$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator', 'author');
<?php if( array_intersect($allowed_roles, $user->roles ) ) { ?>
//stuff here for allowed roles
<?php } ?>
function my_custom_admin_styles() {
?>
<style type="text/css">
.your-custom-css {
height: 300px;
overflow: scroll;
border: 1px solid #ddd;
padding: 15px;
}
</style>
function add_theme_caps() {
$role = get_role( 'author' );
$role->add_cap( 'edit_others_posts' );
}
add_action( 'admin_init', 'add_theme_caps');
@ingozoell
ingozoell / WordPress-Conditional-load-IE-Scripts.php
Last active July 4, 2017 09:18
WordPress: Conditional load IE Scripts
function iz_old_ie_scripts() {
if (!is_admin()) {
// Make responsive websites and media queries work in IE8
// wp_register_script( 'respond', ( '//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js' ), FALSE, NULL, FALSE );
// wp_script_add_data( 'respond', 'conditional', 'lt IE 9' );
// Support for :nth-child(n), :last-child, etc in IE8
wp_register_script( 'selectivizr', ( '//cdnjs.cloudflare.com/ajax/libs/selectivizr/1.0.2/selectivizr-min.js' ), array('jquery'), NULL, FALSE );
wp_script_add_data( 'selectivizr', 'conditional', 'lt IE 9' ); }
}