Skip to content

Instantly share code, notes, and snippets.

@pgroot91
pgroot91 / dom.js
Created August 10, 2018 18:51 — forked from brynner/dom.js
Add data to HTML according to object's property name
// Add data to HTML according to object's property name
function addContentFromDataToHtml(object, dataSet) {
recursiveObject({object: object, callback: addContentFromDataToHtmlCallback, dataSet: dataSet});
}
var recursiveObject = function(recursiveParams) {
if (recursiveParams.parentsItem) {
recursiveParams.parentsItem = recursiveParams.parentsItem+'.';
} else {
recursiveParams.parentsItem = '';
}
@pgroot91
pgroot91 / bradvin.social.share.urls.txt
Created November 12, 2018 14:15 — forked from HoldOffHunger/bradvin.social.share.urls.txt
Social Share URL's (Summary)
http://compose.mail.yahoo.com/?to={email_address}&subject={title}&body={url}
http://digg.com/submit?url={url}
http://pinterest.com/pin/create/link/?url={url}
http://service.weibo.com/share/share.php?url={url}&appkey=&title={title}&pic=&ralateUid=
http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}
http://surfingbird.ru/share?url={url}&description={text}&screenshot={image}&title={title}
http://vk.com/share.php?url={url}&title={title}&comment={text}
http://widget.renren.com/dialog/share?resourceUrl={url}&srcUrl={url}&title={title}&description={text}
http://www.addthis.com/bookmark.php?url={url}
http://www.douban.com/recommend/?url={url}&title={title}
@pgroot91
pgroot91 / wp-admin-modal-dialog.php
Created March 4, 2019 18:47 — forked from anttiviljami/wp-admin-modal-dialog.php
WordPress admin modal dialog example
<?php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
?>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
<?php
/*
Plugin Name: Import demo
Plugin URI: http://royduineveld.nl
Description: A demo import for my blog
Version: 1.0
Author: Roy Duineveld
Author URI: http://royduineveld.nl
*/
<?php
add_filter( 'the_content', 'crd_append_post_links' );
function crd_append_post_links( $content ) {
if ( is_page() ) {
$post_links_data = get_post_meta( get_the_ID() );
if ( isset( $post_links_data[ 'blog_group' ][ 0 ] ) ) {
$blog_list = maybe_unserialize( $post_links_data[ 'blog_group' ][ 0 ] );
$posts_list = '<ul>';
foreach ( $blog_list as $post_info ) {
<?php
/**
* Plugin Name: Multisite: Passwort Reset on Local Blog
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process.
* Version: 1.0.0
* Author: Eric Teubert
* Author URI: http://ericteubert.de
* License: MIT
*/
@pgroot91
pgroot91 / color-scheme-preview.js
Created February 11, 2020 23:07 — forked from digvijayad/color-scheme-preview.js
How to add Color Schemes to your WordPress theme with live preview: full working sample
(function($) {
var style = $('#yourtheme-color-scheme-css'),
api = wp.customize;
if (!style.length) {
style = $('head').append('<style type="text/css" id="yourtheme-color-scheme-css" />')
.find('#yourtheme-color-scheme-css');
}
// Color Scheme CSS.
api.bind('preview-ready', function() {
@pgroot91
pgroot91 / ExampleUsage.php
Created April 24, 2020 14:36 — forked from jonathonbyrdziak/ExampleUsage.php
A Wordpress class that allows you to place watermarks on your images.
<?php
/**
* The constants defined here are used as a fallback to whatever options you
* end up specifying specifically.
*
* @var constant string
*/
define('WATERMARK_SOURCE', ABSPATH.'/wp-content/themes/mytheme/images/fb_thumb_watermark.png');
define('WATERMARK_ORIENTATION', 'bottom right');
@pgroot91
pgroot91 / gist:893ecd4fd9b8ed90043a496e85d46cec
Created May 5, 2020 13:54 — forked from tripflex/gist:ccd02279117faaf365f9
Convert WordPress date format to jQuery UI DatePicker format
if( ! function_exists( 'wp_date_format_php_to_js') ){
/**
* Convert a date format to a jQuery UI DatePicker format
*
* @param string $dateFormat a date format
*
* @return string
*/
function wp_date_format_php_to_js( $dateFormat ) {
@pgroot91
pgroot91 / gist:fa5439ea0790f8fec42136ffbc06b68d
Created May 14, 2020 20:39 — forked from urre/gist:846b89237da760839b3d
Get network wide recent posts from a WordPress Multisite (1 post from every blog except main site), order by date and only show author once (unique authors). Used on http://vertikals.se/
<?php
// Get all blog ids in network except main site (id 1)
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND spam = '0'
AND deleted = '0'
AND archived = '0'