Skip to content

Instantly share code, notes, and snippets.

@konweb
konweb / memo.md
Created May 14, 2019 04:42
WP-CLI memo

command

post

generate

curl https://loripsum.net/api/5/decorate/link/ul/ol/dl/bq/code/headers/prude/ | wp post generate --post_content --count=10
@konweb
konweb / Start wp-cron with cron.md
Last active April 17, 2019 14:17
Start wp-cron with cron
@konweb
konweb / cron-memo.md
Last active August 8, 2019 08:19
cron memo

Cron file location

/etc/
├── cron.d/hoge_cron

Setting of authority

sudo chmod 644 hoge_cron
sudo chown root:root hoge_cron
@konweb
konweb / funcitons.php
Created March 27, 2019 04:03
Change category to radio button with gutenberug
<?php
/**
* Disable display of Gutenberg Post Setting UI for a specific
* taxonomy. While this isn't the official API for this need,
* it works for now because only Gutenberg is dependent on the
* REST API response.
* @Dependencies: Categories Metabox Enhanced
*/
add_filter('rest_prepare_taxonomy', function ($response, $taxonomy) {
if ('category' === $taxonomy->name) {
@konweb
konweb / function.php
Created March 18, 2019 08:23
Set cache by file update date
function action_wp_enqueue_scripts() {
$style_path = '/assets/css/style.css';
wp_enqueue_style('style', get_template_directory_uri() . $style_path, [], date('YmdGis', filemtime(get_theme_file_path().$style_path)));
}
add_action('wp_enqueue_scripts', 'action_wp_enqueue_scripts');
@konweb
konweb / wp-config.php
Created March 18, 2019 04:51
WP Mail SMTP plugin configuration in wp-config
<?php
define('WPMS_ON', true);
define('WPMS_MAILER', 'smtp');
define('WPMS_SMTP_HOST', 'smtp.gmail.com');
define('WPMS_SMTP_PORT', 465);
define('WPMS_SSL', true);
define('WPMS_SMTP_AUTH', true);
define('WPMS_SMTP_USER', 'hoge@gmail.com');
define('WPMS_SMTP_PASS', 'password');
@konweb
konweb / functions.php
Created March 12, 2019 08:11
Allow editors to insert iframe and svg tags
<?php
/**
* Allow editors to insert iframe and svg tags
*/
function filter_map_meta_cap( $caps, $cap, $user_id ) {
if ( 'unfiltered_html' === $cap && user_can( $user_id, 'editor' ) ) {
$caps = array( 'unfiltered_html' );
}
return $caps;
@konweb
konweb / function.php
Created March 8, 2019 02:52
Disabled Gutenberg Block Editor
<?php
// all
add_filter( 'use_block_editor_for_post', '__return_false' );
// Specific post types
add_filter( 'use_block_editor_for_post_type', 'disable_block_editor', 10, 2 );
function disable_block_editor( $use_block_editor, $post_type ) {
if ( $post_type === 'page' ) {
return false;
}
// Set the value of the custom variable '--vh' to the root of the document
document.documentElement.style.setProperty(
'--vh',
`${window.innerHeight * 0.01}px`
)
@konweb
konweb / README.md
Last active April 17, 2019 14:20
Apache add a user to a group

list users

less /etc/group

add group user

gpasswd -a hogehoge apache