View Insert page content
<?
// [insertar slug="contacto"]
function insertPage($atts) {
$output = NULL;
extract(shortcode_atts(array(
"slug" => ''
), $atts));
if (!empty($slug)) {
View Cache
<?php
$cache = 'data.txt';
if(date("Ymd", filemtime($cache)) < date("Ymd") || filesize($cache) < 1):
$data = get_data(); // do your thing
$file = fopen($cache,'w+');
$text = is_array($data) ? json_encode($data) : $data;
fwrite($file, $text);
fclose($file);
else:
$file = fopen($cache,'w+');
View WP Breadcrumbs
//FOR POST
$t = wp_get_post_terms(get_the_id(),'taxonomy');
$t[0] = ($t[0]->parent && !$t[1]->parent) ? $t[0] : $t[1];
if($t[0]->parent)
{ $p = get_term_by('id',$t[0]->parent,'taxonomy');
echo '<a href="'.get_term_link($t[0]->parent,'taxonomy').'">'.$p->name.'</a> &raquo; '; }
echo '<a href="'.get_term_link($t[0]->term_id,'taxonomy').'" class="crumb-current">'.$t[0]->name.'</a>';
//FOR ARCHIVE
$t = get_term_by('id',$wp_query->queried_object_id,'taxonomy');
View delete_posts.sql
DELETE a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( c.post_id = a.ID )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE a.post_type = 'post' AND a.post_date > timestampadd(day, -1, now())
DELETE FROM wp_posts WHERE post_type = 'attachment' AND post_date > timestampadd(day, -1, now())
View plugin.php
add_filter('site_transient_update_plugins', 'remove_update_notification');
function remove_update_notification($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}
View Center hero image
.hero{
height:200px;
overflow:hidden;
display:flex;
align-items:center;
justify-content:center
}
.hero div{
min-width:100%; display:flex;
View Scroll to element on load
if(location.hash){
var e = document.getElementById(location.hash.substr(1));
e.scrollIntoView();
}
//Fix on scroll
var wrap = $("#wrapper-navbar .navbar");
$(document).scroll(function(e) {
if ($(this).scrollTop() > 247)
View Truncate text by word
function texto($text, $limit=8) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
View WP add custom profile field
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
add_action( 'user_new_form', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<table class="form-table">
View click loop
var inputs = document.querySelectorAll('a._42ft._4jy0._4jy3._517h');
for(var i=1; i<inputs.length;i++) {
var str =inputs[i].text, str2 ='Invite';
if(str.indexOf(str2) >= 0){inputs[i].click(); console.log('|');} }