Skip to content

Instantly share code, notes, and snippets.

View Sixl-Daniel's full-sized avatar

Daniel Sixl Sixl-Daniel

View GitHub Profile
@Sixl-Daniel
Sixl-Daniel / wp_usermeta.md
Last active January 12, 2021 19:07 — forked from magnific0/wp_usermeta.md
Show and Edit User Meta in Wordpress

#Show and Edit User Meta in Wordpress

Description

This simple procedure will allow you to:

  1. Display user meta fields under in the user list as additional columsn (Users > All Users).
  2. Display these fields on user profiles.
  3. Edit these fields under user edit.

This method works completely without plugins and involves just some functions and hooks in functions.php. Plugins like "User Meta Display" achieve this to some level, but treat custom meta fiedlds completely different from the regular fields. They are shown and edited in seperate environment and fail to show the meta data is a table list. This method integrates custom user meta along with regular user (meta).

const poll = async ({ fn, validate, interval, maxAttempts }) => {
let attempts = 0;
const executePoll = async (resolve, reject) => {
const result = await fn();
attempts++;
if (validate(result)) {
return resolve(result);
} else if (maxAttempts && attempts === maxAttempts) {
@Sixl-Daniel
Sixl-Daniel / some_plugin.php
Created December 7, 2020 09:05 — forked from dbspringer/some_plugin.php
WordPress front-end uploader & current-user only media filter
<?php
class Some_WP_Plugin {
/**
* Init everything here
*/
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_filter( 'ajax_query_attachments_args', array( $this, 'filter_media' ) );
@Sixl-Daniel
Sixl-Daniel / plugin.php
Created December 3, 2020 17:32 — forked from dbspringer/plugin.php
Front-end Media Example plugin
<?php
/**
* Plugin Name: Front-end Media Example
* Plugin URI: http://derekspringer.wordpress.com
* Description: An example of adding the media loader on the front-end.
* Version: 0.1
* Author: Derek Springer
* Author URI: http://derekspringer.wordpress.com
* License: GPL-2.0+
@Sixl-Daniel
Sixl-Daniel / 2019-https-localhost.md
Created November 18, 2020 09:37 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@Sixl-Daniel
Sixl-Daniel / functions.js
Created October 25, 2020 20:57
Useful functions JS
function calculateGoldenRatio(length) {
const phi = 1.6180339887498948;
const a = Math.round(length / phi)
const b = length - a;
return { a: a, b: b };
}
@Sixl-Daniel
Sixl-Daniel / config.js
Last active October 4, 2020 09:10
Vue.js environment variables
# config.js
const config = {
...,
features: {
...
}.
...
}
@Sixl-Daniel
Sixl-Daniel / Filters.vue
Last active November 13, 2020 11:07
Filter
Vue.filter('getContrastColor', function (backgroundHexColor) {
if (!backgroundHexColor) return '';
const hexcolor = backgroundHexColor.replace("#", "");
const r = parseInt(hexcolor.substr(0, 2), 16);
const g = parseInt(hexcolor.substr(2, 2), 16);
const b = parseInt(hexcolor.substr(4, 2), 16);
var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
return (yiq >= 128) ? '#000000' : '#ffffff';
})
@Sixl-Daniel
Sixl-Daniel / detect-framework.js
Created September 15, 2020 09:16
Detect frontend frameworks and libs
if(!!window.React ||
!!document.querySelector('[data-reactroot], [data-reactid]'))
console.log('React.js');
if(!!window.angular ||
!!document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]') ||
!!document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]'))
console.log('Angular.js');
@Sixl-Daniel
Sixl-Daniel / CodeBox.vue
Last active September 14, 2020 10:31
Vue Components
<template>
<code v-if="active" :class="`code-box${codeBoxVariationClass}`">{{ object | prettyjson }}</code>
</template>
<script>
const defaultObject = [
{ id: 1, title: 'Test', content: 'Sie haben kein Objekt übergeben. Bitte benutzen sie das Attribut :object um Ihr Objekt an die Komponente zu übergeben.' },
];
export default {