joppot

コピペで絶対動く。説明を妥協しない

プログラミング

Customize wordpress bogo plugin’s short code

投稿日:



Abstract

Hello everyone, It’s me candle.
In this time, I will show you how to customize wordpress bogo short code.
The items to introduce are these.

  • The flag display or hide
  • Change the text


Related article

How to change the language form “en-US” to “en” by wordpres bogo

Precondition

WordPress bogo has been installed
You can edit the theme of wordpress


The flag display or hide

Bogo’s short code will show links to other languages.
The flags will be displayed automatically.

In some cases, you don’t need flags.
Let’s hide it.

Open the functions.php in each theme’s folder.
It is generally in the following place.

wp-content/themes/”theme name”/functions.php

Write it.

add_filter( 'bogo_use_flags','bogo_use_flags_false');
function bogo_use_flags_false(){
 return false;
}

You return false with add_filter, the flags will be hide.


It’s seems good.

Change the displayed text

For example, if you change the language from en-US to en,
you feel strange that English text is still “English (United States)”.

From here, I will show you how to change the text from “English (United States)” to “English”.
Of course, you can also change the something another letters.

Open the functions.php and write this.

add_filter( 'bogo_language_switcher','replace_bogo_text');
function replace_bogo_text($output){
 return str_replace(' (United States)','',$output);
}

Actually this function is quite a power technique.
It replaces the whole result generated by [bogo].
I tried to find out the more smart method, but I think that this is the best for now.

You can see that the text is changed.

Change the short code from the foundation

There is a method to change from the fundamentally rather than a change like a patch.
That method is to override the function to generate short code in the bogo plugin.

When large-scale changes, you can customize more finely using this method.
Although I don’t write it in this article, it is written in the following site in detail.

(It is written in Japanese)
https://qox.jp/blog/bogo-wordpress/

Conclustion

Enjoy your wordpress life.

スポンサードリンク

If you think this article is good, share it please

-プログラミング
-,

執筆者:


comment

Your email address will not be published. Required fields are marked *

関連記事

React Project development environment building command create-react-app is too convenient

English 日本語 Abstract Hello everyone It’s me candle. In this time we will build a “react” development environment with create-react-app command and try to hello world. Past react development was created by installing babel and other packages from npm on your own using gulp or webpack. Past react development installed babel and other packages from npm and built servers with gulp and webpack. If you use the create-react-app command, you can create react environment easily. Let’s do it. Precondition Node is already installed

Deploy React to s3 with aws command

Abstract Hello veryone it’s me candle. In this time I will show you how to deploy a react project created by create-react-app to S3. A good thing about React web app is that you can publish the products created by building them as long as you upload them such as html and js files and images to storage. In this article I don’t write these three items. How to get a IAM that can access to S3 Allocate your own domain using Route53 SSL connection of React web app Condition You have aws command Please install the aws command in …

Create the simplest drop down menu in React

Abstract Hello everyone it’s me candle. In this time we will make a most simple drop down menu. Condition Knowledge of react Preparation We create a react project with the below command. create-react-app hello-menu Open src/App.js and write this. import React, { Component } from 'react' class App extends Component { render() { return ( <div> <p>hello menu</p> </div> ) } } export default App Create a components directory in the src directory. mkdir src/components Create a DropDownMenu.js file in the src/components directory. touch src/components/DropDownMenu.js Now on ready. Create a Drop down menu Open the src/components/DropDownMenu.js and write these. import …

Using sphinx how to generate documents of python classes and functions

Abstruct Hello everyone it’s me candle. In this article I will explain how to make documents about classes and functions with Sphinx automatically. condition I will explain it using Python 3, but I think that it will probably work with python 2 as well. Prepare test files Create a main.py and dog.py. touch main.py dog.py Write this to the main.py from dog import Dog def main(): dog = Dog() dog.show_name() if __name__ == "__main__": main() Open the dog.py and write it. class Dog(object): def __init__(self, name="bob"): self.name = name def bark(): print("Bow Wow") def show_name(self): print(self.name) def get_name(self): return self.name …

Tutorial to create a modal using react-modal

Abstract Hello everyone it’s me candle. In this time, let’s create a modal with react-modal. React-modal is a library which can create and handle a modal easily. But However, react-modal is not easy if you try to actually use it. it is necessary to incorporate state management, action, design etc. In this article, I will explain it like a tutorial and we will make a modal together. Condition You have a react knowledge. You installed create-react-app. Set up development env If you already have a some react project, you would use it. Otherwise, you don’t have a any project, please …


I work in the venture company as a CTO. I start to write program in University, first I learned java, C++ and PHP. In the company, I'm developing web services by Rails. I do like to automation.