Skip to content

Instantly share code, notes, and snippets.

Avatar

わいひら yhira

View GitHub Profile
@yhira
yhira / add_default_site_icon_tag.php
Last active May 31, 2020
Cocoonのデフォルトサイトアイコンを変更する
View add_default_site_icon_tag.php
//デフォルトのサイトアイコンを変更する
add_filter('add_default_site_icon_tag', function ($tag){
$tag = '<link rel="icon" href="32x32画像のURL" sizes="32x32" />'.PHP_EOL;
$tag .= '<link rel="icon" href="192x192画像のURL" sizes="192x192" />'.PHP_EOL;
$tag .= '<link rel="apple-touch-icon" href="180x180画像のURL" />'.PHP_EOL;
$tag .= '<meta name="msapplication-TileImage" content="270x270画像のURL" />'.PHP_EOL;
return $tag;
});
@yhira
yhira / balloon.php
Created May 27, 2020
[Cocoon]吹き出しショートコード簡略版
View balloon.php
add_shortcode('hukidashi1', 'hukidashi1Func');
function hukidashi1Func( $atts, $content = null ) {
ob_start();
?>
<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-3 sbs-line sbp-l sbis-cb cf block-box">
<div class="speech-person">
<figure class="speech-icon"><img data-src="http://cocoon.local/wp-content/themes/cocoon-master/images/b-man.png" alt="bbb" class="speech-icon-image " src="http://cocoon.local/wp-content/themes/cocoon-master/images/b-man.png" data-loaded="true">
<noscript><img src="http://cocoon.local/wp-content/themes/cocoon-master/images/b-man.png" alt="bbb" class="speech-icon-image" /></noscript>
</figure>
<div class="speech-name">名前</div>
@yhira
yhira / author-box.php
Last active Apr 24, 2020
プロフィールボックスのHTML
View author-box.php
<div class="author-box border-element no-icon cf">
<figure class="author-thumb"> <img alt="monta" src="https://tukalog.com/wp-content/uploads/2020/03/monta.png" class="avatar avatar-200 photo" width="200" height="200"> </figure>
<div class="author-content">
<div class="author-name"> <a href="https://tukalog.com/profile">monta</a> </div>
<div class="author-description">
<p>hi,
<br> i am a hot spring lover.</p>
</div>
<div class="author-follows"> </div>
</div>
@yhira
yhira / external-blogcard.html
Last active Apr 15, 2020
Cocoon外部ブログカードのHTML例
View external-blogcard.html
<a href="https://wp-simplicity.com/" title="Simplicity" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank" rel="noopener">
<div class="blogcard external-blogcard eb-left cf">
<div class="blogcard-label external-blogcard-label"><span class="fa"></span></div>
<figure class="blogcard-thumbnail external-blogcard-thumbnail"><img src="https://cocoon.local/wp-content/uploads/cocoon-resources/blog-card-cache/7183f3692da296da4ede1d25e5a91233.jpg" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90"></figure>
<div class="blogcard-content external-blogcard-content">
<div class="blogcard-title external-blogcard-title">Simplicity</div>
<div class="blogcard-snippet external-blogcard-snippet">内部SEO施策済みのシンプルな無料Wordpressテーマを公開しています。初心者でも出来る限り分かりやすく使えるように作成しました。</div>
</div>
<div class="blogcard-footer external-blogcard-footer cf">
<div class="blogcard-site external-blogcard-site">
@yhira
yhira / wrap_h2_1st_to_end.php
Last active Mar 20, 2020
Cocoonの最初のH2見出しから本文最後までをdiv要素で囲む
View wrap_h2_1st_to_end.php
//最初のH2見出しから本文最後までをdiv要素で囲む
add_filter('the_content','wrap_h2_1st_to_end', 99999);
function wrap_h2_1st_to_end($the_content) {
//投稿・固定ページの場合
if (is_singular()) {
$h2 = '/<h2/';//H2見出しのパターン
if ( preg_match( $h2, $the_content )) {//H2見出しが本文中にあるかどうか
$the_content = preg_replace($h2, '<div class="hoge"><h2', $the_content.'</div>', 1);//最初のH2を置換
}
}
@yhira
yhira / change_h2_to_but.php
Last active Mar 9, 2020
WordPress本文の特定の文字列の見出しを変更する
View change_h2_to_but.php
add_filter('the_content','change_h2_to_but');
function change_h2_to_but( $content ){
return str_replace('<h2>しかし…</h2>','<h2 id="but">しかし…</h2>', $content );
}
@yhira
yhira / use-withColors.js
Last active Oct 18, 2019
カラーパレットの設定をHOCで制御(修正版)
View use-withColors.js
import classnames from 'classnames';
const {
registerBlockType,
} = wp.blocks;
const {
InspectorControls,
RichText,
withColors,
getColorClassName,
@yhira
yhira / OneColumnBlock.js
Created Oct 17, 2019
withColorsを使ったサンプル
View OneColumnBlock.js
import classnames from 'classnames';
const {
registerBlockType,
} = wp.blocks;
const {
InspectorControls,
RichText,
withColors,
getColorClassName,
@yhira
yhira / fetch_facebook_count.php
Created Apr 30, 2019
Facebookのリアクションカウントを取得する関数
View fetch_facebook_count.php
//Facebookのリアクションカウントを取得する
function fetch_facebook_count($url){
//アクセストークンの入力
$access_token = '取得したアクセストークンを入力';
//URLをURLエンコード
$encoded_url = rawurlencode( $url );
//Facebookにリクエストを送る
$request_url = 'https://graph.facebook.com/?id='.$encoded_url.'&fields=engagement&access_token='.$access_token;
$response = wp_remote_get( $request_url );
$res = 0;
@yhira
yhira / skin.php
Last active Apr 27, 2019
スキン切り換えデモ
View skin.php
add_shortcode('skin', function (){
$skin = isset($_GET['theme-switch']) ? esc_html($_GET['theme-switch']) : null;
if (empty($skin) && isset($_COOKIE['theme-switch'])) {
$skin = esc_html($_COOKIE['theme-switch']);
}
$url = get_permalink().'?';
ob_start();
?>
<select id="theme-switch" class="theme-switch-dropdown" onchange="document.cookie = this.options[this.selectedIndex].value;window.document.location.href='<?php echo $url; ?>'+this.options[this.selectedIndex].value;">
<option value="theme-switch=reset" <?php the_option_selected($skin, null); ?>>▼デザインスキンを選択</option>