Skip to content

Instantly share code, notes, and snippets.

View remcotolsma's full-sized avatar
🏢
Working @pronamic

Remco Tolsma remcotolsma

🏢
Working @pronamic
View GitHub Profile
@remcotolsma
remcotolsma / functions.php
Last active September 13, 2015 13:07
WordPress register_post_type() project with archive and rewite slug.
<?php
function prefix_init() {
register_post_type( 'project', array(
'public' => true,
'label' => __( 'Projects', 'text_domain' ),
'has_archive' => true,
'rewrite' => array( 'slug' => _x( 'projects', 'slug', 'text_domain' ) ),
) );
}
@remcotolsma
remcotolsma / update-wordpress-page-templates.sql
Created September 1, 2015 09:29
WordPress query to update the page templates quickly after renaming page template file.
UPDATE
wp_postmeta
SET
meta_value = 'page-templates/template-overview.php'
WHERE
meta_key = '_wp_page_template'
AND
meta_value = 'page-templates/template-overzicht.php'
;
@remcotolsma
remcotolsma / omnikassa.php
Created June 22, 2015 13:52
Simulate OmniKassa automatic response message with WordPress
<?php
define( 'WP_USE_THEMES', false );
require './wp-blog-header.php';
// Post
$url = 'https://www.example.com/';
$data = 'key1=value1|key2=value2|key3=value3';
@remcotolsma
remcotolsma / Admin.php
Last active August 29, 2015 14:23
WordPress pay Gravity Forms extensions feature/form-settings
<?php
/**
* Title: WordPress pay extension Gravity Forms admin
* Description:
* Copyright: Copyright (c) 2005 - 2015
* Company: Pronamic
* @author Remco Tolsma
* @version 1.1.0
*/
@remcotolsma
remcotolsma / functions.php
Created May 29, 2015 19:19
WordPress filter to display only root categories and sub categories.
<?php
function prefix_get_the_terms( $terms, $post_id, $taxonomy ) {
if ( 'category' == $taxonomy ) {
if ( is_category() ) {
$current = get_queried_object();
$sub_terms = get_terms( $taxonomy, array(
'child_of' => $current->term_id,
'fields' => 'ids',
@remcotolsma
remcotolsma / script.js
Created May 20, 2015 20:33
WordPress theme script for FitVids.JS.
( function( $ ) {
// ...
// FitVids
$( '.entry-content' ).fitVids();
// ...
} )( jQuery );
@remcotolsma
remcotolsma / functions.php
Created May 20, 2015 20:30
Enqueue FitVids.JS in WordPress.
<?php
/**
* Enqueue scripts
*/
function prefix_enqueue_scripts() {
$uri = get_template_directory_uri();
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@remcotolsma
remcotolsma / functions.php
Created May 20, 2015 19:58
Custom WordPress the_terms() function to sort the post terms by "Category Order and Taxonomy Terms Order".
<?php
/**
* The terms
*/
function prefix_the_terms( $post_id, $taxonomy ) {
$term_ids = wp_get_post_terms( $post_id, $taxonomy, array(
'fields' => 'ids',
) );
@remcotolsma
remcotolsma / wp-create-user.php
Created May 18, 2015 18:02
WordPress create an administrator user via FTP/PHP
<?php
require_once 'wp-load.php';
$login = 'remcotolsma';
$passw = '';
$email = '[email protected]';
if ( !username_exists( $login ) && ! email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
@remcotolsma
remcotolsma / GroupIterator.php
Created April 29, 2015 09:05
Group iterator class for PHP
<?php
/**
* Title: Group iterator
* Description:
* Copyright: Copyright (c) 2005 - 2015
* Company: Pronamic
* @author Remco Tolsma
* @version 1.0.0
* @doc http://www.koders.com/java/fidC979E43601174F16239536C65E101FCB0C32E609.aspx?s=idef%3Asort