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
| function _fix_child_css_version( $src ) { | |
| $parts = explode( '?', $src ); | |
| if ( stristr( $parts[0], '-child/style.css' ) ) { | |
| $child_ver = filemtime( get_stylesheet_directory() . '/style.css' ); | |
| return $parts[0] . '?v=' . $child_ver; | |
| } | |
| else { | |
| return $src; | |
| } | |
| } |
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
| <h3>All Post Meta</h3> | |
| <?php $getPostCustom=get_post_custom(); // Get all the data ?> | |
| <?php | |
| foreach($getPostCustom as $name=>$value) { | |
| echo "<strong>".$name."</strong>"." => "; | |
| foreach($value as $nameAr=>$valueAr) { |
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
| function disable_search( $query, $error = true ) { | |
| if ( is_search() ) { | |
| $query->is_search = false; | |
| $query->query_vars[s] = false; | |
| $query->query[s] = false; | |
| // to error | |
| if ( $error == true ) | |
| $query->is_404 = 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
| global $sitepress; | |
| $trid = $sitepress->get_element_trid($post_id); | |
| if($trid){ | |
| $translations = $sitepress->get_element_translations($trid); | |
| // Unset current language | |
| unset($translations[ICL_LANGUAGE_CODE]); | |
| foreach($translations as $translation){ | |
| echo get_post_meta($translation->element_id, 'my_field', 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
| add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments' ); | |
| function show_current_user_attachments( $query ) { | |
| $user_id = get_current_user_id(); | |
| if ( $user_id ) { | |
| $query['author'] = $user_id; | |
| } | |
| return $query; | |
| } |
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
| <script src="/js/panel/app.js?v={{ substr(md5(date("Y-m-d_Hi")),10,18) }}"></script> |
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
| _getPercentInView = function(element){ | |
| $element = $(element); | |
| var pos = $element.offset(), | |
| theViewport = {top:null, left:null, bottom:null, right:null, width:null, height:null}, | |
| theElement = {top:null, left:null, bottom:null, right:null, width:null, height:null}, | |
| elemLeft = pos.left, | |
| elemTop = pos.top, | |
| elemHeight = $element.height(), | |
| elemWidth = $element.width(); |
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
| function load_template_part($template_name, $part_name=null) { | |
| ob_start(); | |
| get_template_part($template_name, $part_name); | |
| $var = ob_get_contents(); | |
| ob_end_clean(); | |
| return $var; | |
| } |
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
| //reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? | |
| $some_string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. | |
| '|[\x00-\x7F][\x80-\xBF]+'. | |
| '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. | |
| '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. | |
| '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', | |
| '?', $some_string ); | |
| //reject overly long 3 byte sequences and UTF-16 surrogates and replace with ? | |
| $some_string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. |
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
| function has_children() { | |
| global $post; | |
| return count( get_posts( array('post_parent' => $post->ID, 'post_type' => $post->post_type) ) ); | |
| } | |
| if ( has_children() ) { | |
| // do something if this item has children | |
| } |