Skip to content

Instantly share code, notes, and snippets.

View salvatorecapolupo's full-sized avatar
🎯
Focusing

Salvatore Capolupo salvatorecapolupo

🎯
Focusing
View GitHub Profile
@annalinneajohansson
annalinneajohansson / ajax.js
Last active December 31, 2023 05:50
Basic AJAX function in WordPress
jQuery(document).ready(function($){
var ajaxurl = object.ajaxurl;
var data = {
action: 'my_action', // wp_ajax_my_action / wp_ajax_nopriv_my_action in ajax.php. Can be named anything.
foobar: 'some value', // translates into $_POST['foobar'] in PHP
};
$.post(ajaxurl, data, function(response) {
alert("Server returned this:" + response);
});
});
@jdevalk
jdevalk / .htaccess
Last active November 28, 2023 20:28
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
@jackreichert
jackreichert / inputtitle_submit.js
Last active September 26, 2020 15:03
Example showing how to use AJAX in WordPress
(function ($) {
$(document).ready(function () {
$('#next').click(function () {
$.post(
PT_Ajax.ajaxurl,
{
// wp ajax action
action: 'ajax-inputtitleSubmit',
// vars
<?php
function writeLog($string) {
$log_file = dirname(__FILE__) . '/log.txt';
if ($fh = @fopen($log_file, "a+")) {
fputs($fh, $string, strlen($string));
fclose($fh);
return true;
}
else {
@DavidWells
DavidWells / add-wordpress-settings-page.php
Created January 28, 2013 05:59
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@arnault-snippet
arnault-snippet / gist:4305869
Created December 16, 2012 09:35
Wordpress : Plugins Header
<?php
/*
Plugin Name: Wptuts+ Favorite Plugins
Plugin URI: http://wp.tutsplus.com/tutorials/plugins/building-the-favorite-plugins-plugin/
Description: Quickly and easily access and install your favorited plugins from WordPress.org, right from your dashboard.
Version: 0.7
Author: Japh
Author URI: http://wp.tutsplus.com/author/japh
License: GPL2
*/
@nucklearproject
nucklearproject / gist:3895429
Created October 15, 2012 20:59
Jquery regex plugin
:regex
jQuery.expr[':'].regex = function(elem, index, match) {
var matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
@snowman-repos
snowman-repos / gist:3817275
Created October 2, 2012 08:16
Htaccess: Set Expires
# Setting "expires" tells browsers downloading these files that
# they don't need to request it again for this specific length of
# time. In otherwords, use the cache instead if you have it. This
# can reduce stress on the server for you, and speed up page load
# time for visitors.
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
@jonsuh
jonsuh / js-ajax-php-json-return.html
Last active September 17, 2022 02:57
jQuery AJAX Call to PHP Script with JSON Return
<div class="the-return">
[HTML is replaced when successful.]
</div>
@joncave
joncave / endpoints.php
Created June 7, 2012 19:41
WP_Rewrite endpoints demo
<?php
/*
Plugin Name: WP_Rewrite endpoints demo
Description: A plugin giving example usage of the WP_Rewrite endpoint API
Plugin URI: http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/
Author: Jon Cave
Author URI: http://joncave.co.uk/
*/
function makeplugins_endpoints_add_endpoint() {