Skip to content

Instantly share code, notes, and snippets.

@twentyfortysix
twentyfortysix / umount.shell
Last active February 13, 2016 19:43
Transmit - MAC/SHELL - force to unmount all transmit connections
pkill -9 -f 'Transmit Disk'
@twentyfortysix
twentyfortysix / NO-png-bmp.php
Last active February 13, 2016 19:45
WP - disable png and other big files to upload
/** prevent uploading of .bmp files. */
add_filter('upload_mimes', function(array $mimes)
{
unset($mimes['bmp']);
unset($mimes['png']);
return $mimes;
});
@twentyfortysix
twentyfortysix / basicLoop.php
Last active November 20, 2017 01:55
WP - basic loop
if ( have_posts() ) :
while ( have_posts() ) : the_post();
endwhile;
endif;
@twentyfortysix
twentyfortysix / disable_emoji.php
Last active February 13, 2016 19:46
WP - disable emoji
// fuck off emoji
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@twentyfortysix
twentyfortysix / loop_brake.php
Last active February 13, 2016 19:47
WP - loop column braker
// The Query
$the_query = new WP_Query( $args_e );
if ($the_query->have_posts()) :
$out .= '<h4 class="subtitle">'.__('Výhry', 'xyz').'</h4>';
// The Loop
$actual_post_count = ($the_query->post_count);
$divide_by = 2;
$i = 0;
@twentyfortysix
twentyfortysix / rename posts (WP)
Last active February 13, 2016 19:48
WP - rename default POST to ...
function change_post_label() {
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
echo '';
}
function change_post_object() {
@twentyfortysix
twentyfortysix / Register meta box (WP)
Last active February 13, 2016 19:48
WP - register metabox
<?php
/**
* Calls the class on the post edit screen.
*/
function call_someClass() {
new someClass();
}
if ( is_admin() ) {
@twentyfortysix
twentyfortysix / register taxonomy (wp)
Last active February 13, 2016 19:48
WP - register taxonomy
<?php
// hook into the init action and call create_my_taxonomies when it fires
add_action( 'init', 'create_my_taxonomies', 0 );
// create two taxonomies, hierarchival_group and liner_groups for the post type "my"
function create_my_taxonomies() {
// ------------ Hierarchical ------------
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
@twentyfortysix
twentyfortysix / register post type.php
Last active February 13, 2016 19:49
WP - register post type
<?php
add_action( 'init', 'register_my_post_type' );
/**
* Register a type post type.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function register_my_post_type() {
$labels = array(
'name' => _x( 'types', 'post type general name', 'your-plugin-textdomain' ),
@twentyfortysix
twentyfortysix / responsive background images
Last active February 13, 2016 19:49
WP - alternative eresponsive background images
// picture ids: array(1, 2, 3)
// $queries = array(
// array('large_screens','min-width: 1450px'),
// array('medium','max-width: 480px'),
// array('large','')
// );
function responsive_background_pictures($id_array, $queries){
$with_euery = '';
$without_euery = '';
// for each style resolution