| @@ -6,52 +6,36 @@ | ||
| 6 | 6 | Author: Takayuki Miyoshi |
| 7 | 7 | Author URI: http://ideasilo.wordpress.com/ |
| 8 | 8 | Text Domain: bogo |
| 9 | 9 | Domain Path: /languages/ |
| 10 | -Version: 2.1 | |
| 10 | +Version: 2.4 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -/* Copyright 2007-2013 Takayuki Miyoshi (email: takayukister at gmail.com) | |
| 13 | +define( 'BOGO_VERSION', '2.4' ); | |
| 14 | 14 | |
| 15 | - This program is free software; you can redistribute it and/or modify | |
| 16 | - it under the terms of the GNU General Public License as published by | |
| 17 | - the Free Software Foundation; either version 2 of the License, or | |
| 18 | - (at your option) any later version. | |
| 15 | +define( 'BOGO_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); | |
| 19 | 16 | |
| 20 | - This program is distributed in the hope that it will be useful, | |
| 21 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 22 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 23 | - GNU General Public License for more details. | |
| 17 | +define( 'BOGO_PLUGIN_NAME', trim( dirname( BOGO_PLUGIN_BASENAME ), '/' ) ); | |
| 24 | 18 | |
| 25 | - You should have received a copy of the GNU General Public License | |
| 26 | - along with this program; if not, write to the Free Software | |
| 27 | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 28 | -*/ | |
| 19 | +define( 'BOGO_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) ); | |
| 29 | 20 | |
| 30 | -define( 'BOGO_VERSION', '2.1' ); | |
| 21 | +define( 'BOGO_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) ); | |
| 31 | 22 | |
| 32 | -if ( ! defined( 'BOGO_PLUGIN_BASENAME' ) ) | |
| 33 | - define( 'BOGO_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); | |
| 34 | - | |
| 35 | -if ( ! defined( 'BOGO_PLUGIN_NAME' ) ) | |
| 36 | - define( 'BOGO_PLUGIN_NAME', trim( dirname( BOGO_PLUGIN_BASENAME ), '/' ) ); | |
| 37 | - | |
| 38 | -if ( ! defined( 'BOGO_PLUGIN_DIR' ) ) | |
| 39 | - define( 'BOGO_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) ); | |
| 40 | - | |
| 41 | -if ( ! defined( 'BOGO_PLUGIN_URL' ) ) | |
| 42 | - define( 'BOGO_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) ); | |
| 43 | - | |
| 44 | 23 | require_once BOGO_PLUGIN_DIR . '/includes/functions.php'; |
| 45 | 24 | require_once BOGO_PLUGIN_DIR . '/includes/rewrite.php'; |
| 46 | 25 | require_once BOGO_PLUGIN_DIR . '/includes/link-template.php'; |
| 26 | +require_once BOGO_PLUGIN_DIR . '/includes/nav-menu.php'; | |
| 47 | 27 | require_once BOGO_PLUGIN_DIR . '/includes/widgets.php'; |
| 48 | -require_once BOGO_PLUGIN_DIR . '/includes/post-l10n-functions.php'; | |
| 49 | -require_once BOGO_PLUGIN_DIR . '/includes/user-l10n-functions.php'; | |
| 50 | -require_once BOGO_PLUGIN_DIR . '/includes/post-l10n.php'; | |
| 51 | -require_once BOGO_PLUGIN_DIR . '/includes/user-l10n.php'; | |
| 28 | +require_once BOGO_PLUGIN_DIR . '/includes/post.php'; | |
| 29 | +require_once BOGO_PLUGIN_DIR . '/includes/user.php'; | |
| 30 | +require_once BOGO_PLUGIN_DIR . '/includes/capabilities.php'; | |
| 52 | 31 | require_once BOGO_PLUGIN_DIR . '/includes/query.php'; |
| 32 | +require_once BOGO_PLUGIN_DIR . '/includes/flags.php'; | |
| 53 | 33 | |
| 34 | +if ( is_admin() ) { | |
| 35 | + require_once BOGO_PLUGIN_DIR . '/admin/admin.php'; | |
| 36 | +} | |
| 37 | + | |
| 54 | 38 | add_action( 'plugins_loaded', 'bogo_plugins_loaded' ); |
| 55 | 39 | |
| 56 | 40 | function bogo_plugins_loaded() { |
| 57 | 41 | load_plugin_textdomain( 'bogo', 'wp-content/plugins/bogo/languages', 'bogo/languages' ); |
| @@ -59,12 +43,10 @@ | ||
| 59 | 43 | |
| 60 | 44 | add_action( 'init', 'bogo_init' ); |
| 61 | 45 | |
| 62 | 46 | function bogo_init() { |
| 63 | - global $bogo_languages; | |
| 47 | + bogo_languages(); | |
| 64 | 48 | |
| 65 | - $bogo_languages = bogo_languages(); | |
| 66 | - | |
| 67 | 49 | if ( ! ( is_admin() || is_robots() || is_feed() || is_trackback() ) ) { |
| 68 | 50 | $locale = get_locale(); |
| 69 | 51 | |
| 70 | 52 | if ( ! isset( $_COOKIE['lang'] ) || $_COOKIE['lang'] != $locale ) |
| @@ -96,9 +78,11 @@ | ||
| 96 | 78 | $url = is_ssl() ? 'https://' : 'http://'; |
| 97 | 79 | $url .= $_SERVER['HTTP_HOST']; |
| 98 | 80 | $url .= $_SERVER['REQUEST_URI']; |
| 99 | 81 | |
| 100 | - $home = trailingslashit( home_url() ); | |
| 82 | + $home = set_url_scheme( get_option( 'home' ) ); | |
| 83 | + $home = trailingslashit( $home ); | |
| 84 | + | |
| 101 | 85 | $available_languages = bogo_available_languages(); |
| 102 | 86 | $available_languages = array_map( 'bogo_lang_slug', array_keys( $available_languages ) ); |
| 103 | 87 | $available_languages = implode( '|', $available_languages ); |
| 104 | 88 | $pattern = '#^' . preg_quote( $home ) . '(' . $available_languages . ')(/|$)#'; |
| @@ -123,7 +107,23 @@ | ||
| 123 | 107 | function bogo_query_vars( $query_vars ) { |
| 124 | 108 | $query_vars[] = 'lang'; |
| 125 | 109 | |
| 126 | 110 | return $query_vars; |
| 111 | +} | |
| 112 | + | |
| 113 | +add_shortcode( 'bogo', 'bogo_language_switcher' ); | |
| 114 | + | |
| 115 | +add_action( 'wp_enqueue_scripts', 'bogo_enqueue_scripts' ); | |
| 116 | + | |
| 117 | +function bogo_enqueue_scripts() { | |
| 118 | + wp_enqueue_style( 'bogo', | |
| 119 | + plugins_url( 'includes/css/style.css', BOGO_PLUGIN_BASENAME ), | |
| 120 | + array(), BOGO_VERSION, 'all' ); | |
| 121 | + | |
| 122 | + if ( is_rtl() ) { | |
| 123 | + wp_enqueue_style( 'bogo-rtl', | |
| 124 | + plugins_url( 'includes/css/style-rtl.css', BOGO_PLUGIN_BASENAME ), | |
| 125 | + array(), BOGO_VERSION, 'all' ); | |
| 126 | + } | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | ?> |