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 | |
/** | |
* I used on a project. | |
* Author: Lenivene Bezerra | |
*/ | |
function esc_var( $t ){ | |
$e = 'UTF-8'; | |
return mb_convert_encoding( htmlentities( $t, ENT_QUOTES, $e ), $e, $e ); | |
} |
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
<select name="year"> | |
<?php | |
$max_years = 100; | |
for ( $id = 1, $year = date('Y'); $year > ( date('Y') - $max_years ); $year-- ) { | |
if( date('Y') - 2 == $year ){ | |
?> | |
<option selected>Selecione o Ano</option> | |
<?php } ?> | |
<option value="<?php echo $year; ?>" id="<?php echo $id; ?>"><?php echo $year; ?></option> | |
<?php $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 | |
/** | |
* Test if the current browser runs on a mobile device. | |
*/ | |
function is_mobile() { | |
$argent = $_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] : null; | |
$mobile = false; | |
if ( empty( $argent ) ) { | |
$is_mobile = $mobile; | |
} elseif ( strpos( $argent, 'Android' ) !== 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( 'wp_head', 'wp_set_ajaxurl' ); | |
function wp_set_ajaxurl() { | |
$html = '<script>'; | |
$html .= 'var ajaxurl = "' . esc_url( self_admin_url( 'admin-ajax.php' ) ) . '";'; | |
$html .= '</script>' . PHP_EOL; | |
echo $html; | |
} |
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( 'pre_get_posts', 'change_limit_mobile' ); | |
function change_limit_mobile( $query ){ | |
$limit = 4; | |
if ( wp_is_mobile() && $query->is_main_query() ){ | |
set_query_var( 'posts_per_page', $limit ); | |
} | |
} |
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
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^ajax /admin/ajax.php [QSA,L] | |
</IfModule> |
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 wp_json_error( $json ){ | |
$json_error = false; | |
$json_decode = json_decode( $json, true ); | |
if ( json_last_error() === JSON_ERROR_NONE ) { | |
if ( !empty( $json ) ){ | |
$json = $json_decode; | |
} else { | |
$json = $json; |
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
<asx Version="3.0"> | |
<entry> | |
<ref href="http://ic.imusicaradios.com.br:8000/brasil.stream.http" /> | |
</entry> | |
<title>Coca-Cola.FM: Sinta o Sabor</title> | |
</asx> |
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
"use strict"; |
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 | |
/** | |
* Insert thumbnail by URL | |
* Is very good to execute wp_insert_post | |
* | |
* @author Lenivene Bezerra | |
* @param string $url Image url external or no | |
* @param int $post_ID Post id to insert thumbnail | |
* @return ID Thumbnail | WP_Error | |
*/ |