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 | |
| // Using 'post_like' custom WP_Query argument: | |
| // https://hwk.fr/code/ajouter-un-argument-post-title-content-like-dans-wp-query | |
| $query = new WP_Query(array( | |
| 'post_type' => 'page', | |
| 'posts_per_page' => 1, | |
| 'post_like' => array( | |
| 'column' => 'post_content', | |
| array( |
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('upload_mimes', 'hwk_upload_mimes_types'); | |
| function hwk_upload_mimes_types($mimes){ | |
| $mimes['svg'] = 'image/svg+xml'; | |
| return $mimes; | |
| } |
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('sanitize_file_name', 'hwk_sanitize_file_name'); | |
| function hwk_sanitize_file_name($input){ | |
| $path = pathinfo($input); | |
| $extension = (isset($path['extension']) && !empty($path['extension'])) ? $path['extension'] : ''; | |
| $file = (!empty($extension)) ? preg_replace('/.' . $extension . '$/', '', $input) : $input; | |
| return sanitize_title(str_replace('_', '-', $file)) . ((!empty($extension)) ? '.' . $extension : ''); | |
| } |
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_where', 'hwk_wp_query_post_like', 10, 2); | |
| function hwk_wp_query_post_like($where = '', &$wp_query){ | |
| global $wpdb; | |
| if(!$post_like = $wp_query->get('post_like')) | |
| return $where; | |
| if(is_string($post_like)) | |
| return $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql($wpdb->esc_like($post_like)) . '%\''; |
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_add_rewrite_rule'); | |
| function hwk_add_rewrite_rule(){ | |
| add_rewrite_tag('%page_filter%', '([^&]+)'); | |
| add_rewrite_rule('^contact/([^/]*)/?', 'index.php?pagename=contact&page_filter=$matches[1]', 'top'); | |
| } | |
| // example.com/contact/commercial | |
| // page-contact.php: |
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('acf/settings/remove_wp_meta_box', '__return_false'); |
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_deregister_builtin_post_type'); | |
| function hwk_deregister_builtin_post_type(){ | |
| global $wp_post_types; | |
| $unregister = array( | |
| 'post', | |
| 'page', | |
| ); |
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('login_enqueue_scripts', '_pit_login_logo_style'); | |
| function _pit_login_logo_style(){ ?> | |
| <style type="text/css"> | |
| #login h1 a, .login h1 a { | |
| background-image: url(<?php header_image(); ?>); | |
| height:80px; | |
| width:320px; | |
| background-repeat: no-repeat; |
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
| acf.add_action('append_field/type=flexible_content', function(e){ | |
| if(e.attr('data-key') == 'field_flexible_template'){ | |
| acf.fields.flexible_content.doFocus(e).add('sub-template-1'); | |
| acf.fields.flexible_content.doFocus(e).add('sub-template-2'); | |
| } | |
| }); |