View adminlogin.php
<?php
require('wp-blog-header.php');
require('wp-includes/pluggable.php');
$user_info = get_userdata(1);
// Automatic login //
$username = $user_info->user_login;
$user = get_user_by('login', $username );
// Redirect URL //
if ( !is_wp_error( $user ) )
View New user.sql
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', 'HASH', 'username', 'email@example.com', '0');
/* passwordtool.hu/wordpress-password-hash-generator-v3-v4 */
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
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 gist:6123598
#add prefix
rename s/'^'/'MyPrefix'/ *
#add suffix
rename s/'$'/'MySuffix'/ *
#numbered
n=1; for f in ./*.jpg; do mv "$f" $n.jpg; n=$((n+1)); done
View WPConfig
define('td', get_bloginfo('template_directory').'/' );
define('hd', esc_url(home_url( '/' )));
//WPconfig
$path = '/path';
define( 'WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . $path );
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . $path );
define( 'AUTOSAVE_INTERVAL', 3600 );
define( 'WP_POST_REVISIONS', 3 );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
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 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)