This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Query | |
add_action('pre_get_posts', 'hwk_dynamic_pre_get_posts'); | |
function hwk_dynamic_pre_get_posts($query){ | |
if(is_admin() || !$query->is_main_query()) | |
return; | |
// Post Types | |
if(is_home() || $query->is_post_type_archive() || is_singular()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('init', 'hwk_post_type_example_register'); | |
function hwk_post_type_example_register(){ | |
register_post_type('example', array( | |
'label' => __('Example'), | |
'has_archive' => __('examples'), | |
'rewrite' => true, | |
'public' => true | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('posts_clauses', 'hwk_wp_query_order_by_taxonomy_terms', 10, 2); | |
function hwk_wp_query_order_by_taxonomy_terms($clauses, $wp_query){ | |
global $wpdb; | |
if(!isset($wp_query->query['orderby']) || strpos($wp_query->query['orderby'], 'tax_') !== 0) | |
return $clauses; | |
$taxonomy = substr_replace($wp_query->query['orderby'], '', 0, strlen('tax_')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hwk_the_json_to_csv($json, $delimiter = ';'){ | |
echo hwk_get_json_to_csv($json, $delimiter); | |
} | |
function hwk_get_json_to_csv($json, $delimiter = ';'){ | |
$data = json_decode($json, true); | |
if(!is_array($data) || empty($data)) | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($){ | |
var filter_date_start = $('.filter_datepicker.filter_datepicker_from'), | |
filter_date_end = $('.filter_datepicker.filter_datepicker_to'), | |
filter_native = $('#filter-by-date'); | |
$('.filter_datepicker').datepicker({ | |
altFormat: 'yy-mm-dd', | |
dateFormat: 'dd/mm/yy', | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Date Picker Default Styles | |
* https://github.com/xwp/wp-jquery-ui-datepicker-skins | |
*/ | |
.ui-datepicker { | |
padding: 0; | |
border: 1px solid #ddd; | |
-webkit-border-radius: 0; | |
-moz-border-radius: 0; | |
border-radius: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.filter_date_range_wrapper{ | |
position:relative; | |
display:inline-block; | |
vertical-align:bottom; | |
} | |
.filter_date_range_wrapper > span{ | |
position:absolute; | |
top:8px; | |
right:6px; | |
color:#ccc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Admin Filter Date Range: Enqueue | |
add_action('admin_enqueue_scripts', 'hwk_filter_date_range_enqueue'); | |
function hwk_filter_date_range_enqueue(){ | |
global $pagenow; | |
if($pagenow != 'edit.php' && $pagenow != 'upload.php') | |
return; | |
wp_enqueue_script('momentjs', '//cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.0/moment.min.js', array(), null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('posts_results', 'hwk_post_object_extend', 10, 2); | |
function hwk_post_object_extend($posts, $query){ | |
if(empty($posts)) | |
return $posts; | |
foreach($posts as $post){ | |
// Post Type = post | |
if(get_post_type($post) != 'post') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Register Post Type | |
add_action('init', 'hwk_post_type_exemple', 0); | |
function hwk_post_type_exemple(){ | |
register_post_type('exemple', array( | |
'hierarchical' => false, // true | false. See 'post_row_actions' & 'page_row_actions' filters | |
'public' => false, | |
'show_ui' => true, | |
'show_in_menu' => true, |