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
| $key = array_search($item_id, array_column($array_name, 'id')); | |
| ____________________________ | |
| function search($array, $key, $value) | |
| { | |
| $results = array(); | |
| if (is_array($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
| <FilesMatch "\.(php)$"> | |
| <IfModule mod_headers.c> | |
| Header set Access-Control-Allow-Origin "*" | |
| </IfModule> | |
| </FilesMatch> |
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
| //escape backslash to avoid errors | |
| var escapeJSON = function(str) { | |
| return str.replace(/\\/g,'\\'); | |
| }; |
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
| $to_remove = array('john'); | |
| $result = array_diff($your_array_name, $to_remove); |
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 | |
| } |
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 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
| _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
| <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
| 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; | |
| } |