I use Valet as my local web development environment (PHP, Laravel, Wordpress, ...)
This gist is my own recipe to install Wordpress from the command line to use it with Valet. Maybe this is useful for you too.
<?php | |
function custom_theme_scripts() { | |
$date = date("dmy"); // apenas gera uma numeração de versão aleatória | |
// seta seu principal arquivo javascript | |
wp_enqueue_script( 'funcoes', get_template_directory_uri() . '/assets/js/scripts.min.js', array('jquery'), $date, true ); | |
// registra uma função js para localizar uma função PHP | |
wp_localize_script( 'funcoes', 'disparaLoad', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); | |
} | |
add_action('wp_enqueue_scripts', 'custom_theme_scripts'); |
<?php | |
$user_ip = getenv('REMOTE_ADDR'); | |
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip")); | |
var_dump($geo); | |
$pais = $geo["geoplugin_countryName"]; | |
$cidade = $geo["geoplugin_city"]; | |
$estado = $geo['geoplugin_region']; |
<?php | |
function jQuery3(){ | |
$date = date("dmy"); | |
if (!is_admin()){ | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', get_template_directory_uri()."/assets/js/jquery.min.js", false, $date); | |
wp_enqueue_script('jquery'); | |
} | |
} | |
add_action('wp_enqueue_scripts', 'jQuery3'); |
<?php | |
// Verifica se não existe nenhuma função com o nome tutsup_session_start | |
if ( ! function_exists( 'tutsup_session_start' ) ) { | |
// Cria a função | |
function tutsup_session_start() { | |
// Inicia uma sessão PHP | |
if ( ! session_id() ) session_start(); | |
} | |
// Executa a ação | |
add_action( 'init', 'tutsup_session_start' ); |
<?php | |
function ajusta_url_imovel($rules) { | |
$new_rules = array( | |
'imoveis/([^/]+)/([^/]+)/?$' => 'index.php?post_type=$matches[1]&$matches[1]=$matches[2]', | |
); | |
$rules = array_merge($new_rules,$rules); | |
exit; |
<?php | |
function jQuery3(){ | |
// Apenas para mudar a versão automaticamente | |
$date = date("dmy"); | |
// Le a função apenas no front do site | |
if (!is_admin()){ | |
// Tira o registro do Jquery que estava funcionando | |
wp_deregister_script('jquery'); | |
// Registra o novo script | |
wp_register_script('jquery', "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js", false, $date); |
<div class="container"> | |
<?php | |
$terms = get_terms( 'categoria-cursos', array( | |
'hide_empty' => false, | |
) ); | |
// var_dump($terms); |