Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter( 'gform_pre_render_2', 'populate_open_positions' );
add_filter( 'gform_pre_validation_2', 'populate_open_positions' );
add_filter( 'gform_admin_pre_render_2', 'populate_open_positions' );
add_filter( 'gform_pre_submission_filter_2', 'populate_open_positions' );
function populate_open_positions( $form ) {
$field_id = 55;
$parent_page = get_page_by_title( 'Open positions' );
@ville6000
ville6000 / functions.php
Last active March 30, 2016 07:12
Date shortcode for WordPress
<?php
function display_date( $atts ) {
$atts = shortcode_atts(
[
'date_format' => 'd.m.Y',
],
$atts,
'date'
);
@ville6000
ville6000 / main.js
Created March 24, 2016 13:16
Display jQuery UI Autocomplete list on input focus
$(function () {
$("#input_field").autocomplete({
source: your_data,
minLength: 0
}).focus(function(){
$(this).data("uiAutocomplete").search($(this).val());
});
});
@ville6000
ville6000 / functions.php
Last active March 30, 2016 08:23
Override Yoast SEO breadcrumb trail
<?php
add_filter( 'wpseo_breadcrumb_links', 'override_yoast_breadcrumb_trail' );
function override_yoast_breadcrumb_trail( $links ) {
if ( get_post_type() === 'employee' ) {
$breadcrumb[] = array(
'url' => get_permalink( get_page_by_title( 'contact' )->ID ),
'text' => __( 'Contact', 'your-text-domain' ),
);
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>ExampleId</id>
<version>0.1</version>
<vqmver>2.5.1</vqmver>
<author>Ville6000</author>
<file name="catalog/view/theme/journal/template/product/product.tpl">
<operation>
<search position="replace"><![CDATA[<input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />]]></search>
@ville6000
ville6000 / index.php
Created January 19, 2016 09:27
Get human readable time difference in WordPress
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
@ville6000
ville6000 / index.php
Last active October 28, 2016 20:29
Get translated permalink with WPML 3.2+
<?php $object_id = apply_filters( 'wpml_object_id', YOUR-PAGE-ID-HERE, 'page' ); ?>
<a href="<?php echo get_permalink( $object_id ); ?>">
<?php _e( 'Link text', 'text-domain' );
</a>
@ville6000
ville6000 / index.php
Last active November 13, 2015 13:20
Order WordPress posts by multiple keys
<?php
$the_query = new WP_Query( array(
'orderby' => array( 'menu_order' => 'ASC', 'title' => 'DESC' ),
) );
@ville6000
ville6000 / index.php
Created November 10, 2015 08:02
Get select fields options from Types custom field
<?php
$field_config = wpcf_admin_fields_get_field( 'field-id' );
$field_options = array();
if ( isset( $field_config['data']['options'] ) ) {
foreach ( $field_config['data']['options'] as $option ) {
if ( isset( $option['value'] ) ) {
$field_options[ $option['title'] ] = $option['value'];
}
}
function Counter () {
var count = 0;
function logNewValue() {
console.log("Count is " + count);
}
return {
add: function () {
count += 1;