This file contains 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 | |
/** | |
* Include in your theme functions | |
*/ | |
add_filter( 'sanitize_file_name', 'sanitize_uploaded_filename' ); | |
function sanitize_uploaded_filename( $filename ) { | |
$fileNewName = sanitize_title( pathinfo( $filename )['filename'] ) . '.' . pathinfo( $filename )['extension']; | |
return $fileNewName; | |
} |
This file contains 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 | |
/** | |
* Usage: | |
* $get_dir_size("path/to/my/folder"); | |
*/ | |
$get_dir_size = function ($directory){ | |
$size = 0; | |
$scan_dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); | |
foreach($scan_dir as $file): |
This file contains 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 | |
/** | |
* USD to BRL | |
* API Docs: https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/aplicacao#!/recursos | |
* https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/aplicacao#!/recursos/CotacaoDolarDia#eyJmb3JtdWxhcmlvIjp7IiRmb3JtYXQiOiJqc29uIiwiJHRvcCI6MTAwLCJkYXRhQ290YWNhbyI6IjA2LTA4LTIwMjEifSwicHJvcHJpZWRhZGVzIjpbMCwxLDJdLCJwZXNxdWlzYWRvIjp0cnVlLCJhY3RpdmVUYWIiOiJkYWRvcyIsImdyaWRTdGF0ZSI6ewMwAzpbewNCAyIEMAQiLANBA30sewNCAyIEMQQiLANBA30sewNCAyIEMgQiLANBA31dLAMxAzp7fSwDMgM6W10sAzMDOnt9LAM0Azp7fSwDNQM6e319LCJwaXZvdE9wdGlvbnMiOnsDYQM6e30sA2IDOltdLANjAzo1MDAsA2QDOltdLANlAzpbXSwDZgM6W10sA2cDOiJrZXlfYV90b196IiwDaAM6ImtleV9hX3RvX3oiLANpAzp7fSwDagM6e30sA2sDOjg1LANsAzpmYWxzZSwDbQM6e30sA24DOnt9LANvAzoiQ29udGFnZW0iLANwAzoiVGFibGUifX0= | |
* https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarDia(dataCotacao=@dataCotacao)?@dataCotacao=%2706-08-2021%27&$top=100&$format=json&$select=cotacaoCompra,cotacaoVenda,dataHoraCotacao | |
* | |
* @param float $value BRL value to convert | |
* @param string $type ' |
This file contains 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 | |
/** | |
* Usage: cpt_make_sortable_column('post_type', array('coluna')); | |
* | |
* @param string $post_type | |
* @param array $columns | |
*/ | |
function cpt_make_sortable_column(string $post_type, array $columns = []){ | |
$filter = "manage_edit-{$post_type}_sortable_columns"; |
This file contains 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 | |
/** | |
* Order array by key | |
* @param $array | |
* @param $array_key | |
* @param string $order | |
* | |
* @return bool | |
*/ |
This file contains 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 | |
/** | |
* Convert CSV file in Array | |
* | |
* @param string $file_csv CSV file path | |
* | |
* @return array|string | |
*/ | |
function csv_to_array(string $file_csv){ | |
if(!file_exists($file_csv)): |
This file contains 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 | |
/** | |
* @author Angelo Rocha | |
* @copyleft 2021 | |
* @license GNU GPL 3 (https://www.gnu.org/licenses/gpl-3.0.html) | |
* | |
* @param string $image Set url to get image | |
* | |
*/ |
This file contains 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( !class_exists('Redux') ) { | |
return; | |
} | |
$opt_name = 'wpss_option'; | |
$theme = wp_get_theme(); |
This file contains 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 | |
/** | |
* Class WPSSCpt | |
* Generate custom post types | |
*/ | |
class WPSSCpt { | |
/** | |
* Class instance |
This file contains 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 | |
/** | |
* Class WPSSDummy | |
* | |
* Generate dummy posts, see parameters of loripsum api: | |
* | |
* (integer) - The number of paragraphs to generate. | |
* short, medium, long, verylong - The average length of a paragraph. | |
* decorate - Add bold, italic and marked text. |
OlderNewer