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 | |
// WordPress Admin Panel search posts with custom post meta values along with title | |
if (!function_exists('ahmeddev125_extend_admin_search')) { | |
add_action('admin_init', 'ahmeddev125_extend_admin_search'); | |
/** | |
* hook the posts search if we're on the admin page for our type | |
*/ |
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 | |
// Time Function | |
function time_elapsed_string($datetime, $full = false) { | |
$now = new DateTime; | |
$ago = new DateTime($datetime); | |
$diff = $now->diff($ago); | |
$diff->w = floor($diff->d / 7); | |
$diff->d -= $diff->w * 7; |
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 | |
// Reading Time | |
function dv_reading_time( $post ) { | |
$mycontent = $post->post_content; | |
$word = str_word_count(strip_tags($mycontent)); | |
$m = floor($word / 200); | |
// $s = floor($word % 200 / (200 / 60)); | |
$est = $m . 'm read'; | |
return $est; | |
} |
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('restrict_manage_posts','ahmeddev125_restrict_properties', 10, 2); | |
function ahmeddev125_restrict_properties( $post_type, $which ) { | |
if( 'properties' !== $post_type ) { | |
return; | |
} | |
$taxonomies = array('states', 'counties'); | |
foreach( $taxonomies as $tax_slug ) { |
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 | |
// Display County (Custom Taxonomy) in States (Custom Taxonomy) - Add New Taxonomy Admin Column | |
add_filter( 'manage_edit-states_columns', 'wpdocs_add_new_states_columns', 10 ); | |
function wpdocs_add_new_states_columns( $columns ) { | |
$columns['county'] = __( 'County' ); | |
return $columns; | |
} | |
add_action( 'manage_states_custom_column', 'wpdocs_show_states_meta_info_in_columns', 10, 3 ); | |
function wpdocs_show_states_meta_info_in_columns( $string, $columns, $term_id ) { |
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 | |
if (!function_exists('get_post_ids_by_meta_key_and_value')) { | |
function get_post_ids_by_meta_key_and_value($key, $value) { | |
global $wpdb; | |
$meta = $wpdb->get_results("SELECT post_id FROM `".$wpdb->postmeta."` WHERE meta_key='".$wpdb->escape($key)."' AND meta_value='".$wpdb->escape($value)."'"); | |
$post_ids = []; | |
foreach( $meta as $m ) { |
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
<header class="hdr_top"></header> | |
<style> | |
.hdr_top { position: fixed; top: 0; left: 0; right: 0; z-index: 2; transition: transform 0.4s; background-color: #000; } | |
.scroll-down .hdr_top { transform: translate3d(0, -100%, 0); } | |
.scroll-up .hdr_top { padding: 10px 0; } | |
</style> | |
<script> | |
// Sticky Header |
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 | |
// Code from (https://www.codegrepper.com/code-examples/php/frameworks/yii/slug+to+string+php) | |
function slugify($text, string $divider = '-') { | |
// replace non letter or digits by divider | |
$text = preg_replace('~[^\pL\d]+~u', $divider, $text); | |
// transliterate | |
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); |
OlderNewer