0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【WordPress】プラグイン

Last updated at Posted at 2019-05-30

MW WP Form カスタマイズ

概要

プラグイン MW WP Form カスタマイズ

施策

エラー文言の変更

function my_validation_rule( $Validation, $data, $Data ) {
 $Validation->set_rule( '種別', 'required', array( 'message' => '種別を選択してください。' ) );
	$Validation->set_rule( 'お名前', 'noEmpty', array( 'message' => 'お名前を入力してください。' ) );
	$Validation->set_rule( '郵便番号', 'noEmpty', array( 'message' => '郵便番号を入力してください。' ) );
	$Validation->set_rule( '都道府県', 'noEmpty', array( 'message' => '都道府県を入力してください。' ) );
	$Validation->set_rule( 'ご住所(市区郡)', 'noEmpty', array( 'message' => 'ご住所(市区郡)を入力してください。' ) );
	$Validation->set_rule( '電話番号', 'noEmpty', array( 'message' => '電話番号を入力してください。' ) );
	$Validation->set_rule( 'mail', 'noEmpty', array( 'message' => 'メールアドレスを入力してください。' ) );
	$Validation->set_rule( 'お問い合わせ内容', 'noEmpty', array( 'message' => 'お問い合わせ内容を入力してください。' ) );
    return $Validation;
}
add_filter( 'mwform_validation_mw-wp-form-**', 'my_validation_rule', 10, 3 );

*は投稿ID

特定の項目にあらかじめ値を代入

/*--------------------------------------------------------
// プラグイン MW WP Form カスタマイズ
--------------------------------------------------------*/
function my_mwform_value( $value, $name ) {
  if ( $name === 'お問い合わせ内容' && !empty( $_GET['ctit'] ) && !is_array( $_GET['ctit'] ) ) {
    return esc_attr($_GET['ctit']);
  }

  if ( $name === '種別' && !empty( $_GET['ctyp'] ) && !is_array( $_GET['ctyp'] ) ) {
    return esc_attr(urldecode($_GET['ctyp']));
  }
  return $value;
}

// 管理画面で作成したフォームの場合、フック名の後のフォーム識別子は「mw-wp-form-xxx」
add_filter( 'mwform_value_mw-wp-form-4', 'my_mwform_value', 10, 2 );


Prime Strategy Bread Crumb カスタマイズ

概要

プラグイン Prime Strategy Bread Crumb カスタマイズ

施策

/*--------------------------------------------------------
// プラグイン Prime Strategy Bread Crumb カスタマイズ
--------------------------------------------------------*/
//パンくず階層調整 カスタム分類では間にカスタム投稿アーカイブを追加する
function custom_bread_crumb( $bread_crumb_arr ) {
  global $post;
  global $wp_query;

  $post_type_object = get_post_type_object( get_post_type( $post ) );
  $product_type = $wp_query->get('product_type');

  if( $post_type_object->name === 'product' && is_tax() ){
    $bca = $bread_crumb_arr[1];
    $bca['title'] = '製品一覧 ' . $bca['title'];
    if($product_type==='product_use'){
      $bread_crumb_arr[1] = array( 'title' => '※※※※※※※', 'link' => home_url('/' . $post_type_object->name . '/use') );
      $bread_crumb_arr[2] = $bca;
    }elseif($product_type==='product_alp'){
      $bread_crumb_arr[1] = array( 'title' => '※※※※※', 'link' => home_url('/' . $post_type_object->name . '/model') );
      $bread_crumb_arr[2] = $bca;
    }else{
      $bread_crumb_arr[1] = array( 'title' => '※※※※※', 'link' => home_url('/' . $post_type_object->name) );
      $bread_crumb_arr[2] = $bca;
    }

  }elseif ($post_type_object->name === 'product' && is_archive() ) {
    if($product_type==='product_use'){
      $bread_crumb_arr[1] = array( 'title' => '※※※', 'link' => home_url('/' . $post_type_object->name . '/use') );
    }elseif($product_type==='product_alp'){
      $bread_crumb_arr[1] = array( 'title' => '※※※※※※', 'link' => home_url('/' . $post_type_object->name . '/model') );
    }else{
      $bread_crumb_arr[1] = array( 'title' => '※※※※※', 'link' => home_url('/' . $post_type_object->name ) );
    }
  }elseif ($post_type_object->name === 'product' && is_single() ) {
    $path = parse_url( wp_get_referer() )['path'];
    $pa = preg_split('/\//', $path)[2];

    $bca = $bread_crumb_arr[2];
    $bca['title'] = '製品詳細 ' . $bca['title'];
    //if($product_type==='product_use'){
    if($pa==='use'){
      $bread_crumb_arr[1] = array( 'title' => '※※※※', 'link' => home_url('/' . $post_type_object->name . '/use') );
      $bread_crumb_arr[2] = $bca;
    //}elseif($product_type==='product_alp'){
    }elseif($pa==='model'){
      $bread_crumb_arr[1] = array( 'title' => '※※※※※', 'link' => home_url('/' . $post_type_object->name . '/model') );
      $bread_crumb_arr[2] = $bca;
    }else{
      $bread_crumb_arr[1] = array( 'title' => '※※※※※※※', 'link' => home_url('/' . $post_type_object->name) );
      $bread_crumb_arr[2] = $bca;
    }
  }elseif ($post_type_object->name === 'faq' && is_tax('faq_cat') ) {
    $bca = $bread_crumb_arr[1];
    $bread_crumb_arr[1] = array( 'title' => '※※※※※※※', 'link' => home_url('/' . $post_type_object->name) );
    $bread_crumb_arr[2] = $bca;
  }elseif ($post_type_object->name === 'post' && is_single() ) {
    $bca = $bread_crumb_arr[3];
    $bread_crumb_arr[2] = $bca;
    array_pop($bread_crumb_arr);
  }

  return $bread_crumb_arr;
}
add_filter( 'bread_crumb_arr', 'custom_bread_crumb' );

bogo

概要

プラグイン bogo カスタマイズ

施策

テーマ翻訳ファイルを読み込み

function textdomain_setup(){
	load_theme_textdomain( 'testsite' );
}
add_action( 'after_setup_theme', 'textdomain_setup' );

カスタム投稿タイプでもbogoを使えるようにする

function my_localizable_post_types( $localizable ) {
	$args = array(
		'public'   => true,
		'_builtin' => false
	);
	$custom_post_types = get_post_types( $args );
	return array_merge( $localizable, $custom_post_types );
}
add_filter( 'bogo_localizable_post_types', 'my_localizable_post_types', 10, 1 );

bogoプラグインのスタイルシート削除

add_action( 'wp_enqueue_scripts', function() {
	wp_dequeue_style( 'bogo' );
});

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?