投稿者: admin

  • Elementorで権限毎にwidgetを非表示にする方法

    Elementorで権限毎にwidgetを非表示にする方法

    // GET CURRENT USER ROLE
    function get_current_user_role() {
    if( is_user_logged_in() ) {
    $user = wp_get_current_user();
    $role = ( array ) $user->roles;
    return $role[0];
    } else {
    return false;
    }
    }

    // Remove the Elementor Widgets from the left-hand Panel in the Live Editor

    global $elementor_widget_blacklist;

    $elementor_widget_blacklist = [
    // FREE
    ‘read-more’,
    ‘sidebar’,
    ‘audio’,

    // PRO
    ‘posts’,
    ‘portfolio’,
    ‘slides’,
    // ‘form’,
    ‘login’,
    ‘media-carousel’,
    ‘testimonial-carousel’,
    ‘nav-menu’,
    ‘pricing’,
    ‘facebook-comment’,
    ‘nav-menu’,
    ‘animated-headline’,
    ‘price-list’,
    ‘price-table’,
    ‘facebook-button’,
    ‘facebook-comments’,
    ‘facebook-embed’,
    ‘facebook-page’,
    ‘add-to-cart’,
    ‘categories’,
    ‘elements’,
    ‘products’,
    ‘flip-box’,
    ‘carousel’,
    ‘countdown’,
    ‘share-buttons’,
    ‘author-box’,
    ‘breadcrumbs’,
    ‘search-form’,
    ‘post-navigation’,
    ‘post-comments’,
    ‘theme-elements’,
    // ‘blockquote’,
    ‘template’,
    ‘wp-widget-audio’,
    ‘woocommerce’,
    ‘social’,
    ‘library’,
    ‘reviews’,
    ‘gallery’,
    ‘table-of-contents’,
    ‘html’,
    ‘star-rating’,
    ‘sitemap’,
    ‘theme-site-logo’,
    ‘theme-site-title’,
    ‘theme-page-title’,
    ‘theme-post-title’,
    ‘theme-post-excerpt’,
    ‘post-info’,
    ‘theme-post-featured-image’
    ];

    // CHECK CURRENT USER ROLE AND EXECUTE RESTRICTION IF NEEDED (in thix exemple for editor role)

    if( is_admin() && get_current_user_role() == ‘editor’) {

    // Remove all the Elementor Free & Pro Widgets listed above
    add_action(‘elementor/widgets/widgets_registered’, function($widgets_manager){
    global $elementor_widget_blacklist;
    foreach($elementor_widget_blacklist as $widget_name){
    $widgets_manager->unregister_widget_type($widget_name);
    }
    }, 15);

    // Remove the regular WordPress Widgets from the left-hand Panel in the Live Editor
    if ( ! function_exists( ‘ddw_tweak_elementor_remove_wp_widgets’ ) ) :
    add_filter( ‘elementor/widgets/black_list’, ‘ddw_tweak_elementor_remove_wp_widgets’ );

    function ddw_tweak_elementor_remove_wp_widgets( $black_list ) {
    /** Bail early if Elementor not active or tweak not wanted */
    if ( ! defined( ‘ELEMENTOR_VERSION’ ) ) {
    return $black_list;
    }

    /**
    * Get all registered WordPress widgets, but only the classes
    * (= the first-level array keys)
    */
    $black_list = array_keys( $GLOBALS[ ‘wp_widget_factory’ ]->widgets );

    /** Return black list array for filter */
    return (array) $black_list;

    }
    endif;

    }

  • WordPressカテゴリーページで説明を表示する方法

    カテゴリーページで説明を読み込み出力方法をメモ。

    <?php if(!is_paged()):?>
    <?php if(category_description()):?>

    <?php echo category_description(); ?>

    <?php endif;?>

    一行目はカテゴリーページが数ページある場合に1ページ目にだけに出力るための条件分岐。

  • EmEditor ワイルドカードで置換

    htmlタグから classを全部取り除きたいとき。

    .*? がワイルドカードとして使える

    テキストエディタで正規表現検索で、class= .*?> を検索し > に変換すればOK

  • WordPress キャッチアイ画像を背景画像にするCSS PHP

    <section class="" style="background-image: url(<?php echo get_the_post_thumbnail_url( get_the_ID(), 'learge' );?> )!important;">

  • Bootstrap4 card-columnsのbreakpointsを変更し表示card数を変更する方法

    Bootstrap4ではMasonryのような表示を可能にする.card-columns が加わった。

    https://getbootstrap.jp/docs/4.2/components/card/

    Responsiveに対応しているのだが、Breakpointブレークポイントを変更する方法が掲載されていなかったのでメモ。

    Cssで簡単に変更することができる。

    CSSでBootstrap4 card-columnsのbreakpointsを変更

    @media (min-width: 576px) {
        .card-columns {
            column-count: 2;
        }
    }
    @media (min-width: 768px) {
        .card-columns {
            column-count: 3;
        }
    }
    @media (min-width: 992px) {
        .card-columns {
            column-count: 4;
        }
    }
    @media (min-width: 1200px) {
        .card-columns {
            column-count: 5;
        }
    }
    

    SASSでBootstrap4 card-columnsのbreakpointsを変更

    .card-columns {
      @include media-breakpoint-only(xl) {
        column-count: 5;
      }
      @include media-breakpoint-only(lg) {
        column-count: 4;
      }
      @include media-breakpoint-only(md) {
        column-count: 3;
      }
      @include media-breakpoint-only(sm) {
        column-count: 2;
      }
    }
  • NumPadアプリをWindowsで使う方法 設定覚書

    ノートパソコンなどでテンキーがついていない場合や、スマホをテンキーとして使うときに便利なのがiOS用アプリNumPadだ。

    基本的にはiOS同士でつなげることを想定しているようだが、Windowsでも使用することができる。

    以下公式サポートに英語で少し解説されていたが、少し分かりづらかったのでメモ。

    https://help.edovia.com/hc/en-us/articles/115005205747-Configuring-Windows-for-Remote-Access

    1. TightVNC をWindows PCにインストール
    2. 右下のインジケーターからTightVNCのアイコンにマウスをのせるとIPアドレスが表示されるのでメモ。複数出る場合は一番右。
    3. TightVNCをダブルクリックし、ポート番号とパスワードを設定
    4. iphoneまたipadを同じWifiに接続しアプリを設定

    接続はスムーズで、ちょっとテンキーがほしいという場合に便利だ

     

  • wordpressの記事をmysqlから重複レコードを検索するコード

     

    SELECT
    *
    FROM
    wp_posts table1
    WHERE
    EXISTS (
    SELECT
    *
    FROM
    wp_posts table2
    WHERE
    table1.post_name = table2.post_name
    GROUP BY
    table2.post_name
    HAVING
    COUNT(table2.post_name) > 1
    )
    ORDER BY
    table1.post_name

  • Gmailの不要メールを容量でフィルターをかけて削除する方法

    Gmailは無料で利用できる容量が限られているため、利用方法によっては頻繁にメールを削除する必要がある。
    不要メールを削除する上で役立つフィルターを以下に紹介する。

    Gmailを容量でフィルターをかけ削除

    以下は10mb以上で重要、またはスターのタグが付いていないメールを抽出する
    larger:10m -is:starred or -is:important

    Gmailを日付でフィルターをかけ削除

    以下はスターや重要のタグが付いておらず、2018/01/01より古い日付でフィルターを掛けている
    -is:starred or -is:important older:2018/01/01

     

  • mysql phpmyadmin で空白のデータ、値のないデータをLIKE検索する

    値の何文字目かを指定して検索する

    DELETE FROM [テーブル名] WHERE [列名] like ‘__________任意の検索文字%’;

    手前にある文字数分”_”を挿入する

    mysql phpmyadmin で空白のデータ、値のないデータをLIKE検索する

    not like %_%で削除できる

  • seoプラグインYoasto SEOのmeta部分にcustomfieldの値を使う方法

    seoプラグインYoasto SEOのmeta description部分は任意のcustomfield(カスタムフィールド)の値を使用する事ができる。

    %%cf_<custom-field-name>%%

    上記のタグで任意のカスタムフィールドを説明文に使うことが出来る。