Skip to content

Instantly share code, notes, and snippets.

View meloniq's full-sized avatar
👣
Don't overthink!

Andrzej Piotrowski meloniq

👣
Don't overthink!
View GitHub Profile
@meloniq
meloniq / functions.php
Created April 20, 2017 20:46
[ClassiPress theme + Anonymous plugin] Change the anonymous author name to the one from custom field
<?php
/**
* Change the anonymous author name.
*
* @param string $author_meta The value of the metadata.
* @param int $user_id The user ID.
*
* @return string
*/
@meloniq
meloniq / functions.php
Created February 21, 2017 19:40
[ClassiPress] Change quantity of featured ads displayed in slider
<?php
/**
* Change quantity of featured ads displayed in slider.
*
* @param array $args
*
* @return array
*/
function childtheme_gimme_more_featured_ads( $args ) {
@meloniq
meloniq / functions.php
Last active January 9, 2017 06:43
[ClassiPress] Don't show saved Custom Form field on frontend
<?php
/**
* Don't show saved Custom Form field on frontend.
*
* @param object $field
* @param object $post
* @param string $location
*
* @return object|bool
@meloniq
meloniq / functions.php
Created October 21, 2016 05:20
[Language bar flags] Remove tooltip on flags
/**
* Dequeue language bar tooltip.
*
* @return void
*/
function childtheme_dequeue_lang_bar_tooltip() {
wp_dequeue_script( 'langbf_tooltip' );
}
add_action( 'wp_enqueue_scripts', 'childtheme_dequeue_lang_bar_tooltip', 11 );
@meloniq
meloniq / functions.php
Last active October 20, 2016 05:22
[Clipper] Add 'more [store name] coupons text under the description of each coupon, on single coupon page.
/**
* Adds 'more [store name] coupons' text on singular coupon page.
*
* @param string $content
*
* @return string
*/
function childtheme_store_more_after_content( $content ) {
global $post;
@meloniq
meloniq / functions.php
Created September 29, 2016 19:13
Strip all HTML tags from user profile description field
/**
* Strip all HTML tags from user profile description field.
*
* @param int $user_id
*
* @return void
*/
function childtheme_strip_html_from_user_profile_description( $user_id ) {
if ( ! isset( $_POST['description'] ) ) {
return;
@meloniq
meloniq / functions.php
Created September 28, 2016 06:13
[ClassiPress] Make the description field optional
/**
* Mark description field as not required.
*
* @param object $result
* @param object $post
*
* @return object
*/
function childtheme_make_description_not_required( $result, $post ) {
if ( $result->field_name == 'post_content' ) {
@meloniq
meloniq / functions.php
Created May 5, 2016 16:43
[Vantage] Change Custom-Forms sanitization method for textarea fields
<?php
function childtheme_custom_forms_textarea_sanitize( $form, $form_id ) {
foreach ( $form as $key => $field ) {
if ( 'textarea' == $field['type'] ) {
$form[ $key ]['sanitize'] = 'wp_kses_post';
}
}
@meloniq
meloniq / functions.php
Created January 30, 2016 07:17
[WP Tags Cloud widget] Set number of tags you would like to display
<?php
function childtheme_set_tag_cloud_items_number( $args ) {
// set number of tags you would like to display in the WP Tags Cloud widget
$args['number'] = 69;
return $args;
}
add_filter( 'widget_tag_cloud_args', 'childtheme_set_tag_cloud_items_number', 10, 1 );
<?php
/**
* Class that validate and retrieve data from PESEL number in object-oriented style
*
* Example:
* $pesel = new Pesel('85042510356');
* $pesel->getBirthday()->format("d-m-Y")
* $pesel->getSex()
* $pesel->getAge("%a")