Skip to content

Instantly share code, notes, and snippets.

@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 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 / 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 / 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 / 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 / basicLoop.php
Last active November 20, 2017 01:55
WP - basic loop
if ( have_posts() ) :
while ( have_posts() ) : the_post();
endwhile;
endif;
@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 / 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 / register_feed.php
Last active February 13, 2016 19:43
WP - create custom json feed
// register json feed
class custom_feed {
public $feed = 'json';
public function __construct() {
add_action( 'init', array( $this, 'init' ) );
}
@twentyfortysix
twentyfortysix / create_user.sql
Last active February 13, 2016 19:41
SQL - create new user
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', '[email protected]', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');