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 | |
/** | |
* Get Facebook count. | |
* | |
* @param intval $post_id | |
* @return intval | |
*/ | |
function get_facebook_count( $post_id = 0 ) { | |
global $post; | |
$post_id = ( (int)$post_id > 0 ) ? (int)$post_id : (int)$post->ID; |
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 | |
/** | |
* Alternative get_post function. | |
* @return object|false | |
*/ | |
public static function my_get_post() { | |
$result = get_post(); | |
$page_for_posts = get_option( 'page_for_posts' ); | |
if ( is_home() && $page_for_posts && ( ! is_object( $result ) || ( $page_for_posts != $result->ID ) ) ) { |
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
pagespeed on; | |
# pagespeed RewriteLevel PassThrough; | |
pagespeed RewriteLevel CoreFilters; | |
pagespeed FileCachePath /var/cache/nginx/ngx_pagespeed; | |
pagespeed EnableFilters collapse_whitespace,remove_comments,remove_quotes; | |
pagespeed EnableFilters inline_google_font_css,move_css_above_scripts,move_css_to_head,flatten_css_imports,prioritize_critical_css,combine_css,rewrite_css,fallback_rewrite_css_urls,inline_css,extend_cache_css; | |
pagespeed CssFlattenMaxBytes 5120; | |
pagespeed EnableFilters rewrite_javascript,combine_javascript,defer_javascript,inline_javascript; | |
pagespeed EnableFilters lazyload_images,rewrite_images,convert_jpeg_to_progressive,convert_png_to_jpeg,convert_jpeg_to_webp,recompress_images,recompress_jpeg,recompress_png,recompress_webp,convert_gif_to_png,strip_image_color_profile,strip_image_meta_data; |
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
/** | |
* SSL Setting | |
*/ | |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === "https") { | |
$_SERVER['HTTPS'] = 'on'; | |
} | |
define('FORCE_SSL_LOGIN', true); | |
define('FORCE_SSL_ADMIN', true); |
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
function http_host_301_redirect() { | |
$site_host = parse_url( get_bloginfo('url', 'raw' ) ); | |
$site_host = $site_host['host']; | |
$http_host = $_SERVER["HTTP_HOST"]; | |
$redirect = ( empty( $_SERVER["HTTPS"] ) ? "http://" : "https://" ) . $site_host . $_SERVER["REQUEST_URI"]; | |
if ( $site_host === $http_host || !wp_http_validate_url( $redirect ) ) | |
return; | |
wp_redirect( $redirect, 301 ); |
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
/** | |
* Replace the buffer. | |
* | |
* @link http://insnvlovn.blogspot.jp/2010/04/php-obstart.html | |
* @param buffer $buffer | |
* @return buffer $buffer | |
*/ | |
function buffer_replace( $buffer ) { | |
$pattern = array( "/(?:\r\n)|[\r\n]/", "/[\\x00-\\x09\\x0b-\\x1f]/" ); | |
$replace = array( "\n", " " ); |
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
table { | |
border-collapse: collapse; | |
border-spacing: 0; | |
border-width: 1px 0 0 1px; | |
table-layout: fixed; | |
width: auto; | |
} | |
thead, th { | |
background: #ddd; | |
text-align: left; |
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
/** | |
* 記事更新時に Facebook のサイト情報のキャッシュを削除する | |
* | |
* @link http://2inc.org/blog/2014/11/11/4485/ | |
*/ | |
class fb_ogp_cache_clear { | |
private $api = 'https://graph.facebook.com?id=%s&scrape=true'; | |
static function init() { | |
static $instance = false; |
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
var escapeQuotHTML = function(str){ | |
return str.replace(/&/g,'&').replace(/"/g, '"').replace(/\'/g, ''').replace(/</g,'<').replace(/>/g,'>'); | |
}; | |
var escapeHTML = function(str){ | |
var div = document.createElement('div'); | |
var text = document.createTextNode(str); | |
div.appendChild(text); | |
return div.innerHTML; |
OlderNewer