This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUrlParameter(a) { | |
a = a.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); | |
a = RegExp("[\\?&]" + a + "=([^&#]*)").exec(location.search); | |
return null === a ? "" : decodeURIComponent(a[1].replace(/\+/g, " ")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.) | |
*/ | |
function hip_widget_first_last_classes( $params ) { | |
global $my_widget_num; // Global a counter array | |
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing | |
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: PLUGIN NAME | |
Plugin URI: | |
Description: PLUGIN DESCRIPTION | |
Version: 1 | |
Author: Hippies | |
Author URI: http://hippies.se/ | |
************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* SCHEDULE AN EVENT TO RUN EVERY HOUR */ | |
/* | |
When you schedule an event in a plugin, | |
call wp_schedule_event on plugin activation otherwise you will end up with a lot of scheduled events. | |
*/ | |
register_activation_hook(__FILE__, 'my_plugin_activation'); | |
function my_plugin_activation() { | |
wp_schedule_event( time(), 'hourly', 'my_hourly_event_action'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function populate_children_hierarchically( $child ) { | |
$child_array = array( 'title' => $child->title, 'url' => $child->url ); | |
if( !empty( $child->children ) ) { | |
foreach( $child->children as $granchild ) { | |
$child_array[] = populate_children_hierarchically( $granchild ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Hide Widget Titles! | |
Plugin URI: | |
Description: Prevent widget titles from displaying frontend by prepending them with an exclamation mark (ie. !Widget Title) | |
Version: 1 | |
Author: Hippies | |
Author URI: http://hippies.se/ | |
************************************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Solution to order first by date, then by start time (both are meta values) | |
* http://wordpress.stackexchange.com/a/67391/5045 | |
* */ | |
add_action( 'pre_get_posts', 'pre_get_posts_programpunkter' ); | |
function pre_get_posts_programpunkter( $query ) { | |
if( !is_admin() && is_post_type_archive( 'programpunkt' ) && $query->is_main_query() ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# http://kovshenin.com/2012/the-wordpress-settings-api/ | |
# http://codex.wordpress.org/Settings_API | |
add_action( 'admin_menu', 'my_admin_menu' ); | |
function my_admin_menu() { | |
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' ); | |
} | |
add_action( 'admin_init', 'my_admin_init' ); |
NewerOlder