Skip to content

Instantly share code, notes, and snippets.

@jenovateurs
jenovateurs / SendMessageSlackWebhook.php
Last active November 8, 2021 00:54
Send Message With Webhook Slack using PHP
<?php
public static function sendMessage($sMessage){
$webhookurl = 'https://hooks.slack.com/services/WEBHOOK';
$timestamp = date("c", strtotime("now"));
$json_data = json_encode([
// Message
"text" => $sMessage
@nemoo
nemoo / Gitwebmarkdown
Created October 25, 2014 12:24
Tampermonkey script for chrome to display README.md files rendered as html from markdown in gitweb
// ==UserScript==
// @name Gitwebmarkdown
// @version 0.1
// @description renders readme files in markdown
// @include http://yourserverhere.com/git/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js
// ==/UserScript==
var converter = new Showdown.converter();
@auser
auser / app.js
Last active October 11, 2017 03:01
The complete source for the http://www.ng-newsletter.com/posts/chrome-apps-on-angular.html article. Enjoy!
angular.module('myApp', ['ngRoute'])
.provider('Weather', function() {
var apiKey = "";
this.getUrl = function(type, ext) {
return "http://api.wunderground.com/api/" +
this.apiKey + "/" + type + "/q/" +
ext + '.json';
};
@thefuxia
thefuxia / t5-silent-flush.php
Last active August 11, 2016 11:03
T5 Silent Flush - Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Silent Flush
* Description: Flushes rewrite rules whenever a custom post type or taxonomy is registered and not already part of these rules. This is a soft flush, the .htaccess will not be rewritten.
* Version: 2013.05.04
* Author: Thomas Scholz <[email protected]>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
@thefuxia
thefuxia / t5-spam-block.php
Last active December 15, 2015 12:09
T5 Spam Block Stop comments based on a block list before they can enter the database.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Spam Block
* Description: Block spam before it reaches the database.
* Plugin URI: https://github.com/toscho/T5-Spam-Block
* Version: 2013.03.31
* Author: Thomas Scholz
* Author URI: http://toscho.de
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
@thefuxia
thefuxia / functions.php
Created March 18, 2013 09:49
Count posts in post-format "status".
add_action( 'wp_footer', 'count_statuses' );
function count_statuses()
{
$status = 'status';
$num = get_term_post_count_by_type( "post-format-$status", 'post_format' );
print "<pre>{$status}es: $num</pre>";
}
/**
* Count all post in a term.
@franz-josef-kaiser
franz-josef-kaiser / debug_register_pt_args.class.php
Last active December 14, 2015 10:18
Shows the arguments of a newly registered post type right after it was registered. Helps inspecting which defaults have been added by core and if one of the developers arguments got overwritten. Simply add `&debug_pt_args=true` to your URL and set `WP_DEBUG` to `TRUE`.
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) Debug Register Post Type Args
* Description: Shows the arguments of a newly registered post type right after it was
* registered. Helps inspecting which defaults have been added by core and if
* one of the developers arguments got overwritten. Simply add
* <code>&debug_pt_args=true</code> to your URL and set
* <code>WP_DEBUG</code> to <code>TRUE</code> in your <code>wp-config.php</code>.
* Plugin URl: http://wordpress.stackexchange.com/questions/89066
@franz-josef-kaiser
franz-josef-kaiser / wpse67107_restrict_upload.php
Created February 26, 2013 10:39
Restrict the maximum file size as well as the maximum allowed resolution for images uploaded to WordPress.
<?php
/**
* Plugin Name: (#67107) »kaiser« Restrict file upload via image dimensions
*/
function wpse67107_restrict_upload( $file )
{
$file_data = getimagesize( $file );
// Abort when we can't get any info:
if ( ! $file_data )
@mbijon
mbijon / posts_search_demo.php
Created February 18, 2013 18:48
WordPress posts_search filter example, for Tom Barrett on WP-Hackers list 2013-02-18
function tcb_filter_search( $term ) {
if ( is_search() )
$search = "(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
return $search;
}
add_filter( 'posts_search', 'tcb_filter_search', null, 2 );
@franz-josef-kaiser
franz-josef-kaiser / sys_bot.php
Last active August 4, 2020 06:29
Creates and maintains the SysBot User (which has the role of "editor"). Purpose of this bot user: You're importing data into a WordPress CustomPostType (for e.g.: via a HTTP request). During import/fetch you need a user who is the author of those CPTs posts. You could go with a fake ID, but this will successfully prevent you to use taxonomies, a…
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: SysBot
* Description: Creates and maintains the SysBot User (which has the role of "editor")
* Author: Franz Josef Kaiser
*/
# PUBLIC API #
function get_bot()