Skip to content

Instantly share code, notes, and snippets.

@vdite
vdite / notify-on-new-post.php
Last active March 28, 2024 21:33
Send an email notification to the Wordpress administrator when a new post is published.
<?php
/**
Plugin Name: Alert Admin on new Post
Plugin URI: http://wordpress.stackexchange.com/questions/19040/alert-email-when-any-post-or-page-is-changed
Description: Send an email notification to the administrator when a new post is published.
Author: TheDeadMedic, transfered by Viktor Dite
Version: 1.0
Copyright CC share alike
* @param string $new_status
@vdite
vdite / Completely Remove RSS Feeds in WordPress
Created June 28, 2013 20:04
Completely Remove RSS Feeds in WordPress
<?php
// add this to yout functions.php file
// you may just want to kill all your RSS Feeds, wordpress does provide
remove_action('do_feed', 'disable_all_feeds', 1);
remove_action('do_feed_rdf', 'disable_all_feeds', 1);
remove_action('do_feed_rss', 'disable_all_feeds', 1);
remove_action('do_feed_rss2', 'disable_all_feeds', 1);
remove_action('do_feed_atom', 'disable_all_feeds', 1);
@vdite
vdite / debug php in the browser console
Created July 7, 2013 11:43
best way to debug php in the browser console
<?php
/**
* Send debug code to the Javascript console
*/
function debug_to_console($data) {
if(is_array($data) || is_object($data))
{
echo("<script>
if(console.debug!="undefined"){
console.log('PHP: ".json_encode($data)."');
@vdite
vdite / array_over_get.php
Last active August 28, 2020 09:06
How to transfer an Array over URL GET Parameters
<?php
/* array_over_get.php */
$image_arr=array("1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg");
$serial_arr=urlencode(base64_encode(serialize($image_arr)));
echo '<img src="process_images.php?arr='.$serial_arr.'" alt="stacked image"/>';
?>
<?php
@vdite
vdite / jquery-if-file-exist.js
Last active July 20, 2018 22:22
jQuery: how to check if file exists
var base='http://mizine.de';
var url='/image_path_to_test.jpg';
var fallback_url='/image_path_exists_for_fallback_image.jpg';
/** Asynchronous!!! **/
$.get(base+url).done(function(){
$('#any_DOM_id').append('<img id="my_image" src="'+url+'"/>');
}).fail(function(){
$('#any_DOM_id').append('<img id="my_image" src="'+fallback_url+'"/>');
});
<!DOCTYPE html>
<html dir="LTR" lang="de">
<head>
<script type="text/javascript">
/** Disable tracking if the opt-out cookie exists. **/
if (document.cookie.indexOf('optOutPlease=true') > -1) {
/** Opt-Out Cookie set here, no tracking, no Tagmanager **/
}else{
/** Put your Javascript Google Tag Manager code beneath
@vdite
vdite / Get all POST Variables from the array
Created June 19, 2013 19:48
PHP: howto automatically create variables with the same name as key in POST array
// One more cautios way of extracting all input fields at once is:
extract( $_POST, EXTR_OVERWRITE, "form_" );
// This way all your input variables will be called $form_foo and $form_bar at least.
// Avoid doing that in the global scope - not because global is evil, but because nobody ever cleans up there.
// http://goo.gl/3Q5RV
// Thanks to Sergej Müller @wpSEO
// you know this how you are doing:
$username=$_POST["username"];
$age=$_POST["age"];
@vdite
vdite / atrack.php
Last active April 19, 2017 22:14
This Script ist for Offline Conversion Tracking in Google Anylytics. Contact: http://mizine.de
<?php
/**
This Script ist for Offline Conversion Tracking in Google Anylytics
Author: Viktor Dite
Contact: http://mizine.de
Version: v0.2
**/
$uaid = 'UA-XXXXXXX-X'; // Your Analytics UAID
@vdite
vdite / get_parameter_javascript.html
Created December 5, 2013 13:33
how to grab URL GET parameters with Javascript
<div class="content">
<p>Lorem Ipsum Anything</p>
<script type="text/javascript">
if(window.location.href.match(/arg=testA/)){
document.write('<button name="button">Click me</button>');
}elseif(window.location.href.match(/arg=TestB/)){
document.write('<button name="button">Click me now!</button>');
}else{
document.write('<button name="button">Show me</button>');
}
@vdite
vdite / log_arrays_to_file.php
Last active December 23, 2015 20:09
This is how to var_dump to a file with php
<?php
/** Thanks to Pascal Landau
** https://plus.google.com/105523642741376989823/posts
**/
$handle = fopen("path/log.log","a");
fwrite($handle, var_export($array_or_object, true));
fclose($handle);
?>