Skip to content

Instantly share code, notes, and snippets.

View keesiemeijer's full-sized avatar

Kees Meijer keesiemeijer

View GitHub Profile
@keesiemeijer
keesiemeijer / gist:9320762
Created March 3, 2014 08:29
WordPress: Checks if new post is created
<?php
/**
* Checks if post status is new
*/
add_action( 'transition_post_status', 'post_unpublished', 10, 3 );
function post_unpublished( $new_status, $old_status, $post ) {
if ( $old_status == 'new' ) {
// do stuff for new post
}
@keesiemeijer
keesiemeijer / reversed-pagination.php
Last active August 29, 2015 14:04
Reversed WordPress Pagination
<?php
/**
* Reversed Pagination for WordPress - proof of concept
*
* WARNING! Not suitable for use on a live website!
*
* Proof of concept for reversed pagination as discussed here
* http://nerd.vasilis.nl/problem-paginated-archive-pages-blogs/
* and here (Dutch)
* http://wasstra.at/035/
@keesiemeijer
keesiemeijer / poc-related-posts.php
Last active August 29, 2015 14:11
Proof of concept to get related words from WordPress post title and filename.
@keesiemeijer
keesiemeijer / poc-related-words-functions.html
Created December 12, 2014 17:45
Output for proof of concept to get related words from WordPress post title and filename. Functions.
@keesiemeijer
keesiemeijer / poc-related-words-classes.html
Created December 12, 2014 17:52
Output for proof of concept to get related words from WordPress post title and filename. Classes
@keesiemeijer
keesiemeijer / poc-related-words-methods.html
Created December 12, 2014 18:01
Output for proof of concept to get related words from WordPress post title and filename. Methods
@keesiemeijer
keesiemeijer / poc-related-words-hooks.html
Created December 12, 2014 18:10
Output for proof of concept to get related words from WordPress post title and filename. Hooks.
@keesiemeijer
keesiemeijer / excluded libs
Last active August 29, 2015 14:11
Exluded libraries for https://developer.wordpress.org/reference/ when parsing WordPress with the WP Parser
excluded files
'wp-includes/class-snoopy.php',
'wp-includes/class-simplepie.php',
'wp-includes/class-IXR.php',
'wp-includes/class-phpass.php',
'wp-includes/class-phpmailer.php',
'wp-includes/class-pop3.php',
'wp-includes/class-json.php',
'wp-includes/class-smtp.php',
'wp-admin/includes/class-pclzip.php',
@keesiemeijer
keesiemeijer / gist:7b8b7e99a44b496659be
Created December 18, 2014 22:05
parsing query.php 4.1
Processing file 427 of 479 "wp-includes/query.php".
Updated function "get_query_var"
Updated function "get_queried_object"
Updated function "get_queried_object_id"
Updated function "set_query_var"
Updated function "query_posts"
Updated function "wp_reset_query"
Updated function "wp_reset_postdata"
Updated function "is_archive"
Updated function "is_post_type_archive"
@keesiemeijer
keesiemeijer / functions.php
Last active November 16, 2015 16:23
Easy way to have text linking to images
<?php
add_filter( 'attachment_fields_to_edit', 'km_attachment_text_link_field', 10, 2 );
function km_attachment_text_link_field( $form_fields, $post ) {
$form_fields['km-text-link'] = array(
'label' => 'Text Link',
'input' => 'text',
'value' => '',
'helps' => 'If Text Link is provided, the image will be linked from a text link',