Skip to content

Instantly share code, notes, and snippets.

View joeydenbraven's full-sized avatar

Joey den Braven joeydenbraven

View GitHub Profile
@joeydenbraven
joeydenbraven / read-metadata.php
Created November 19, 2015 08:23
A way to get meta data from external url via php including opengraph items, so you can use it on your site.
<?php
// Url
$link = 'http://www.google.com';
//Get all meta tags and loop through them
if($link!=''){
$sites_html = file_get_contents($link);
$html = new DOMDocument();
@$html->loadHTML($sites_html);
$meta_og_img = null;
foreach($html->getElementsByTagName('meta') as $meta) {
@joeydenbraven
joeydenbraven / wordpress-redirectall-functions.php
Last active November 19, 2015 08:53
Close Wordpress wp-admin and redirect all users for own login
<?php
// Put this in functions file
function redirect_login_page() {
// Closes all forms going to Wordpress admin, make sure you got a form to login on this page because you'll be redirected to this page
$login_page = home_url( '/profiles/' );
$page_viewed = basename($_SERVER['REQUEST_URI']);
if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($login_page);
exit;
}
@joeydenbraven
joeydenbraven / scroll-up-or-down.js
Last active November 23, 2015 10:53
jQuery script that will activate for scrolling up or down.
var iScrollPos = 0;
$(window).scroll(function () {
var iCurScrollPos = $(this).scrollTop();
if(iCurScrollPos<=300){
//Do nothing within 300px and down range
}
else {
var spacerheight = $('header').height();
if (iCurScrollPos > iScrollPos) {
//Scrolling Down
@joeydenbraven
joeydenbraven / yoast-acfpro.js
Last active April 22, 2019 10:35
Combines Yoast with ACF Pro - works with repeater and flexible fields
(function( $ ) {
var acfPlugin;
//http://stackoverflow.com/a/965962
jQuery.expr[':'].parents = function(a,i,m){
return jQuery(a).parents(m[3]).length < 1;
};
var AcfPlugin = function() {
@joeydenbraven
joeydenbraven / wordpress-login-shortcode.php
Last active July 11, 2016 08:05
Creates a Wordpress login shortcode, so you can create your own login page!
// add this to your functions file
add_shortcode('shortcode_name_here', 'my_login_form_shortcode');
function my_login_form_shortcode( $attr ) {
if ( is_user_logged_in() )
return '';
/* Set up some defaults. */
$defaults = array(
'label_username' => 'Username',
@joeydenbraven
joeydenbraven / scan_dir.php
Last active March 28, 2023 15:05
Scan dir sorted on modified date
function scan_dir($dir) {
$ignored = array('.', '..', '.svn', '.htaccess'); // -- ignore these file names
$files = array(); //----------------------------------- create an empty files array to play with
foreach (scandir($dir) as $file) {
if ($file[0] === '.') continue; //----------------- ignores all files starting with '.'
if (in_array($file, $ignored)) continue; //-------- ignores all files given in $ignored
$files[$file] = filemtime($dir . '/' . $file); //-- add to files list
}
arsort($files); //------------------------------------- sort file values (creation timestamps)
$files = array_keys($files); //------------------------ get all files after sorting
@joeydenbraven
joeydenbraven / html5-form-structure.php
Last active October 13, 2019 16:29
HTML5 form structure
<form id="123" method="post" action="" form-id="123" class="-form" onsubmit="event.preventDefault();">
<form-header class="-header">
<h6>Chapter</h6>
<h3>Title</h3>
<p>What to expect in this form</p>
</form-header>
<form-fields class="-fields">
<form-field class="-field -required" data-field="a7993147">
<label class="-label">
<span class="-title">Uw naam</span>