Skip to content

Instantly share code, notes, and snippets.

View w3guy's full-sized avatar
✍️
Typing...

Collins Agbonghama w3guy

✍️
Typing...
View GitHub Profile
@hasinhayder
hasinhayder / functions.php
Created October 29, 2014 19:12
Redirect WordPress posts to the editor if someone types /edit at the end of the permalink
<?php
function init_url_rewrite_rule(){
add_rewrite_endpoint( 'edit',EP_PERMALINK | EP_PAGES | EP_ATTACHMENT );
if(get_option("EDIT_REWRITE_RULE")!=1){
flush_rewrite_rules();
update_option("EDIT_REWRITE_RULE",1);
}
}
function redirect_edit_url(){
@Wysie
Wysie / gist:03934b6a79a715772abd
Last active January 7, 2025 21:32
Upload to Amazon S3 Instead of Server for Sendy Email Image Uploads
//Using S3.php from https://github.com/tpyo/amazon-s3-php-class. Place it in includes/helpers
//Replaces Sendy's includes/create/upload.php
<?php
include('../functions.php');
include('../login/auth.php');
require_once('../helpers/S3.php');
//Init
$file = $_FILES['file']['tmp_name'];
@michaelwilhelmsen
michaelwilhelmsen / simplepie-fetch-image.php
Created May 9, 2014 11:00
Using the built in Simplepie library in Wordpress, this function fetches the first img of each post. Display it using: echo '<img src="' .get_first_image_url($item->get_content()). '"/>';
/**
* Gets RSS Image Item Link
*
* Place the following inside rss markup
* to display the the first image of that post:
* echo '<img src="' .get_first_image_url($item->get_content()). '"/>';
*
*/
function get_first_image_url($html) {
if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) {
@rxnlabs
rxnlabs / php-wp-add-tinymce-button.php
Last active July 2, 2022 15:28
WordPress - Add button to TinyMCE editor in WordPress. Great for creating menus so users can add shortcodes without having to remember the syntax
<?php
/*Add this code to your functions.php file of current theme OR plugin file if you're making a plugin*/
//add the button to the tinymce editor
add_action('media_buttons_context','add_my_tinymce_media_button');
function add_my_tinymce_media_button($context){
return $context.=__("
<a href=\"#TB_inline?width=480&inlineId=my_shortcode_popup&width=640&height=513\" class=\"button thickbox\" id=\"my_shortcode_popup_button\" title=\"Add My Shortcode\">Add My Shortcode</a>");
}
@nikolov-tmw
nikolov-tmw / multiple-roles-per-user.php
Last active September 5, 2024 01:45
Multiple roles per user WordPress plugin.
<?php
/**
* Plugin Name: Multiple Roles per User
* Description: Allows anyone who can edit users to set multiple roles per user. In a default WordPress environment that wouldn't have much of an effect, since the user would have the privileges of the top-privileged role that you assign to him. But if you have custom roles with custom privileges, this might be helpful.
* Version: 1
* Author: nikolov.tmw
* Author URI: http://paiyakdev.com/
* License: GPL2
*/
/*

Please read the new and updated version.

Sendy

Sendy is a self hosted email newsletter application that lets you send trackable emails via Amazon Simple Email Service (SES).

Heroku

You can deploy Sendy on Heroku using the following instructions (I assume you've already installed the heroku toolbelt).

@A973C
A973C / index.html
Created July 16, 2013 18:13
A CodePen by Philipp Unger. Login form
<head>
<link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://sscol.jebal.comuv.com/css/font.css">
</head>
<body>
<h2>Inspired by <a href="http://dribbble.com/shots/899672-Login-Form">this dribbble shot</a> made by <a href="http://dribbble.com/ionuss">Ionut Zamfir</a>.</h2>
<div class="ribbon"></div>
<div class="login">
<h1>Let's get started.</h1>
<p>This will be an amazing experience</p>
@pento
pento / commercial-client.php
Created July 2, 2013 12:29
Sample Commercial Plugin update server and client
<?php
/*
* Plugin Name: Commercial Client
* Plugin URI: http://pento.net/
* Description: A sample client plugin for showing updates for non-WordPress.org plugins
* Author: pento
* Version: 0.1
* Author URI: http://pento.net/
* License: GPL2+
*/
@r-a-y
r-a-y / gist:5578432
Last active July 23, 2020 06:55
Disable BuddyPress' registration and use WP's instead. Paste this in /wp-content/plugins/bp-custom.php.
/**
* Disables BuddyPress' registration process and fallsback to WordPress' one.
*/
function my_disable_bp_registration() {
remove_action( 'bp_init', 'bp_core_wpsignup_redirect' );
remove_action( 'bp_screens', 'bp_core_screen_signup' );
}
add_action( 'bp_loaded', 'my_disable_bp_registration' );
@mculp
mculp / gist:4661524
Last active March 11, 2017 13:56
Heroku, DNSimple, and very rare SSL trust issues

Background story

Perhaps 1 out of 100 visitors to Connect for a Cause were getting an 'untrusted certificate' error, where if you clicked the Technical Details button, it said the error code was sec_error_unknown_issuer

Usually, if your certificate isn't trusted, it isn't trusted. You usually don't get 99% of your traffic through without any warning. I kept telling people that I thought their browser may had cached something from an earlier time when we (read: they) had a legitimate issue with the certificate. Then, I was playing around on my linux box, and I hit the site, and boom -- This Connection is Untrusted.

So, right when I took over at Connect, I bought a wildcard cert from DNSimple and followed the Heroku SSL Endpoint Documentation to add the certificate and key I was given through the DNSimple web application to my heroku domains. Easy enough, and things were working for me and everyone el